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(e){a=null}if(!a)Spry.Utils.msProgIDs.splice(0,1)}}if(!a&&window.XMLHttpRequest)a=new XMLHttpRequest()}catch(e){a=null}if(!a)Spry.Debug.reportError("Failed to create an XMLHttpRequest object!");return a};Spry.Utils.loadURL=function(a,b,c,d,f){var g=new Spry.Utils.loadURL.Request();g.method=a;g.url=b;g.async=c;g.successCallback=d;Spry.Utils.setOptions(g,f);try{g.xhRequest=Spry.Utils.createXMLHttpRequest();if(!g.xhRequest)return null;if(g.async)g.xhRequest.onreadystatechange=function(){Spry.Utils.loadURL.callback(g)};g.xhRequest.open(g.method,g.url,g.async,g.username,g.password);if(g.headers){for(var h in g.headers)g.xhRequest.setRequestHeader(h,g.headers[h])}g.xhRequest.send(g.postData);if(!g.async)Spry.Utils.loadURL.callback(g)}catch(e){if(g.errorCallback)g.errorCallback(g);else Spry.Debug.reportError("Exception caught while loading "+b+": "+e);g=null}return g};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 if(a.errorCallback)a.errorCallback(a)};Spry.Utils.loadURL.Request=function(){var a=Spry.Utils.loadURL.Request.props;var b=a.length;for(var i=0;i<b;i++)this[a[i]]=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,b){if(!a)return;var c=Spry.Utils.loadURL.Request.props;var d=c.length;for(var i=0;i<d;i++){var e=c[i];if(a[e]!=undefined){this[e]=a[e];if(b)a[e]=undefined}}};Spry.Utils.loadURL.Request.prototype.clone=function(){var a=Spry.Utils.loadURL.Request.props;var b=a.length;var c=new Spry.Utils.loadURL.Request;for(var i=0;i<b;i++)c[a[i]]=this[a[i]];if(this.headers){c.headers={};Spry.Utils.setOptions(c.headers,this.headers)}return c};Spry.Utils.setInnerHTML=function(a,b,c){if(!a)return;a=Spry.$(a);var d="<script[^>]*>(.|\s|\n|\r)*?</script>";a.innerHTML=b.replace(new RegExp(d,"img"),"");if(c)return;var e=b.match(new RegExp(d,"img"));if(e){var f=e.length;for(var i=0;i<f;i++){var s=e[i].replace(/<script[^>]*>[\s\r\n]*(<\!--)?|(-->)?[\s\r\n]*<\/script>/img,"");Spry.Utils.eval(s)}}};Spry.Utils.updateContent=function(b,c,d,e){Spry.Utils.loadURL("GET",c,true,function(a){Spry.Utils.setInnerHTML(b,a.xhRequest.responseText);if(d)d(b,c)},e)};if(!Spry.$$){Spry.Utils.addEventListener=function(a,b,c,d){try{a=Spry.$(a);if(a.addEventListener)a.addEventListener(b,c,d);else if(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 if(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 if(typeof window.attachEvent!='undefined')window.attachEvent('onload',a)};Spry.Utils.getAttribute=function(a,b){a=Spry.$(a);if(!a||!b)return null;try{var c=a.getAttribute(b)}catch(e){c==undefined}if(c==undefined&&b.search(/:/)!=-1){try{var c=a.getAttribute(b.replace(/:/,""))}catch(e){c==undefined}}return c};Spry.Utils.setAttribute=function(a,b,c){a=Spry.$(a);if(!a||!b)return;if(b=="class")a.className=c;else{try{a.setAttribute(b,c)}catch(e){}if(b.search(/:/)!=-1&&a.getAttribute(b)==undefined)a.setAttribute(b.replace(/:/,""),c)}};Spry.Utils.removeAttribute=function(a,b){a=Spry.$(a);if(!a||!b)return;try{a.removeAttribute(b)}catch(e){}if(b.search(/:/)!=-1)a.removeAttribute(b.replace(/:/,""));if(b=="class")a.removeAttribute("className")};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 i=0,elements=[],length=arguments.length;i<length;i++)elements.push(Spry.$(arguments[i]));return elements}if(typeof a=='string')a=document.getElementById(a);return a}}Spry.Utils.getObjectByName=function(a){var b=null;if(a){var c=window;var d=a.split(".");for(var i=0;c&&i<d.length;i++){b=c[d[i]];c=b}}return b};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 d=Spry.Utils.decodeEntities.div;if(!d){d=document.createElement('div');Spry.Utils.decodeEntities.div=d;if(!d)return a}d.innerHTML=a;if(d.childNodes.length==1&&d.firstChild.nodeType==3&&d.firstChild.nextSibling==null)a=d.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(a){var b="";var c=a.match(/^<[^\s>]+\s*/)[0];var d=a.match(/\s*\/?>$/)[0];var e=a.replace(/^<[^\s>]+\s*|\s*\/?>/g,"");b+=c;if(e){var f=0;var g=0;while(f<e.length){while(e.charAt(g)!='='&&g<e.length)++g;if(g>=e.length){b+=e.substring(f,g);break}++g;b+=e.substring(f,g);f=g;if(e.charAt(g)=='"'||e.charAt(g)=="'"){var h=g++;while(g<e.length){if(e.charAt(g)==e.charAt(h)){g++;break}else if(e.charAt(g)=="\\")g++;g++}b+=e.substring(f,g);f=g}else{b+="\"";var i=e.slice(g).search(/\s/);g=(i!=-1)?(g+i):e.length;b+=e.slice(f,g);b+="\"";f=g}}}b+=d;return b};Spry.Utils.fixUpIEInnerHTML=function(a){var b="";var c=new RegExp("<\\!--|<\\!\\[CDATA\\[|<\\w+[^<>]*>|-->|\\]\\](>|\&gt;)","g");var d=0;var e=0;while(a.length){var f=c.exec(a);if(!f||!f[0]){b+=a.substr(d,a.length-d);break}if(f.index!=d){b+=a.substr(d,f.index-d)}if(f[0]=="<!--"||f[0]=="<![CDATA["){++e;b+=f[0]}else if(f[0]=="-->"||f[0]=="]]>"||(e&&f[0]=="]]&gt;")){--e;b+=f[0]}else if(!e&&f[0].charAt(0)=='<')b+=Spry.Utils.fixupIETagAttributes(f[0]);else b+=f[0];d=c.lastIndex}return b};Spry.Utils.stringToXMLDoc=function(a){var b=null;try{var c=new ActiveXObject("Microsoft.XMLDOM");c.async=false;c.loadXML(a);b=c}catch(e){try{var d=new DOMParser;b=d.parseFromString(a,'text/xml')}catch(e){Spry.Debug.reportError("Caught exception in Spry.Utils.stringToXMLDoc(): "+e+"\n");b=null}}return b};Spry.Utils.serializeObject=function(a){var b="";var c=true;if(a==null||a==undefined)return b+a;var d=typeof a;if(d=="number"||d=="boolean")b+=a;else if(d=="string")b+="\""+Spry.Utils.escapeQuotesAndLineBreaks(a)+"\"";else if(a.constructor==Array){b+="[";for(var i=0;i<a.length;i++){if(!c)b+=", ";b+=Spry.Utils.serializeObject(a[i]);c=false}b+="]"}else if(d=="object"){b+="{";for(var p in a){if(!c)b+=", ";b+="\""+p+"\": "+Spry.Utils.serializeObject(a[p]);c=false}b+="}"}return b};Spry.Utils.getNodesByFunc=function(a,b){var c=new Array;var d=new Array;var f=a;while(f){if(b(f))d.push(f);if(f.hasChildNodes()){c.push(f);f=f.firstChild}else{if(f==a)f=null;else try{f=f.nextSibling}catch(e){f=null}}while(!f&&c.length>0){f=c.pop();if(f==a)f=null;else try{f=f.nextSibling}catch(e){f=null}}}if(c&&c.length>0)Spry.Debug.trace("-- WARNING: Spry.Utils.getNodesByFunc() failed to traverse all nodes!\n");return d};Spry.Utils.getFirstChildWithNodeName=function(a,b){var c=a.firstChild;while(c){if(c.nodeName==b)return c;c=c.nextSibling}return null};Spry.Utils.setOptions=function(a,b,c){if(!b)return;for(var d in b){if(c&&b[d]==undefined)continue;a[d]=b[d]}};Spry.Utils.SelectionManager={};Spry.Utils.SelectionManager.selectionGroups=new Object;Spry.Utils.SelectionManager.SelectionGroup=function(){this.selectedElements=new Array};Spry.Utils.SelectionManager.SelectionGroup.prototype.select=function(a,b,c){var d=null;if(!c){this.clearSelection()}else{for(var i=0;i<this.selectedElements.length;i++){d=this.selectedElements[i].element;if(d.element==a){if(d.className!=b){Spry.Utils.removeClassName(a,d.className);Spry.Utils.addClassName(a,b)}return}}}d=new Object;d.element=a;d.className=b;this.selectedElements.push(d);Spry.Utils.addClassName(a,b)};Spry.Utils.SelectionManager.SelectionGroup.prototype.unSelect=function(a){for(var i=0;i<this.selectedElements.length;i++){var b=this.selectedElements[i].element;if(b.element==a){Spry.Utils.removeClassName(b.element,b.className);return}}};Spry.Utils.SelectionManager.SelectionGroup.prototype.clearSelection=function(){var a=null;do{a=this.selectedElements.shift();if(a)Spry.Utils.removeClassName(a.element,a.className)}while(a)};Spry.Utils.SelectionManager.getSelectionGroup=function(a){if(!a)return null;var b=Spry.Utils.SelectionManager.selectionGroups[a];if(!b){b=new Spry.Utils.SelectionManager.SelectionGroup();Spry.Utils.SelectionManager.selectionGroups[a]=b}return b};Spry.Utils.SelectionManager.select=function(a,b,c,d){var e=Spry.Utils.SelectionManager.getSelectionGroup(a);if(!e)return;e.select(b,c,d)};Spry.Utils.SelectionManager.unSelect=function(a,b){var c=Spry.Utils.SelectionManager.getSelectionGroup(a);if(!c)return;c.unSelect(b,className)};Spry.Utils.SelectionManager.clearSelection=function(a){var b=Spry.Utils.SelectionManager.getSelectionGroup(a);if(!b)return;b.clearSelection()};Spry.Utils.Notifier=function(){this.observers=[];this.suppressNotifications=0};Spry.Utils.Notifier.prototype.addObserver=function(a){if(!a)return;var b=this.observers.length;for(var i=0;i<b;i++){if(this.observers[i]==a)return}this.observers[b]=a};Spry.Utils.Notifier.prototype.removeObserver=function(a){if(!a)return;for(var i=0;i<this.observers.length;i++){if(this.observers[i]==a){this.observers.splice(i,1);break}}};Spry.Utils.Notifier.prototype.notifyObservers=function(a,b){if(!a)return;if(!this.suppressNotifications){var c=this.observers.length;for(var i=0;i<c;i++){var d=this.observers[i];if(d){if(typeof d=="function")d(a,this,b);else if(d[a])d[a](this,b)}}}};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){var a=Spry.Debug.flushQueuedMessages.msgs;for(var i=0;i<a.length;i++)Spry.Debug.debugOut(a[i].msg,a[i].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(e){}};Spry.Debug.debugOut=function(a,b){if(!Spry.Debug.debugWindow){Spry.Debug.createDebugWindow();if(!Spry.Debug.debugWindow){if(!Spry.Debug.flushQueuedMessages.msgs)Spry.Debug.flushQueuedMessages.msgs=new Array;Spry.Debug.flushQueuedMessages.msgs.push({msg:a,color:b});return}}var d=document.createElement("div");if(b)d.style.backgroundColor=b;d.innerHTML=a;Spry.Debug.debugWindow.appendChild(d)};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(t){t=t?Spry.$(t):document.body;var u=null;var v=Spry.Utils.getNodesByFunc(t,function(a){try{if(a.nodeType!=1)return false;var b="spry:region";var c=Spry.Utils.getAttribute(a,b);if(c==undefined){b="spry:detailregion";c=Spry.Utils.getAttribute(a,b)}if(c){if(u){var d=a.parentNode;while(d){if(d==u){Spry.Debug.reportError("Found a nested "+b+" in the following markup. Nested regions are currently not supported.<br/><pre>"+Spry.Utils.encodeEntities(d.innerHTML)+"</pre>");return false}d=d.parentNode}}c=a.getAttribute("id");if(!c){a.setAttribute("id","spryregion"+(++Spry.Data.initRegions.nextUniqueRegionID))}u=a;return true}else if(c=="")Spry.Debug.reportError(b+" attributes require one or more data set names as values!")}catch(e){}return false});var w,dataSets,i;var x=[];for(i=0;i<v.length;i++){var y=v[i];var z=false;w=y.getAttribute("id");var A="spry:region";var B=Spry.Utils.getAttribute(y,A);if(B==undefined){A="spry:detailregion";B=Spry.Utils.getAttribute(y,A);z=true}if(!B){Spry.Debug.reportError("spry:region and spry:detailregion attributes require one or more data set names as values!");continue}Spry.Utils.removeAttribute(y,A);Spry.Utils.removeClassName(y,Spry.Data.Region.hiddenRegionClassName);dataSets=Spry.Data.Region.strToDataSetsArray(B);if(!dataSets.length){Spry.Debug.reportError("spry:region or spry:detailregion attribute has no data set!");continue}var C=false;var D=false;var E="";var F=null;var G={};var H={};B=Spry.Utils.getAttribute(y,"spry:readystate");if(B)H["ready"]=B;B=Spry.Utils.getAttribute(y,"spry:errorstate");if(B)H["error"]=B;B=Spry.Utils.getAttribute(y,"spry:loadingstate");if(B)H["loading"]=B;B=Spry.Utils.getAttribute(y,"spry:expiredstate");if(B)H["expired"]=B;var I=Spry.Utils.getNodesByFunc(y,function(a){try{if(a.nodeType==1){var b=a.attributes;var c=Spry.Data.Region.PI.orderedInstructions.length;var d=null;var f=null;for(var i=0;i<c;i++){var g=Spry.Data.Region.PI.orderedInstructions[i];var h=Spry.Utils.getAttribute(a,g);if(h==undefined)continue;var j=Spry.Data.Region.PI.instructions[g];var k=(a==y)?true:j.childrenOnly;var l=j.getOpenTag(a,g);var m=j.getCloseTag(a,g);if(k){var n=document.createComment(l);var o=document.createComment(m);if(!d)a.insertBefore(n,a.firstChild);else a.insertBefore(n,d.nextSibling);d=n;if(!f)a.appendChild(o);else a.insertBefore(o,f);f=o}else{var p=a.parentNode;p.insertBefore(document.createComment(l),a);p.insertBefore(document.createComment(m),a.nextSibling)}if(g=="spry:state"||g=="sprystate")G[h]=true;Spry.Utils.removeAttribute(a,g)}if(Spry.Data.Region.enableBehaviorAttributes){var q=Spry.Data.Region.behaviorAttrs;for(var r in q){var s=Spry.Utils.getAttribute(a,r);if(s!=undefined){C=true;if(q[r].setup)q[r].setup(a,s)}}}}}catch(e){}return false});E=y.innerHTML;if(window.ActiveXObject&&!Spry.Data.Region.disableIEInnerHTMLFixUp&&E.search(/=\{/)!=-1){if(Spry.Data.Region.debug)Spry.Debug.trace("<hr />Performing IE innerHTML fix up of Region: "+w+"<br /><br />"+Spry.Utils.encodeEntities(E));E=Spry.Utils.fixUpIEInnerHTML(E)}if(Spry.Data.Region.debug)Spry.Debug.trace("<hr />Region template markup for '"+w+"':<br /><br />"+Spry.Utils.encodeEntities(E));if(!D){y.innerHTML=""}var J=new Spry.Data.Region(y,w,z,E,dataSets,G,H,C);Spry.Data.regionsArray[J.name]=J;x.push(J)}for(var i=0;i<x.length;i++)x[i].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(e){Spry.Debug.reportError("Spry.Data.updateRegion("+a+") caught an exception: "+e+"\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(a){var b=Spry.Utils.getObjectByName(a);if(typeof b!="object"||!b.getData||!b.filter)return null;return b};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(a,b){var c=undefined;if(!b)b=this.getCurrentRow();switch(a){case"ds_RowNumber":c=this.getRowNumber(b);break;case"ds_RowNumberPlus1":c=this.getRowNumber(b)+1;break;case"ds_RowCount":c=this.getRowCount();break;case"ds_UnfilteredRowCount":c=this.getRowCount(true);break;case"ds_CurrentRowNumber":c=this.getCurrentRowNumber();break;case"ds_CurrentRowID":c=this.getCurrentRowID();break;case"ds_EvenOddRow":c=(this.getRowNumber(b)%2)?Spry.Data.Region.evenRowClassName:Spry.Data.Region.oddRowClassName;break;case"ds_SortOrder":c=this.getSortOrder();break;case"ds_SortColumn":c=this.getSortColumn();break;default:if(b)c=b[a];break}return c};Spry.Data.DataSet.prototype.setDataFromArray=function(a,b){this.notifyObservers("onPreLoad");this.unfilteredData=null;this.filteredData=null;this.data=[];this.dataHash={};var c=a.length;for(var i=0;i<c;i++){var d=a[i];if(d.ds_RowID==undefined)d.ds_RowID=i;this.dataHash[d.ds_RowID]=d;this.data.push(d)}this.loadData(b)};Spry.Data.DataSet.prototype.loadData=function(a){var b=this;this.pendingRequest=new Object;this.dataWasLoaded=false;var c=function(){b.pendingRequest=null;b.dataWasLoaded=true;b.applyColumnTypes();b.disableNotifications();b.filterAndSortData();b.enableNotifications();b.notifyObservers("onPostLoad");b.notifyObservers("onDataChanged")};if(a)c();else this.pendingRequest.timer=setTimeout(c,0)};Spry.Data.DataSet.prototype.filterAndSortData=function(){if(this.filterDataFunc)this.filterData(this.filterDataFunc,true);if(this.distinctOnLoad)this.distinct(this.distinctFieldsOnLoad);if(this.keepSorted&&this.getSortColumn())this.sort(this.lastSortColumns,this.lastSortOrder);else if(this.sortOnLoad)this.sort(this.sortOnLoad,this.sortOrderOnLoad);if(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(){if(this.pendingRequest&&this.pendingRequest.timer)clearTimeout(this.pendingRequest.timer);this.pendingRequest=null};Spry.Data.DataSet.prototype.getRowCount=function(a){var b=this.getData(a);return b?b.length:0};Spry.Data.DataSet.prototype.getRowByID=function(a){if(!this.data)return null;return this.dataHash[a]};Spry.Data.DataSet.prototype.getRowByRowNumber=function(a,b){var c=this.getData(b);if(c&&a>=0&&a<c.length)return c[a];return 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(a,b){if(a){var c=this.getData(b);if(c&&c.length){var d=c.length;for(var i=0;i<d;i++){if(c[i]==a)return i}}}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(a,b,c){var d=[];var e=this.getData(c);if(e){var f=e.length;for(var i=0;i<f;i++){var g=e[i];var h=true;for(var j in a){if(a[j]!=g[j]){h=false;break}}if(h){if(b)return g;d.push(g)}}}return b?null:d};Spry.Data.DataSet.prototype.setColumnType=function(a,b){if(a){if(typeof a=="string")a=[a];for(var i=0;i<a.length;i++)this.columnTypes[a[i]]=b}};Spry.Data.DataSet.prototype.getColumnType=function(a){if(this.columnTypes[a])return this.columnTypes[a];return"string"};Spry.Data.DataSet.prototype.applyColumnTypes=function(){var a=this.getData(true);var b=a.length;var c=[];if(b<1)return;for(var d in this.columnTypes){var e=this.columnTypes[d];if(e!="string"){for(var i=0;i<b;i++){var f=a[i];var g=f[d];if(g!=undefined){if(e=="number")f[d]=new Number(g);else if(e=="html")f[d]=Spry.Utils.decodeEntities(g)}}}}};Spry.Data.DataSet.prototype.distinct=function(a){if(this.data){var b=this.data;this.data=[];this.dataHash={};var c=false;var d={};var i=0;var e=[];if(typeof a=="string")e=[a];else if(a)e=a;else for(var f in b[0])e[i++]=f;for(var i=0;i<b.length;i++){var g=b[i];var h="";for(var j=0;j<e.length;j++){f=e[j];if(f!="ds_RowID"){if(h)h+=",";h+=f+":"+"\""+g[f]+"\""}}if(!d[h]){this.data.push(g);this.dataHash[g['ds_RowID']]=g;d[h]=true}else c=true}if(c)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 if(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 c={oldSortColumns:this.lastSortColumns,oldSortOrder:this.lastSortOrder,newSortColumns:a,newSortOrder:b};this.notifyObservers("onPreSort",c);var d=a[a.length-1];var e=Spry.Data.DataSet.prototype.sort.getSortFunc(d,this.getColumnType(d),b);for(var i=a.length-2;i>=0;i--){d=a[i];e=Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc(Spry.Data.DataSet.prototype.sort.getSortFunc(d,this.getColumnType(d),b),e)}if(this.unfilteredData){this.unfilteredData.sort(e);if(this.filterFunc)this.filter(this.filterFunc,true)}else this.data.sort(e);this.lastSortColumns=a.slice(0);this.lastSortOrder=b;this.notifyObservers("onPostSort",c)};Spry.Data.DataSet.prototype.sort.getSortFunc=function(m,n,o){var p=null;if(n=="number"){if(o=="ascending")p=function(a,b){a=a[m];b=b[m];if(a==undefined||b==undefined)return(a==b)?0:(a?1:-1);return a-b};else p=function(a,b){a=a[m];b=b[m];if(a==undefined||b==undefined)return(a==b)?0:(a?-1:1);return b-a}}else if(n=="date"){if(o=="ascending")p=function(a,b){var c=a[m];var d=b[m];c=c?(new Date(c)):0;d=d?(new Date(d)):0;return c-d};else p=function(a,b){var c=a[m];var d=b[m];c=c?(new Date(c)):0;d=d?(new Date(d)):0;return d-c}}else{if(o=="ascending")p=function(a,b){a=a[m];b=b[m];if(a==undefined||b==undefined)return(a==b)?0:(a?1:-1);var c=a.toString();var d=b.toString();var e=c.toLowerCase();var f=d.toLowerCase();var g=c.length>d.length?d.length:c.length;for(var i=0;i<g;i++){var h=e.charAt(i);var j=f.charAt(i);var k=c.charAt(i);var l=d.charAt(i);if(h>j)return 1;else if(h<j)return-1;else if(k>l)return 1;else if(k<l)return-1}if(c.length==d.length)return 0;else if(c.length>d.length)return 1;return-1};else p=function(a,b){a=a[m];b=b[m];if(a==undefined||b==undefined)return(a==b)?0:(a?-1:1);var c=a.toString();var d=b.toString();var e=c.toLowerCase();var f=d.toLowerCase();var g=c.length>d.length?d.length:c.length;for(var i=0;i<g;i++){var h=e.charAt(i);var j=f.charAt(i);var k=c.charAt(i);var l=d.charAt(i);if(h>j)return-1;else if(h<j)return 1;else if(k>l)return-1;else if(k<l)return 1}if(c.length==d.length)return 0;else if(c.length>d.length)return-1;return 1}}return p};Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc=function(d,e){return function(a,b){var c=d(a,b);if(c==0)c=e(a,b);return c}};Spry.Data.DataSet.prototype.filterData=function(a,b){var c=false;if(!a){this.filterDataFunc=null;c=true}else{this.filterDataFunc=a;if(this.dataWasLoaded&&((this.unfilteredData&&this.unfilteredData.length)||(this.data&&this.data.length))){if(this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null}var d=this.data;this.data=[];this.dataHash={};for(var i=0;i<d.length;i++){var e=a(this,d[i],i);if(e){this.data.push(e);this.dataHash[e["ds_RowID"]]=e}}c=true}}if(c){if(!b){this.disableNotifications();if(this.filterFunc)this.filter(this.filterFunc,true);this.enableNotifications()}this.notifyObservers("onDataChanged")}};Spry.Data.DataSet.prototype.filter=function(a,b){var c=false;if(!a){if(this.filterFunc&&this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null;this.filterFunc=null;c=true}}else{this.filterFunc=a;if(this.dataWasLoaded&&(this.unfilteredData||(this.data&&this.data.length))){if(!this.unfilteredData)this.unfilteredData=this.data;var d=this.unfilteredData;this.data=[];for(var i=0;i<d.length;i++){var e=a(this,d[i],i);if(e)this.data.push(e)}c=true}}if(c)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(){if(this.loadIntervalID)clearInterval(this.loadIntervalID);this.loadInterval=0;this.loadIntervalID=null};Spry.Data.DataSet.nextDataSetID=0;Spry.Data.HTTPSourceDataSet=function(a,b){Spry.Data.DataSet.call(this);this.url=a;this.dataSetsForDataRefStrings=new Array;this.hasDataRefStrings=false;this.useCache=true;this.setRequestInfo(b,true);Spry.Utils.setOptions(this,b,true);this.recalculateDataSetDependencies();if(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(a,b){this.requestInfo=new Spry.Utils.loadURL.Request();this.requestInfo.extractRequestOptions(a,b);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;var i=0;for(i=0;i<this.dataSetsForDataRefStrings.length;i++){var a=this.dataSetsForDataRefStrings[i];if(a)a.removeObserver(this)}this.dataSetsForDataRefStrings=new Array();var b=this.getDataRefStrings();var c=0;for(var n=0;n<b.length;n++){var d=Spry.Data.Region.getTokensFromStr(b[n]);for(i=0;d&&i<d.length;i++){if(d[i].search(/{[^}:]+::[^}]+}/)!=-1){var e=d[i].replace(/^\{|::.*\}/g,"");var a=null;if(!this.dataSetsForDataRefStrings[e]){a=Spry.Data.getDataSetByName(e);if(e&&a){this.dataSetsForDataRefStrings[e]=a;this.dataSetsForDataRefStrings[c++]=a;this.hasDataRefStrings=true}}}}}for(i=0;i<this.dataSetsForDataRefStrings.length;i++){var a=this.dataSetsForDataRefStrings[i];a.addObserver(this)}};Spry.Data.HTTPSourceDataSet.prototype.getDataRefStrings=function(){var a=[];if(this.url)a.push(this.url);if(this.requestInfo&&this.requestInfo.postData)a.push(this.requestInfo.postData);return a};Spry.Data.HTTPSourceDataSet.prototype.attemptLoadData=function(){for(var i=0;i<this.dataSetsForDataRefStrings.length;i++){var a=this.dataSetsForDataRefStrings[i];if(a.getLoadDataRequestIsPending()||!a.getDataWasLoaded())return}this.loadData()};Spry.Data.HTTPSourceDataSet.prototype.onCurrentRowChanged=function(a,b){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onPostSort=function(a,b){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onDataChanged=function(a,b){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.loadData=function(){if(!this.url)return;this.cancelLoadData();var a=this.url;var b=this.requestInfo.postData;if(this.hasDataRefStrings){var c=true;for(var i=0;i<this.dataSetsForDataRefStrings.length;i++){var d=this.dataSetsForDataRefStrings[i];if(d.getLoadDataRequestIsPending())c=false;else if(!d.getDataWasLoaded()){d.loadData();c=false}}if(!c)return;a=Spry.Data.Region.processDataRefString(null,this.url,this.dataSetsForDataRefStrings);if(!a)return;if(b&&(typeof b)=="string")b=Spry.Data.Region.processDataRefString(null,b,this.dataSetsForDataRefStrings)}this.notifyObservers("onPreLoad");this.data=null;this.dataWasLoaded=false;this.unfilteredData=null;this.dataHash=null;this.curRowID=0;var e=this.requestInfo.clone();e.url=a;e.postData=b;this.pendingRequest=new Object;this.pendingRequest.data=Spry.Data.HTTPSourceDataSet.LoadManager.loadData(e,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(a,b){if(this.url==a){if(!b||(this.requestInfo.method==b.method&&(b.method!="POST"||this.requestInfo.postData==b.postData)))return}this.url=a;this.setRequestInfo(b);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(a){this.dataHash=new Object;this.data=new Array;this.dataWasLoaded=true};Spry.Data.HTTPSourceDataSet.prototype.xhRequestProcessor=function(a){var b=a.responseText;if(a.status==200||a.status==0)return b;return null};Spry.Data.HTTPSourceDataSet.prototype.sessionExpiredChecker=function(a){if(a.xhRequest.responseText=='session expired')return true;return false};Spry.Data.HTTPSourceDataSet.prototype.setSessionExpiredChecker=function(a){this.sessionExpiredChecker=a};Spry.Data.HTTPSourceDataSet.prototype.onRequestResponse=function(a,b){this.setDataFromDoc(a.rawData)};Spry.Data.HTTPSourceDataSet.prototype.onRequestError=function(a,b){this.notifyObservers("onLoadError",b)};Spry.Data.HTTPSourceDataSet.prototype.onRequestSessionExpired=function(a,b){this.notifyObservers("onSessionExpired",b)};Spry.Data.HTTPSourceDataSet.LoadManager={};Spry.Data.HTTPSourceDataSet.LoadManager.cache=[];Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest=function(a,b,c){Spry.Utils.Notifier.call(this);this.reqInfo=a;this.rawData=null;this.timer=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED;this.xhRequestProcessor=b;this.sessionExpiredChecker=c};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 c=this.reqInfo.clone();c.successCallback=function(a){b.loadDataCallback(a)};c.errorCallback=c.successCallback;this.timer=setTimeout(function(){b.timer=null;Spry.Utils.loadURL(c.method,c.url,c.async,c.successCallback,c)},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(a,b,c){if(!a)return null;var d=null;var e=null;if(c){e=Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey(a);d=Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]}if(d){if(d.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED){if(b)d.addObserver(b);return d}else if(d.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL){if(b)setTimeout(function(){b.setDataFromDoc(d.rawData)},0);return d}}if(!d){d=new Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest(a,(b?b.xhRequestProcessor:null),(b?b.sessionExpiredChecker:null));if(c){Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]=d;d.addObserver({onRequestError:function(){Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]=undefined}})}}if(b)d.addObserver(b);d.loadData();return d};Spry.Data.HTTPSourceDataSet.LoadManager.cancelLoadData=function(a,b){if(a){if(b)a.removeObserver(b);else a.cancelLoadData()}};Spry.Data.XMLDataSet=function(a,b,c){this.xpath=b;this.doc=null;this.subPaths=[];this.entityEncodeStrings=true;Spry.Data.HTTPSourceDataSet.call(this,a,c);var d=typeof this.subPaths;if(d=="string"||(d=="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=[];if(this.url)a.push(this.url);if(this.xpath)a.push(this.xpath);if(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(a,b,c){var d="";if(!a)return;try{var f=a.firstChild;while(f){try{if(f.nodeType==3)d+=b?Spry.Utils.encodeEntities(f.data):f.data;else if(f.nodeType==4)d+=c?Spry.Utils.encodeEntities(f.data):f.data}catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+e+"\n")}f=f.nextSibling}}catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+e+"\n")}return d};Spry.Data.XMLDataSet.createObjectForNode=function(a,b,c){if(!a)return null;var d=new Object();var i=0;var f=null;try{for(i=0;i<a.attributes.length;i++){f=a.attributes[i];if(f&&f.nodeType==2)d["@"+f.name]=f.value}}catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+e+"\n")}var g=a.firstChild;if(g&&!g.nextSibling&&g.nodeType!=1){d[a.nodeName]=Spry.Data.XMLDataSet.getNodeText(a,b,c)}while(g){if(g.nodeType==1){if(!Spry.Data.XMLDataSet.nodeContainsElementNode(g)){d[g.nodeName]=Spry.Data.XMLDataSet.getNodeText(g,b,c);try{var h=g.nodeName+"/@";for(i=0;i<g.attributes.length;i++){f=g.attributes[i];if(f&&f.nodeType==2)d[h+f.name]=f.value}}catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+e+"\n")}}}g=g.nextSibling}return d};Spry.Data.XMLDataSet.getRecordSetFromXMLDoc=function(a,b,c,d){if(!a||!b)return null;var f=new Object();f.xmlDoc=a;f.xmlPath=b;f.dataHash=new Object;f.data=new Array;f.getData=function(){return this.data};var g=new ExprContext(a);var h=xpathParse(b);var e=h.evaluate(g);var j=e.nodeSetValue();var k=true;if(j&&j.length>0)k=j[0].nodeType!=2;var l=0;var m=true;var n=false;if(typeof d=="boolean")m=n=d;for(var i=0;i<j.length;i++){var o=null;if(c)o=new Object;else{if(k)o=Spry.Data.XMLDataSet.createObjectForNode(j[i],m,n);else{o=new Object;o["@"+j[i].name]=j[i].value}}if(o){o['ds_RowID']=l++;o['ds_XMLNode']=j[i];f.dataHash[o['ds_RowID']]=o;f.data.push(o)}}return f};Spry.Data.XMLDataSet.PathNode=function(a){this.path=a;this.subPaths=[];this.xpath=""};Spry.Data.XMLDataSet.PathNode.prototype.addSubPath=function(a){var b=this.findSubPath(a);if(!b){b=new Spry.Data.XMLDataSet.PathNode(a);this.subPaths.push(b)}return b};Spry.Data.XMLDataSet.PathNode.prototype.findSubPath=function(a){var b=this.subPaths.length;for(var i=0;i<b;i++){var c=this.subPaths[i];if(a==c.path)return c}return null};Spry.Data.XMLDataSet.PathNode.prototype.consolidate=function(){var a=this.subPaths.length;if(!this.xpath&&a==1){var b=this.subPaths[0];this.path+=((b[0]!="/")?"/":"")+b.path;this.xpath=b.xpath;this.subPaths=b.subPaths;this.consolidate();return}for(var i=0;i<a;i++)this.subPaths[i].consolidate()};Spry.Data.XMLDataSet.prototype.convertXPathsToPathTree=function(a){var b=a.length;var c=new Spry.Data.XMLDataSet.PathNode("");for(var i=0;i<b;i++){var d=a[i];var e=d.replace(/\/\//g,"/__SPRYDS__");e=e.replace(/^\//,"");var f=e.split(/\//);var g=f.length;var h=c;for(var j=0;j<g;j++){var k=f[j].replace(/__SPRYDS__/,"//");h=h.addSubPath(k)}h.xpath=d}c.consolidate();return c};Spry.Data.XMLDataSet.prototype.flattenSubPaths=function(a,b){if(!a||!b)return;var c=b.length;if(c<1)return;var d=a.data;var e={};var f=[];var g=[];for(var i=0;i<c;i++){var h=b[i];if(typeof h=="object")h=h.path;if(!h)h="";f[i]=Spry.Data.Region.processDataRefString(null,h,this.dataSetsForDataRefStrings);g[i]=f[i].replace(/\[.*\]/g,"")}var m;var n=d.length;var o=[];for(var i=0;i<n;i++){m=d[i];var p=[m];for(var j=0;j<c;j++){var q=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(m.ds_XMLNode,f[j],(b[j].xpath?false:true),this.entityEncodeStrings);if(q&&q.data&&q.data.length){if(typeof b[j]=="object"&&b[j].subPaths){var r=b[j].subPaths;spType=typeof r;if(spType=="string")r=[r];else if(spType=="object"&&spType.constructor==Object)r=[r];this.flattenSubPaths(q,r)}var s=q.data;var t=s.length;var u=g[j]+"/";var v=p.length;var w=[];for(var k=0;k<v;k++){var x=p[k];for(var l=0;l<t;l++){var y=new Object;var z=s[l];for(A in x)y[A]=x[A];for(var A in z){var B=u+A;if(u==(A+"/")||u.search(new RegExp("\\/"+A+"\\/$"))!=-1)B=g[j];y[B]=z[A]}w.push(y)}}p=w}}o=o.concat(p)}d=o;n=d.length;for(i=0;i<n;i++){m=d[i];m.ds_RowID=i;e[m.ds_RowID]=m}a.data=d;a.dataHash=e};Spry.Data.XMLDataSet.prototype.loadDataIntoDataSet=function(a){var b=null;var c=Spry.Data.Region.processDataRefString(null,this.xpath,this.dataSetsForDataRefStrings);var d=this.subPaths;var e=false;if(this.subPaths&&this.subPaths.length>0){var f=[];var g=d.length;for(var i=0;i<g;i++){var h=Spry.Data.Region.processDataRefString(null,d[i],this.dataSetsForDataRefStrings);if(h.charAt(0)!='/')h=c+"/"+h;f.push(h)}f.unshift(c);var j=this.convertXPathsToPathTree(f);c=j.path;d=j.subPaths;e=j.xpath?false:true}b=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(a,c,e,this.entityEncodeStrings);if(!b){Spry.Debug.reportError("Spry.Data.XMLDataSet.loadDataIntoDataSet() failed to create dataSet '"+this.name+"'for '"+this.xpath+"' - "+this.url+"\n");return}this.flattenSubPaths(b,d);this.doc=b.xmlDoc;this.data=b.data;this.dataHash=b.dataHash;this.dataWasLoaded=(this.doc!=null)};Spry.Data.XMLDataSet.prototype.xhRequestProcessor=function(a){var b=a.responseXML;var c=false;if(a.status!=200){if(a.status==0){if(a.responseText&&(!b||!b.firstChild))c=true}}else if(!b){c=true}if(c)b=Spry.Utils.stringToXMLDoc(a.responseText);if(!b||!b.firstChild||b.firstChild.nodeName=="parsererror")return null;return b};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(a,b,c,d,f,g,h,j){this.regionNode=a;this.name=b;this.isDetailRegion=c;this.data=d;this.dataSets=f;this.hasBehaviorAttributes=j;this.tokens=null;this.currentState=null;this.states={ready:true};this.stateMap={};Spry.Utils.setOptions(this.states,g);Spry.Utils.setOptions(this.stateMap,h);for(var i=0;i<this.dataSets.length;i++){var k=this.dataSets[i];try{if(k)k.addObserver(this)}catch(e){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(a,b){var n=Spry.Data.Region.notifiers[a];if(!n){n=new Spry.Utils.Notifier();Spry.Data.Region.notifiers[a]=n}n.addObserver(b)};Spry.Data.Region.removeObserver=function(a,b){var n=Spry.Data.Region.notifiers[a];if(n)n.removeObserver(b)};Spry.Data.Region.notifyObservers=function(a,b,c){var n=Spry.Data.Region.notifiers[b.name];if(n){var d={};if(c&&typeof c=="object")d=c;else d.data=c;d.region=b;d.regionID=b.name;d.regionNode=b.regionNode;n.notifyObservers(a,d)}};Spry.Data.Region.RS_Error=0x01;Spry.Data.Region.RS_LoadingData=0x02;Spry.Data.Region.RS_PreUpdate=0x04;Spry.Data.Region.RS_PostUpdate=0x08;Spry.Data.Region.prototype.getState=function(){return this.currentState};Spry.Data.Region.prototype.mapState=function(a,b){this.stateMap[a]=b};Spry.Data.Region.prototype.getMappedState=function(a){var b=this.stateMap[a];return b?b:a};Spry.Data.Region.prototype.setState=function(a,b){var c={state:a,mappedState:this.getMappedState(a)};if(!b)Spry.Data.Region.notifyObservers("onPreStateChange",this,c);this.currentState=c.mappedState?c.mappedState:a;if(this.states[this.currentState]){var d={state:this.currentState};if(!b)Spry.Data.Region.notifyObservers("onPreUpdate",this,d);var e=this.transform();if(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);if(this.hasBehaviorAttributes)this.attachBehaviors();if(!b)Spry.Data.Region.notifyObservers("onPostUpdate",this,d)}if(!b)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=new Array;for(var i=0;i<this.dataSets.length;i++){if(this.dataSets[i]==a)return}this.dataSets.push(a);a.addObserver(this)};Spry.Data.Region.prototype.removeDataSet=function(a){if(!a||this.dataSets)return;for(var i=0;i<this.dataSets.length;i++){if(this.dataSets[i]==a){this.dataSets.splice(i,1);a.removeObserver(this);return}}};Spry.Data.Region.prototype.onPreLoad=function(a){if(this.currentState!="loading")this.setState("loading")};Spry.Data.Region.prototype.onLoadError=function(a){if(this.currentState!="error")this.setState("error");Spry.Data.Region.notifyObservers("onError",this)};Spry.Data.Region.prototype.onSessionExpired=function(a){if(this.currentState!="expired")this.setState("expired");Spry.Data.Region.notifyObservers("onExpired",this)};Spry.Data.Region.prototype.onCurrentRowChanged=function(a,b){if(this.isDetailRegion)this.updateContent()};Spry.Data.Region.prototype.onPostSort=function(a,b){this.updateContent()};Spry.Data.Region.prototype.onDataChanged=function(a,b){this.updateContent()};Spry.Data.Region.enableBehaviorAttributes=true;Spry.Data.Region.behaviorAttrs={};Spry.Data.Region.behaviorAttrs["spry:select"]={attach:function(b,c,d){var e=null;var f=Spry.Utils.getAttribute(c,"spry:selectgroup");if(f!=undefined){e=f;Spry.Utils.removeAttribute(c,"spry:selectgroup")}if(!e)e="default";Spry.Utils.addEventListener(c,"click",function(a){Spry.Utils.SelectionManager.select(e,c,d)},false);if(Spry.Utils.getAttribute(c,"spry:selected")!=undefined){Spry.Utils.removeAttribute(c,"spry:selected");Spry.Utils.SelectionManager.select(e,c,d)}Spry.Utils.removeAttribute(c,"spry:select")}};Spry.Data.Region.behaviorAttrs["spry:hover"]={attach:function(b,c,d){Spry.Utils.addEventListener(c,"mouseover",function(a){Spry.Utils.addClassName(c,d)},false);Spry.Utils.addEventListener(c,"mouseout",function(a){Spry.Utils.removeClassName(c,d)},false);Spry.Utils.removeAttribute(c,"spry:hover")}};Spry.Data.Region.setUpRowNumberForEvenOddAttr=function(a,b,c,d){if(!c){Spry.Debug.showError("The "+b+" attribute requires a CSS class name as its value!");a.attributes.removeNamedItem(b);return}var e="";var f=c.split(/\s/);if(f.length>1){e=f[0];a.setAttribute(b,f[1])}a.setAttribute(d,"{"+(e?(e+"::"):"")+"ds_RowNumber}")};Spry.Data.Region.behaviorAttrs["spry:even"]={setup:function(a,b){Spry.Data.Region.setUpRowNumberForEvenOddAttr(a,"spry:even",b,"spryevenrownumber")},attach:function(a,b,c){if(c){rowNumAttr=b.attributes.getNamedItem("spryevenrownumber");if(rowNumAttr&&rowNumAttr.value){var d=parseInt(rowNumAttr.value);if(d%2)Spry.Utils.addClassName(b,c)}}Spry.Utils.removeAttribute(b,"spry:even");b.removeAttribute("spryevenrownumber")}};Spry.Data.Region.behaviorAttrs["spry:odd"]={setup:function(a,b){Spry.Data.Region.setUpRowNumberForEvenOddAttr(a,"spry:odd",b,"spryoddrownumber")},attach:function(a,b,c){if(c){rowNumAttr=b.attributes.getNamedItem("spryoddrownumber");if(rowNumAttr&&rowNumAttr.value){var d=parseInt(rowNumAttr.value);if(d%2==0)Spry.Utils.addClassName(b,c)}}Spry.Utils.removeAttribute(b,"spry:odd");b.removeAttribute("spryoddrownumber")}};Spry.Data.Region.setRowAttrClickHandler=function(b,c,d,e){if(c){var f=Spry.Data.getDataSetByName(c);if(f){rowIDAttr=b.attributes.getNamedItem(d);if(rowIDAttr){var g=rowIDAttr.value;if(g)Spry.Utils.addEventListener(b,"click",function(a){f[e](g)},false)}}}};Spry.Data.Region.behaviorAttrs["spry:setrow"]={setup:function(a,b){if(!b){Spry.Debug.reportError("The spry:setrow attribute requires a data set name as its value!");Spry.Utils.removeAttribute(a,"spry:setrow");return}a.setAttribute("spryrowid","{"+b+"::ds_RowID}")},attach:function(a,b,c){Spry.Data.Region.setRowAttrClickHandler(b,c,"spryrowid","setCurrentRow");Spry.Utils.removeAttribute(b,"spry:setrow");b.removeAttribute("spryrowid")}};Spry.Data.Region.behaviorAttrs["spry:setrownumber"]={setup:function(a,b){if(!b){Spry.Debug.reportError("The spry:setrownumber attribute requires a data set name as its value!");Spry.Utils.removeAttribute(a,"spry:setrownumber");return}a.setAttribute("spryrownumber","{"+b+"::ds_RowID}")},attach:function(a,b,c){Spry.Data.Region.setRowAttrClickHandler(b,c,"spryrownumber","setCurrentRowNumber");Spry.Utils.removeAttribute(b,"spry:setrownumber");b.removeAttribute("spryrownumber")}};Spry.Data.Region.behaviorAttrs["spry:sort"]={attach:function(b,c,d){if(!d)return;var e=b.getDataSets()[0];var f="toggle";var g=d.split(/\s/);if(g.length>1){var h=Spry.Data.getDataSetByName(g[0]);if(h){e=h;g.shift()}if(g.length>1){var i=g[g.length-1];if(i=="ascending"||i=="descending"||i=="toggle"){f=i;g.pop()}}}if(e&&g.length>0)Spry.Utils.addEventListener(c,"click",function(a){e.sort(g,f)},false);Spry.Utils.removeAttribute(c,"spry:sort")}};Spry.Data.Region.prototype.attachBehaviors=function(){var g=this;Spry.Utils.getNodesByFunc(this.regionNode,function(a){if(!a||a.nodeType!=1)return false;try{var b=Spry.Data.Region.behaviorAttrs;for(var c in b){var d=Spry.Utils.getAttribute(a,c);if(d!=undefined){var f=b[c];if(f&&f.attach)f.attach(g,a,d)}}}catch(e){}return false})};Spry.Data.Region.prototype.updateContent=function(){var a=true;var b=this.getDataSets();if(!b||b.length<1){Spry.Debug.reportError("updateContent(): Region '"+this.name+"' has no data set!\n");return}for(var i=0;i<b.length;i++){var c=b[i];if(c){if(c.getLoadDataRequestIsPending())a=false;else if(!c.getDataWasLoaded()){c.loadData();a=false}}}if(!a){Spry.Data.Region.notifyObservers("onLoadingData",this);return}this.setState("ready")};Spry.Data.Region.prototype.clearContent=function(){this.regionNode.innerHTML=""};Spry.Data.Region.processContentPI=function(a){var b="";var c=/<!--\s*<\/?spry:content\s*[^>]*>\s*-->/mg;var d=0;var e=0;while(a.length){var f=c.exec(a);if(!f||!f[0]){b+=a.substr(d,a.length-d);break}if(!e&&f.index!=d){b+=a.substr(d,f.index-d)}if(f[0].search(/<\//)!=-1){--e;if(e)Spry.Debug.reportError("Nested spry:content regions are not allowed!\n")}else{++e;var g=f[0].replace(/.*\bdataref="/,"");b+=g.replace(/".*$/,"")}d=c.lastIndex}return b};Spry.Data.Region.prototype.tokenizeData=function(a){if(!a)return null;var b=new Spry.Data.Region.Token(Spry.Data.Region.Token.LIST_TOKEN,null,null,null);var c=new Array;var d=Spry.Data.Region.processContentPI(a);c.push(b);var e=/((<!--\s*){0,1}<\/{0,1}spry:[^>]+>(\s*-->){0,1})|((\{|%7[bB])[^\}\s%]+(\}|%7[dD]))/mg;var f=0;while(d.length){var g=e.exec(d);var h=null;if(!g||!g[0]){var i=d.substr(f,d.length-f);h=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,i,i);c[c.length-1].addChild(h);break}if(g.index!=f){var i=d.substr(f,g.index-f);h=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,i,i);c[c.length-1].addChild(h)}if(g[0].search(/^({|%7[bB])/)!=-1){var j=g[0];var k=g[0];j=j.replace(/^({|%7[bB])/,"");j=j.replace(/(}|%7[dD])$/,"");var l=null;var m=j.split(/::/);if(m.length>1){l=m[0];j=m[1]}k=k.replace(/^%7[bB]/,"{");k=k.replace(/%7[dD]$/,"}");h=new Spry.Data.Region.Token(Spry.Data.Region.Token.VALUE_TOKEN,l,j,new String(k));c[c.length-1].addChild(h)}else if(g[0].charAt(0)=='<'){var n=g[0].replace(/^(<!--\s*){0,1}<\/?/,"");n=n.replace(/>(\s*-->){0,1}|\s.*$/,"");if(g[0].search(/<\//)!=-1){if(c[c.length-1].tokenType!=Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN){Spry.Debug.reportError("Invalid processing instruction close tag: "+n+" -- "+g[0]+"\n");return null}c.pop()}else{var o=Spry.Data.Region.PI.instructions[n];if(o){var p=null;var q="";if(g[0].search(/^.*\bselect=\"/)!=-1){q=g[0].replace(/^.*\bselect=\"/,"");q=q.replace(/".*$/,"");if(q){p=Spry.Data.getDataSetByName(q);if(!p){Spry.Debug.reportError("Failed to retrieve data set ("+q+") for "+n+"\n");q=""}}}var r=null;if(g[0].search(/^.*\btest=\"/)!=-1){r=g[0].replace(/^.*\btest=\"/,"");r=r.replace(/".*$/,"");r=Spry.Utils.decodeEntities(r)}var s=null;if(g[0].search(/^.*\bname=\"/)!=-1){s=g[0].replace(/^.*\bname=\"/,"");s=s.replace(/".*$/,"");s=Spry.Utils.decodeEntities(s)}var t=new Spry.Data.Region.Token.PIData(n,q,r,s);h=new Spry.Data.Region.Token(Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN,p,t,new String(g[0]));c[c.length-1].addChild(h);c.push(h)}else{Spry.Debug.reportError("Unsupported region processing instruction: "+g[0]+"\n");return null}}}else{Spry.Debug.reportError("Invalid region token: "+g[0]+"\n");return null}f=e.lastIndex}return b};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,b){var c=undefined;try{if(a.search(/^\s*function::/)!=-1)c=this.callScriptFunction(a,b);else c=Spry.Utils.eval(Spry.Data.Region.processDataRefString(b,a,null,true))}catch(e){Spry.Debug.trace("Caught exception in Spry.Data.Region.prototype.evaluateExpression() while evaluating: "+Spry.Utils.encodeEntities(a)+"\n    Exception:"+e+"\n")}return c};Spry.Data.Region.prototype.processTokenChildren=function(a,b,c){var d=b.children;var e=d.length;for(var i=0;i<e;i++)this.processTokens(a,d[i],c)};Spry.Data.Region.prototype.processTokens=function(a,b,c){var i=0;switch(b.tokenType){case Spry.Data.Region.Token.LIST_TOKEN:this.processTokenChildren(a,b,c);break;case Spry.Data.Region.Token.STRING_TOKEN:a.push(b.data);break;case Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN:if(b.data.name=="spry:repeat"){var d=null;if(b.dataSet)d=b.dataSet;else d=this.dataSets[0];if(d){var e=c.getDataSetContext(d);if(!e){Spry.Debug.reportError("processTokens() failed to get a data set context!\n");break}e.pushState();var f=e.getData();var g=f.length;for(i=0;i<g;i++){e.setRowIndex(i);var h=true;if(b.data.jsExpr)h=this.evaluateExpression(b.data.jsExpr,c);if(h)this.processTokenChildren(a,b,c)}e.popState()}}else if(b.data.name=="spry:if"){var h=true;if(b.data.jsExpr)h=this.evaluateExpression(b.data.jsExpr,c);if(h)this.processTokenChildren(a,b,c)}else if(b.data.name=="spry:choose"){var k=null;var l=null;var h=false;var j=0;for(j=0;j<b.children.length;j++){var m=b.children[j];if(m.tokenType==Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN){if(m.data.name=="spry:when"){if(m.data.jsExpr){h=this.evaluateExpression(m.data.jsExpr,c);if(h){l=m;break}}}else if(m.data.name=="spry:default")k=m}}if(!l&&k)l=k;if(l)this.processTokenChildren(a,l,c)}else if(b.data.name=="spry:state"){var h=true;if(!b.data.regionState||b.data.regionState==this.currentState)this.processTokenChildren(a,b,c)}else{Spry.Debug.reportError("processTokens(): Unknown processing instruction: "+b.data.name+"\n");return""}break;case Spry.Data.Region.Token.VALUE_TOKEN:var d=b.dataSet;var n=undefined;if(d&&d=="function"){n=this.callScriptFunction(b.data,c)}else{if(!d&&this.dataSets&&this.dataSets.length>0&&this.dataSets[0]){d=this.dataSets[0]}if(!d){Spry.Debug.reportError("processTokens(): Value reference has no data set specified: "+b.regionStr+"\n");return""}n=c.getValueFromDataSet(d,b.data)}if(typeof n!="undefined")a.push(n+"");break;default:Spry.Debug.reportError("processTokens(): Invalid token type: "+b.regionStr+"\n");break}};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(a,b,c){if(!a||!b)return"";var d="";try{var f=Spry.Utils.getAttribute(a,b);if(f)d=Spry.Utils.encodeEntities(f)}catch(e){d=""}if(!d){Spry.Debug.reportError(b+" attribute requires a JavaScript expression that returns true or false!\n");return""}return"<"+Spry.Data.Region.PI.instructions[b].tagName+" "+c+"=\""+d+"\">"};Spry.Data.Region.PI.buildOpenTagForTest=function(a,b){return Spry.Data.Region.PI.buildOpenTagForValueAttr(a,b,"test")};Spry.Data.Region.PI.buildOpenTagForState=function(a,b){return Spry.Data.Region.PI.buildOpenTagForValueAttr(a,b,"name")};Spry.Data.Region.PI.buildOpenTagForRepeat=function(a,b){if(!a||!b)return"";var c=Spry.Utils.getAttribute(a,b);if(c)c=c.replace(/\s/g,"");else{Spry.Debug.reportError(b+" attribute requires a data set name!\n");return""}var d="";var e=Spry.Utils.getAttribute(a,"spry:test");if(e!=undefined){if(e)d=" test=\""+Spry.Utils.encodeEntities(e)+"\"";Spry.Utils.removeAttribute(a,"spry:test")}return"<"+Spry.Data.Region.PI.instructions[b].tagName+" select=\""+c+"\""+d+">"};Spry.Data.Region.PI.buildOpenTagForContent=function(a,b){if(!a||!b)return"";var c="";try{var d=Spry.Utils.getAttribute(a,b);if(d)c=Spry.Utils.encodeEntities(d)}catch(e){c=""}if(!c){Spry.Debug.reportError(b+" attribute requires a data reference!\n");return""}return"<"+Spry.Data.Region.PI.instructions[b].tagName+" dataref=\""+c+"\">"};Spry.Data.Region.PI.buildOpenTag=function(a,b){return"<"+Spry.Data.Region.PI.instructions[b].tagName+">"};Spry.Data.Region.PI.buildCloseTag=function(a,b){return"</"+Spry.Data.Region.PI.instructions[b].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){if(!a)return null;return a.match(/{[^}]+}/g)};Spry.Data.Region.processDataRefString=function(a,b,c,d){if(!b)return"";if(!a&&!c)return b;var e="";var f=new RegExp("\\{([^\\}:]+::)?[^\\}]+\\}","g");var g=0;while(g<b.length){var h=f.exec(b);if(!h||!h[0]){e+=b.substr(g,b.length-g);return e}if(h.index!=g)e+=b.substr(g,h.index-g);var i="";if(h[0].search(/^\{[^}:]+::/)!=-1)i=h[0].replace(/^\{|::.*/g,"");var j=h[0].replace(/^\{|.*::|\}/g,"");var k=null;var l="";if(a)l=a.getValueFromDataSet(i,j);else{var m=i?c[i]:c[0];if(m)l=m.getValue(j)}if(typeof l!="undefined"){l+="";e+=d?Spry.Utils.escapeQuotesAndLineBreaks(l):l}if(g==f.lastIndex){var n=h.index+h[0].length;if(n<b.length)e+=b.substr(n);break}g=f.lastIndex}return e};Spry.Data.Region.strToDataSetsArray=function(a,b){var c=new Array;var d={};if(!a)return c;a=a.replace(/\s+/g," ");a=a.replace(/^\s|\s$/g,"");var f=a.split(/ /);for(var i=0;i<f.length;i++){if(f[i]&&!Spry.Data.Region.PI.instructions[f[i]]){try{var g=Spry.Data.getDataSetByName(f[i]);if(!d[f[i]]){if(b)c.push(f[i]);else c.push(g);d[f[i]]=true}}catch(e){}}}return c};Spry.Data.Region.DSContext=function(g,h){var j=g;var k=h;var l=[{rowIndex:-1}];var m=null;var n=[];var o=function(){return l[l.length-1].rowIndex};this.resetAll=function(){l=[{rowIndex:j.getCurrentRow()}]};this.getDataSet=function(){return j};this.getNumRows=function(a){var b=this.getCurrentState().data;return b?b.length:j.getRowCount(a)};this.getData=function(){var a=this.getCurrentState().data;return a?a:j.getData()};this.setData=function(a){this.getCurrentState().data=a};this.getValue=function(a,b){var c="";var d=this.getCurrentState();var e=d.nestedDS?d.nestedDS:this.getDataSet();if(e)c=e.getValue(a,b);return c};this.getCurrentRow=function(){if(l.length<2||o()<0)return j.getCurrentRow();var a=this.getData();var b=o();if(b<0||b>a.length){Spry.Debug.reportError("Invalid index used in Spry.Data.Region.DSContext.getCurrentRow()!\n");return null}return a[b]};this.getRowIndex=function(){var a=o();if(a>=0)return a;return j.getRowNumber(j.getCurrentRow())};this.setRowIndex=function(a){this.getCurrentState().rowIndex=a;var b=this.getData();var c=n.length;for(var i=0;i<c;i++)n[i].syncDataWithParentRow(this,a,b)};this.syncDataWithParentRow=function(a,b,c){var d=c[b];if(d){nestedDS=j.getNestedDataSetForParentRow(d);if(nestedDS){var e=this.getCurrentState();e.nestedDS=nestedDS;e.data=nestedDS.getData();e.rowIndex=nestedDS.getCurrentRowNumber();e.rowIndex=e.rowIndex<0?0:e.rowIndex;var f=n.length;for(var i=0;i<f;i++)n[i].syncDataWithParentRow(this,e.rowIndex,e.data)}}};this.pushState=function(){var a=this.getCurrentState();var b=new Object;b.rowIndex=a.rowIndex;b.data=a.data;b.nestedDS=a.nestedDS;l.push(b);var c=n.length;for(var i=0;i<c;i++)n[i].pushState()};this.popState=function(){if(l.length<2){Spry.Debug.reportError("Stack underflow in Spry.Data.Region.DSContext.popState()!\n");return}var a=n.length;for(var i=0;i<a;i++)n[i].popState();l.pop()};this.getCurrentState=function(){return l[l.length-1]};this.addChild=function(a){var b=n.length;for(var i=0;i<b;i++){if(n[i]==a)return}n.push(a)}};Spry.Data.Region.ProcessingContext=function(a){this.region=a;this.dataSetContexts=[];if(a&&a.dataSets){var b=a.dataSets.slice(0);var c=b.length;for(var i=0;i<c;i++){var d=a.dataSets[i];while(d&&d.getParentDataSet){var e=false;d=d.getParentDataSet();if(d&&this.indexOf(b,d)==-1)b.push(d)}}for(i=0;i<b.length;i++)this.dataSetContexts.push(new Spry.Data.Region.DSContext(b[i],this));var f=this.dataSetContexts;var g=f.length;for(i=0;i<g;i++){var h=f[i];var d=h.getDataSet();if(d.getParentDataSet){var j=d.getParentDataSet();if(j){var k=this.getDataSetContext(j);if(k)k.addChild(h)}}}}};Spry.Data.Region.ProcessingContext.prototype.indexOf=function(a,b){if(a){var c=a.length;for(var i=0;i<c;i++)if(a[i]==b)return i}return-1};Spry.Data.Region.ProcessingContext.prototype.getDataSetContext=function(a){if(!a){if(this.dataSetContexts.length>0)return this.dataSetContexts[0];return null}if(typeof a=='string'){a=Spry.Data.getDataSetByName(a);if(!a)return null}for(var i=0;i<this.dataSetContexts.length;i++){var b=this.dataSetContexts[i];if(b.getDataSet()==a)return b}return null};Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet=function(){var a="";var b="";if(arguments.length>1){a=arguments[0];b=arguments[1]}else{var c=arguments[0].replace(/\s*{\s*|\s*}\s*/g,"");if(c.search("::")!=-1){a=c.replace(/::.*/,"");b=c.replace(/.*::/,"")}else b=c}var d="";var e=this.getDataSetContext(a);if(e)d=e.getValue(b,e.getCurrentRow());else Spry.Debug.reportError("getValueFromDataSet: Failed to get "+a+" context for the "+this.region.regionNode.id+" region.\n");return d};Spry.Data.Region.ProcessingContext.prototype.$v=Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet;Spry.Data.Region.ProcessingContext.prototype.getCurrentRowForDataSet=function(a){var b=this.getDataSetContext(a);if(b)return b.getCurrentRow();return null};Spry.Data.Region.Token=function(a,b,c,d){var e=this;this.tokenType=a;this.dataSet=b;this.data=c;this.regionStr=d;this.parent=null;this.children=null};Spry.Data.Region.Token.prototype.addChild=function(a){if(!a)return;if(!this.children)this.children=new Array;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(a,b,c,d){var e=this;this.name=a;this.data=b;this.jsExpr=c;this.regionState=d};Spry.Utils.addLoadListener(function(){setTimeout(function(){if(Spry.Data.initRegionsOnLoad)Spry.Data.initRegions()},0)});
