
var my_track="titm";var my_initial="../include/initial.asp";var my_detail="product_detail.aspx";var myStyle='&linecolor='+escape('#AAAAAA')+'&menu=category'+'&body=bodyblue'+'&bold=bodyheading'+'&hlcolor='+escape('#88C4FF')+'&bgcolor='+escape('#E0FFE0')+'&menucolor='+escape('#E0FFE0')+'&hdcolor='+escape('#B0B0B0')+'&idcolor='+escape('#FFFFFF')+'&header=bodywhite'+'&rowcolor='+escape('#E0FFE0')+'&row=bodyblack'+'&label=bodyblue'+'&heading=heading'+'&detail='+escape(my_detail)+'&popup=yes';InitialHeader(false);function InitialHeader(bRefresh)
{var i,sStr,page,curPage=""+window.location,myid="";curPage=curPage.toLowerCase();if(curPage.indexOf('.asp')>0&&window.goback!=null)
{sStr=curPage;i=sStr.lastIndexOf("/");if(i>0)sStr=sStr.substring(0,i+1);curPage=goback.toLowerCase();if(curPage.indexOf(sStr)==0)curPage="";i=curPage.lastIndexOf('.asp?pid=');if(i<=0)i=curPage.lastIndexOf('.asp?file=');if(i>0&&my_detail.indexOf('.asp')<0)
{i=curPage.lastIndexOf('/',i);sStr=curPage.substring(i+1,curPage.length);i=sStr.indexOf('?');sStr=sStr.substring(0,i);my_detail=sStr+'?file='+my_detail;}}
i=curPage.lastIndexOf("?");if(i>0)
{myid='&'+curPage.substring(i+1,curPage.length);curPage=curPage.substring(0,i);i=myid.lastIndexOf('&id=');if(i<0)
myid='';else
{if(i>0)myid=myid.substring(i,myid.length);i=myid.indexOf('#',1)
if(i>0)myid=myid.substring(0,i);i=myid.indexOf('&',1)
if(i>0)myid=myid.substring(0,i);}}
i=curPage.lastIndexOf("/");if(i>7)
curPage=curPage.substring(0,i+1);else if(curPage.length&&i<0)
curPage+='/';page=my_initial+"?track="+my_track+"+"+escape(curPage);if(window.sessionid)
page+="&id="+sessionid;else if(myid.length)
page+=myid;if(bRefresh)
page+='&rnd='+Math.round(Math.random()*100000);if(curPage.indexOf('http')<0&&my_initial.indexOf('://')<0&&curPage.length)
{alert('To properly preview the page: \n\nEdit "header.js" file to Prefix "my_initial" variable with a full domain URL.');}
else if(!window.parent||(!window.parent.sitename&&!window.parent.fixHTMLArea))
{document.write('<'+'script language="JavaScript" src="'+
page+'"></'+'script>\r\n');}}
if(window.parent&&window.parent.sitename&&!window.parent.fixHTMLArea)
{eval("var sessionid = window.parent.sessionid;");eval("var cart = window.parent.cart;");eval("function quickcart(sParams) {window.parent.quickcart(sParams, window)}");eval("function insertstatic(sURL) {window.parent.insertstatic(sURL, window)}");eval("function insertpage(sURL) {window.parent.insertpage(sURL, window)}");eval("function submitform(sForm, sURL) {window.parent.submitform(sForm, sURL, window)}");}
var myStyle0='?'+myStyle.substring(1,myStyle.length);function setStyle(sField,sValue)
{var thisStyle=myStyle;var i,j,sStr;i=thisStyle.indexOf('&'+sField+'=');if(i>=0)
{j=thisStyle.indexOf('&',i+1);if(j==0)j=thisStyle.length;sStr=thisStyle.substring(i,j);thisStyle=thisStyle.replace(sStr,'&'+sField+'='+escape(sValue));}
else
thisStyle+='&'+sField+'='+escape(sValue);return thisStyle;}
var MojoZoom=(function(){var $=function(id){return document.getElementById(id);};var dc=function(tag){return document.createElement(tag);};var defaultWidth=300;var defaultHeight=300;function addEvent(element,ev,handler)
{var doHandler=function(e){return handler(e||window.event);}
if(element.addEventListener){element.addEventListener(ev,doHandler,false);}else if(element.attachEvent){element.attachEvent("on"+ev,doHandler);}}
function getElementPos(element)
{var x=element.offsetLeft;var y=element.offsetTop;var parent=element.offsetParent;while(parent){x+=parent.offsetLeft;y+=parent.offsetTop;parent=parent.offsetParent;}
return{x:x,y:y}}
function getEventMousePos(element,e){var scrollX=document.body.scrollLeft||document.documentElement.scrollLeft;var scrollY=document.body.scrollTop||document.documentElement.scrollTop;if(e.currentTarget){var pos=getElementPos(element);return{x:e.clientX-pos.x+scrollX,y:e.clientY-pos.y+scrollY}}
return{x:e.offsetX,y:e.offsetY}}
function makeZoomable(img,zoomSrc,zoomImgCtr,zoomWidth,zoomHeight,alwaysShow){if(!img.complete&&!img.__mojoZoomQueued){addEvent(img,"load",function(){img.__mojoZoomQueued=true;setTimeout(function(){makeZoomable(img,zoomSrc,zoomImgCtr,zoomWidth,zoomHeight,alwaysShow);},1);});return;}
img.__mojoZoomQueued=false;setTimeout(function(){var isIE=!!document.all&&!!window.attachEvent&&!window.opera;var isIE6 = document.all && !!window.attachEvent && !window.XMLHttpRequest && !window.opera;var w=img.offsetWidth;var h=img.offsetHeight;var oldParent=img.parentNode;if(oldParent.nodeName!="A"){var linkParent=dc("a");oldParent.replaceChild(linkParent,img);linkParent.appendChild(img);}else{var linkParent=oldParent;}
linkParent.style.position="relative";linkParent.style.display="block";if(isIE){linkParent.style.zIndex="-1";}linkParent.style.width=w+"px";linkParent.style.height=h+"px";var imgLeft=img.offsetLeft;var imgTop=img.offsetTop;var zoom=dc("div");zoom.className="mojozoom_marker";var zoomImg=dc("img");zoomImg.className="mojozoom_img";zoomImg.style.position="absolute";zoomImg.style.left="-9999px";zoomImg.style.top="-9999px";document.body.appendChild(zoomImg);var parent=img.parentNode;var ctr=dc("div");with(ctr.style){position="absolute";left=imgLeft+"px";top=imgTop+"px";width=w+"px";height=h+"px";overflow="hidden";display="none";}
ctr.appendChild(zoom);parent.appendChild(ctr);var zoomInput=parent;if(img.__mojoZoomOverlay)
parent.removeChild(img.__mojoZoomOverlay);img.__mojoZoomOverlay=ctr;if(img.__mojoZoomImage&&img.__mojoZoomImage.parentNode)
img.__mojoZoomImage.parentNode.removeChild(img.__mojoZoomImage);img.__mojoZoomImage=zoomImg;var useDefaultCtr=false;if(!zoomImgCtr){zoomImgCtr=dc("div");zoomImgCtr.className="mojozoom_imgctr";var imgPos=getElementPos(img);zoomImgCtr.style.left=w+imgPos.x+"px";zoomImgCtr.style.top=imgPos.y+"px";zoomImgCtr.style.width=(zoomWidth?zoomWidth:defaultWidth)+"px";zoomImgCtr.style.height=(zoomHeight?zoomHeight:defaultHeight)+"px";document.body.appendChild(zoomImgCtr);useDefaultCtr=true;}
zoomImgCtr.style.overflow="hidden";if(!alwaysShow){zoomImgCtr.style.visibility="hidden";}
addEvent(zoomImg,"load",function(){if(!zoomImg.parentNode)return;var zoomWidth=zoomImg.offsetWidth;var zoomHeight=zoomImg.offsetHeight;var ctrWidth=zoomImgCtr.offsetWidth;var ctrHeight=zoomImgCtr.offsetHeight;var ratioW=zoomWidth/w;var ratioH=zoomHeight/h;var markerWidth=Math.round(ctrWidth/ratioW);var markerHeight=Math.round(ctrHeight/ratioH);document.body.removeChild(zoomImg);zoomImgCtr.appendChild(zoomImg);var zoomFill=dc("div");zoomFill.className="mojozoom_fill";zoom.appendChild(zoomFill);var zoomBorder=dc("div");zoomBorder.className="mojozoom_border";zoom.appendChild(zoomBorder);zoom.style.width=markerWidth+"px";zoom.style.height=markerHeight+"px";if(alwaysShow){zoom.style.left="0px";zoom.style.top="0px";zoomImg.style.left="0px";zoomImg.style.top="0px";}
var isInImage=false;if(!alwaysShow){addEvent(zoomInput,"mouseout",function(e){var target=e.target||e.srcElement;if(!target)return;if(target.nodeName!="DIV")return;var relTarget=e.relatedTarget||e.toElement;if(!relTarget)return;while(relTarget!=target&&relTarget.nodeName!="BODY"&&relTarget.parentNode){relTarget=relTarget.parentNode;}
if(relTarget!=target){isInImage=false;ctr.style.display="none";zoomImgCtr.style.visibility="hidden";}});addEvent(document.body,"mouseover",function(e){if(isInImage&&!(e.toElement==zoomBorder||e.target==zoomBorder)){ctr.style.display="none";zoomImgCtr.style.visibility="hidden";isInImage=false;}});}
addEvent(zoomInput,"mousemove",function(e){isInImage=true;var imgPos=getElementPos(img);if(useDefaultCtr){var iLeft,iTop,zp=document.getElementById('zoom_position');if(zp&&(img.offsetWidth/defaultWidth>0.5||img.offsetHeight/defaultHeight>0.5))
{var zoomPos=getElementPos(zp);iLeft=-20+zoomPos.x+"px";iTop=zoomPos.y+"px";}
else
{var X=0,Y=0,iClientX=1,iClientY=1;if(window.innerWidth&&typeof(window.innerWidth)=='number')
{iClientX=window.innerWidth;iClientY=window.innerHeight;}
else if(document.documentElement&&document.documentElement.clientWidth)
{iClientX=document.documentElement.clientWidth;iClientY=document.documentElement.clientHeight;}
else if(document.body&&document.body.clientWidth)
{iClientX=document.body.clientWidth;iClientY=document.body.clientHeight;}
if(window.event)
{Y=window.event.clientY;X=window.event.clientX;}
else
{X=e.clientX;Y=e.clientY;}
if(X<iClientX*2/3)iLeft=w+imgPos.x+"px";else iLeft=-50-defaultWidth+imgPos.x+"px";if(Y<iClientY*2/3)iTop=imgPos.y+"px";else iTop=-defaultHeight+imgPos.y+"px";}
zoomImgCtr.style.left=iLeft;zoomImgCtr.style.top=iTop;}
ctr.style.display="block";zoomImgCtr.style.visibility="visible";zoomImgCtr.style.backgroundColor="#FFFFFF";var pos=getEventMousePos(zoomInput,e);if(e.srcElement&&isIE){if(e.srcElement==zoom)return;if(e.srcElement!=zoomInput){var zoomImgPos=getElementPos(e.srcElement);pos.x-=(imgPos.x-zoomImgPos.x);pos.y-=(imgPos.y-zoomImgPos.y);}}
var x=markerWidth/2;var y=markerHeight/2;if(!isIE){pos.x-=imgLeft;pos.y-=imgTop;}
if(pos.x<x)pos.x=x;if(pos.x>w-x)pos.x=w-x;if(pos.y<y)pos.y=y;if(pos.y>h-y)pos.y=h-y;var left=((pos.x-x)|0);var top=((pos.y-y)|0);zoom.style.left=left+"px";zoom.style.top=top+"px";zoomImg.style.left=-((pos.x*ratioW-ctrWidth/2)|0)+"px";zoomImg.style.top=-((pos.y*ratioH-ctrHeight/2)|0)+"px";});});setTimeout(function(){zoomImg.src=img.getAttribute("data-zoomsrc");},1);},1);}
function init(){var images=document.getElementsByTagName("img");for(var i=0;i<images.length;i++){var img=images[i];var zoomSrc=img.getAttribute("data-zoomsrc");if(zoomSrc){makeZoomable(img,zoomSrc,document.getElementById(img.getAttribute("id")+"_zoom"),null,null,img.getAttribute("data-zoomalwaysshow")=="true");}}}
return{addEvent:addEvent,init:init,makeZoomable:makeZoomable};})();MojoZoom.addEvent(window,"load",MojoZoom.init);function displayZoom(ctrl,sURL,sID)
{var i=0,objImage,sURL0;if(!MojoZoom||!sURL||!sURL.length||!sID||!sID.length)return;for(i=0;i<document.images.length;i++)
{objImage=document.images[i];if(objImage.getAttribute('name')==sID||objImage.getAttribute('id')==sID)
{sURL0=objImage.getAttribute('data-zoomsrc');if(sURL0!=sURL)
{objImage.setAttribute('data-zoomsrc',sURL);setTimeout("MojoZoom.init()",100);ctrl.onmousemove=null;}
break;}}}
// SprySearchCombined
var REGEXP_UNICODE=function(){for(var b=[" ","\u0120",-1,"!","\u0120",-1,"\u0120","\u0120",0,"\u0121","\u0120",-1,"\u0121","\u0120|\u0121",0,"\u0122","\u0120|\u0121",-1,"\u0120","[\u0120]",0,"\u0121","[\u0120]",-1,"\u0121","[\u0120\u0121]",0,"\u0122","[\u0120\u0121]",-1,"\u0121","[\u0120-\u0121]",0,"\u0122","[\u0120-\u0121]",-1],a=0;a<b.length;a+=3)if(b[a].search(new RegExp(b[a+1]))!=b[a+2])return false;return true}(),XML_S="[ \t\r\n]+",XML_EQ="("+XML_S+")?=("+XML_S+")?",XML_CHAR_REF="&#[0-9]+;|&#x[0-9a-fA-F]+;",XML10_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.0\"|'1\\.0')",XML10_BASE_CHAR=REGEXP_UNICODE?"A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3":"A-Za-z",XML10_IDEOGRAPHIC=REGEXP_UNICODE?"\u4e00-\u9fa5\u3007\u3021-\u3029":"",XML10_COMBINING_CHAR=REGEXP_UNICODE?"\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a":"",XML10_DIGIT=REGEXP_UNICODE?"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29":"0-9",XML10_EXTENDER=REGEXP_UNICODE?"\u00b7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035\u309d-\u309e\u30fc-\u30fe":"",XML10_LETTER=XML10_BASE_CHAR+XML10_IDEOGRAPHIC,XML10_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._:"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-",XML10_NAME="["+XML10_LETTER+"_:]["+XML10_NAME_CHAR+"]*",XML10_ENTITY_REF="&"+XML10_NAME+";",XML10_REFERENCE=XML10_ENTITY_REF+"|"+XML_CHAR_REF,XML10_ATT_VALUE='"(([^<&"]|'+XML10_REFERENCE+")*)\"|'(([^<&']|"+XML10_REFERENCE+")*)'",XML10_ATTRIBUTE="("+XML10_NAME+")"+XML_EQ+"("+XML10_ATT_VALUE+")",XML11_VERSION_INFO=XML_S+"version"+XML_EQ+"(\"1\\.1\"|'1\\.1')",XML11_NAME_START_CHAR=REGEXP_UNICODE?":A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd":":A-Z_a-z",XML11_NAME_CHAR=XML11_NAME_START_CHAR+(REGEXP_UNICODE?"\\.0-9\u00b7\u0300-\u036f\u203f-\u2040-":"\\.0-9-"),XML11_NAME="["+XML11_NAME_START_CHAR+"]["+XML11_NAME_CHAR+"]*",XML11_ENTITY_REF="&"+XML11_NAME+";",XML11_REFERENCE=XML11_ENTITY_REF+"|"+XML_CHAR_REF,XML11_ATT_VALUE='"(([^<&"]|'+XML11_REFERENCE+")*)\"|'(([^<&']|"+XML11_REFERENCE+")*)'",XML11_ATTRIBUTE="("+XML11_NAME+")"+XML_EQ+"("+XML11_ATT_VALUE+")",XML_NC_NAME_CHAR=XML10_LETTER+XML10_DIGIT+"\\._"+XML10_COMBINING_CHAR+XML10_EXTENDER+"-",XML_NC_NAME="["+XML10_LETTER+"_]["+XML_NC_NAME_CHAR+"]*",DOM_ELEMENT_NODE=1,DOM_ATTRIBUTE_NODE=2,DOM_TEXT_NODE=3,DOM_CDATA_SECTION_NODE=4,DOM_ENTITY_REFERENCE_NODE=5,DOM_ENTITY_NODE=6,DOM_PROCESSING_INSTRUCTION_NODE=7,DOM_COMMENT_NODE=8,DOM_DOCUMENT_NODE=9,DOM_DOCUMENT_TYPE_NODE=10,DOM_DOCUMENT_FRAGMENT_NODE=11,DOM_NOTATION_NODE=12;function xpathLog(){}function xsltLog(){}function xsltLogXml(){}function assert(a){if(!a)throw"Assertion failed";}function stringSplit(b,e){var a=b.indexOf(e);if(a==-1)return[b];var c=[];c.push(b.substr(0,a));while(a!=-1){var d=b.indexOf(e,a+1);if(d!=-1)c.push(b.substr(a+1,d-a-1));else c.push(b.substr(a+1));a=d}return c}function mapExec(b,c){for(var a=0;a<b.length;++a)c.call(this,b[a],a)}function mapExpr(b,d){for(var c=[],a=0;a<b.length;++a)c.push(d(b[a]));return c}function reverseInplace(a){for(var b=0;b<a.length/2;++b){var d=a[b],c=a.length-b-1;a[b]=a[c];a[c]=d}}function removeFromArray(b,d,e){for(var c=0,a=0;a<b.length;++a)if(b[a]===d||e&&b[a]==d){b.splice(a--,1);c++}return c}function copyArray(c,b){for(var a=0;a<b.length;++a)c.push(b[a])}function xmlValue(a){if(!a)return"";var b="";if(a.nodeType==DOM_TEXT_NODE||a.nodeType==DOM_CDATA_SECTION_NODE||a.nodeType==DOM_ATTRIBUTE_NODE)b+=a.nodeValue;else if(a.nodeType==DOM_ELEMENT_NODE||a.nodeType==DOM_DOCUMENT_NODE||a.nodeType==DOM_DOCUMENT_FRAGMENT_NODE)for(var c=0;c<a.childNodes.length;++c)b+=arguments.callee(a.childNodes[c]);return b}function xpathParse(a){xpathLog("parse "+a);xpathParseInit();var n=xpathCacheLookup(a);if(n){xpathLog(" ... cached");return n}if(a.match(/^(\$|@)?\w+$/i)){var h=makeSimpleExpr(a);xpathParseCache[a]=h;xpathLog(" ... simple");return h}if(a.match(/^\w+(\/\w+)*$/i)){var h=makeSimpleExpr2(a);xpathParseCache[a]=h;xpathLog(" ... simple 2");return h}var m=a,f=[],g=null,c=null,o=false,l=0,k=0,j=0;while(!o){l++;a=a.replace(/^\s*/,"");c=g;g=null;for(var b=null,e="",i=0;i<xpathTokenRules.length;++i){var d=xpathTokenRules[i].re.exec(a);k++;if(d&&d.length>0&&d[0].length>e.length){b=xpathTokenRules[i];e=d[0];break}}if(b&&(b==TOK_DIV||b==TOK_MOD||b==TOK_AND||b==TOK_OR)&&(!c||c.tag==TOK_AT||c.tag==TOK_DSLASH||c.tag==TOK_SLASH||c.tag==TOK_AXIS||c.tag==TOK_DOLLAR))b=TOK_QNAME;if(b){a=a.substr(e.length);xpathLog("token: "+e+" -- "+b.label);g={tag:b,match:e,prec:b.prec?b.prec:0,expr:makeTokenExpr(e)}}else{xpathLog("DONE");o=true}while(xpathReduce(f,g)){j++;xpathLog("stack: "+stackToString(f))}}xpathLog("stack: "+stackToString(f));if(f.length!=1)throw"XPath parse error "+m+":\n"+stackToString(f);var d=f[0].expr;xpathParseCache[m]=d;xpathLog("XPath parse: "+l+" / "+k+" / "+j);return d}var xpathParseCache={};function xpathCacheLookup(a){return xpathParseCache[a]}function xpathReduce(c,b){var a=null;if(c.length>0){var j=c[c.length-1],e=xpathRules[j.tag.key];if(e)for(var d=0;d<e.length;++d){var f=e[d],h=xpathMatchStack(c,f[1]);if(h.length){a={tag:f[0],rule:f,match:h};a.prec=xpathGrammarPrecedence(a);break}}}var g;if(a&&(!b||a.prec>b.prec||b.tag.left&&a.prec>=b.prec)){for(var d=0;d<a.match.matchlength;++d)c.pop();xpathLog("reduce "+a.tag.label+" "+a.prec+" ahead "+(b?b.tag.label+" "+b.prec+(b.tag.left?" left":""):" none "));var i=mapExpr(a.match,function(a){return a.expr});a.expr=a.rule[3].apply(null,i);c.push(a);g=true}else{if(b){xpathLog("shift "+b.tag.label+" "+b.prec+(b.tag.left?" left":"")+" over "+(a?a.tag.label+" "+a.prec:" none"));c.push(b)}g=false}return g}function xpathMatchStack(e,f){var i=e.length,h=f.length,b,c,d=[];d.matchlength=0;var a=0;for(b=h-1,c=i-1;b>=0&&c>=0;--b,c-=a){a=0;var g=[];if(f[b]==Q_MM){b-=1;d.push(g);while(c-a>=0&&e[c-a].tag==f[b]){g.push(e[c-a]);a+=1;d.matchlength+=1}}else if(f[b]==Q_01){b-=1;d.push(g);while(c-a>=0&&a<2&&e[c-a].tag==f[b]){g.push(e[c-a]);a+=1;d.matchlength+=1}}else if(f[b]==Q_1M){b-=1;d.push(g);if(e[c].tag==f[b])while(c-a>=0&&e[c-a].tag==f[b]){g.push(e[c-a]);a+=1;d.matchlength+=1}else return[]}else if(e[c].tag==f[b]){d.push(e[c]);a+=1;d.matchlength+=1}else return[];reverseInplace(g);g.expr=mapExpr(g,function(a){return a.expr})}reverseInplace(d);return b==-1?d:[]}function xpathTokenPrecedence(a){return a.prec||2}function xpathGrammarPrecedence(a){var b=0;if(a.rule)if(a.rule.length>=3&&a.rule[2]>=0)b=a.rule[2];else for(var c=0;c<a.rule[1].length;++c){var e=xpathTokenPrecedence(a.rule[1][c]);b=Math.max(b,e)}else if(a.tag)b=xpathTokenPrecedence(a.tag);else if(a.length)for(var d=0;d<a.length;++d){var e=xpathGrammarPrecedence(a[d]);b=Math.max(b,e)}return b}function stackToString(c){for(var a="",b=0;b<c.length;++b){if(a)a+="\n";a+=c[b].tag.label}return a}function ExprContext(a,d,c,b){this.node=a;this.position=d||0;this.nodelist=c||[a];this.variables={};this.parent=b||null;if(b)this.root=b.root;else if(this.node.nodeType==DOM_DOCUMENT_NODE)this.root=a;else this.root=a.ownerDocument}ExprContext.prototype.clone=function(c,a,b){return new ExprContext(c||this.node,typeof a!="undefined"?a:this.position,b||this.nodelist,this)};ExprContext.prototype.setVariable=function(b,a){this.variables[b]=a};ExprContext.prototype.getVariable=function(a){return typeof this.variables[a]!="undefined"?this.variables[a]:this.parent?this.parent.getVariable(a):null};ExprContext.prototype.setNode=function(a){this.node=this.nodelist[a];this.position=a};ExprContext.prototype.contextSize=function(){return this.nodelist.length};function StringValue(a){this.value=a;this.type="string"}StringValue.prototype.stringValue=function(){return this.value};StringValue.prototype.booleanValue=function(){return this.value.length>0};StringValue.prototype.numberValue=function(){return this.value-0};StringValue.prototype.nodeSetValue=function(){throw this;};function BooleanValue(a){this.value=a;this.type="boolean"}BooleanValue.prototype.stringValue=function(){return""+this.value};BooleanValue.prototype.booleanValue=function(){return this.value};BooleanValue.prototype.numberValue=function(){return this.value?1:0};BooleanValue.prototype.nodeSetValue=function(){throw this;};function NumberValue(a){this.value=a;this.type="number"}NumberValue.prototype.stringValue=function(){return""+this.value};NumberValue.prototype.booleanValue=function(){return!!this.value};NumberValue.prototype.numberValue=function(){return this.value-0};NumberValue.prototype.nodeSetValue=function(){throw this;};function NodeSetValue(a){this.value=a;this.type="node-set"}NodeSetValue.prototype.stringValue=function(){return this.value.length==0?"":xmlValue(this.value[0])};NodeSetValue.prototype.booleanValue=function(){return this.value.length>0};NodeSetValue.prototype.numberValue=function(){return this.stringValue()-0};NodeSetValue.prototype.nodeSetValue=function(){return this.value};function TokenExpr(a){this.value=a}TokenExpr.prototype.evaluate=function(){return new StringValue(this.value)};function LocationExpr(){this.absolute=false;this.steps=[]}LocationExpr.prototype.appendStep=function(a){this.steps.push(a)};LocationExpr.prototype.prependStep=function(c){var b=this.steps;this.steps=[c];for(var a=0;a<b.length;++a)this.steps.push(b[a])};LocationExpr.prototype.evaluate=function(b){var a;if(this.absolute)a=b.root;else a=b.node;var c=[];xPathStep(c,this.steps,0,a,b);return new NodeSetValue(c)};function xPathStep(e,c,d,g,f){for(var i=c[d],h=f.clone(g),b=i.evaluate(h).nodeSetValue(),a=0;a<b.length;++a)if(d==c.length-1)e.push(b[a]);else xPathStep(e,c,d+1,b[a],f)}function StepExpr(c,b,a){this.axis=c;this.nodetest=b;this.predicate=a||[]}StepExpr.prototype.appendPredicate=function(a){this.predicate.push(a)};StepExpr.prototype.evaluate=function(h){var c=h.node,b=[];if(this.axis==xpathAxis.ANCESTOR_OR_SELF){b.push(c);for(var a=c.parentNode;a;a=a.parentNode)b.push(a)}else if(this.axis==xpathAxis.ANCESTOR)for(var a=c.parentNode;a;a=a.parentNode)b.push(a);else if(this.axis==xpathAxis.ATTRIBUTE)copyArray(b,c.attributes);else if(this.axis==xpathAxis.CHILD)copyArray(b,c.childNodes);else if(this.axis==xpathAxis.DESCENDANT_OR_SELF){b.push(c);xpathCollectDescendants(b,c)}else if(this.axis==xpathAxis.DESCENDANT)xpathCollectDescendants(b,c);else if(this.axis==xpathAxis.FOLLOWING)for(var a=c;a;a=a.parentNode)for(var d=a.nextSibling;d;d=d.nextSibling){b.push(d);xpathCollectDescendants(b,d)}else if(this.axis==xpathAxis.FOLLOWING_SIBLING)for(var a=c.nextSibling;a;a=a.nextSibling)b.push(a);else if(this.axis==xpathAxis.NAMESPACE)alert("not implemented: axis namespace");else if(this.axis==xpathAxis.PARENT)c.parentNode&&b.push(c.parentNode);else if(this.axis==xpathAxis.PRECEDING)for(var a=c;a;a=a.parentNode)for(var d=a.previousSibling;d;d=d.previousSibling){b.push(d);xpathCollectDescendantsReverse(b,d)}else if(this.axis==xpathAxis.PRECEDING_SIBLING)for(var a=c.previousSibling;a;a=a.previousSibling)b.push(a);else if(this.axis==xpathAxis.SELF)b.push(c);else throw"ERROR -- NO SUCH AXIS: "+this.axis;var f=b;b=[];for(var e=0;e<f.length;++e){var a=f[e];this.nodetest.evaluate(h.clone(a,e,f)).booleanValue()&&b.push(a)}for(var e=0;e<this.predicate.length;++e){var f=b;b=[];for(var g=0;g<f.length;++g){var a=f[g];this.predicate[e].evaluate(h.clone(a,g,f)).booleanValue()&&b.push(a)}}return new NodeSetValue(b)};function NodeTestAny(){this.value=new BooleanValue(true)}NodeTestAny.prototype.evaluate=function(){return this.value};function NodeTestElementOrAttribute(){}NodeTestElementOrAttribute.prototype.evaluate=function(a){return new BooleanValue(a.node.nodeType==DOM_ELEMENT_NODE||a.node.nodeType==DOM_ATTRIBUTE_NODE)};function NodeTestText(){}NodeTestText.prototype.evaluate=function(a){return new BooleanValue(a.node.nodeType==DOM_TEXT_NODE)};function NodeTestComment(){}NodeTestComment.prototype.evaluate=function(a){return new BooleanValue(a.node.nodeType==DOM_COMMENT_NODE)};function NodeTestPI(a){this.target=a}NodeTestPI.prototype.evaluate=function(a){return new BooleanValue(a.node.nodeType==DOM_PROCESSING_INSTRUCTION_NODE&&(!this.target||a.node.nodeName==this.target))};function NodeTestNC(a){this.regex=new RegExp("^"+a+":");this.nsprefix=a}NodeTestNC.prototype.evaluate=function(a){var b=a.node;return new BooleanValue(this.regex.match(b.nodeName))};function NodeTestName(a){this.name=a}NodeTestName.prototype.evaluate=function(a){var b=a.node;return new BooleanValue(b.nodeName==this.name)};function PredicateExpr(a){this.expr=a}PredicateExpr.prototype.evaluate=function(b){var a=this.expr.evaluate(b);return a.type=="number"?new BooleanValue(b.position==a.numberValue()-1):new BooleanValue(a.booleanValue())};function FunctionCallExpr(a){this.name=a;this.args=[]}FunctionCallExpr.prototype.appendArg=function(a){this.args.push(a)};FunctionCallExpr.prototype.evaluate=function(c){var a=""+this.name.value,b=this.xpathfunctions[a];if(b)return b.call(this,c);else{xpathLog("XPath NO SUCH FUNCTION "+a);return new BooleanValue(false)}};FunctionCallExpr.prototype.xpathfunctions={last:function(a){assert(this.args.length==0);return new NumberValue(a.contextSize())},position:function(a){assert(this.args.length==0);return new NumberValue(a.position+1)},count:function(a){assert(this.args.length==1);var b=this.args[0].evaluate(a);return new NumberValue(b.nodeSetValue().length)},id:function(e){assert(this.args.length==1);var d=this.args[0].evaluate(e),f=[],b;if(d.type=="node-set"){b=[];for(var g=d.nodeSetValue(),a=0;a<g.length;++a)for(var i=xmlValue(g[a]).split(/\s+/),c=0;c<i.length;++c)b.push(i[c])}else b=d.stringValue().split(/\s+/);for(var j=e.node.ownerDocument,a=0;a<b.length;++a){var h=j.getElementById(b[a]);h&&f.push(h)}return new NodeSetValue(f)},"local-name":function(){alert("not implmented yet: XPath function local-name()")},"namespace-uri":function(){alert("not implmented yet: XPath function namespace-uri()")},name:function(b){assert(this.args.length==1||this.args.length==0);var a;if(this.args.length==0)a=[b.node];else a=this.args[0].evaluate(b).nodeSetValue();return a.length==0?new StringValue(""):new StringValue(a[0].nodeName)},string:function(a){assert(this.args.length==1||this.args.length==0);return this.args.length==0?new StringValue((new NodeSetValue([a.node])).stringValue()):new StringValue(this.args[0].evaluate(a).stringValue())},concat:function(c){for(var b="",a=0;a<this.args.length;++a)b+=this.args[a].evaluate(c).stringValue();return new StringValue(b)},"starts-with":function(a){assert(this.args.length==2);var b=this.args[0].evaluate(a).stringValue(),c=this.args[1].evaluate(a).stringValue();return new BooleanValue(b.indexOf(c)==0)},contains:function(a){assert(this.args.length==2);var b=this.args[0].evaluate(a).stringValue(),c=this.args[1].evaluate(a).stringValue();return new BooleanValue(b.indexOf(c)!=-1)},"substring-before":function(b){assert(this.args.length==2);var c=this.args[0].evaluate(b).stringValue(),e=this.args[1].evaluate(b).stringValue(),d=c.indexOf(e),a;if(d==-1)a="";else a=c.substr(0,d);return new StringValue(a)},"substring-after":function(b){assert(this.args.length==2);var c=this.args[0].evaluate(b).stringValue(),d=this.args[1].evaluate(b).stringValue(),e=c.indexOf(d),a;if(e==-1)a="";else a=c.substr(e+d.length);return new StringValue(a)},substring:function(a){assert(this.args.length==2||this.args.length==3);var e=this.args[0].evaluate(a).stringValue(),f=this.args[1].evaluate(a).numberValue(),b;if(this.args.length==2){var d=Math.max(0,Math.round(f)-1);b=e.substr(d)}else{var h=this.args[2].evaluate(a).numberValue(),c=Math.round(f)-1,d=Math.max(0,c),g=Math.round(h)-Math.max(0,-c);b=e.substr(d,g)}return new StringValue(b)},"string-length":function(b){var a;if(this.args.length>0)a=this.args[0].evaluate(b).stringValue();else a=(new NodeSetValue([b.node])).stringValue();return new NumberValue(a.length)},"normalize-space":function(b){var a;if(this.args.length>0)a=this.args[0].evaluate(b).stringValue();else a=(new NodeSetValue([b.node])).stringValue();a=a.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");return new StringValue(a)},translate:function(b){assert(this.args.length==3);for(var c=this.args[0].evaluate(b).stringValue(),d=this.args[1].evaluate(b).stringValue(),e=this.args[2].evaluate(b).stringValue(),a=0;a<d.length;++a)c=c.replace(new RegExp(d.charAt(a),"g"),e.charAt(a));return new StringValue(c)},"boolean":function(a){assert(this.args.length==1);return new BooleanValue(this.args[0].evaluate(a).booleanValue())},not:function(a){assert(this.args.length==1);var b=!this.args[0].evaluate(a).booleanValue();return new BooleanValue(b)},"true":function(){assert(this.args.length==0);return new BooleanValue(true)},"false":function(){assert(this.args.length==0);return new BooleanValue(false)},lang:function(c){assert(this.args.length==1);var e=this.args[0].evaluate(c).stringValue(),b,a=c.node;while(a&&a!=a.parentNode){b=a.getAttribute("xml:lang");if(b)break;a=a.parentNode}if(!b)return new BooleanValue(false);else{var d=new RegExp("^"+e+"$","i");return new BooleanValue(b.match(d)||b.replace(/_.*$/,"").match(d))}},number:function(a){assert(this.args.length==1||this.args.length==0);return this.args.length==1?new NumberValue(this.args[0].evaluate(a).numberValue()):new NumberValue((new NodeSetValue([a.node])).numberValue())},sum:function(d){assert(this.args.length==1);for(var c=this.args[0].evaluate(d).nodeSetValue(),b=0,a=0;a<c.length;++a)b+=xmlValue(c[a])-0;return new NumberValue(b)},floor:function(a){assert(this.args.length==1);var b=this.args[0].evaluate(a).numberValue();return new NumberValue(Math.floor(b))},ceiling:function(a){assert(this.args.length==1);var b=this.args[0].evaluate(a).numberValue();return new NumberValue(Math.ceil(b))},round:function(a){assert(this.args.length==1);var b=this.args[0].evaluate(a).numberValue();return new NumberValue(Math.round(b))},"ext-join":function(d){assert(this.args.length==2);for(var c=this.args[0].evaluate(d).nodeSetValue(),e=this.args[1].evaluate(d).stringValue(),a="",b=0;b<c.length;++b){if(a)a+=e;a+=xmlValue(c[b])}return new StringValue(a)},"ext-if":function(a){assert(this.args.length==3);return this.args[0].evaluate(a).booleanValue()?this.args[1].evaluate(a):this.args[2].evaluate(a)},"ext-cardinal":function(a){assert(this.args.length>=1);for(var d=this.args[0].evaluate(a).numberValue(),b=[],c=0;c<d;++c)b.push(a.node);return new NodeSetValue(b)}};function UnionExpr(a,b){this.expr1=a;this.expr2=b}UnionExpr.prototype.evaluate=function(f){for(var a=this.expr1.evaluate(f).nodeSetValue(),e=this.expr2.evaluate(f).nodeSetValue(),g=a.length,c=0;c<e.length;++c){for(var h=e[c],d=false,b=0;b<g;++b)if(a[b]==h){d=true;b=g}!d&&a.push(h)}return new NodeSetValue(a)};function PathExpr(a,b){this.filter=a;this.rel=b}PathExpr.prototype.evaluate=function(f){for(var b=this.filter.evaluate(f).nodeSetValue(),e=[],a=0;a<b.length;++a)for(var d=this.rel.evaluate(f.clone(b[a],a,b)).nodeSetValue(),c=0;c<d.length;++c)e.push(d[c]);return new NodeSetValue(e)};function FilterExpr(b,a){this.expr=b;this.predicate=a}FilterExpr.prototype.evaluate=function(e){for(var a=this.expr.evaluate(e).nodeSetValue(),d=0;d<this.predicate.length;++d){var c=a;a=[];for(var b=0;b<c.length;++b){var f=c[b];this.predicate[d].evaluate(e.clone(f,b,c)).booleanValue()&&a.push(f)}}return new NodeSetValue(a)};function UnaryMinusExpr(a){this.expr=a}UnaryMinusExpr.prototype.evaluate=function(a){return new NumberValue(-this.expr.evaluate(a).numberValue())};function BinaryExpr(a,c,b){this.expr1=a;this.expr2=b;this.op=c}BinaryExpr.prototype.evaluate=function(a){var b;switch(this.op.value){case"or":b=new BooleanValue(this.expr1.evaluate(a).booleanValue()||this.expr2.evaluate(a).booleanValue());break;case"and":b=new BooleanValue(this.expr1.evaluate(a).booleanValue()&&this.expr2.evaluate(a).booleanValue());break;case"+":b=new NumberValue(this.expr1.evaluate(a).numberValue()+this.expr2.evaluate(a).numberValue());break;case"-":b=new NumberValue(this.expr1.evaluate(a).numberValue()-this.expr2.evaluate(a).numberValue());break;case"*":b=new NumberValue(this.expr1.evaluate(a).numberValue()*this.expr2.evaluate(a).numberValue());break;case"mod":b=new NumberValue(this.expr1.evaluate(a).numberValue()%this.expr2.evaluate(a).numberValue());break;case"div":b=new NumberValue(this.expr1.evaluate(a).numberValue()/this.expr2.evaluate(a).numberValue());break;case"=":b=this.compare(a,function(a,b){return a==b});break;case"!=":b=this.compare(a,function(a,b){return a!=b});break;case"<":b=this.compare(a,function(a,b){return a<b});break;case"<=":b=this.compare(a,function(a,b){return a<=b});break;case">":b=this.compare(a,function(a,b){return a>b});break;case">=":b=this.compare(a,function(a,b){return a>=b});break;default:alert("BinaryExpr.evaluate: "+this.op.value)}return b};BinaryExpr.prototype.compare=function(m,e){var b=this.expr1.evaluate(m),c=this.expr2.evaluate(m),a;if(b.type=="node-set"&&c.type=="node-set"){var k=b.nodeSetValue(),l=c.nodeSetValue();a=false;for(var g=0;g<k.length;++g)for(var h=0;h<l.length;++h)if(e(xmlValue(k[g]),xmlValue(l[h]))){a=true;h=l.length;g=k.length}}else if(b.type=="node-set"||c.type=="node-set")if(b.type=="number"){var j=b.numberValue(),f=c.nodeSetValue();a=false;for(var d=0;d<f.length;++d){var i=xmlValue(f[d])-0;if(e(j,i)){a=true;break}}}else if(c.type=="number"){var f=b.nodeSetValue(),j=c.numberValue();a=false;for(var d=0;d<f.length;++d){var i=xmlValue(f[d])-0;if(e(i,j)){a=true;break}}}else if(b.type=="string"){var j=b.stringValue(),f=c.nodeSetValue();a=false;for(var d=0;d<f.length;++d){var i=xmlValue(f[d]);if(e(j,i)){a=true;break}}}else if(c.type=="string"){var f=b.nodeSetValue(),j=c.stringValue();a=false;for(var d=0;d<f.length;++d){var i=xmlValue(f[d]);if(e(i,j)){a=true;break}}}else a=e(b.booleanValue(),c.booleanValue());else if(b.type=="boolean"||c.type=="boolean")a=e(b.booleanValue(),c.booleanValue());else if(b.type=="number"||c.type=="number")a=e(b.numberValue(),c.numberValue());else a=e(b.stringValue(),c.stringValue());return new BooleanValue(a)};function LiteralExpr(a){this.value=a}LiteralExpr.prototype.evaluate=function(){return new StringValue(this.value)};function NumberExpr(a){this.value=a}NumberExpr.prototype.evaluate=function(){return new NumberValue(this.value)};function VariableExpr(a){this.name=a}VariableExpr.prototype.evaluate=function(a){return a.getVariable(this.name)};function makeTokenExpr(a){return new TokenExpr(a)}function passExpr(a){return a}function makeLocationExpr1(b,a){a.absolute=true;return a}function makeLocationExpr2(b,a){a.absolute=true;a.prependStep(makeAbbrevStep(b.value));return a}function makeLocationExpr3(){var a=new LocationExpr;a.appendStep(makeAbbrevStep("."));a.absolute=true;return a}function makeLocationExpr4(b){var a=new LocationExpr;a.absolute=true;a.appendStep(makeAbbrevStep(b.value));return a}function makeLocationExpr5(b){var a=new LocationExpr;a.appendStep(b);return a}function makeLocationExpr6(a,c,b){a.appendStep(b);return a}function makeLocationExpr7(a,b){a.appendStep(makeAbbrevStep(b.value));return a}function makeStepExpr1(a){return makeAbbrevStep(a.value)}function makeStepExpr2(a){return makeAbbrevStep(a.value)}function makeStepExpr3(a,c,b){return new StepExpr(a.value,b)}function makeStepExpr4(b,a){return new StepExpr("attribute",a)}function makeStepExpr5(a){return new StepExpr("child",a)}function makeStepExpr6(a,b){a.appendPredicate(b);return a}function makeAbbrevStep(a){switch(a){case"//":return new StepExpr("descendant-or-self",new NodeTestAny);case".":return new StepExpr("self",new NodeTestAny);case"..":return new StepExpr("parent",new NodeTestAny)}}function makeNodeTestExpr1(){return new NodeTestElementOrAttribute}function makeNodeTestExpr2(a){return new NodeTestNC(a.value)}function makeNodeTestExpr3(a){return new NodeTestName(a.value)}function makeNodeTestExpr4(a){var b=a.value.replace(/\s*\($/,"");switch(b){case"node":return new NodeTestAny;case"text":return new NodeTestText;case"comment":return new NodeTestComment;case"processing-instruction":return new NodeTestPI("")}}function makeNodeTestExpr5(c,b){var a=c.replace(/\s*\($/,"");if(a!="processing-instruction")throw a;return new NodeTestPI(b.value)}function makePredicateExpr(c,a){return new PredicateExpr(a)}function makePrimaryExpr(c,a){return a}function makeFunctionCallExpr1(a){return new FunctionCallExpr(a)}function makeFunctionCallExpr2(e,g,d,c){var a=new FunctionCallExpr(e);a.appendArg(d);for(var b=0;b<c.length;++b)a.appendArg(c[b]);return a}function makeArgumentExpr(b,a){return a}function makeUnionExpr(a,c,b){return new UnionExpr(a,b)}function makePathExpr1(a,c,b){return new PathExpr(a,b)}function makePathExpr2(c,b,a){a.prependStep(makeAbbrevStep(b.value));return new PathExpr(c,a)}function makeFilterExpr(b,a){return a.length>0?new FilterExpr(b,a):b}function makeUnaryMinusExpr(b,a){return new UnaryMinusExpr(a)}function makeBinaryExpr(a,c,b){return new BinaryExpr(a,c,b)}function makeLiteralExpr(a){var b=a.value.substring(1,a.value.length-1);return new LiteralExpr(b)}function makeNumberExpr(a){return new NumberExpr(a.value)}function makeVariableReference(b,a){return new VariableExpr(a.value)}function makeSimpleExpr(a){if(a.charAt(0)=="$")return new VariableExpr(a.substr(1));else if(a.charAt(0)=="@"){var c=new NodeTestName(a.substr(1)),d=new StepExpr("attribute",c),b=new LocationExpr;b.appendStep(d);return b}else if(a.match(/^[0-9]+$/))return new NumberExpr(a);else{var c=new NodeTestName(a),d=new StepExpr("child",c),b=new LocationExpr;b.appendStep(d);return b}}function makeSimpleExpr2(d){for(var b=stringSplit(d,"/"),c=new LocationExpr,a=0;a<b.length;++a){var e=new NodeTestName(b[a]),f=new StepExpr("child",e);c.appendStep(f)}return c}var xpathAxis={ANCESTOR_OR_SELF:"ancestor-or-self",ANCESTOR:"ancestor",ATTRIBUTE:"attribute",CHILD:"child",DESCENDANT_OR_SELF:"descendant-or-self",DESCENDANT:"descendant",FOLLOWING_SIBLING:"following-sibling",FOLLOWING:"following",NAMESPACE:"namespace",PARENT:"parent",PRECEDING_SIBLING:"preceding-sibling",PRECEDING:"preceding",SELF:"self"},xpathAxesRe=[xpathAxis.ANCESTOR_OR_SELF,xpathAxis.ANCESTOR,xpathAxis.ATTRIBUTE,xpathAxis.CHILD,xpathAxis.DESCENDANT_OR_SELF,xpathAxis.DESCENDANT,xpathAxis.FOLLOWING_SIBLING,xpathAxis.FOLLOWING,xpathAxis.NAMESPACE,xpathAxis.PARENT,xpathAxis.PRECEDING_SIBLING,xpathAxis.PRECEDING,xpathAxis.SELF].join("|"),TOK_PIPE={label:"|",prec:17,re:new RegExp("^\\|")},TOK_DSLASH={label:"//",prec:19,re:new RegExp("^//")},TOK_SLASH={label:"/",prec:30,re:new RegExp("^/")},TOK_AXIS={label:"::",prec:20,re:new RegExp("^::")},TOK_COLON={label:":",prec:1e3,re:new RegExp("^:")},TOK_AXISNAME={label:"[axis]",re:new RegExp("^("+xpathAxesRe+")")},TOK_PARENO={label:"(",prec:34,re:new RegExp("^\\(")},TOK_PARENC={label:")",re:new RegExp("^\\)")},TOK_DDOT={label:"..",prec:34,re:new RegExp("^\\.\\.")},TOK_DOT={label:".",prec:34,re:new RegExp("^\\.")},TOK_AT={label:"@",prec:34,re:new RegExp("^@")},TOK_COMMA={label:",",re:new RegExp("^,")},TOK_OR={label:"or",prec:10,re:new RegExp("^or\\b")},TOK_AND={label:"and",prec:11,re:new RegExp("^and\\b")},TOK_EQ={label:"=",prec:12,re:new RegExp("^=")},TOK_NEQ={label:"!=",prec:12,re:new RegExp("^!=")},TOK_GE={label:">=",prec:13,re:new RegExp("^>=")},TOK_GT={label:">",prec:13,re:new RegExp("^>")},TOK_LE={label:"<=",prec:13,re:new RegExp("^<=")},TOK_LT={label:"<",prec:13,re:new RegExp("^<")},TOK_PLUS={label:"+",prec:14,re:new RegExp("^\\+"),left:true},TOK_MINUS={label:"-",prec:14,re:new RegExp("^\\-"),left:true},TOK_DIV={label:"div",prec:15,re:new RegExp("^div\\b"),left:true},TOK_MOD={label:"mod",prec:15,re:new RegExp("^mod\\b"),left:true},TOK_BRACKO={label:"[",prec:32,re:new RegExp("^\\[")},TOK_BRACKC={label:"]",re:new RegExp("^\\]")},TOK_DOLLAR={label:"$",re:new RegExp("^\\$")},TOK_NCNAME={label:"[ncname]",re:new RegExp("^"+XML_NC_NAME)},TOK_ASTERISK={label:"*",prec:15,re:new RegExp("^\\*"),left:true},TOK_LITERALQ={label:"[litq]",prec:20,re:new RegExp("^'[^\\']*'")},TOK_LITERALQQ={label:"[litqq]",prec:20,re:new RegExp('^"[^\\"]*"')},TOK_NUMBER={label:"[number]",prec:35,re:new RegExp("^\\d+(\\.\\d*)?")},TOK_QNAME={label:"[qname]",re:new RegExp("^("+XML_NC_NAME+":)?"+XML_NC_NAME)},TOK_NODEO={label:"[nodetest-start]",re:new RegExp("^(processing-instruction|comment|text|node)\\(")},xpathTokenRules=[TOK_DSLASH,TOK_SLASH,TOK_DDOT,TOK_DOT,TOK_AXIS,TOK_COLON,TOK_AXISNAME,TOK_NODEO,TOK_PARENO,TOK_PARENC,TOK_BRACKO,TOK_BRACKC,TOK_AT,TOK_COMMA,TOK_OR,TOK_AND,TOK_NEQ,TOK_EQ,TOK_GE,TOK_GT,TOK_LE,TOK_LT,TOK_PLUS,TOK_MINUS,TOK_ASTERISK,TOK_PIPE,TOK_MOD,TOK_DIV,TOK_LITERALQ,TOK_LITERALQQ,TOK_NUMBER,TOK_QNAME,TOK_NCNAME,TOK_DOLLAR],XPathLocationPath={label:"LocationPath"},XPathRelativeLocationPath={label:"RelativeLocationPath"},XPathAbsoluteLocationPath={label:"AbsoluteLocationPath"},XPathStep={label:"Step"},XPathNodeTest={label:"NodeTest"},XPathPredicate={label:"Predicate"},XPathLiteral={label:"Literal"},XPathExpr={label:"Expr"},XPathPrimaryExpr={label:"PrimaryExpr"},XPathVariableReference={label:"Variablereference"},XPathNumber={label:"Number"},XPathFunctionCall={label:"FunctionCall"},XPathArgumentRemainder={label:"ArgumentRemainder"},XPathPathExpr={label:"PathExpr"},XPathUnionExpr={label:"UnionExpr"},XPathFilterExpr={label:"FilterExpr"},XPathDigits={label:"Digits"},xpathNonTerminals=[XPathLocationPath,XPathRelativeLocationPath,XPathAbsoluteLocationPath,XPathStep,XPathNodeTest,XPathPredicate,XPathLiteral,XPathExpr,XPathPrimaryExpr,XPathVariableReference,XPathNumber,XPathFunctionCall,XPathArgumentRemainder,XPathPathExpr,XPathUnionExpr,XPathFilterExpr,XPathDigits],Q_01={label:"?"},Q_MM={label:"*"},Q_1M={label:"+"},ASSOC_LEFT=true,xpathGrammarRules=[[XPathLocationPath,[XPathRelativeLocationPath],18,passExpr],[XPathLocationPath,[XPathAbsoluteLocationPath],18,passExpr],[XPathAbsoluteLocationPath,[TOK_SLASH,XPathRelativeLocationPath],18,makeLocationExpr1],[XPathAbsoluteLocationPath,[TOK_DSLASH,XPathRelativeLocationPath],18,makeLocationExpr2],[XPathAbsoluteLocationPath,[TOK_SLASH],0,makeLocationExpr3],[XPathAbsoluteLocationPath,[TOK_DSLASH],0,makeLocationExpr4],[XPathRelativeLocationPath,[XPathStep],31,makeLocationExpr5],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_SLASH,XPathStep],31,makeLocationExpr6],[XPathRelativeLocationPath,[XPathRelativeLocationPath,TOK_DSLASH,XPathStep],31,makeLocationExpr7],[XPathStep,[TOK_DOT],33,makeStepExpr1],[XPathStep,[TOK_DDOT],33,makeStepExpr2],[XPathStep,[TOK_AXISNAME,TOK_AXIS,XPathNodeTest],33,makeStepExpr3],[XPathStep,[TOK_AT,XPathNodeTest],33,makeStepExpr4],[XPathStep,[XPathNodeTest],33,makeStepExpr5],[XPathStep,[XPathStep,XPathPredicate],33,makeStepExpr6],[XPathNodeTest,[TOK_ASTERISK],33,makeNodeTestExpr1],[XPathNodeTest,[TOK_NCNAME,TOK_COLON,TOK_ASTERISK],33,makeNodeTestExpr2],[XPathNodeTest,[TOK_QNAME],33,makeNodeTestExpr3],[XPathNodeTest,[TOK_NODEO,TOK_PARENC],33,makeNodeTestExpr4],[XPathNodeTest,[TOK_NODEO,XPathLiteral,TOK_PARENC],33,makeNodeTestExpr5],[XPathPredicate,[TOK_BRACKO,XPathExpr,TOK_BRACKC],33,makePredicateExpr],[XPathPrimaryExpr,[XPathVariableReference],33,passExpr],[XPathPrimaryExpr,[TOK_PARENO,XPathExpr,TOK_PARENC],33,makePrimaryExpr],[XPathPrimaryExpr,[XPathLiteral],30,passExpr],[XPathPrimaryExpr,[XPathNumber],30,passExpr],[XPathPrimaryExpr,[XPathFunctionCall],30,passExpr],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,TOK_PARENC],-1,makeFunctionCallExpr1],[XPathFunctionCall,[TOK_QNAME,TOK_PARENO,XPathExpr,XPathArgumentRemainder,Q_MM,TOK_PARENC],-1,makeFunctionCallExpr2],[XPathArgumentRemainder,[TOK_COMMA,XPathExpr],-1,makeArgumentExpr],[XPathUnionExpr,[XPathPathExpr],20,passExpr],[XPathUnionExpr,[XPathUnionExpr,TOK_PIPE,XPathPathExpr],20,makeUnionExpr],[XPathPathExpr,[XPathLocationPath],20,passExpr],[XPathPathExpr,[XPathFilterExpr],19,passExpr],[XPathPathExpr,[XPathFilterExpr,TOK_SLASH,XPathRelativeLocationPath],20,makePathExpr1],[XPathPathExpr,[XPathFilterExpr,TOK_DSLASH,XPathRelativeLocationPath],20,makePathExpr2],[XPathFilterExpr,[XPathPrimaryExpr,XPathPredicate,Q_MM],20,makeFilterExpr],[XPathExpr,[XPathPrimaryExpr],16,passExpr],[XPathExpr,[XPathUnionExpr],16,passExpr],[XPathExpr,[TOK_MINUS,XPathExpr],-1,makeUnaryMinusExpr],[XPathExpr,[XPathExpr,TOK_OR,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_AND,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_EQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_NEQ,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_LE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GT,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_GE,XPathExpr],-1,makeBinaryExpr],[XPathExpr,[XPathExpr,TOK_PLUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MINUS,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_ASTERISK,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_DIV,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathExpr,[XPathExpr,TOK_MOD,XPathExpr],-1,makeBinaryExpr,ASSOC_LEFT],[XPathLiteral,[TOK_LITERALQ],-1,makeLiteralExpr],[XPathLiteral,[TOK_LITERALQQ],-1,makeLiteralExpr],[XPathNumber,[TOK_NUMBER],-1,makeNumberExpr],[XPathVariableReference,[TOK_DOLLAR,TOK_QNAME],200,makeVariableReference]],xpathRules=[];function xpathParseInit(){if(xpathRules.length)return;xpathGrammarRules.sort(function(c,d){var a=c[1].length,b=d[1].length;return a<b?1:a>b?-1:0});for(var f=1,a=0;a<xpathNonTerminals.length;++a)xpathNonTerminals[a].key=f++;for(a=0;a<xpathTokenRules.length;++a)xpathTokenRules[a].key=f++;xpathLog("XPath parse INIT: "+f+" rules");function e(b,a,c){if(!b[a])b[a]=[];b[a].push(c)}for(a=0;a<xpathGrammarRules.length;++a)for(var d=xpathGrammarRules[a],c=d[1],b=c.length-1;b>=0;--b)if(c[b]==Q_1M){e(xpathRules,c[b-1].key,d);break}else if(c[b]==Q_MM||c[b]==Q_01){e(xpathRules,c[b-1].key,d);--b}else{e(xpathRules,c[b].key,d);break}xpathLog("XPath parse INIT: "+xpathRules.length+" rule bins");var g=0;mapExec(xpathRules,function(a){if(a)g+=a.length});xpathLog("XPath parse INIT: "+g/xpathRules.length+" average bin size")}function xpathCollectDescendants(b,c){for(var a=c.firstChild;a;a=a.nextSibling){b.push(a);arguments.callee(b,a)}}function xpathCollectDescendantsReverse(b,c){for(var a=c.lastChild;a;a=a.previousSibling){b.push(a);arguments.callee(b,a)}}function xpathDomEval(b,c){var a=xpathParse(b),d=a.evaluate(new ExprContext(c));return d}function xpathSort(b,h){if(h.length==0)return;for(var c=[],a=0;a<b.contextSize();++a){for(var g=b.nodelist[a],e={node:g,key:[]},l=b.clone(g,0,[g]),i=0;i<h.length;++i){var d=h[i],k=d.expr.evaluate(l),f;if(d.type=="text")f=k.stringValue();else if(d.type=="number")f=k.numberValue();e.key.push({value:f,order:d.order})}e.key.push({value:a,order:"ascending"});c.push(e)}c.sort(xpathSortByKey);for(var j=[],a=0;a<c.length;++a)j.push(c[a].node);b.nodelist=j;b.setNode(0)}function xpathSortByKey(b,c){for(var a=0;a<b.key.length;++a){var d=b.key[a].order=="descending"?-1:1;if(b.key[a].value>c.key[a].value)return+1*d;else if(b.key[a].value<c.key[a].value)return-1*d}return 0}function xpathEval(b,a){var c=xpathParse(b),d=c.evaluate(a);return d}var Spry;if(!Spry)Spry={};if(!Spry.Widget)Spry.Widget={};Spry.Widget.BrowserSniff=function(){var i=navigator.appName.toString(),h=navigator.platform.toString(),a=navigator.userAgent.toString();this.mozilla=this.ie=this.opera=this.safari=false;var f=/Opera.([0-9\.]*)/i,g=/MSIE.([0-9\.]*)/i,e=/gecko/i,d=/(applewebkit|safari)\/([\d\.]*)/i,b=false;if(b=a.match(f)){this.opera=true;this.version=parseFloat(b[1])}else if(b=a.match(g)){this.ie=true;this.version=parseFloat(b[1])}else if(b=a.match(d)){this.safari=true;this.version=parseFloat(b[2])}else if(a.match(e)){var c=/rv:\s*([0-9\.]+)/i;b=a.match(c);this.mozilla=true;this.version=parseFloat(b[1])}this.windows=this.mac=this.linux=false;this.Platform=a.match(/windows/i)?"windows":a.match(/linux/i)?"linux":a.match(/mac/i)?"mac":a.match(/unix/i)?"unix":"unknown";this[this.Platform]=true;this.v=this.version;if(this.safari&&this.mac&&this.mozilla)this.mozilla=false};Spry.is=new Spry.Widget.BrowserSniff;Spry.Widget.AutoSuggest=function(f,c,e,g,a){if(!this.isBrowserSupported())return;a=a||{};this.init(f,c,e,g);Spry.Widget.Utils.setOptions(this,a);if(Spry.Widget.AutoSuggest.onloadDidFire)this.attachBehaviors();else Spry.Widget.AutoSuggest.loadQueue.push(this);this.dataset.addObserver(this);var d=Spry.Widget.Utils.getElementID(c),b=this;this._notifyDataset={onPostUpdate:function(){b.attachClickBehaviors()},onPreUpdate:function(){b.removeClickBehaviours()}};Spry.Data.Region.addObserver(d,this._notifyDataset);Spry.Widget.Utils.addEventListener(window,"unload",function(){b.destroy()},false);this.attachClickBehaviors();this.handleKeyUp(null);this.showSuggestions(false)};Spry.Widget.AutoSuggest.prototype.init=function(d,c,b,a){this.region=Spry.Widget.Utils.getElement(d);if(!this.region)return;this.minCharsType=false;this.containsString=false;this.loadFromServer=false;this.urlParam="";this.suggestionIsVisible=false;this.stopFocus=false;this.hasFocus=false;this.showSuggestClass="showSuggestClass";this.hideSuggestClass="hideSuggestClass";this.hoverSuggestClass="hoverSuggestClass";this.movePrevKeyCode=Spry.Widget.AutoSuggest.KEY_UP;this.moveNextKeyCode=Spry.Widget.AutoSuggest.KEY_DOWN;this.textElement=Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel(this.region,"INPUT");this.textElement.setAttribute("AutoComplete","off");this.suggestRegion=Spry.Widget.Utils.getElement(c);Spry.Widget.Utils.makePositioned(this.suggestRegion);Spry.Widget.Utils.addClassName(this.suggestRegion,this.hideSuggestClass);this.timerID=null;if(typeof b=="string")this.dataset=window[b];else this.dataset=b;this.field=a;if(typeof a=="string"&&a.indexOf(",")!=-1){a=a.replace(/\s*,\s*/ig,",");this.field=a.split(",")}};Spry.Widget.AutoSuggest.prototype.isBrowserSupported=function(){return Spry.is.ie&&Spry.is.v>=5&&Spry.is.windows||Spry.is.mozilla&&Spry.is.v>=1.4||Spry.is.safari||Spry.is.opera&&Spry.is.v>=9};Spry.Widget.AutoSuggest.prototype.getValue=function(){return!this.textElement?"":this.textElement.value};Spry.Widget.AutoSuggest.prototype.setValue=function(a){if(!this.textElement)return;this.textElement.value=a;this.showSuggestions(false)};Spry.Widget.AutoSuggest.prototype.focus=function(){if(!this.textElement)return;this.textElement.focus()};Spry.Widget.AutoSuggest.prototype.showSuggestions=function(a){if(this.region&&this.isVisibleSuggestion()!=a)if(a&&this.hasFocus){Spry.Widget.Utils.addClassName(this.region,this.showSuggestClass);Spry.is.ie&&Spry.is.version<7&&this.createIframeLayer(this.suggestRegion)}else{Spry.is.ie&&Spry.is.version<7&&this.removeIframeLayer();Spry.Widget.Utils.removeClassName(this.region,this.showSuggestClass)}this.suggestionIsVisible=Spry.Widget.Utils.hasClassName(this.region,this.showSuggestClass)};Spry.Widget.AutoSuggest.prototype.isVisibleSuggestion=function(){return this.suggestionIsVisible};Spry.Widget.AutoSuggest.prototype.onDataChanged=function(c){var a=c.getData(true),b=this.getValue();this.showSuggestions(a&&(!this.minCharsType||b.length>=this.minCharsType)&&(a.length>1||a.length==1&&this.childs[0]&&this.childs[0].attributes.getNamedItem("spry:suggest").value!=this.getValue()))};Spry.Widget.AutoSuggest.prototype.nodeMouseOver=function(d,b){for(var c=this.childs.length,a=0;a<c;a++)if(this.childs[a]!=b&&Spry.Widget.Utils.hasClassName(this.childs[a],this.hoverSuggestClass)){Spry.Widget.Utils.removeClassName(this.childs[a],this.hoverSuggestClass);break}};Spry.Widget.AutoSuggest.prototype.handleKeyUp=function(b){if(this.timerID){clearTimeout(this.timerID);this.timerID=null}if(b&&this.isSpecialKey(b)){this.handleSpecialKeys(b);return}var a=this,c=function(){a.timerID=null;a.loadDataSet()};if(!this.loadFromServer)c=function(){a.timerID=null;a.filterDataSet()};this.timerID=setTimeout(c,200)};Spry.Widget.AutoSuggest.prototype.scrollVisible=function(a){if(typeof this.scrolParent=="undefined"){var b=a;this.scrolParent=false;while(!this.scrolParent){var c=Spry.Widget.Utils.getStyleProp(b,"overflow");if(!c||c.toLowerCase()=="scroll"){this.scrolParent=b;break}if(b==this.region)break;b=b.parentNode}}if(this.scrolParent!=false){var d=parseInt(Spry.Widget.Utils.getStyleProp(this.scrolParent,"height"),10);if(a.offsetTop<this.scrolParent.scrollTop)this.scrolParent.scrollTop=a.offsetTop;else if(a.offsetTop+a.offsetHeight>this.scrolParent.scrollTop+d){this.scrolParent.scrollTop=a.offsetTop+a.offsetHeight-d+5;if(this.scrolParent.scrollTop<0)this.scrolParent.scrollTop=0}}};Spry.Widget.AutoSuggest.KEY_UP=38;Spry.Widget.AutoSuggest.KEY_DOWN=40;Spry.Widget.AutoSuggest.prototype.handleSpecialKeys=function(c){switch(c.keyCode){case this.moveNextKeyCode:case this.movePrevKeyCode:if(!(this.childs.length>0)||!this.getValue())return;var e=this.childs.length-1,d=false,f=false,h=this.dataset.getData();if(this.childs.length>1||h&&h.length==1&&this.childs[0]&&this.childs[0].attributes.getNamedItem("spry:suggest").value!=this.getValue())this.showSuggestions(true);else return;for(var b=Spry.Widget.Utils,a=0;a<this.childs.length;a++){if(d){b.addClassName(this.childs[a],this.hoverSuggestClass);this.scrollVisible(this.childs[a]);break}if(b.hasClassName(this.childs[a],this.hoverSuggestClass)){b.removeClassName(this.childs[a],this.hoverSuggestClass);f=true;if(c.keyCode==this.moveNextKeyCode){d=true;continue}else{b.addClassName(this.childs[e],this.hoverSuggestClass);this.scrollVisible(this.childs[e]);break}}e=a}if(!f||d&&a==this.childs.length){b.addClassName(this.childs[0],this.hoverSuggestClass);this.scrollVisible(this.childs[0])}b.stopEvent(c);break;case 27:this.showSuggestions(false);break;if(!this.isVisibleSuggestion())return;for(var a=0;a<this.childs.length;a++)if(Spry.Widget.Utils.hasClassName(this.childs[a],this.hoverSuggestClass)){var g=this.childs[a].attributes.getNamedItem("spry:suggest");if(g){this.setValue(g.value);this.handleKeyUp(null)}Spry.Widget.Utils.stopEvent(c);return false}break;case 9:this.showSuggestions(false)}return};Spry.Widget.AutoSuggest.prototype.filterDataSet=function(){var g=this.containsString,b=this.field,a=this.getValue();if(this.previousString&&this.previousString==a)return;this.previousString=a;if(!a||this.minCharsType&&this.minCharsType>a.length){this.dataset.filter(function(){return null});this.showSuggestions(false);return}var c=Spry.Widget.Utils.escapeRegExp(a);if(!g)c="^"+c;var e=new RegExp(c,"ig");if(this.maxListItems>0)this.dataset.maxItems=this.maxListItems;var f=function(d,a){if(d.maxItems>0&&d.maxItems<=d.data.length)return null;if(typeof b=="object")for(var g=b.length,f=0;f<g;f++){var c=a[b[f]];if(c&&c.search(e)!=-1)return a}else{var c=a[b];if(c&&c.search(e)!=-1)return a}return null};this.dataset.filter(f);var d=this.dataset.getData();this.showSuggestions(d&&(!this.minCharsType||a.length>=this.minCharsType)&&(d.length>1||d.length==1&&this.childs[0]&&this.childs[0].attributes.getNamedItem("spry:suggest").value!=a))};Spry.Widget.AutoSuggest.prototype.loadDataSet=function(){var a=this.getValue(),b=this.dataset;b.cancelLoadData();b.useCache=false;if(!a||this.minCharsType&&this.minCharsType>a.length){this.showSuggestions(false);return}if(this.previousString&&this.previousString==a){var c=b.getData();this.showSuggestions(c&&(c.length>1||c.length==1&&this.childs[0].attributes.getNamedItem("spry:suggest").value!=a));return}this.previousString=a;var d=Spry.Widget.Utils.addReplaceParam(b.url,this.urlParam,a);b.setURL(d);b.loadData()};Spry.Widget.AutoSuggest.prototype.addMouseListener=function(a,d){var b=this,c=Spry.Widget.Utils.addEventListener;c(a,"click",function(a){return b.nodeClick(a,d);b.handleKeyUp(null)},false);c(a,"mouseover",function(c){Spry.Widget.Utils.addClassName(a,b.hoverSuggestClass);b.nodeMouseOver(c,a)},false);c(a,"mouseout",function(c){Spry.Widget.Utils.removeClassName(a,b.hoverSuggestClass);b.nodeMouseOver(c,a)},false)};Spry.Widget.AutoSuggest.prototype.removeMouseListener=function(a,d){var b=this,c=Spry.Widget.Utils.removeEventListener;c(a,"click",function(a){b.nodeClick(a,d);b.handleKeyUp(null)},false);c(a,"mouseover",function(c){Spry.Widget.Utils.addClassName(a,b.hoverSuggestClass);b.nodeMouseOver(c,a)},false);c(a,"mouseout",function(c){Spry.Widget.Utils.removeClassName(a,b.hoverSuggestClass);b.nodeMouseOver(c,a)},false)};Spry.Widget.AutoSuggest.prototype.attachClickBehaviors=function(){var b=this,a=Spry.Utils.getNodesByFunc(this.region,function(a){if(a.nodeType==1){var c=a.attributes.getNamedItem("spry:suggest");if(c){b.addMouseListener(a,c.value);return true}}return false});this.childs=a};Spry.Widget.AutoSuggest.prototype.removeClickBehaviours=function(){var a=this,b=Spry.Utils.getNodesByFunc(this.region,function(b){if(b.nodeType==1){var c=b.attributes.getNamedItem("spry:suggest");if(c){a.removeMouseListener(b,c.value);return true}}return false})};Spry.Widget.AutoSuggest.prototype.destroy=function(){this.removeClickBehaviours();Spry.Data.Region.removeObserver(Spry.Widget.Utils.getElementID(this.suggestRegion),this._notifyDataset);if(this.event_handlers)for(var a=0;a<this.event_handlers.length;a++)Spry.Widget.Utils.removeEventListener(this.event_handlers[a][0],this.event_handlers[a][1],this.event_handlers[a][2],false);for(var b in this)if(typeof this[b]!="function")try{delete this[b]}catch(c){}};Spry.Widget.AutoSuggest.onloadDidFire=false;Spry.Widget.AutoSuggest.loadQueue=[];Spry.Widget.AutoSuggest.processLoadQueue=function(){Spry.Widget.AutoSuggest.onloadDidFire=true;for(var b=Spry.Widget.AutoSuggest.loadQueue,c=b.length,a=0;a<c;a++)b[a].attachBehaviors()};Spry.Widget.AutoSuggest.addLoadListener=function(a){if(typeof window.addEventListener!="undefined")window.addEventListener("load",a,false);else if(typeof document.addEventListener!="undefined")document.addEventListener("load",a,false);else typeof window.attachEvent!="undefined"&&window.attachEvent("onload",a)};Spry.Widget.AutoSuggest.addLoadListener(Spry.Widget.AutoSuggest.processLoadQueue);Spry.Widget.AutoSuggest.prototype.attachBehaviors=function(){this.event_handlers=[];var a=this,c=function(b){a.handleKeyUp(b)};this.event_handlers.push([this.textElement,"keydown",c]);this.event_handlers.push([this.textElement,"focus",function(b){a.stopFocus&&a.handleKeyUp(b);a.hasFocus=true;a.stopFocus=false}]);this.event_handlers.push([this.textElement,"drop",c]);this.event_handlers.push([this.textElement,"dragdrop",c]);var d=false;if(Spry.is.opera)d=function(){setTimeout(function(){if(!a.clickInList)a.showSuggestions(false);else{a.stopFocus=true;a.textElement.focus()}a.clickInList=false;a.hasFocus=false},100)};else d=function(){if(!a.clickInList)a.showSuggestions(false);else{a.stopFocus=true;a.textElement.focus()}a.clickInList=false;a.hasFocus=false};this.event_handlers.push([this.textElement,"blur",d]);this.event_handlers.push([this.suggestRegion,"mousedown",function(){a.clickInList=true}]);for(var b=0;b<this.event_handlers.length;b++)Spry.Widget.Utils.addEventListener(this.event_handlers[b][0],this.event_handlers[b][1],this.event_handlers[b][2],false)};Spry.Widget.AutoSuggest.prototype.createIframeLayer=function(b){if(typeof this.iframeLayer=="undefined"){var a=document.createElement("iframe");a.tabIndex="-1";a.src='javascript:"";';a.scrolling="no";a.frameBorder="0";a.className="iframeSuggest";b.parentNode.appendChild(a);this.iframeLayer=a}this.iframeLayer.style.left=b.offsetLeft+"px";this.iframeLayer.style.top=b.offsetTop+"px";this.iframeLayer.style.width=b.offsetWidth+"px";this.iframeLayer.style.height=b.offsetHeight+"px";this.iframeLayer.style.display="block"};Spry.Widget.AutoSuggest.prototype.removeIframeLayer=function(){if(this.iframeLayer)this.iframeLayer.style.display="none"};if(!Spry.Widget.Utils)Spry.Widget.Utils={};Spry.Widget.Utils.specialSafariNavKeys=",63232,63233,63234,63235,63272,63273,63275,63276,63277,63289,";Spry.Widget.Utils.specialCharacters=",9,13,27,38,40,";Spry.Widget.Utils.specialCharacters+=",33,34,35,36,37,39,45,46,";Spry.Widget.Utils.specialCharacters+=",16,17,18,19,20,144,145,";Spry.Widget.Utils.specialCharacters+=",112,113,114,115,116,117,118,119,120,121,122,123,";Spry.Widget.Utils.specialCharacters+=Spry.Widget.Utils.specialSafariNavKeys;Spry.Widget.AutoSuggest.prototype.isSpecialKey=function(a){return Spry.Widget.Utils.specialCharacters.indexOf(","+a.keyCode+",")!=-1||this.moveNextKeyCode==a.keyCode||this.movePrevKeyCode==a.keyCode};Spry.Widget.Utils.getElementID=function(a){return typeof a=="string"&&a?a:a.getAttribute("id")};Spry.Widget.Utils.getElement=function(a){return a&&typeof a=="string"?document.getElementById(a):a};Spry.Widget.Utils.addReplaceParam=function(e,d,h){var f="",b="",a=e.indexOf("?");if(a!=-1){f=e.slice(0,a);b=e.slice(a+1)}else f=e;b=b.replace("?","");var c=b.split("&");if(d.lastIndexOf("/")!=-1)d=d.slice(d.lastIndexOf("/")+1);for(a=0;a<c.length;a++){var g=c[a].split("=");if(g[0]&&g[0]==decodeURI(d)||c[a]==decodeURI(d))c[a]=null}c[c.length]=encodeURIComponent(d)+"="+encodeURIComponent(h);b="";for(a=0;a<c.length;a++)if(c[a])b+="&"+c[a];b=b.slice(1);e=f+"?"+b;return e};Spry.Widget.Utils.addClassName=function(a,b){if(!a)return;if(!a.className)a.className="";if(!a||a.className.search(new RegExp("\\b"+b+"\\b"))!=-1)return;a.className+=" "+b};Spry.Widget.Utils.removeClassName=function(a,b){if(!a)return;if(!a.className){a.className="";return}a.className=a.className.replace(new RegExp("\\s*\\b"+b+"\\b","g"),"")};Spry.Widget.Utils.hasClassName=function(a,b){if(!a||!b)return false;if(!a.className)a.className="";return a.className.search(new RegExp("\\s*\\b"+b+"\\b"))!=-1};Spry.Widget.Utils.addEventListener=function(a,b,d,c){try{if(a.addEventListener)a.addEventListener(b,d,c);else a.attachEvent&&a.attachEvent("on"+b,d,c)}catch(e){}};Spry.Widget.Utils.removeEventListener=function(a,b,d,c){try{if(a.removeEventListener)a.removeEventListener(b,d,c);else a.detachEvent&&a.detachEvent("on"+b,d,c)}catch(e){}};Spry.Widget.Utils.stopEvent=function(a){a.cancelBubble=true;a.returnValue=false;try{this.stopPropagation(a)}catch(b){}try{this.preventDefault(a)}catch(b){}};Spry.Widget.Utils.stopPropagation=function(a){if(a.stopPropagation)a.stopPropagation();else a.cancelBubble=true};Spry.Widget.Utils.preventDefault=function(a){if(a.preventDefault)a.preventDefault();else a.returnValue=false};Spry.Widget.Utils.setOptions=function(d,a,c){if(!a)return;for(var b in a){if(typeof c!="undefined"&&c&&typeof a[b]=="undefined")continue;d[b]=a[b]}};Spry.Widget.Utils.firstValid=function(){for(var b=null,a=0;a<Spry.Widget.Utils.firstValid.arguments.length;a++)if(typeof Spry.Widget.Utils.firstValid.arguments[a]!="undefined"){b=Spry.Widget.Utils.firstValid.arguments[a];break}return b};Spry.Widget.Utils.camelize=function(f){for(var b=f.split("-"),d=true,c="",a=0;a<b.length;a++)if(b[a].length>0)if(d){c=b[a];d=false}else{var e=b[a];c+=e.charAt(0).toUpperCase()+e.substring(1)}return c};Spry.Widget.Utils.getStyleProp=function(b,d){var a,c=Spry.Widget.Utils.camelize(d);try{a=b.style[c];if(!a)if(document.defaultView&&document.defaultView.getComputedStyle){var e=document.defaultView.getComputedStyle(b,null);a=e?e.getPropertyValue(d):null}else if(b.currentStyle)a=b.currentStyle[c]}catch(f){}return a=="auto"?null:a};Spry.Widget.Utils.makePositioned=function(a){var b=Spry.Widget.Utils.getStyleProp(a,"position");if(!b||b=="static"){a.style.position="relative";if(window.opera){a.style.top=0;a.style.left=0}}};Spry.Widget.Utils.escapeRegExp=function(a){return a.replace(/([\.\/\]\[\{\}\(\)\\\$\^\?\*\|\!\=\+\-])/g,"\\$1")};Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel=function(c,b){var a=c.getElementsByTagName(b);return a?a[0]:null};var Spry;if(!Spry)Spry={};if(!Spry.Utils)Spry.Utils={};Spry.Utils.msProgIDs=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0"];Spry.Utils.createXMLHttpRequest=function(){var a=null;try{if(window.ActiveXObject)while(!a&&Spry.Utils.msProgIDs.length){try{a=new ActiveXObject(Spry.Utils.msProgIDs[0])}catch(b){a=null}!a&&Spry.Utils.msProgIDs.splice(0,1)}if(!a&&window.XMLHttpRequest)a=new XMLHttpRequest}catch(b){a=null}!a&&Spry.Debug.reportError("Failed to create an XMLHttpRequest object!");return a};Spry.Utils.loadURL=function(e,c,f,d,g){var a=new Spry.Utils.loadURL.Request;a.method=e;a.url=c;a.async=f;a.successCallback=d;Spry.Utils.setOptions(a,g);try{a.xhRequest=Spry.Utils.createXMLHttpRequest();if(!a.xhRequest)return null;if(a.async)a.xhRequest.onreadystatechange=function(){Spry.Utils.loadURL.callback(a)};a.xhRequest.open(a.method,a.url,a.async,a.username,a.password);if(a.headers)for(var b in a.headers)a.xhRequest.setRequestHeader(b,a.headers[b]);a.xhRequest.send(a.postData);!a.async&&Spry.Utils.loadURL.callback(a)}catch(h){if(a.errorCallback)a.errorCallback(a);else Spry.Debug.reportError("Exception caught while loading "+c+": "+h);a=null}return a};Spry.Utils.loadURL.callback=function(a){if(!a||a.xhRequest.readyState!=4)return;if(a.successCallback&&(a.xhRequest.status==200||a.xhRequest.status==0))a.successCallback(a);else a.errorCallback&&a.errorCallback(a)};Spry.Utils.loadURL.Request=function(){for(var b=Spry.Utils.loadURL.Request.props,c=b.length,a=0;a<c;a++)this[b[a]]=null;this.method="GET";this.async=true;this.headers={}};Spry.Utils.loadURL.Request.props=["method","url","async","username","password","postData","successCallback","errorCallback","headers","userData","xhRequest"];Spry.Utils.loadURL.Request.prototype.extractRequestOptions=function(a,e){if(!a)return;for(var d=Spry.Utils.loadURL.Request.props,f=d.length,c=0;c<f;c++){var b=d[c];if(a[b]!=undefined){this[b]=a[b];if(e)a[b]=undefined}}};Spry.Utils.loadURL.Request.prototype.clone=function(){for(var c=Spry.Utils.loadURL.Request.props,d=c.length,a=new Spry.Utils.loadURL.Request,b=0;b<d;b++)a[c[b]]=this[c[b]];if(this.headers){a.headers={};Spry.Utils.setOptions(a.headers,this.headers)}return a};Spry.Utils.setInnerHTML=function(a,e,f){if(!a)return;a=Spry.$(a);var d="<script[^>]*>(.|s|\n|\r)*?<\/script>";a.innerHTML=e.replace(new RegExp(d,"img"),"");if(f)return;var b=e.match(new RegExp(d,"img"));if(b)for(var g=b.length,c=0;c<g;c++){var h=b[c].replace(/<script[^>]*>[\s\r\n]*(<\!--)?|(-->)?[\s\r\n]*<\/script>/img,"");Spry.Utils.eval(h)}};Spry.Utils.updateContent=function(b,c,a,d){Spry.Utils.loadURL("GET",c,true,function(d){Spry.Utils.setInnerHTML(b,d.xhRequest.responseText);a&&a(b,c)},d)};if(!Spry.$$){Spry.Utils.addEventListener=function(a,b,c,d){try{a=Spry.$(a);if(a.addEventListener)a.addEventListener(b,c,d);else a.attachEvent&&a.attachEvent("on"+b,c)}catch(e){}};Spry.Utils.removeEventListener=function(a,b,c,d){try{a=Spry.$(a);if(a.removeEventListener)a.removeEventListener(b,c,d);else a.detachEvent&&a.detachEvent("on"+b,c)}catch(e){}};Spry.Utils.addLoadListener=function(a){if(typeof window.addEventListener!="undefined")window.addEventListener("load",a,false);else if(typeof document.addEventListener!="undefined")document.addEventListener("load",a,false);else typeof window.attachEvent!="undefined"&&window.attachEvent("onload",a)};Spry.Utils.addClassName=function(a,b){a=Spry.$(a);if(!a||!b||a.className&&a.className.search(new RegExp("\\b"+b+"\\b"))!=-1)return;a.className+=(a.className?" ":"")+b};Spry.Utils.removeClassName=function(a,b){a=Spry.$(a);if(!a||!b||a.className&&a.className.search(new RegExp("\\b"+b+"\\b"))==-1)return;a.className=a.className.replace(new RegExp("\\s*\\b"+b+"\\b","g"),"")};Spry.$=function(a){if(arguments.length>1){for(var b=0,c=[],d=arguments.length;b<d;b++)c.push(Spry.$(arguments[b]));return c}if(typeof a=="string")a=document.getElementById(a);return a}}Spry.Utils.getObjectByName=function(e){var a=null;if(e)for(var b=window,d=e.split("."),c=0;b&&c<d.length;c++){a=b[d[c]];b=a}return a};Spry.Utils.eval=function(a){return eval(a)};Spry.Utils.escapeQuotesAndLineBreaks=function(a){if(a){a=a.replace(/\\/g,"\\\\");a=a.replace(/["']/g,"\\$&");a=a.replace(/\n/g,"\\n");a=a.replace(/\r/g,"\\r")}return a};Spry.Utils.encodeEntities=function(a){if(a&&a.search(/[&<>"]/)!=-1){a=a.replace(/&/g,"&amp;");a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");a=a.replace(/"/g,"&quot;")}return a};Spry.Utils.decodeEntities=function(a){var b=Spry.Utils.decodeEntities.div;if(!b){b=document.createElement("div");Spry.Utils.decodeEntities.div=b;if(!b)return a}b.innerHTML=a;if(b.childNodes.length==1&&b.firstChild.nodeType==3&&b.firstChild.nextSibling==null)a=b.firstChild.data;else{a=a.replace(/&lt;/gi,"<");a=a.replace(/&gt;/gi,">");a=a.replace(/&quot;/gi,'"');a=a.replace(/&amp;/gi,"&")}return a};Spry.Utils.fixupIETagAttributes=function(e){var c="",h=e.match(/^<[^\s>]+\s*/)[0],i=e.match(/\s*\/?>$/)[0],b=e.replace(/^<[^\s>]+\s*|\s*\/?>/g,"");c+=h;if(b){var d=0,a=0;while(d<b.length){while(b.charAt(a)!="="&&a<b.length)++a;if(a>=b.length){c+=b.substring(d,a);break}++a;c+=b.substring(d,a);d=a;if(b.charAt(a)=='"'||b.charAt(a)=="'"){var g=a++;while(a<b.length){if(b.charAt(a)==b.charAt(g)){a++;break}else if(b.charAt(a)=="\\")a++;a++}c+=b.substring(d,a);d=a}else{c+='"';var f=b.slice(a).search(/\s/);a=f!=-1?a+f:b.length;c+=b.slice(d,a);c+='"';d=a}}}c+=i;return c};Spry.Utils.fixUpIEInnerHTML=function(d){var b="",f=new RegExp("<\\!--|<\\!\\[CDATA\\[|<\\w+[^<>]*>|-->|\\]\\](>|&gt;)","g"),c=0,e=0;while(d.length){var a=f.exec(d);if(!a||!a[0]){b+=d.substr(c,d.length-c);break}if(a.index!=c)b+=d.substr(c,a.index-c);if(a[0]=="<!--"||a[0]=="<![CDATA["){++e;b+=a[0]}else if(a[0]=="-->"||a[0]=="]\]>"||e&&a[0]=="]]&gt;"){--e;b+=a[0]}else if(!e&&a[0].charAt(0)=="<")b+=Spry.Utils.fixupIETagAttributes(a[0]);else b+=a[0];c=f.lastIndex}return b};Spry.Utils.stringToXMLDoc=function(c){var a=null;try{var b=new ActiveXObject("Microsoft.XMLDOM");b.async=false;b.loadXML(c);a=b}catch(e){try{var d=new DOMParser;a=d.parseFromString(c,"text/xml")}catch(e){Spry.Debug.reportError("Caught exception in Spry.Utils.stringToXMLDoc(): "+e+"\n");a=null}}return a};Spry.Utils.serializeObject=function(b){var a="",c=true;if(b==null||b==undefined)return a+b;var d=typeof b;if(d=="number"||d=="boolean")a+=b;else if(d=="string")a+='"'+Spry.Utils.escapeQuotesAndLineBreaks(b)+'"';else if(b.constructor==Array){a+="[";for(var e=0;e<b.length;e++){if(!c)a+=", ";a+=Spry.Utils.serializeObject(b[e]);c=false}a+="]"}else if(d=="object"){a+="{";for(var f in b){if(!c)a+=", ";a+='"'+f+'": '+Spry.Utils.serializeObject(b[f]);c=false}a+="}"}return a};Spry.Utils.getNodesByFunc=function(c,e){var b=[],d=[],a=c;while(a){e(a)&&d.push(a);if(a.hasChildNodes()){b.push(a);a=a.firstChild}else if(a==c)a=null;else try{a=a.nextSibling}catch(f){a=null}while(!a&&b.length>0){a=b.pop();if(a==c)a=null;else try{a=a.nextSibling}catch(f){a=null}}}b&&b.length>0&&Spry.Debug.trace("-- WARNING: Spry.Utils.getNodesByFunc() failed to traverse all nodes!\n");return d};Spry.Utils.getFirstChildWithNodeName=function(c,b){var a=c.firstChild;while(a){if(a.nodeName==b)return a;a=a.nextSibling}return null};Spry.Utils.setOptions=function(d,a,c){if(!a)return;for(var b in a){if(c&&a[b]==undefined)continue;d[b]=a[b]}};Spry.Utils.SelectionManager={};Spry.Utils.SelectionManager.selectionGroups={};Spry.Utils.SelectionManager.SelectionGroup=function(){this.selectedElements=[]};Spry.Utils.SelectionManager.SelectionGroup.prototype.select=function(b,c,e){var a=null;if(!e)this.clearSelection();else for(var d=0;d<this.selectedElements.length;d++){a=this.selectedElements[d].element;if(a.element==b){if(a.className!=c){Spry.Utils.removeClassName(b,a.className);Spry.Utils.addClassName(b,c)}return}}a={};a.element=b;a.className=c;this.selectedElements.push(a);Spry.Utils.addClassName(b,c)};Spry.Utils.SelectionManager.SelectionGroup.prototype.unSelect=function(c){for(var b=0;b<this.selectedElements.length;b++){var a=this.selectedElements[b].element;if(a.element==c){Spry.Utils.removeClassName(a.element,a.className);return}}};Spry.Utils.SelectionManager.SelectionGroup.prototype.clearSelection=function(){var a=null;do{a=this.selectedElements.shift();a&&Spry.Utils.removeClassName(a.element,a.className)}while(a)};Spry.Utils.SelectionManager.getSelectionGroup=function(b){if(!b)return null;var a=Spry.Utils.SelectionManager.selectionGroups[b];if(!a){a=new Spry.Utils.SelectionManager.SelectionGroup;Spry.Utils.SelectionManager.selectionGroups[b]=a}return a};Spry.Utils.SelectionManager.select=function(b,e,d,c){var a=Spry.Utils.SelectionManager.getSelectionGroup(b);if(!a)return;a.select(e,d,c)};Spry.Utils.SelectionManager.unSelect=function(b,c){var a=Spry.Utils.SelectionManager.getSelectionGroup(b);if(!a)return;a.unSelect(c,className)};Spry.Utils.SelectionManager.clearSelection=function(b){var a=Spry.Utils.SelectionManager.getSelectionGroup(b);if(!a)return;a.clearSelection()};Spry.Utils.Notifier=function(){this.observers=[];this.suppressNotifications=0};Spry.Utils.Notifier.prototype.addObserver=function(a){if(!a)return;for(var c=this.observers.length,b=0;b<c;b++)if(this.observers[b]==a)return;this.observers[c]=a};Spry.Utils.Notifier.prototype.removeObserver=function(b){if(!b)return;for(var a=0;a<this.observers.length;a++)if(this.observers[a]==b){this.observers.splice(a,1);break}};Spry.Utils.Notifier.prototype.notifyObservers=function(b,d){if(!b)return;if(!this.suppressNotifications)for(var e=this.observers.length,c=0;c<e;c++){var a=this.observers[c];if(a)if(typeof a=="function")a(b,this,d);else a[b]&&a[b](this,d)}};Spry.Utils.Notifier.prototype.enableNotifications=function(){if(--this.suppressNotifications<0){this.suppressNotifications=0;Spry.Debug.reportError("Unbalanced enableNotifications() call!\n")}};Spry.Utils.Notifier.prototype.disableNotifications=function(){++this.suppressNotifications};Spry.Debug={};Spry.Debug.enableTrace=true;Spry.Debug.debugWindow=null;Spry.Debug.onloadDidFire=false;Spry.Utils.addLoadListener(function(){Spry.Debug.onloadDidFire=true;Spry.Debug.flushQueuedMessages()});Spry.Debug.flushQueuedMessages=function(){if(Spry.Debug.flushQueuedMessages.msgs){for(var b=Spry.Debug.flushQueuedMessages.msgs,a=0;a<b.length;a++)Spry.Debug.debugOut(b[a].msg,b[a].color);Spry.Debug.flushQueuedMessages.msgs=null}};Spry.Debug.createDebugWindow=function(){if(!Spry.Debug.enableTrace||Spry.Debug.debugWindow||!Spry.Debug.onloadDidFire)return;try{Spry.Debug.debugWindow=document.createElement("div");var a=Spry.Debug.debugWindow;a.style.fontSize="12px";a.style.fontFamily="console";a.style.position="absolute";a.style.width="400px";a.style.height="300px";a.style.overflow="auto";a.style.border="solid 1px black";a.style.backgroundColor="white";a.style.color="black";a.style.bottom="0px";a.style.right="0px";a.setAttribute("id","SpryDebugWindow");document.body.appendChild(Spry.Debug.debugWindow)}catch(b){}};Spry.Debug.debugOut=function(c,a){if(!Spry.Debug.debugWindow){Spry.Debug.createDebugWindow();if(!Spry.Debug.debugWindow){if(!Spry.Debug.flushQueuedMessages.msgs)Spry.Debug.flushQueuedMessages.msgs=[];Spry.Debug.flushQueuedMessages.msgs.push({msg:c,color:a});return}}var b=document.createElement("div");if(a)b.style.backgroundColor=a;b.innerHTML=c;Spry.Debug.debugWindow.appendChild(b)};Spry.Debug.trace=function(a){Spry.Debug.debugOut(a)};Spry.Debug.reportError=function(a){Spry.Debug.debugOut(a,"red")};Spry.Data={};Spry.Data.regionsArray={};Spry.Data.initRegionsOnLoad=true;Spry.Data.initRegions=function(e){e=e?Spry.$(e):document.body;for(var g=null,n=Spry.Utils.getNodesByFunc(e,function(b){try{if(b.nodeType!=1)return false;var c="spry:region",a=b.attributes.getNamedItem(c);if(!a){c="spry:detailregion";a=b.attributes.getNamedItem(c)}if(a){if(g){var d=b.parentNode;while(d){if(d==g){Spry.Debug.reportError("Found a nested "+c+" in the following markup. Nested regions are currently not supported.<br/><pre>"+Spry.Utils.encodeEntities(d.innerHTML)+"</pre>");return false}d=d.parentNode}}if(a.value){a=b.attributes.getNamedItem("id");(!a||!a.value)&&b.setAttribute("id","spryregion"+ ++Spry.Data.initRegions.nextUniqueRegionID);g=b;return true}else Spry.Debug.reportError(c+" attributes require one or more data set names as values!")}}catch(e){}return false}),f,i,h=[],c=0;c<n.length;c++){var a=n[c],l=false;f=a.attributes.getNamedItem("id").value;attr=a.attributes.getNamedItem("spry:region");if(!attr){attr=a.attributes.getNamedItem("spry:detailregion");l=true}if(!attr.value){Spry.Debug.reportError("spry:region and spry:detailregion attributes require one or more data set names as values!");continue}a.attributes.removeNamedItem(attr.nodeName);Spry.Utils.removeClassName(a,Spry.Data.Region.hiddenRegionClassName);i=Spry.Data.Region.strToDataSetsArray(attr.value);if(!i.length){Spry.Debug.reportError("spry:region or spry:detailregion attribute has no data set!");continue}var k=false,o=false,b="",q=null,m={},d={};attr=a.attributes.getNamedItem("spry:readystate");if(attr&&attr.value)d.ready=attr.value;attr=a.attributes.getNamedItem("spry:errorstate");if(attr&&attr.value)d.error=attr.value;attr=a.attributes.getNamedItem("spry:loadingstate");if(attr&&attr.value)d.loading=attr.value;attr=a.attributes.getNamedItem("spry:expiredstate");if(attr&&attr.value)d.expired=attr.value;var p=Spry.Utils.getNodesByFunc(a,function(b){try{if(b.nodeType==1){for(var n=b.attributes,u=Spry.Data.Region.PI.orderedInstructions.length,e=null,f=null,l=0;l<u;l++){var c=Spry.Data.Region.PI.orderedInstructions[l],s=n.getNamedItem(c);if(!s)continue;var j=Spry.Data.Region.PI.instructions[c],t=b==a?true:j.childrenOnly,p=j.getOpenTag(b,c),o=j.getCloseTag(b,c);if(t){var h=document.createComment(p),g=document.createComment(o);if(!e)b.insertBefore(h,b.firstChild);else b.insertBefore(h,e.nextSibling);e=h;if(!f)b.appendChild(g);else b.insertBefore(g,f);f=g}else{var q=b.parentNode;q.insertBefore(document.createComment(p),b);q.insertBefore(document.createComment(o),b.nextSibling)}if(c=="spry:state")m[s.value]=true;b.removeAttribute(c)}if(Spry.Data.Region.enableBehaviorAttributes){var i=Spry.Data.Region.behaviorAttrs;for(var d in i){var r=n.getNamedItem(d);if(r){k=true;i[d].setup&&i[d].setup(b,r.value)}}}}}catch(v){}return false});b=a.innerHTML;if(window.ActiveXObject&&!Spry.Data.Region.disableIEInnerHTMLFixUp&&b.search(/=\{/)!=-1){Spry.Data.Region.debug&&Spry.Debug.trace("<hr />Performing IE innerHTML fix up of Region: "+f+"<br /><br />"+Spry.Utils.encodeEntities(b));b=Spry.Utils.fixUpIEInnerHTML(b)}Spry.Data.Region.debug&&Spry.Debug.trace("<hr />Region template markup for '"+f+"':<br /><br />"+Spry.Utils.encodeEntities(b));if(!o)a.innerHTML="";var j=new Spry.Data.Region(a,f,l,b,i,m,d,k);Spry.Data.regionsArray[j.name]=j;h.push(j)}for(var c=0;c<h.length;c++)h[c].updateContent()};Spry.Data.initRegions.nextUniqueRegionID=0;Spry.Data.updateRegion=function(a){if(!a||!Spry.Data.regionsArray||!Spry.Data.regionsArray[a])return;try{Spry.Data.regionsArray[a].updateContent()}catch(b){Spry.Debug.reportError("Spry.Data.updateRegion("+a+") caught an exception: "+b+"\n")}};Spry.Data.getRegion=function(a){return Spry.Data.regionsArray[a]};Spry.Data.updateAllRegions=function(){if(!Spry.Data.regionsArray)return;for(var a in Spry.Data.regionsArray)Spry.Data.updateRegion(a)};Spry.Data.getDataSetByName=function(b){var a=Spry.Utils.getObjectByName(b);return typeof a!="object"||!a.getData||!a.filter?null:a};Spry.Data.DataSet=function(a){Spry.Utils.Notifier.call(this);this.name="";this.internalID=Spry.Data.DataSet.nextDataSetID++;this.curRowID=0;this.data=[];this.unfilteredData=null;this.dataHash={};this.columnTypes={};this.filterFunc=null;this.filterDataFunc=null;this.distinctOnLoad=false;this.distinctFieldsOnLoad=null;this.sortOnLoad=null;this.sortOrderOnLoad="ascending";this.keepSorted=false;this.dataWasLoaded=false;this.pendingRequest=null;this.lastSortColumns=[];this.lastSortOrder="";this.loadIntervalID=0;Spry.Utils.setOptions(this,a)};Spry.Data.DataSet.prototype=new Spry.Utils.Notifier;Spry.Data.DataSet.prototype.constructor=Spry.Data.DataSet;Spry.Data.DataSet.prototype.getData=function(a){return a&&this.unfilteredData?this.unfilteredData:this.data};Spry.Data.DataSet.prototype.getUnfilteredData=function(){return this.getData(true)};Spry.Data.DataSet.prototype.getLoadDataRequestIsPending=function(){return this.pendingRequest!=null};Spry.Data.DataSet.prototype.getDataWasLoaded=function(){return this.dataWasLoaded};Spry.Data.DataSet.prototype.getValue=function(c,b){var a=undefined;if(!b)b=this.getCurrentRow();switch(c){case"ds_RowNumber":a=this.getRowNumber(b);break;case"ds_RowNumberPlus1":a=this.getRowNumber(b)+1;break;case"ds_RowCount":a=this.getRowCount();break;case"ds_UnfilteredRowCount":a=this.getRowCount(true);break;case"ds_CurrentRowNumber":a=this.getCurrentRowNumber();break;case"ds_CurrentRowID":a=this.getCurrentRowID();break;case"ds_EvenOddRow":a=this.getRowNumber(b)%2?Spry.Data.Region.evenRowClassName:Spry.Data.Region.oddRowClassName;break;case"ds_SortOrder":a=this.getSortOrder();break;case"ds_SortColumn":a=this.getSortColumn();break;default:if(b)a=b[c]}return a};Spry.Data.DataSet.prototype.setDataFromArray=function(c,d){this.notifyObservers("onPreLoad");this.unfilteredData=null;this.filteredData=null;this.data=[];this.dataHash={};for(var e=c.length,b=0;b<e;b++){var a=c[b];if(a.ds_RowID==undefined)a.ds_RowID=b;this.dataHash[a.ds_RowID]=a;this.data.push(a)}this.loadData(d)};Spry.Data.DataSet.prototype.loadData=function(c){var a=this;this.pendingRequest={};this.dataWasLoaded=false;var b=function(){a.pendingRequest=null;a.dataWasLoaded=true;a.applyColumnTypes();a.disableNotifications();a.filterAndSortData();a.enableNotifications();a.notifyObservers("onPostLoad");a.notifyObservers("onDataChanged")};if(c)b();else this.pendingRequest.timer=setTimeout(b,0)};Spry.Data.DataSet.prototype.filterAndSortData=function(){this.filterDataFunc&&this.filterData(this.filterDataFunc,true);this.distinctOnLoad&&this.distinct(this.distinctFieldsOnLoad);if(this.keepSorted&&this.getSortColumn())this.sort(this.lastSortColumns,this.lastSortOrder);else this.sortOnLoad&&this.sort(this.sortOnLoad,this.sortOrderOnLoad);this.filterFunc&&this.filter(this.filterFunc,true);if(this.data&&this.data.length>0)this.curRowID=this.data[0].ds_RowID;else this.curRowID=0};Spry.Data.DataSet.prototype.cancelLoadData=function(){this.pendingRequest&&this.pendingRequest.timer&&clearTimeout(this.pendingRequest.timer);this.pendingRequest=null};Spry.Data.DataSet.prototype.getRowCount=function(b){var a=this.getData(b);return a?a.length:0};Spry.Data.DataSet.prototype.getRowByID=function(a){return!this.data?null:this.dataHash[a]};Spry.Data.DataSet.prototype.getRowByRowNumber=function(a,c){var b=this.getData(c);return b&&a>=0&&a<b.length?b[a]:null};Spry.Data.DataSet.prototype.getCurrentRow=function(){return this.getRowByID(this.curRowID)};Spry.Data.DataSet.prototype.setCurrentRow=function(a){if(this.curRowID==a)return;var b={oldRowID:this.curRowID,newRowID:a};this.curRowID=a;this.notifyObservers("onCurrentRowChanged",b)};Spry.Data.DataSet.prototype.getRowNumber=function(c,d){if(c){var a=this.getData(d);if(a&&a.length)for(var e=a.length,b=0;b<e;b++)if(a[b]==c)return b}return-1};Spry.Data.DataSet.prototype.getCurrentRowNumber=function(){return this.getRowNumber(this.getCurrentRow())};Spry.Data.DataSet.prototype.getCurrentRowID=function(){return this.curRowID};Spry.Data.DataSet.prototype.setCurrentRowNumber=function(a){if(!this.data||a>=this.data.length){Spry.Debug.trace("Invalid row number: "+a+"\n");return}var b=this.data[a].ds_RowID;if(b==undefined||this.curRowID==b)return;this.setCurrentRow(b)};Spry.Data.DataSet.prototype.findRowsWithColumnValues=function(e,d,i){var h=[],a=this.getData(i);if(a)for(var j=a.length,c=0;c<j;c++){var b=a[c],g=true;for(var f in e)if(e[f]!=b[f]){g=false;break}if(g){if(d)return b;h.push(b)}}return d?null:h};Spry.Data.DataSet.prototype.setColumnType=function(a,c){if(a){if(typeof a=="string")a=[a];for(var b=0;b<a.length;b++)this.columnTypes[a[b]]=c}};Spry.Data.DataSet.prototype.getColumnType=function(a){return this.columnTypes[a]?this.columnTypes[a]:"string"};Spry.Data.DataSet.prototype.applyColumnTypes=function(){var g=this.getData(true),f=g.length,h=[];if(f<1)return;for(var a in this.columnTypes){var b=this.columnTypes[a];if(b!="string")for(var e=0;e<f;e++){var c=g[e],d=c[a];if(d!=undefined)if(b=="number")c[a]=new Number(d);else if(b=="html")c[a]=Spry.Utils.decodeEntities(d)}}};Spry.Data.DataSet.prototype.distinct=function(d){if(this.data){var g=this.data;this.data=[];this.dataHash={};var j=false,i={},f=0,c=[];if(typeof d=="string")c=[d];else if(d)c=d;else for(var a in g[0])c[f++]=a;for(var f=0;f<g.length;f++){for(var e=g[f],b="",h=0;h<c.length;h++){a=c[h];if(a!="ds_RowID"){if(b)b+=",";b+=a+':"'+e[a]+'"'}}if(!i[b]){this.data.push(e);this.dataHash[e.ds_RowID]=e;i[b]=true}else j=true}j&&this.notifyObservers("onDataChanged")}};Spry.Data.DataSet.prototype.getSortColumn=function(){return this.lastSortColumns&&this.lastSortColumns.length>0?this.lastSortColumns[0]:""};Spry.Data.DataSet.prototype.getSortOrder=function(){return this.lastSortOrder?this.lastSortOrder:""};Spry.Data.DataSet.prototype.sort=function(a,b){if(!a)return;if(typeof a=="string")a=[a,"ds_RowID"];else a.length<2&&a[0]!="ds_RowID"&&a.push("ds_RowID");if(!b)b="toggle";if(b=="toggle")if(this.lastSortColumns.length>0&&this.lastSortColumns[0]==a[0]&&this.lastSortOrder=="ascending")b="descending";else b="ascending";if(b!="ascending"&&b!="descending"){Spry.Debug.reportError("Invalid sort order type specified: "+b+"\n");return}var f={oldSortColumns:this.lastSortColumns,oldSortOrder:this.lastSortOrder,newSortColumns:a,newSortOrder:b};this.notifyObservers("onPreSort",f);for(var c=a[a.length-1],d=Spry.Data.DataSet.prototype.sort.getSortFunc(c,this.getColumnType(c),b),e=a.length-2;e>=0;e--){c=a[e];d=Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc(Spry.Data.DataSet.prototype.sort.getSortFunc(c,this.getColumnType(c),b),d)}if(this.unfilteredData){this.unfilteredData.sort(d);this.filterFunc&&this.filter(this.filterFunc,true)}else this.data.sort(d);this.lastSortColumns=a.slice(0);this.lastSortOrder=b;this.notifyObservers("onPostSort",f)};Spry.Data.DataSet.prototype.sort.getSortFunc=function(a,d,c){var b=null;if(d=="number")if(c=="ascending")b=function(b,c){b=b[a];c=c[a];return b==undefined||c==undefined?b==c?0:b?1:-1:b-c};else b=function(b,c){b=b[a];c=c[a];return b==undefined||c==undefined?b==c?0:b?-1:1:c-b};else if(d=="date")if(c=="ascending")b=function(d,e){var b=d[a],c=e[a];b=b?new Date(b):0;c=c?new Date(c):0;return b-c};else b=function(d,e){var b=d[a],c=e[a];b=b?new Date(b):0;c=c?new Date(c):0;return c-b};else if(c=="ascending")b=function(d,f){d=d[a];f=f[a];if(d==undefined||f==undefined)return d==f?0:d?1:-1;for(var b=d.toString(),c=f.toString(),l=b.toLowerCase(),m=c.toLowerCase(),k=b.length>c.length?c.length:b.length,e=0;e<k;e++){var g=l.charAt(e),h=m.charAt(e),i=b.charAt(e),j=c.charAt(e);if(g>h)return 1;else if(g<h)return-1;else if(i>j)return 1;else if(i<j)return-1}return b.length==c.length?0:b.length>c.length?1:-1};else b=function(d,f){d=d[a];f=f[a];if(d==undefined||f==undefined)return d==f?0:d?-1:1;for(var b=d.toString(),c=f.toString(),l=b.toLowerCase(),m=c.toLowerCase(),k=b.length>c.length?c.length:b.length,e=0;e<k;e++){var g=l.charAt(e),h=m.charAt(e),i=b.charAt(e),j=c.charAt(e);if(g>h)return-1;else if(g<h)return 1;else if(i>j)return-1;else if(i<j)return 1}return b.length==c.length?0:b.length>c.length?-1:1};return b};Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc=function(a,b){return function(d,e){var c=a(d,e);if(c==0)c=b(d,e);return c}};Spry.Data.DataSet.prototype.filterData=function(d,f){var c=false;if(!d){this.filterDataFunc=null;c=true}else{this.filterDataFunc=d;if(this.dataWasLoaded&&(this.unfilteredData&&this.unfilteredData.length||this.data&&this.data.length)){if(this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null}var e=this.data;this.data=[];this.dataHash={};for(var b=0;b<e.length;b++){var a=d(this,e[b],b);if(a){this.data.push(a);this.dataHash[a.ds_RowID]=a}}c=true}}if(c){if(!f){this.disableNotifications();this.filterFunc&&this.filter(this.filterFunc,true);this.enableNotifications()}this.notifyObservers("onDataChanged")}};Spry.Data.DataSet.prototype.filter=function(c){var b=false;if(!c){if(this.filterFunc&&this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null;this.filterFunc=null;b=true}}else{this.filterFunc=c;if(this.dataWasLoaded&&(this.unfilteredData||this.data&&this.data.length)){if(!this.unfilteredData)this.unfilteredData=this.data;var e=this.unfilteredData;this.data=[];for(var a=0;a<e.length;a++){var d=c(this,e[a],a);d&&this.data.push(d)}b=true}}b&&this.notifyObservers("onDataChanged")};Spry.Data.DataSet.prototype.startLoadInterval=function(a){this.stopLoadInterval();if(a>0){var b=this;this.loadInterval=a;this.loadIntervalID=setInterval(function(){b.loadData()},a)}};Spry.Data.DataSet.prototype.stopLoadInterval=function(){this.loadIntervalID&&clearInterval(this.loadIntervalID);this.loadInterval=0;this.loadIntervalID=null};Spry.Data.DataSet.nextDataSetID=0;Spry.Data.HTTPSourceDataSet=function(b,a){Spry.Data.DataSet.call(this);this.url=b;this.dataSetsForDataRefStrings=[];this.hasDataRefStrings=false;this.useCache=true;this.setRequestInfo(a,true);Spry.Utils.setOptions(this,a,true);this.recalculateDataSetDependencies();this.loadInterval>0&&this.startLoadInterval(this.loadInterval)};Spry.Data.HTTPSourceDataSet.prototype=new Spry.Data.DataSet;Spry.Data.HTTPSourceDataSet.prototype.constructor=Spry.Data.HTTPSourceDataSet;Spry.Data.HTTPSourceDataSet.prototype.setRequestInfo=function(b,a){this.requestInfo=new Spry.Utils.loadURL.Request;this.requestInfo.extractRequestOptions(b,a);if(this.requestInfo.method=="POST"){if(!this.requestInfo.headers)this.requestInfo.headers={};if(!this.requestInfo.headers["Content-Type"])this.requestInfo.headers["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8"}};Spry.Data.HTTPSourceDataSet.prototype.recalculateDataSetDependencies=function(){this.hasDataRefStrings=false;for(var a=0,a=0;a<this.dataSetsForDataRefStrings.length;a++){var b=this.dataSetsForDataRefStrings[a];b&&b.removeObserver(this)}this.dataSetsForDataRefStrings=[];for(var f=this.getDataRefStrings(),g=0,e=0;e<f.length;e++){var d=Spry.Data.Region.getTokensFromStr(f[e]);for(a=0;d&&a<d.length;a++)if(d[a].search(/{[^}:]+::[^}]+}/)!=-1){var c=d[a].replace(/^\{|::.*\}/g,""),b=null;if(!this.dataSetsForDataRefStrings[c]){b=Spry.Data.getDataSetByName(c);if(c&&b){this.dataSetsForDataRefStrings[c]=b;this.dataSetsForDataRefStrings[g++]=b;this.hasDataRefStrings=true}}}}for(a=0;a<this.dataSetsForDataRefStrings.length;a++){var b=this.dataSetsForDataRefStrings[a];b.addObserver(this)}};Spry.Data.HTTPSourceDataSet.prototype.getDataRefStrings=function(){var a=[];this.url&&a.push(this.url);this.requestInfo&&this.requestInfo.postData&&a.push(this.requestInfo.postData);return a};Spry.Data.HTTPSourceDataSet.prototype.attemptLoadData=function(){for(var a=0;a<this.dataSetsForDataRefStrings.length;a++){var b=this.dataSetsForDataRefStrings[a];if(b.getLoadDataRequestIsPending()||!b.getDataWasLoaded())return}this.loadData()};Spry.Data.HTTPSourceDataSet.prototype.onCurrentRowChanged=function(){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onPostSort=function(){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onDataChanged=function(){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.loadData=function(){if(!this.url)return;this.cancelLoadData();var d=this.url,a=this.requestInfo.postData;if(this.hasDataRefStrings){for(var b=true,f=0;f<this.dataSetsForDataRefStrings.length;f++){var e=this.dataSetsForDataRefStrings[f];if(e.getLoadDataRequestIsPending())b=false;else if(!e.getDataWasLoaded()){e.loadData();b=false}}if(!b)return;d=Spry.Data.Region.processDataRefString(null,this.url,this.dataSetsForDataRefStrings);if(!d)return;if(a&&typeof a=="string")a=Spry.Data.Region.processDataRefString(null,a,this.dataSetsForDataRefStrings)}this.notifyObservers("onPreLoad");this.data=null;this.dataWasLoaded=false;this.unfilteredData=null;this.dataHash=null;this.curRowID=0;var c=this.requestInfo.clone();c.url=d;c.postData=a;this.pendingRequest={};this.pendingRequest.data=Spry.Data.HTTPSourceDataSet.LoadManager.loadData(c,this,this.useCache)};Spry.Data.HTTPSourceDataSet.prototype.cancelLoadData=function(){if(this.pendingRequest){Spry.Data.HTTPSourceDataSet.LoadManager.cancelLoadData(this.pendingRequest.data,this);this.pendingRequest=null}};Spry.Data.HTTPSourceDataSet.prototype.getURL=function(){return this.url};Spry.Data.HTTPSourceDataSet.prototype.setURL=function(b,a){if(this.url==b)if(!a||this.requestInfo.method==a.method&&(a.method!="POST"||this.requestInfo.postData==a.postData))return;this.url=b;this.setRequestInfo(a);this.cancelLoadData();this.recalculateDataSetDependencies();this.dataWasLoaded=false};Spry.Data.HTTPSourceDataSet.prototype.setDataFromDoc=function(a){this.pendingRequest=null;this.loadDataIntoDataSet(a);this.applyColumnTypes();this.disableNotifications();this.filterAndSortData();this.enableNotifications();this.notifyObservers("onPostLoad");this.notifyObservers("onDataChanged")};Spry.Data.HTTPSourceDataSet.prototype.loadDataIntoDataSet=function(){this.dataHash={};this.data=[];this.dataWasLoaded=true};Spry.Data.HTTPSourceDataSet.prototype.xhRequestProcessor=function(a){var b=a.responseText;return a.status==200||a.status==0?b:null};Spry.Data.HTTPSourceDataSet.prototype.sessionExpiredChecker=function(a){return a.xhRequest.responseText=="session expired"?true:false};Spry.Data.HTTPSourceDataSet.prototype.setSessionExpiredChecker=function(a){this.sessionExpiredChecker=a};Spry.Data.HTTPSourceDataSet.prototype.onRequestResponse=function(a){this.setDataFromDoc(a.rawData)};Spry.Data.HTTPSourceDataSet.prototype.onRequestError=function(b,a){this.notifyObservers("onLoadError",a)};Spry.Data.HTTPSourceDataSet.prototype.onRequestSessionExpired=function(b,a){this.notifyObservers("onSessionExpired",a)};Spry.Data.HTTPSourceDataSet.LoadManager={};Spry.Data.HTTPSourceDataSet.LoadManager.cache=[];Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest=function(c,b,a){Spry.Utils.Notifier.call(this);this.reqInfo=c;this.rawData=null;this.timer=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED;this.xhRequestProcessor=b;this.sessionExpiredChecker=a};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype=new Spry.Utils.Notifier;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.constructor=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED=1;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED=2;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED=3;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL=4;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.loadDataCallback=function(a){if(a.xhRequest.readyState!=4)return;var b=null;if(this.xhRequestProcessor)b=this.xhRequestProcessor(a.xhRequest);if(this.sessionExpiredChecker){Spry.Utils.setOptions(a,{rawData:b},false);if(this.sessionExpiredChecker(a)){this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED;this.notifyObservers("onRequestSessionExpired",a);this.observers.length=0;return}}if(!b){this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED;this.notifyObservers("onRequestError",a);this.observers.length=0;return}this.rawData=b;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL;this.notifyObservers("onRequestResponse",a);this.observers.length=0};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.loadData=function(){var b=this;this.cancelLoadData();this.rawData=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED;var a=this.reqInfo.clone();a.successCallback=function(a){b.loadDataCallback(a)};a.errorCallback=a.successCallback;this.timer=setTimeout(function(){b.timer=null;Spry.Utils.loadURL(a.method,a.url,a.async,a.successCallback,a)},0)};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.cancelLoadData=function(){if(this.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED){if(this.timer){this.timer.clearTimeout();this.timer=null}this.rawData=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED}};Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey=function(a){return a.method+"::"+a.url+"::"+a.postData+"::"+a.username};Spry.Data.HTTPSourceDataSet.LoadManager.loadData=function(d,b,e){if(!d)return null;var a=null,c=null;if(e){c=Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey(d);a=Spry.Data.HTTPSourceDataSet.LoadManager.cache[c]}if(a)if(a.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED){b&&a.addObserver(b);return a}else if(a.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL){b&&setTimeout(function(){b.setDataFromDoc(a.rawData)},0);return a}if(!a){a=new Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest(d,b?b.xhRequestProcessor:null,b?b.sessionExpiredChecker:null);if(e){Spry.Data.HTTPSourceDataSet.LoadManager.cache[c]=a;a.addObserver({onRequestError:function(){Spry.Data.HTTPSourceDataSet.LoadManager.cache[c]=undefined}})}}b&&a.addObserver(b);a.loadData();return a};Spry.Data.HTTPSourceDataSet.LoadManager.cancelLoadData=function(a,b){if(a)if(b)a.removeObserver(b);else a.cancelLoadData()};Spry.Data.XMLDataSet=function(d,c,b){this.xpath=c;this.doc=null;this.subPaths=[];this.entityEncodeStrings=true;Spry.Data.HTTPSourceDataSet.call(this,d,b);var a=typeof this.subPaths;if(a=="string"||a=="object"&&this.subPaths.constructor!=Array)this.subPaths=[this.subPaths]};Spry.Data.XMLDataSet.prototype=new Spry.Data.HTTPSourceDataSet;Spry.Data.XMLDataSet.prototype.constructor=Spry.Data.XMLDataSet;Spry.Data.XMLDataSet.prototype.getDataRefStrings=function(){var a=[];this.url&&a.push(this.url);this.xpath&&a.push(this.xpath);this.requestInfo&&this.requestInfo.postData&&a.push(this.requestInfo.postData);return a};Spry.Data.XMLDataSet.prototype.getDocument=function(){return this.doc};Spry.Data.XMLDataSet.prototype.getXPath=function(){return this.xpath};Spry.Data.XMLDataSet.prototype.setXPath=function(a){if(this.xpath!=a){this.xpath=a;if(this.dataWasLoaded&&this.doc){this.notifyObservers("onPreLoad");this.setDataFromDoc(this.doc)}}};Spry.Data.XMLDataSet.nodeContainsElementNode=function(a){if(a){a=a.firstChild;while(a){if(a.nodeType==1)return true;a=a.nextSibling}}return false};Spry.Data.XMLDataSet.getNodeText=function(c,e,d){var b="";if(!c)return;try{var a=c.firstChild;while(a){try{if(a.nodeType==3)b+=e?Spry.Utils.encodeEntities(a.data):a.data;else if(a.nodeType==4)b+=d?Spry.Utils.encodeEntities(a.data):a.data}catch(f){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+f+"\n")}a=a.nextSibling}}catch(f){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+f+"\n")}return b};Spry.Data.XMLDataSet.createObjectForNode=function(d,g,f){if(!d)return null;var e={},c=0,b=null;try{for(c=0;c<d.attributes.length;c++){b=d.attributes[c];if(b&&b.nodeType==2)e["@"+b.name]=b.value}}catch(i){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+i+"\n")}var a=d.firstChild;if(a&&!a.nextSibling&&a.nodeType!=1)e[d.nodeName]=Spry.Data.XMLDataSet.getNodeText(d,g,f);while(a){if(a.nodeType==1)if(!Spry.Data.XMLDataSet.nodeContainsElementNode(a)){e[a.nodeName]=Spry.Data.XMLDataSet.getNodeText(a,g,f);try{var h=a.nodeName+"/@";for(c=0;c<a.attributes.length;c++){b=a.attributes[c];if(b&&b.nodeType==2)e[h+b.name]=b.value}}catch(i){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+i+"\n")}}a=a.nextSibling}return e};Spry.Data.XMLDataSet.getRecordSetFromXMLDoc=function(e,f,k,g){if(!e||!f)return null;var c={};c.xmlDoc=e;c.xmlPath=f;c.dataHash={};c.data=[];c.getData=function(){return this.data};var n=new ExprContext(e),l=xpathParse(f),o=l.evaluate(n),b=o.nodeSetValue(),h=true;if(b&&b.length>0)h=b[0].nodeType!=2;var m=0,j=true,i=false;if(typeof g=="boolean")j=i=g;for(var d=0;d<b.length;d++){var a=null;if(k)a={};else if(h)a=Spry.Data.XMLDataSet.createObjectForNode(b[d],j,i);else{a={};a["@"+b[d].name]=b[d].value}if(a){a.ds_RowID=m++;a.ds_XMLNode=b[d];c.dataHash[a.ds_RowID]=a;c.data.push(a)}}return c};Spry.Data.XMLDataSet.PathNode=function(a){this.path=a;this.subPaths=[];this.xpath=""};Spry.Data.XMLDataSet.PathNode.prototype.addSubPath=function(b){var a=this.findSubPath(b);if(!a){a=new Spry.Data.XMLDataSet.PathNode(b);this.subPaths.push(a)}return a};Spry.Data.XMLDataSet.PathNode.prototype.findSubPath=function(d){for(var c=this.subPaths.length,a=0;a<c;a++){var b=this.subPaths[a];if(d==b.path)return b}return null};Spry.Data.XMLDataSet.PathNode.prototype.consolidate=function(){var c=this.subPaths.length;if(!this.xpath&&c==1){var a=this.subPaths[0];this.path+=(a[0]!="/"?"/":"")+a.path;this.xpath=a.xpath;this.subPaths=a.subPaths;this.consolidate();return}for(var b=0;b<c;b++)this.subPaths[b].consolidate()};Spry.Data.XMLDataSet.prototype.convertXPathsToPathTree=function(f){for(var j=f.length,c=new Spry.Data.XMLDataSet.PathNode(""),d=0;d<j;d++){var h=f[d],a=h.replace(/\/\//g,"/__SPRYDS__");a=a.replace(/^\//,"");for(var g=a.split(/\//),i=g.length,b=c,e=0;e<i;e++){var k=g[e].replace(/__SPRYDS__/,"//");b=b.addSubPath(k)}b.xpath=h}c.consolidate();return c};Spry.Data.XMLDataSet.prototype.flattenSubPaths=function(k,c){if(!k||!c)return;var n=c.length;if(n<1)return;for(var g=k.data,x={},o=[],l=[],a=0;a<n;a++){var f=c[a];if(typeof f=="object")f=f.path;if(!f)f="";o[a]=Spry.Data.Region.processDataRefString(null,f,this.dataSetsForDataRefStrings);l[a]=o[a].replace(/\[.*\]/g,"")}for(var e,r=g.length,q=[],a=0;a<r;a++){e=g[a];for(var j=[e],b=0;b<n;b++){var i=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(e.ds_XMLNode,o[b],c[b].xpath?false:true,this.entityEncodeStrings);if(i&&i.data&&i.data.length){if(typeof c[b]=="object"&&c[b].subPaths){var h=c[b].subPaths;spType=typeof h;if(spType=="string")h=[h];else if(spType=="object"&&spType.constructor==Object)h=[h];this.flattenSubPaths(i,h)}for(var w=i.data,B=w.length,m=l[b]+"/",A=j.length,v=[],s=0;s<A;s++)for(var z=j[s],t=0;t<B;t++){var p={},y=w[t];for(d in z)p[d]=z[d];for(var d in y){var u=m+d;if(m==d+"/"||m.search(new RegExp("\\/"+d+"\\/$"))!=-1)u=l[b];p[u]=y[d]}v.push(p)}j=v}}q=q.concat(j)}g=q;r=g.length;for(a=0;a<r;a++){e=g[a];e.ds_RowID=a;x[e.ds_RowID]=e}k.data=g;k.dataHash=x};Spry.Data.XMLDataSet.prototype.loadDataIntoDataSet=function(j){var a=null,c=Spry.Data.Region.processDataRefString(null,this.xpath,this.dataSetsForDataRefStrings),d=this.subPaths,h=false;if(this.subPaths&&this.subPaths.length>0){for(var e=[],i=d.length,g=0;g<i;g++){var b=Spry.Data.Region.processDataRefString(null,d[g],this.dataSetsForDataRefStrings);if(b.charAt(0)!="/")b=c+"/"+b;e.push(b)}e.unshift(c);var f=this.convertXPathsToPathTree(e);c=f.path;d=f.subPaths;h=f.xpath?false:true}a=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(j,c,h,this.entityEncodeStrings);if(!a){Spry.Debug.reportError("Spry.Data.XMLDataSet.loadDataIntoDataSet() failed to create dataSet '"+this.name+"'for '"+this.xpath+"' - "+this.url+"\n");return}this.flattenSubPaths(a,d);this.doc=a.xmlDoc;this.data=a.data;this.dataHash=a.dataHash;this.dataWasLoaded=this.doc!=null};Spry.Data.XMLDataSet.prototype.xhRequestProcessor=function(b){var a=b.responseXML,c=false;if(b.status!=200){if(b.status==0)if(b.responseText&&(!a||!a.firstChild))c=true}else if(!a)c=true;if(c)a=Spry.Utils.stringToXMLDoc(b.responseText);return!a||!a.firstChild||a.firstChild.nodeName=="parsererror"?null:a};Spry.Data.XMLDataSet.prototype.sessionExpiredChecker=function(a){if(a.xhRequest.responseText=="session expired")return true;else if(a.rawData){var b=a.rawData.documentElement.firstChild;if(b&&b.nodeValue=="session expired")return true}return false};Spry.Data.Region=function(g,j,d,i,h,f,e,c){this.regionNode=g;this.name=j;this.isDetailRegion=d;this.data=i;this.dataSets=h;this.hasBehaviorAttributes=c;this.tokens=null;this.currentState=null;this.states={ready:true};this.stateMap={};Spry.Utils.setOptions(this.states,f);Spry.Utils.setOptions(this.stateMap,e);for(var a=0;a<this.dataSets.length;a++){var b=this.dataSets[a];try{b&&b.addObserver(this)}catch(k){Spry.Debug.reportError("Failed to add '"+this.name+"' as a dataSet observer!\n")}}};Spry.Data.Region.hiddenRegionClassName="SpryHiddenRegion";Spry.Data.Region.evenRowClassName="even";Spry.Data.Region.oddRowClassName="odd";Spry.Data.Region.notifiers={};Spry.Data.Region.evalScripts=true;Spry.Data.Region.addObserver=function(b,c){var a=Spry.Data.Region.notifiers[b];if(!a){a=new Spry.Utils.Notifier;Spry.Data.Region.notifiers[b]=a}a.addObserver(c)};Spry.Data.Region.removeObserver=function(c,b){var a=Spry.Data.Region.notifiers[c];a&&a.removeObserver(b)};Spry.Data.Region.notifyObservers=function(e,b,c){var d=Spry.Data.Region.notifiers[b.name];if(d){var a={};if(c&&typeof c=="object")a=c;else a.data=c;a.region=b;a.regionID=b.name;a.regionNode=b.regionNode;d.notifyObservers(e,a)}};Spry.Data.Region.RS_Error=1;Spry.Data.Region.RS_LoadingData=2;Spry.Data.Region.RS_PreUpdate=4;Spry.Data.Region.RS_PostUpdate=8;Spry.Data.Region.prototype.getState=function(){return this.currentState};Spry.Data.Region.prototype.mapState=function(b,a){this.stateMap[b]=a};Spry.Data.Region.prototype.getMappedState=function(b){var a=this.stateMap[b];return a?a:b};Spry.Data.Region.prototype.setState=function(b,a){var c={state:b,mappedState:this.getMappedState(b)};!a&&Spry.Data.Region.notifyObservers("onPreStateChange",this,c);this.currentState=c.mappedState?c.mappedState:b;if(this.states[b]){var d={state:this.currentState};!a&&Spry.Data.Region.notifyObservers("onPreUpdate",this,d);var e=this.transform();Spry.Data.Region.debug&&Spry.Debug.trace("<hr />Generated region markup for '"+this.name+"':<br /><br />"+Spry.Utils.encodeEntities(e));Spry.Utils.setInnerHTML(this.regionNode,e,!Spry.Data.Region.evalScripts);this.hasBehaviorAttributes&&this.attachBehaviors();!a&&Spry.Data.Region.notifyObservers("onPostUpdate",this,d)}!a&&Spry.Data.Region.notifyObservers("onPostStateChange",this,c)};Spry.Data.Region.prototype.getDataSets=function(){return this.dataSets};Spry.Data.Region.prototype.addDataSet=function(a){if(!a)return;if(!this.dataSets)this.dataSets=[];for(var b=0;b<this.dataSets.length;b++)if(this.dataSets[b]==a)return;this.dataSets.push(a);a.addObserver(this)};Spry.Data.Region.prototype.removeDataSet=function(b){if(!b||this.dataSets)return;for(var a=0;a<this.dataSets.length;a++)if(this.dataSets[a]==b){this.dataSets.splice(a,1);b.removeObserver(this);return}};Spry.Data.Region.prototype.onPreLoad=function(){this.currentState!="loading"&&this.setState("loading")};Spry.Data.Region.prototype.onLoadError=function(){this.currentState!="error"&&this.setState("error");Spry.Data.Region.notifyObservers("onError",this)};Spry.Data.Region.prototype.onSessionExpired=function(){this.currentState!="expired"&&this.setState("expired");Spry.Data.Region.notifyObservers("onExpired",this)};Spry.Data.Region.prototype.onCurrentRowChanged=function(){this.isDetailRegion&&this.updateContent()};Spry.Data.Region.prototype.onPostSort=function(){this.updateContent()};Spry.Data.Region.prototype.onDataChanged=function(){this.updateContent()};Spry.Data.Region.enableBehaviorAttributes=true;Spry.Data.Region.behaviorAttrs={};Spry.Data.Region.behaviorAttrs["spry:select"]={attach:function(d,b,c){var a=null;try{a=b.attributes.getNamedItem("spry:selectgroup").value}catch(e){}if(!a)a="default";Spry.Utils.addEventListener(b,"click",function(){Spry.Utils.SelectionManager.select(a,b,c)},false);b.attributes.getNamedItem("spry:selected")&&Spry.Utils.SelectionManager.select(a,b,c)}};Spry.Data.Region.behaviorAttrs["spry:hover"]={attach:function(c,a,b){Spry.Utils.addEventListener(a,"mouseover",function(){Spry.Utils.addClassName(a,b)},false);Spry.Utils.addEventListener(a,"mouseout",function(){Spry.Utils.removeClassName(a,b)},false)}};Spry.Data.Region.setUpRowNumberForEvenOddAttr=function(d,c,e,f){if(!e){Spry.Debug.showError("The "+c+" attribute requires a CSS class name as its value!");d.attributes.removeNamedItem(c);return}var a="",b=e.split(/\s/);if(b.length>1){a=b[0];d.setAttribute(c,b[1])}d.setAttribute(f,"{"+(a?a+"::":"")+"ds_RowNumber}")};Spry.Data.Region.behaviorAttrs["spry:even"]={setup:function(b,a){Spry.Data.Region.setUpRowNumberForEvenOddAttr(b,"spry:even",a,"spryevenrownumber")},attach:function(d,a,b){if(b){rowNumAttr=a.attributes.getNamedItem("spryevenrownumber");if(rowNumAttr&&rowNumAttr.value){var c=parseInt(rowNumAttr.value);c%2&&Spry.Utils.addClassName(a,b)}}a.removeAttribute("spry:even");a.removeAttribute("spryevenrownumber")}};Spry.Data.Region.behaviorAttrs["spry:odd"]={setup:function(b,a){Spry.Data.Region.setUpRowNumberForEvenOddAttr(b,"spry:odd",a,"spryoddrownumber")},attach:function(d,a,b){if(b){rowNumAttr=a.attributes.getNamedItem("spryoddrownumber");if(rowNumAttr&&rowNumAttr.value){var c=parseInt(rowNumAttr.value);c%2==0&&Spry.Utils.addClassName(a,b)}}a.removeAttribute("spry:odd");a.removeAttribute("spryoddrownumber")}};Spry.Data.Region.setRowAttrClickHandler=function(c,b,f,e){if(b){var d=Spry.Data.getDataSetByName(b);if(d){rowIDAttr=c.attributes.getNamedItem(f);if(rowIDAttr){var a=rowIDAttr.value;a&&Spry.Utils.addEventListener(c,"click",function(){d[e](a)},false)}}}};Spry.Data.Region.behaviorAttrs["spry:setrow"]={setup:function(b,a){if(!a){Spry.Debug.reportError("The spry:setrow attribute requires a data set name as its value!");b.removeAttribute("spry:setrow");return}b.setAttribute("spryrowid","{"+a+"::ds_RowID}")},attach:function(c,a,b){Spry.Data.Region.setRowAttrClickHandler(a,b,"spryrowid","setCurrentRow");a.removeAttribute("spry:setrow");a.removeAttribute("spryrowid")}};Spry.Data.Region.behaviorAttrs["spry:setrownumber"]={setup:function(b,a){if(!a){Spry.Debug.reportError("The spry:setrownumber attribute requires a data set name as its value!");b.removeAttribute("spry:setrownumber");return}b.setAttribute("spryrownumber","{"+a+"::ds_RowID}")},attach:function(c,a,b){Spry.Data.Region.setRowAttrClickHandler(a,b,"spryrownumber","setCurrentRowNumber");a.removeAttribute("spry:setrownumber");a.removeAttribute("spryrownumber")}};Spry.Data.Region.behaviorAttrs["spry:sort"]={attach:function(h,g,f){if(!f)return;var c=h.getDataSets()[0],e="toggle",a=f.split(/\s/);if(a.length>1){var d=Spry.Data.getDataSetByName(a[0]);if(d){c=d;a.shift()}if(a.length>1){var b=a[a.length-1];if(b=="ascending"||b=="descending"||b=="toggle"){e=b;a.pop()}}}c&&a.length>0&&Spry.Utils.addEventListener(g,"click",function(){c.sort(a,e)},false);g.removeAttribute("spry:sort")}};Spry.Data.Region.prototype.attachBehaviors=function(){var a=this;Spry.Utils.getNodesByFunc(this.regionNode,function(b){if(!b||b.nodeType!=1)return false;try{var e=Spry.Data.Region.behaviorAttrs;for(var d in e){var f=b.attributes.getNamedItem(d);if(f){var c=e[d];c&&c.attach&&c.attach(a,b,f.value)}}}catch(g){}return false})};Spry.Data.Region.prototype.updateContent=function(){var c=true,a=this.getDataSets();if(!a||a.length<1){Spry.Debug.reportError("updateContent(): Region '"+this.name+"' has no data set!\n");return}for(var d=0;d<a.length;d++){var b=a[d];if(b)if(b.getLoadDataRequestIsPending())c=false;else if(!b.getDataWasLoaded()){b.loadData();c=false}}if(!c){Spry.Data.Region.notifyObservers("onLoadingData",this);return}this.setState("ready")};Spry.Data.Region.prototype.clearContent=function(){this.regionNode.innerHTML=""};Spry.Data.Region.processContentPI=function(c){var e="",f=/<!--\s*<\/?spry:content\s*[^>]*>\s*-->/mg,a=0,d=0;while(c.length){var b=f.exec(c);if(!b||!b[0]){e+=c.substr(a,c.length-a);break}if(!d&&b.index!=a)e+=c.substr(a,b.index-a);if(b[0].search(/<\//)!=-1){--d;d&&Spry.Debug.reportError("Nested spry:content regions are not allowed!\n")}else{++d;var g=b[0].replace(/.*\bdataref="/,"");e+=g.replace(/".*$/,"")}a=f.lastIndex}return e};Spry.Data.Region.prototype.tokenizeData=function(q){if(!q)return null;var p=new Spry.Data.Region.Token(Spry.Data.Region.Token.LIST_TOKEN,null,null,null),b=[],k=Spry.Data.Region.processContentPI(q);b.push(p);var r=/((<!--\s*){0,1}<\/{0,1}spry:[^>]+>(\s*-->){0,1})|((\{|%7[bB])[^\}\s%]+(\}|%7[dD]))/mg,f=0;while(k.length){var a=r.exec(k),c=null;if(!a||!a[0]){var l=k.substr(f,k.length-f);c=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,l,l);b[b.length-1].addChild(c);break}if(a.index!=f){var l=k.substr(f,a.index-f);c=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,l,l);b[b.length-1].addChild(c)}if(a[0].search(/^({|%7[bB])/)!=-1){var e=a[0],j=a[0];e=e.replace(/^({|%7[bB])/,"");e=e.replace(/(}|%7[dD])$/,"");var o=null,m=e.split(/::/);if(m.length>1){o=m[0];e=m[1]}j=j.replace(/^%7[bB]/,"{");j=j.replace(/%7[dD]$/,"}");c=new Spry.Data.Region.Token(Spry.Data.Region.Token.VALUE_TOKEN,o,e,new String(j));b[b.length-1].addChild(c)}else if(a[0].charAt(0)=="<"){var i=a[0].replace(/^(<!--\s*){0,1}<\/?/,"");i=i.replace(/>(\s*-->){0,1}|\s.*$/,"");if(a[0].search(/<\//)!=-1){if(b[b.length-1].tokenType!=Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN){Spry.Debug.reportError("Invalid processing instruction close tag: "+i+" -- "+a[0]+"\n");return null}b.pop()}else{var t=Spry.Data.Region.PI.instructions[i];if(t){var n=null,d="";if(a[0].search(/^.*\bselect=\"/)!=-1){d=a[0].replace(/^.*\bselect=\"/,"");d=d.replace(/".*$/,"");if(d){n=Spry.Data.getDataSetByName(d);if(!n){Spry.Debug.reportError("Failed to retrieve data set ("+d+") for "+i+"\n");d=""}}}var h=null;if(a[0].search(/^.*\btest=\"/)!=-1){h=a[0].replace(/^.*\btest=\"/,"");h=h.replace(/".*$/,"");h=Spry.Utils.decodeEntities(h)}var g=null;if(a[0].search(/^.*\bname=\"/)!=-1){g=a[0].replace(/^.*\bname=\"/,"");g=g.replace(/".*$/,"");g=Spry.Utils.decodeEntities(g)}var s=new Spry.Data.Region.Token.PIData(i,d,h,g);c=new Spry.Data.Region.Token(Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN,n,s,new String(a[0]));b[b.length-1].addChild(c);b.push(c)}else{Spry.Debug.reportError("Unsupported region processing instruction: "+a[0]+"\n");return null}}}else{Spry.Debug.reportError("Invalid region token: "+a[0]+"\n");return null}f=r.lastIndex}return p};Spry.Data.Region.prototype.callScriptFunction=function(a,b){var c=undefined;a=a.replace(/^\s*\{?\s*function::\s*|\s*\}?\s*$/g,"");var d=Spry.Utils.getObjectByName(a);if(d)c=d(this.name,function(){return b.getValueFromDataSet.apply(b,arguments)});return c};Spry.Data.Region.prototype.evaluateExpression=function(a,c){var b=undefined;try{if(a.search(/^\s*function::/)!=-1)b=this.callScriptFunction(a,c);else b=Spry.Utils.eval(Spry.Data.Region.processDataRefString(c,a,null,true))}catch(d){Spry.Debug.trace("Caught exception in Spry.Data.Region.prototype.evaluateExpression() while evaluating: "+Spry.Utils.encodeEntities(a)+"\n    Exception:"+d+"\n")}return b};Spry.Data.Region.prototype.processTokenChildren=function(d,e,c){for(var b=e.children,f=b.length,a=0;a<f;a++)this.processTokens(d,b[a],c)};Spry.Data.Region.prototype.processTokens=function(d,a,b){var j=0;switch(a.tokenType){case Spry.Data.Region.Token.LIST_TOKEN:this.processTokenChildren(d,a,b);break;case Spry.Data.Region.Token.STRING_TOKEN:d.push(a.data);break;case Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN:if(a.data.name=="spry:repeat"){var c=null;if(a.dataSet)c=a.dataSet;else c=this.dataSets[0];if(c){var h=b.getDataSetContext(c);if(!h){Spry.Debug.reportError("processTokens() failed to get a data set context!\n");break}h.pushState();var m=h.getData(),n=m.length;for(j=0;j<n;j++){h.setRowIndex(j);var f=true;if(a.data.jsExpr)f=this.evaluateExpression(a.data.jsExpr,b);f&&this.processTokenChildren(d,a,b)}h.popState()}}else if(a.data.name=="spry:if"){var f=true;if(a.data.jsExpr)f=this.evaluateExpression(a.data.jsExpr,b);f&&this.processTokenChildren(d,a,b)}else if(a.data.name=="spry:choose"){for(var k=null,g=null,f=false,l=0,l=0;l<a.children.length;l++){var e=a.children[l];if(e.tokenType==Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN)if(e.data.name=="spry:when"){if(e.data.jsExpr){f=this.evaluateExpression(e.data.jsExpr,b);if(f){g=e;break}}}else if(e.data.name=="spry:default")k=e}if(!g&&k)g=k;g&&this.processTokenChildren(d,g,b)}else if(a.data.name=="spry:state"){var f=true;(!a.data.regionState||a.data.regionState==this.currentState)&&this.processTokenChildren(d,a,b)}else{Spry.Debug.reportError("processTokens(): Unknown processing instruction: "+a.data.name+"\n");return""}break;case Spry.Data.Region.Token.VALUE_TOKEN:var c=a.dataSet,i=undefined;if(c&&c=="function")i=this.callScriptFunction(a.data,b);else{if(!c&&this.dataSets&&this.dataSets.length>0&&this.dataSets[0])c=this.dataSets[0];if(!c){Spry.Debug.reportError("processTokens(): Value reference has no data set specified: "+a.regionStr+"\n");return""}i=b.getValueFromDataSet(c,a.data)}typeof i!="undefined"&&d.push(i+"");break;default:Spry.Debug.reportError("processTokens(): Invalid token type: "+a.regionStr+"\n")}};Spry.Data.Region.prototype.transform=function(){if(this.data&&!this.tokens)this.tokens=this.tokenizeData(this.data);if(!this.tokens)return"";processContext=new Spry.Data.Region.ProcessingContext(this);if(!processContext)return"";var a=[""];this.processTokens(a,this.tokens,processContext);return a.join("")};Spry.Data.Region.PI={};Spry.Data.Region.PI.instructions={};Spry.Data.Region.PI.buildOpenTagForValueAttr=function(d,b,e){if(!d||!b)return"";var a="";try{var c=d.attributes.getNamedItem(b);if(c&&c.value)a=Spry.Utils.encodeEntities(c.value)}catch(f){a=""}if(!a){Spry.Debug.reportError(b+" attribute requires a JavaScript expression that returns true or false!\n");return""}return"<"+Spry.Data.Region.PI.instructions[b].tagName+" "+e+'="'+a+'">'};Spry.Data.Region.PI.buildOpenTagForTest=function(b,a){return Spry.Data.Region.PI.buildOpenTagForValueAttr(b,a,"test")};Spry.Data.Region.PI.buildOpenTagForState=function(b,a){return Spry.Data.Region.PI.buildOpenTagForValueAttr(b,a,"name")};Spry.Data.Region.PI.buildOpenTagForRepeat=function(d,c){if(!d||!c)return"";var a="";try{var f=d.attributes.getNamedItem(c);if(f&&f.value){a=f.value;a=a.replace(/\s/g,"")}}catch(g){a=""}if(!a){Spry.Debug.reportError(c+" attribute requires a data set name!\n");return""}var e="";try{var b=d.attributes.getNamedItem("spry:test");if(b){if(b.value)e=' test="'+Spry.Utils.encodeEntities(b.value)+'"';d.attributes.removeNamedItem(b.nodeName)}}catch(g){e=""}return"<"+Spry.Data.Region.PI.instructions[c].tagName+' select="'+a+'"'+e+">"};Spry.Data.Region.PI.buildOpenTagForContent=function(d,b){if(!d||!b)return"";var a="";try{var c=d.attributes.getNamedItem(b);if(c&&c.value)a=Spry.Utils.encodeEntities(c.value)}catch(e){a=""}if(!a){Spry.Debug.reportError(b+" attribute requires a data reference!\n");return""}return"<"+Spry.Data.Region.PI.instructions[b].tagName+' dataref="'+a+'">'};Spry.Data.Region.PI.buildOpenTag=function(b,a){return"<"+Spry.Data.Region.PI.instructions[a].tagName+">"};Spry.Data.Region.PI.buildCloseTag=function(b,a){return"</"+Spry.Data.Region.PI.instructions[a].tagName+">"};Spry.Data.Region.PI.instructions["spry:state"]={tagName:"spry:state",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForState,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:if"]={tagName:"spry:if",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeat"]={tagName:"spry:repeat",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeatchildren"]={tagName:"spry:repeat",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:choose"]={tagName:"spry:choose",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:when"]={tagName:"spry:when",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:default"]={tagName:"spry:default",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:content"]={tagName:"spry:content",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForContent,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.orderedInstructions=["spry:state","spry:if","spry:repeat","spry:repeatchildren","spry:choose","spry:when","spry:default","spry:content"];Spry.Data.Region.getTokensFromStr=function(a){return!a?null:a.match(/{[^}]+}/g)};Spry.Data.Region.processDataRefString=function(g,a,h,m){if(!a)return"";if(!g&&!h)return a;var d="",i=new RegExp("\\{([^\\}:]+::)?[^\\}]+\\}","g"),c=0;while(c<a.length){var b=i.exec(a);if(!b||!b[0]){d+=a.substr(c,a.length-c);return d}if(b.index!=c)d+=a.substr(c,b.index-c);var f="";if(b[0].search(/^\{[^}:]+::/)!=-1)f=b[0].replace(/^\{|::.*/g,"");var k=b[0].replace(/^\{|.*::|\}/g,""),n=null,e="";if(g)e=g.getValueFromDataSet(f,k);else{var l=f?h[f]:h[0];if(l)e=l.getValue(k)}if(typeof e!="undefined"){e+="";d+=m?Spry.Utils.escapeQuotesAndLineBreaks(e):e}if(c==i.lastIndex){var j=b.index+b[0].length;if(j<a.length)d+=a.substr(j);break}c=i.lastIndex}return d};Spry.Data.Region.strToDataSetsArray=function(c,f){var d=[],e={};if(!c)return d;c=c.replace(/\s+/g," ");c=c.replace(/^\s|\s$/g,"");for(var b=c.split(/ /),a=0;a<b.length;a++)if(b[a]&&!Spry.Data.Region.PI.instructions[b[a]])try{var g=Spry.Data.getDataSetByName(b[a]);if(!e[b[a]]){if(f)d.push(b[a]);else d.push(g);e[b[a]]=true}}catch(h){}return d};Spry.Data.Region.DSContext=function(f,e){var c=f,g=e,b=[{rowIndex:-1}],h=null,a=[],d=function(){return b[b.length-1].rowIndex};this.resetAll=function(){b=[{rowIndex:c.getCurrentRow()}]};this.getDataSet=function(){return c};this.getNumRows=function(b){var a=this.getCurrentState().data;return a?a.length:c.getRowCount(b)};this.getData=function(){var a=this.getCurrentState().data;return a?a:c.getData()};this.setData=function(a){this.getCurrentState().data=a};this.getValue=function(e,d){var b="",a=this.getCurrentState(),c=a.nestedDS?a.nestedDS:this.getDataSet();if(c)b=c.getValue(e,d);return b};this.getCurrentRow=function(){if(b.length<2||d()<0)return c.getCurrentRow();var e=this.getData(),a=d();if(a<0||a>e.length){Spry.Debug.reportError("Invalid index used in Spry.Data.Region.DSContext.getCurrentRow()!\n");return null}return e[a]};this.getRowIndex=function(){var a=d();return a>=0?a:c.getRowNumber(c.getCurrentRow())};this.setRowIndex=function(c){this.getCurrentState().rowIndex=c;for(var e=this.getData(),d=a.length,b=0;b<d;b++)a[b].syncDataWithParentRow(this,c,e)};this.syncDataWithParentRow=function(i,h,g){var e=g[h];if(e){nestedDS=c.getNestedDataSetForParentRow(e);if(nestedDS){var b=this.getCurrentState();b.nestedDS=nestedDS;b.data=nestedDS.getData();b.rowIndex=nestedDS.getCurrentRowNumber();b.rowIndex=b.rowIndex<0?0:b.rowIndex;for(var f=a.length,d=0;d<f;d++)a[d].syncDataWithParentRow(this,b.rowIndex,b.data)}}};this.pushState=function(){var d=this.getCurrentState(),c={};c.rowIndex=d.rowIndex;c.data=d.data;c.nestedDS=d.nestedDS;b.push(c);for(var f=a.length,e=0;e<f;e++)a[e].pushState()};this.popState=function(){if(b.length<2){Spry.Debug.reportError("Stack underflow in Spry.Data.Region.DSContext.popState()!\n");return}for(var d=a.length,c=0;c<d;c++)a[c].popState();b.pop()};this.getCurrentState=function(){return b[b.length-1]};this.addChild=function(c){for(var d=a.length,b=0;b<d;b++)if(a[b]==c)return;a.push(c)}};Spry.Data.Region.ProcessingContext=function(d){this.region=d;this.dataSetContexts=[];if(d&&d.dataSets){for(var c=d.dataSets.slice(0),j=c.length,a=0;a<j;a++){var b=d.dataSets[a];while(b&&b.getParentDataSet){var k=false;b=b.getParentDataSet();b&&this.indexOf(c,b)==-1&&c.push(b)}}for(a=0;a<c.length;a++)this.dataSetContexts.push(new Spry.Data.Region.DSContext(c[a],this));var e=this.dataSetContexts,i=e.length;for(a=0;a<i;a++){var h=e[a],b=h.getDataSet();if(b.getParentDataSet){var f=b.getParentDataSet();if(f){var g=this.getDataSetContext(f);g&&g.addChild(h)}}}}};Spry.Data.Region.ProcessingContext.prototype.indexOf=function(b,d){if(b)for(var c=b.length,a=0;a<c;a++)if(b[a]==d)return a;return-1};Spry.Data.Region.ProcessingContext.prototype.getDataSetContext=function(a){if(!a)return this.dataSetContexts.length>0?this.dataSetContexts[0]:null;if(typeof a=="string"){a=Spry.Data.getDataSetByName(a);if(!a)return null}for(var b=0;b<this.dataSetContexts.length;b++){var c=this.dataSetContexts[b];if(c.getDataSet()==a)return c}return null};Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet=function(){var c="",a="";if(arguments.length>1){c=arguments[0];a=arguments[1]}else{var b=arguments[0].replace(/\s*{\s*|\s*}\s*/g,"");if(b.search("::")!=-1){c=b.replace(/::.*/,"");a=b.replace(/.*::/,"")}else a=b}var e="",d=this.getDataSetContext(c);if(d)e=d.getValue(a,d.getCurrentRow());else Spry.Debug.reportError("getValueFromDataSet: Failed to get "+c+" context for the "+this.region.regionNode.id+" region.\n");return e};Spry.Data.Region.ProcessingContext.prototype.$v=Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet;Spry.Data.Region.ProcessingContext.prototype.getCurrentRowForDataSet=function(b){var a=this.getDataSetContext(b);return a?a.getCurrentRow():null};Spry.Data.Region.Token=function(b,c,d,a){var e=this;this.tokenType=b;this.dataSet=c;this.data=d;this.regionStr=a;this.parent=null;this.children=null};Spry.Data.Region.Token.prototype.addChild=function(a){if(!a)return;if(!this.children)this.children=[];this.children.push(a);a.parent=this};Spry.Data.Region.Token.LIST_TOKEN=0;Spry.Data.Region.Token.STRING_TOKEN=1;Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN=2;Spry.Data.Region.Token.VALUE_TOKEN=3;Spry.Data.Region.Token.PIData=function(c,d,b,a){var e=this;this.name=c;this.data=d;this.jsExpr=b;this.regionState=a};Spry.Utils.addLoadListener(function(){setTimeout(function(){Spry.Data.initRegionsOnLoad&&Spry.Data.initRegions()},0)})
