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}if(!a){Spry.Utils.msProgIDs.splice(0,1)}}}if(!a&&window.XMLHttpRequest){a=new XMLHttpRequest()}}catch(b){a=null}if(!a){Spry.Debug.reportError("Failed to create an XMLHttpRequest object!")}return a};Spry.Utils.loadURL=function(i,b,c,h,f){var d=new Spry.Utils.loadURL.Request();d.method=i;d.url=b;d.async=c;d.successCallback=h;Spry.Utils.setOptions(d,f);try{d.xhRequest=Spry.Utils.createXMLHttpRequest();if(!d.xhRequest){return null}if(d.async){d.xhRequest.onreadystatechange=function(){Spry.Utils.loadURL.callback(d)}}d.xhRequest.open(d.method,d.url,d.async,d.username,d.password);if(d.headers){for(var a in d.headers){d.xhRequest.setRequestHeader(a,d.headers[a])}}d.xhRequest.send(d.postData);if(!d.async){Spry.Utils.loadURL.callback(d)}}catch(g){if(d.errorCallback){d.errorCallback(d)}else{Spry.Debug.reportError("Exception caught while loading "+b+": "+g)}d=null}return d};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 b=Spry.Utils.loadURL.Request.props;var c=b.length;for(var 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(d,c){if(!d){return}var b=Spry.Utils.loadURL.Request.props;var e=b.length;for(var a=0;a<e;a++){var f=b[a];if(d[f]!=undefined){this[f]=d[f];if(c){d[f]=undefined}}}};Spry.Utils.loadURL.Request.prototype.clone=function(){var b=Spry.Utils.loadURL.Request.props;var d=b.length;var c=new Spry.Utils.loadURL.Request;for(var a=0;a<d;a++){c[b[a]]=this[b[a]]}if(this.headers){c.headers={};Spry.Utils.setOptions(c.headers,this.headers)}return c};Spry.Utils.setInnerHTML=function(ele,str,preventScripts){if(!ele){return}ele=Spry.$(ele);var scriptExpr="<script[^>]*>(.|s|\n|\r)*?<\/script>";ele.innerHTML=str.replace(new RegExp(scriptExpr,"img"),"");if(preventScripts){return}var matches=str.match(new RegExp(scriptExpr,"img"));if(matches){var numMatches=matches.length;for(var i=0;i<numMatches;i++){var s=matches[i].replace(/<script[^>]*>[\s\r\n]*(<\!--)?|(-->)?[\s\r\n]*<\/script>/img,"");Spry.Utils.eval(s)}}};Spry.Utils.updateContent=function(d,b,a,c){Spry.Utils.loadURL("GET",b,true,function(e){Spry.Utils.setInnerHTML(d,e.xhRequest.responseText);if(a){a(d,b)}},c)};if(!Spry.$$){Spry.Utils.addEventListener=function(c,b,d,a){try{c=Spry.$(c);if(c.addEventListener){c.addEventListener(b,d,a)}else{if(c.attachEvent){c.attachEvent("on"+b,d)}}}catch(f){}};Spry.Utils.removeEventListener=function(c,b,d,a){try{c=Spry.$(c);if(c.removeEventListener){c.removeEventListener(b,d,a)}else{if(c.detachEvent){c.detachEvent("on"+b,d)}}}catch(f){}};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(c,a){c=Spry.$(c);if(!c||!a){return null}try{var b=c.getAttribute(a)}catch(d){b==undefined}if(b==undefined&&a.search(/:/)!=-1){try{var b=c.getAttribute(a.replace(/:/,""))}catch(d){b==undefined}}return b};Spry.Utils.setAttribute=function(c,a,b){c=Spry.$(c);if(!c||!a){return}if(a=="class"){c.className=b}else{try{c.setAttribute(a,b)}catch(d){}if(a.search(/:/)!=-1&&c.getAttribute(a)==undefined){c.setAttribute(a.replace(/:/,""),b)}}};Spry.Utils.removeAttribute=function(b,a){b=Spry.$(b);if(!b||!a){return}try{b.removeAttribute(a)}catch(c){}if(a.search(/:/)!=-1){b.removeAttribute(a.replace(/:/,""))}if(a=="class"){b.removeAttribute("className")}};Spry.Utils.addClassName=function(b,a){b=Spry.$(b);if(!b||!a||(b.className&&b.className.search(new RegExp("\\b"+a+"\\b"))!=-1)){return}b.className+=(b.className?" ":"")+a};Spry.Utils.removeClassName=function(b,a){b=Spry.$(b);if(!b||!a||(b.className&&b.className.search(new RegExp("\\b"+a+"\\b"))==-1)){return}b.className=b.className.replace(new RegExp("\\s*\\b"+a+"\\b","g"),"")};Spry.$=function(b){if(arguments.length>1){for(var a=0,d=[],c=arguments.length;a<c;a++){d.push(Spry.$(arguments[a]))}return d}if(typeof b=="string"){b=document.getElementById(b)}return b}}Spry.Utils.getObjectByName=function(c){var a=null;if(c){var e=window;var b=c.split(".");for(var d=0;e&&d<b.length;d++){a=e[b[d]];e=a}}return a};Spry.Utils.eval=function(str){return eval(str)};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(b){var a=Spry.Utils.decodeEntities.div;if(!a){a=document.createElement("div");Spry.Utils.decodeEntities.div=a;if(!a){return b}}a.innerHTML=b;if(a.childNodes.length==1&&a.firstChild.nodeType==3&&a.firstChild.nextSibling==null){b=a.firstChild.data}else{b=b.replace(/&lt;/gi,"<");b=b.replace(/&gt;/gi,">");b=b.replace(/&quot;/gi,'"');b=b.replace(/&amp;/gi,"&")}return b};Spry.Utils.fixupIETagAttributes=function(h){var b="";var a=h.match(/^<[^\s>]+\s*/)[0];var e=h.match(/\s*\/?>$/)[0];var i=h.replace(/^<[^\s>]+\s*|\s*\/?>/g,"");b+=a;if(i){var g=0;var c=0;while(g<i.length){while(i.charAt(c)!="="&&c<i.length){++c}if(c>=i.length){b+=i.substring(g,c);break}++c;b+=i.substring(g,c);g=c;if(i.charAt(c)=='"'||i.charAt(c)=="'"){var f=c++;while(c<i.length){if(i.charAt(c)==i.charAt(f)){c++;break}else{if(i.charAt(c)=="\\"){c++}}c++}b+=i.substring(g,c);g=c}else{b+='"';var d=i.slice(c).search(/\s/);c=(d!=-1)?(c+d):i.length;b+=i.slice(g,c);b+='"';g=c}}}b+=e;return b};Spry.Utils.fixUpIEInnerHTML=function(f){var e="";var d=new RegExp("<\\!--|<\\!\\[CDATA\\[|<\\w+[^<>]*>|-->|\\]\\](>|&gt;)","g");var a=0;var b=0;while(f.length){var c=d.exec(f);if(!c||!c[0]){e+=f.substr(a,f.length-a);break}if(c.index!=a){e+=f.substr(a,c.index-a)}if(c[0]=="<!--"||c[0]=="<![CDATA["){++b;e+=c[0]}else{if(c[0]=="-->"||c[0]=="]]>"||(b&&c[0]=="]]&gt;")){--b;e+=c[0]}else{if(!b&&c[0].charAt(0)=="<"){e+=Spry.Utils.fixupIETagAttributes(c[0])}else{e+=c[0]}}}a=d.lastIndex}return e};Spry.Utils.stringToXMLDoc=function(f){var b=null;try{var a=new ActiveXObject("Microsoft.XMLDOM");a.async=false;a.loadXML(f);b=a}catch(c){try{var d=new DOMParser;b=d.parseFromString(f,"text/xml")}catch(c){Spry.Debug.reportError("Caught exception in Spry.Utils.stringToXMLDoc(): "+c+"\n");b=null}}return b};Spry.Utils.serializeObject=function(d){var f="";var c=true;if(d==null||d==undefined){return f+d}var e=typeof d;if(e=="number"||e=="boolean"){f+=d}else{if(e=="string"){f+='"'+Spry.Utils.escapeQuotesAndLineBreaks(d)+'"'}else{if(d.constructor==Array){f+="[";for(var a=0;a<d.length;a++){if(!c){f+=", "}f+=Spry.Utils.serializeObject(d[a]);c=false}f+="]"}else{if(e=="object"){f+="{";for(var b in d){if(!c){f+=", "}f+='"'+b+'": '+Spry.Utils.serializeObject(d[b]);c=false}f+="}"}}}}return f};Spry.Utils.getNodesByFunc=function(a,d){var f=new Array;var c=new Array;var b=a;while(b){if(d(b)){c.push(b)}if(b.hasChildNodes()){f.push(b);b=b.firstChild}else{if(b==a){b=null}else{try{b=b.nextSibling}catch(g){b=null}}}while(!b&&f.length>0){b=f.pop();if(b==a){b=null}else{try{b=b.nextSibling}catch(g){b=null}}}}if(f&&f.length>0){Spry.Debug.trace("-- WARNING: Spry.Utils.getNodesByFunc() failed to traverse all nodes!\n")}return c};Spry.Utils.getFirstChildWithNodeName=function(a,c){var b=a.firstChild;while(b){if(b.nodeName==c){return b}b=b.nextSibling}return null};Spry.Utils.setOptions=function(d,c,a){if(!c){return}for(var b in c){if(a&&c[b]==undefined){continue}d[b]=c[b]}};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(b,c,e){var d=null;if(!e){this.clearSelection()}else{for(var a=0;a<this.selectedElements.length;a++){d=this.selectedElements[a].element;if(d.element==b){if(d.className!=c){Spry.Utils.removeClassName(b,d.className);Spry.Utils.addClassName(b,c)}return}}}d=new Object;d.element=b;d.className=c;this.selectedElements.push(d);Spry.Utils.addClassName(b,c)};Spry.Utils.SelectionManager.SelectionGroup.prototype.unSelect=function(b){for(var a=0;a<this.selectedElements.length;a++){var c=this.selectedElements[a].element;if(c.element==b){Spry.Utils.removeClassName(c.element,c.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,e){var d=Spry.Utils.SelectionManager.getSelectionGroup(a);if(!d){return}d.select(b,c,e)};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(b){if(!b){return}var a=this.observers.length;for(var c=0;c<a;c++){if(this.observers[c]==b){return}}this.observers[a]=b};Spry.Utils.Notifier.prototype.removeObserver=function(a){if(!a){return}for(var b=0;b<this.observers.length;b++){if(this.observers[b]==a){this.observers.splice(b,1);break}}};Spry.Utils.Notifier.prototype.notifyObservers=function(b,d){if(!b){return}if(!this.suppressNotifications){var a=this.observers.length;for(var c=0;c<a;c++){var e=this.observers[c];if(e){if(typeof e=="function"){e(b,this,d)}else{if(e[b]){e[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){var b=Spry.Debug.flushQueuedMessages.msgs;for(var 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 b=Spry.Debug.debugWindow;b.style.fontSize="12px";b.style.fontFamily="console";b.style.position="absolute";b.style.width="400px";b.style.height="300px";b.style.overflow="auto";b.style.border="solid 1px black";b.style.backgroundColor="white";b.style.color="black";b.style.bottom="0px";b.style.right="0px";b.setAttribute("id","SpryDebugWindow");document.body.appendChild(Spry.Debug.debugWindow)}catch(a){}};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=new Array}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(r){r=r?Spry.$(r):document.body;var l=null;var a=Spry.Utils.getNodesByFunc(r,function(v){try{if(v.nodeType!=1){return false}var i="spry:region";var x=Spry.Utils.getAttribute(v,i);if(x==undefined){i="spry:detailregion";x=Spry.Utils.getAttribute(v,i)}if(x){if(l){var u=v.parentNode;while(u){if(u==l){Spry.Debug.reportError("Found a nested "+i+" in the following markup. Nested regions are currently not supported.<br/><pre>"+Spry.Utils.encodeEntities(u.innerHTML)+"</pre>");return false}u=u.parentNode}}x=v.getAttribute("id");if(!x){v.setAttribute("id","spryregion"+(++Spry.Data.initRegions.nextUniqueRegionID))}l=v;return true}else{if(x==""){Spry.Debug.reportError(i+" attributes require one or more data set names as values!")}}}catch(w){}return false});var t,k,o;var d=[];for(o=0;o<a.length;o++){var p=a[o];var b=false;t=p.getAttribute("id");var n="spry:region";var j=Spry.Utils.getAttribute(p,n);if(j==undefined){n="spry:detailregion";j=Spry.Utils.getAttribute(p,n);b=true}if(!j){Spry.Debug.reportError("spry:region and spry:detailregion attributes require one or more data set names as values!");continue}Spry.Utils.removeAttribute(p,n);Spry.Utils.removeClassName(p,Spry.Data.Region.hiddenRegionClassName);k=Spry.Data.Region.strToDataSetsArray(j);if(!k.length){Spry.Debug.reportError("spry:region or spry:detailregion attribute has no data set!");continue}var f=false;var m=false;var q="";var g=null;var c={};var h={};j=Spry.Utils.getAttribute(p,"spry:readystate");if(j){h.ready=j}j=Spry.Utils.getAttribute(p,"spry:errorstate");if(j){h.error=j}j=Spry.Utils.getAttribute(p,"spry:loadingstate");if(j){h.loading=j}j=Spry.Utils.getAttribute(p,"spry:expiredstate");if(j){h.expired=j}var s=Spry.Utils.getNodesByFunc(p,function(I){try{if(I.nodeType==1){var A=I.attributes;var y=Spry.Data.Region.PI.orderedInstructions.length;var v=null;var u=null;for(var K=0;K<y;K++){var J=Spry.Data.Region.PI.orderedInstructions[K];var D=Spry.Utils.getAttribute(I,J);if(D==undefined){continue}var H=Spry.Data.Region.PI.instructions[J];var C=(I==p)?true:H.childrenOnly;var G=H.getOpenTag(I,J);var z=H.getCloseTag(I,J);if(C){var E=document.createComment(G);var F=document.createComment(z);if(!v){I.insertBefore(E,I.firstChild)}else{I.insertBefore(E,v.nextSibling)}v=E;if(!u){I.appendChild(F)}else{I.insertBefore(F,u)}u=F}else{var B=I.parentNode;B.insertBefore(document.createComment(G),I);B.insertBefore(document.createComment(z),I.nextSibling)}if(J=="spry:state"||J=="sprystate"){c[D]=true}Spry.Utils.removeAttribute(I,J)}if(Spry.Data.Region.enableBehaviorAttributes){var M=Spry.Data.Region.behaviorAttrs;for(var w in M){var x=Spry.Utils.getAttribute(I,w);if(x!=undefined){f=true;if(M[w].setup){M[w].setup(I,x)}}}}}}catch(L){}return false});q=p.innerHTML;if(window.ActiveXObject&&!Spry.Data.Region.disableIEInnerHTMLFixUp&&q.search(/=\{/)!=-1){if(Spry.Data.Region.debug){Spry.Debug.trace("<hr />Performing IE innerHTML fix up of Region: "+t+"<br /><br />"+Spry.Utils.encodeEntities(q))}q=Spry.Utils.fixUpIEInnerHTML(q)}if(Spry.Data.Region.debug){Spry.Debug.trace("<hr />Region template markup for '"+t+"':<br /><br />"+Spry.Utils.encodeEntities(q))}if(!m){p.innerHTML=""}var e=new Spry.Data.Region(p,t,b,q,k,c,h,f);Spry.Data.regionsArray[e.name]=e;d.push(e)}for(var o=0;o<d.length;o++){d[o].updateContent()}};Spry.Data.initRegions.nextUniqueRegionID=0;Spry.Data.updateRegion=function(b){if(!b||!Spry.Data.regionsArray||!Spry.Data.regionsArray[b]){return}try{Spry.Data.regionsArray[b].updateContent()}catch(a){Spry.Debug.reportError("Spry.Data.updateRegion("+b+") caught an exception: "+a+"\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(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]}break}return a};Spry.Data.DataSet.prototype.setDataFromArray=function(a,e){this.notifyObservers("onPreLoad");this.unfilteredData=null;this.filteredData=null;this.data=[];this.dataHash={};var b=a.length;for(var c=0;c<b;c++){var d=a[c];if(d.ds_RowID==undefined){d.ds_RowID=c}this.dataHash[d.ds_RowID]=d;this.data.push(d)}this.loadData(e)};Spry.Data.DataSet.prototype.loadData=function(c){var a=this;this.pendingRequest=new Object;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(){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(b){if(this.curRowID==b){return}var a={oldRowID:this.curRowID,newRowID:b};this.curRowID=b;this.notifyObservers("onCurrentRowChanged",a)};Spry.Data.DataSet.prototype.getRowNumber=function(e,a){if(e){var c=this.getData(a);if(c&&c.length){var d=c.length;for(var b=0;b<d;b++){if(c[b]==e){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(f,a,c){var d=[];var k=this.getData(c);if(k){var g=k.length;for(var e=0;e<g;e++){var j=k[e];var b=true;for(var h in f){if(f[h]!=j[h]){b=false;break}}if(b){if(a){return j}d.push(j)}}}return a?null:d};Spry.Data.DataSet.prototype.setColumnType=function(c,b){if(c){if(typeof c=="string"){c=[c]}for(var a=0;a<c.length;a++){this.columnTypes[c[a]]=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 d=this.getData(true);var f=d.length;var e=[];if(f<1){return}for(var a in this.columnTypes){var c=this.columnTypes[a];if(c!="string"){for(var b=0;b<f;b++){var h=d[b];var g=h[a];if(g!=undefined){if(c=="number"){h[a]=new Number(g)}else{if(c=="html"){h[a]=Spry.Utils.decodeEntities(g)}}}}}}};Spry.Data.DataSet.prototype.distinct=function(h){if(this.data){var f=this.data;this.data=[];this.dataHash={};var d=false;var g={};var e=0;var l=[];if(typeof h=="string"){l=[h]}else{if(h){l=h}else{for(var a in f[0]){l[e++]=a}}}for(var e=0;e<f.length;e++){var b=f[e];var k="";for(var c=0;c<l.length;c++){a=l[c];if(a!="ds_RowID"){if(k){k+=","}k+=a+':"'+b[a]+'"'}}if(!g[k]){this.data.push(b);this.dataHash[b.ds_RowID]=b;g[k]=true}else{d=true}}if(d){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(f,e){if(!f){return}if(typeof f=="string"){f=[f,"ds_RowID"]}else{if(f.length<2&&f[0]!="ds_RowID"){f.push("ds_RowID")}}if(!e){e="toggle"}if(e=="toggle"){if(this.lastSortColumns.length>0&&this.lastSortColumns[0]==f[0]&&this.lastSortOrder=="ascending"){e="descending"}else{e="ascending"}}if(e!="ascending"&&e!="descending"){Spry.Debug.reportError("Invalid sort order type specified: "+e+"\n");return}var d={oldSortColumns:this.lastSortColumns,oldSortOrder:this.lastSortOrder,newSortColumns:f,newSortOrder:e};this.notifyObservers("onPreSort",d);var b=f[f.length-1];var a=Spry.Data.DataSet.prototype.sort.getSortFunc(b,this.getColumnType(b),e);for(var c=f.length-2;c>=0;c--){b=f[c];a=Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc(Spry.Data.DataSet.prototype.sort.getSortFunc(b,this.getColumnType(b),e),a)}if(this.unfilteredData){this.unfilteredData.sort(a);if(this.filterFunc){this.filter(this.filterFunc,true)}}else{this.data.sort(a)}this.lastSortColumns=f.slice(0);this.lastSortOrder=e;this.notifyObservers("onPostSort",d)};Spry.Data.DataSet.prototype.sort.getSortFunc=function(d,c,a){var b=null;if(c=="number"){if(a=="ascending"){b=function(f,e){f=f[d];e=e[d];if(f==undefined||e==undefined){return(f==e)?0:(f?1:-1)}return f-e}}else{b=function(f,e){f=f[d];e=e[d];if(f==undefined||e==undefined){return(f==e)?0:(f?-1:1)}return e-f}}}else{if(c=="date"){if(a=="ascending"){b=function(g,e){var h=g[d];var f=e[d];h=h?(new Date(h)):0;f=f?(new Date(f)):0;return h-f}}else{b=function(g,e){var h=g[d];var f=e[d];h=h?(new Date(h)):0;f=f?(new Date(f)):0;return f-h}}}else{if(a=="ascending"){b=function(l,k){l=l[d];k=k[d];if(l==undefined||k==undefined){return(l==k)?0:(l?1:-1)}var o=l.toString();var m=k.toString();var e=o.toLowerCase();var f=m.toLowerCase();var h=o.length>m.length?m.length:o.length;for(var g=0;g<h;g++){var p=e.charAt(g);var n=f.charAt(g);var j=o.charAt(g);var q=m.charAt(g);if(p>n){return 1}else{if(p<n){return -1}else{if(j>q){return 1}else{if(j<q){return -1}}}}}if(o.length==m.length){return 0}else{if(o.length>m.length){return 1}}return -1}}else{b=function(l,k){l=l[d];k=k[d];if(l==undefined||k==undefined){return(l==k)?0:(l?-1:1)}var o=l.toString();var m=k.toString();var e=o.toLowerCase();var f=m.toLowerCase();var h=o.length>m.length?m.length:o.length;for(var g=0;g<h;g++){var p=e.charAt(g);var n=f.charAt(g);var j=o.charAt(g);var q=m.charAt(g);if(p>n){return -1}else{if(p<n){return 1}else{if(j>q){return -1}else{if(j<q){return 1}}}}}if(o.length==m.length){return 0}else{if(o.length>m.length){return -1}}return 1}}}}return b};Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc=function(b,a){return function(d,c){var e=b(d,c);if(e==0){e=a(d,c)}return e}};Spry.Data.DataSet.prototype.filterData=function(e,c){var d=false;if(!e){this.filterDataFunc=null;d=true}else{this.filterDataFunc=e;if(this.dataWasLoaded&&((this.unfilteredData&&this.unfilteredData.length)||(this.data&&this.data.length))){if(this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null}var f=this.data;this.data=[];this.dataHash={};for(var b=0;b<f.length;b++){var a=e(this,f[b],b);if(a){this.data.push(a);this.dataHash[a.ds_RowID]=a}}d=true}}if(d){if(!c){this.disableNotifications();if(this.filterFunc){this.filter(this.filterFunc,true)}this.enableNotifications()}this.notifyObservers("onDataChanged")}};Spry.Data.DataSet.prototype.filter=function(f,c){var e=false;if(!f){if(this.filterFunc&&this.unfilteredData){this.data=this.unfilteredData;this.unfilteredData=null;this.filterFunc=null;e=true}}else{this.filterFunc=f;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 b=0;b<d.length;b++){var a=f(this,d[b],b);if(a){this.data.push(a)}}e=true}}if(e){this.notifyObservers("onDataChanged")}};Spry.Data.DataSet.prototype.startLoadInterval=function(b){this.stopLoadInterval();if(b>0){var a=this;this.loadInterval=b;this.loadIntervalID=setInterval(function(){a.loadData()},b)}};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 b=0;for(b=0;b<this.dataSetsForDataRefStrings.length;b++){var d=this.dataSetsForDataRefStrings[b];if(d){d.removeObserver(this)}}this.dataSetsForDataRefStrings=new Array();var a=this.getDataRefStrings();var c=0;for(var g=0;g<a.length;g++){var e=Spry.Data.Region.getTokensFromStr(a[g]);for(b=0;e&&b<e.length;b++){if(e[b].search(/{[^}:]+::[^}]+}/)!=-1){var f=e[b].replace(/^\{|::.*\}/g,"");var d=null;if(!this.dataSetsForDataRefStrings[f]){d=Spry.Data.getDataSetByName(f);if(f&&d){this.dataSetsForDataRefStrings[f]=d;this.dataSetsForDataRefStrings[c++]=d;this.hasDataRefStrings=true}}}}}for(b=0;b<this.dataSetsForDataRefStrings.length;b++){var d=this.dataSetsForDataRefStrings[b];d.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 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(b,a){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onPostSort=function(b,a){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.onDataChanged=function(b,a){this.attemptLoadData()};Spry.Data.HTTPSourceDataSet.prototype.loadData=function(){if(!this.url){return}this.cancelLoadData();var c=this.url;var a=this.requestInfo.postData;if(this.hasDataRefStrings){var b=true;for(var d=0;d<this.dataSetsForDataRefStrings.length;d++){var f=this.dataSetsForDataRefStrings[d];if(f.getLoadDataRequestIsPending()){b=false}else{if(!f.getDataWasLoaded()){f.loadData();b=false}}}if(!b){return}c=Spry.Data.Region.processDataRefString(null,this.url,this.dataSetsForDataRefStrings);if(!c){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 e=this.requestInfo.clone();e.url=c;e.postData=a;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(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(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 a=this;this.cancelLoadData();this.rawData=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED;var b=this.reqInfo.clone();b.successCallback=function(c){a.loadDataCallback(c)};b.errorCallback=b.successCallback;this.timer=setTimeout(function(){a.timer=null;Spry.Utils.loadURL(b.method,b.url,b.async,b.successCallback,b)},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(c,d,b){if(!c){return null}var a=null;var e=null;if(b){e=Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey(c);a=Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]}if(a){if(a.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED){if(d){a.addObserver(d)}return a}else{if(a.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL){if(d){setTimeout(function(){d.setDataFromDoc(a.rawData)},0)}return a}}}if(!a){a=new Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest(c,(d?d.xhRequestProcessor:null),(d?d.sessionExpiredChecker:null));if(b){Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]=a;a.addObserver({onRequestError:function(){Spry.Data.HTTPSourceDataSet.LoadManager.cache[e]=undefined}})}}if(d){a.addObserver(d)}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(b,a,d){this.xpath=a;this.doc=null;this.subPaths=[];this.entityEncodeStrings=true;Spry.Data.HTTPSourceDataSet.call(this,b,d);var c=typeof this.subPaths;if(c=="string"||(c=="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(d,c,b){var a="";if(!d){return}try{var g=d.firstChild;while(g){try{if(g.nodeType==3){a+=c?Spry.Utils.encodeEntities(g.data):g.data}else{if(g.nodeType==4){a+=b?Spry.Utils.encodeEntities(g.data):g.data}}}catch(f){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+f+"\n")}g=g.nextSibling}}catch(f){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+f+"\n")}return a};Spry.Data.XMLDataSet.createObjectForNode=function(c,h,k){if(!c){return null}var d=new Object();var f=0;var j=null;try{for(f=0;f<c.attributes.length;f++){j=c.attributes[f];if(j&&j.nodeType==2){d["@"+j.name]=j.value}}}catch(g){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+g+"\n")}var b=c.firstChild;if(b&&!b.nextSibling&&b.nodeType!=1){d[c.nodeName]=Spry.Data.XMLDataSet.getNodeText(c,h,k)}while(b){if(b.nodeType==1){if(!Spry.Data.XMLDataSet.nodeContainsElementNode(b)){d[b.nodeName]=Spry.Data.XMLDataSet.getNodeText(b,h,k);try{var a=b.nodeName+"/@";for(f=0;f<b.attributes.length;f++){j=b.attributes[f];if(j&&j.nodeType==2){d[a+j.name]=j.value}}}catch(g){Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+g+"\n")}}}b=b.nextSibling}return d};Spry.Data.XMLDataSet.getRecordSetFromXMLDoc=function(q,p,l,m){if(!q||!p){return null}var n=new Object();n.xmlDoc=q;n.xmlPath=p;n.dataHash=new Object;n.data=new Array;n.getData=function(){return this.data};var o=new ExprContext(q);var b=xpathParse(p);var h=b.evaluate(o);var c=h.nodeSetValue();var a=true;if(c&&c.length>0){a=c[0].nodeType!=2}var f=0;var g=true;var k=false;if(typeof m=="boolean"){g=k=m}for(var d=0;d<c.length;d++){var j=null;if(l){j=new Object}else{if(a){j=Spry.Data.XMLDataSet.createObjectForNode(c[d],g,k)}else{j=new Object;j["@"+c[d].name]=c[d].value}}if(j){j.ds_RowID=f++;j.ds_XMLNode=c[d];n.dataHash[j.ds_RowID]=j;n.data.push(j)}}return n};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){var a=this.subPaths.length;for(var c=0;c<a;c++){var b=this.subPaths[c];if(d==b.path){return b}}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 c=0;c<a;c++){this.subPaths[c].consolidate()}};Spry.Data.XMLDataSet.prototype.convertXPathsToPathTree=function(h){var e=h.length;var l=new Spry.Data.XMLDataSet.PathNode("");for(var g=0;g<e;g++){var k=h[g];var d=k.replace(/\/\//g,"/__SPRYDS__");d=d.replace(/^\//,"");var a=d.split(/\//);var b=a.length;var c=l;for(var f=0;f<b;f++){var m=a[f].replace(/__SPRYDS__/,"//");c=c.addSubPath(m)}c.xpath=k}l.consolidate();return l};Spry.Data.XMLDataSet.prototype.flattenSubPaths=function(s,n){if(!s||!n){return}var y=n.length;if(y<1){return}var F=s.data;var w={};var o=[];var a=[];for(var B=0;B<y;B++){var p=n[B];if(typeof p=="object"){p=p.path}if(!p){p=""}o[B]=Spry.Data.Region.processDataRefString(null,p,this.dataSetsForDataRefStrings);a[B]=o[B].replace(/\[.*\]/g,"")}var q;var m=F.length;var t=[];for(var B=0;B<m;B++){q=F[B];var D=[q];for(var A=0;A<y;A++){var E=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(q.ds_XMLNode,o[A],(n[A].xpath?false:true),this.entityEncodeStrings);if(E&&E.data&&E.data.length){if(typeof n[A]=="object"&&n[A].subPaths){var C=n[A].subPaths;spType=typeof C;if(spType=="string"){C=[C]}else{if(spType=="object"&&spType.constructor==Object){C=[C]}}this.flattenSubPaths(E,C)}var v=E.data;var e=v.length;var u=a[A]+"/";var d=D.length;var r=[];for(var z=0;z<d;z++){var g=D[z];for(var x=0;x<e;x++){var c=new Object;var b=v[x];for(f in g){c[f]=g[f]}for(var f in b){var h=u+f;if(u==(f+"/")||u.search(new RegExp("\\/"+f+"\\/$"))!=-1){h=a[A]}c[h]=b[f]}r.push(c)}}D=r}}t=t.concat(D)}F=t;m=F.length;for(B=0;B<m;B++){q=F[B];q.ds_RowID=B;w[q.ds_RowID]=q}s.data=F;s.dataHash=w};Spry.Data.XMLDataSet.prototype.loadDataIntoDataSet=function(e){var b=null;var a=Spry.Data.Region.processDataRefString(null,this.xpath,this.dataSetsForDataRefStrings);var f=this.subPaths;var g=false;if(this.subPaths&&this.subPaths.length>0){var k=[];var j=f.length;for(var d=0;d<j;d++){var h=Spry.Data.Region.processDataRefString(null,f[d],this.dataSetsForDataRefStrings);if(h.charAt(0)!="/"){h=a+"/"+h}k.push(h)}k.unshift(a);var c=this.convertXPathsToPathTree(k);a=c.path;f=c.subPaths;g=c.xpath?false:true}b=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(e,a,g,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,f);this.doc=b.xmlDoc;this.data=b.data;this.dataHash=b.dataHash;this.dataWasLoaded=(this.doc!=null)};Spry.Data.XMLDataSet.prototype.xhRequestProcessor=function(b){var c=b.responseXML;var a=false;if(b.status!=200){if(b.status==0){if(b.responseText&&(!c||!c.firstChild)){a=true}}}else{if(!c){a=true}}if(a){c=Spry.Utils.stringToXMLDoc(b.responseText)}if(!c||!c.firstChild||c.firstChild.nodeName=="parsererror"){return null}return c};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(d,a,j,h,m,b,f,l){this.regionNode=d;this.name=a;this.isDetailRegion=j;this.data=h;this.dataSets=m;this.hasBehaviorAttributes=l;this.tokens=null;this.currentState=null;this.states={ready:true};this.stateMap={};Spry.Utils.setOptions(this.states,b);Spry.Utils.setOptions(this.stateMap,f);for(var g=0;g<this.dataSets.length;g++){var c=this.dataSets[g];try{if(c){c.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,a){var c=Spry.Data.Region.notifiers[b];if(!c){c=new Spry.Utils.Notifier();Spry.Data.Region.notifiers[b]=c}c.addObserver(a)};Spry.Data.Region.removeObserver=function(b,a){var c=Spry.Data.Region.notifiers[b];if(c){c.removeObserver(a)}};Spry.Data.Region.notifyObservers=function(b,d,c){var e=Spry.Data.Region.notifiers[d.name];if(e){var a={};if(c&&typeof c=="object"){a=c}else{a.data=c}a.region=d;a.regionID=d.name;a.regionNode=d.regionNode;e.notifyObservers(b,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,c){var a={state:b,mappedState:this.getMappedState(b)};if(!c){Spry.Data.Region.notifyObservers("onPreStateChange",this,a)}this.currentState=a.mappedState?a.mappedState:b;if(this.states[this.currentState]){var e={state:this.currentState};if(!c){Spry.Data.Region.notifyObservers("onPreUpdate",this,e)}var d=this.transform();if(Spry.Data.Region.debug){Spry.Debug.trace("<hr />Generated region markup for '"+this.name+"':<br /><br />"+Spry.Utils.encodeEntities(d))}Spry.Utils.setInnerHTML(this.regionNode,d,!Spry.Data.Region.evalScripts);if(this.hasBehaviorAttributes){this.attachBehaviors()}if(!c){Spry.Data.Region.notifyObservers("onPostUpdate",this,e)}}if(!c){Spry.Data.Region.notifyObservers("onPostStateChange",this,a)}};Spry.Data.Region.prototype.getDataSets=function(){return this.dataSets};Spry.Data.Region.prototype.addDataSet=function(b){if(!b){return}if(!this.dataSets){this.dataSets=new Array}for(var a=0;a<this.dataSets.length;a++){if(this.dataSets[a]==b){return}}this.dataSets.push(b);b.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(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(a,d,e){var c=null;var b=Spry.Utils.getAttribute(d,"spry:selectgroup");if(b!=undefined){c=b;Spry.Utils.removeAttribute(d,"spry:selectgroup")}if(!c){c="default"}Spry.Utils.addEventListener(d,"click",function(f){Spry.Utils.SelectionManager.select(c,d,e)},false);if(Spry.Utils.getAttribute(d,"spry:selected")!=undefined){Spry.Utils.removeAttribute(d,"spry:selected");Spry.Utils.SelectionManager.select(c,d,e)}Spry.Utils.removeAttribute(d,"spry:select")}};Spry.Data.Region.behaviorAttrs["spry:hover"]={attach:function(a,b,c){Spry.Utils.addEventListener(b,"mouseover",function(d){Spry.Utils.addClassName(b,c)},false);Spry.Utils.addEventListener(b,"mouseout",function(d){Spry.Utils.removeClassName(b,c)},false);Spry.Utils.removeAttribute(b,"spry:hover")}};Spry.Data.Region.setUpRowNumberForEvenOddAttr=function(d,a,e,b){if(!e){Spry.Debug.showError("The "+a+" attribute requires a CSS class name as its value!");d.attributes.removeNamedItem(a);return}var f="";var c=e.split(/\s/);if(c.length>1){f=c[0];d.setAttribute(a,c[1])}d.setAttribute(b,"{"+(f?(f+"::"):"")+"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(c,f,a,e){if(f){var d=Spry.Data.getDataSetByName(f);if(d){rowIDAttr=c.attributes.getNamedItem(a);if(rowIDAttr){var b=rowIDAttr.value;if(b){Spry.Utils.addEventListener(c,"click",function(g){d[e](b)},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(a,d,f){if(!f){return}var e=a.getDataSets()[0];var c="toggle";var h=f.split(/\s/);if(h.length>1){var b=Spry.Data.getDataSetByName(h[0]);if(b){e=b;h.shift()}if(h.length>1){var g=h[h.length-1];if(g=="ascending"||g=="descending"||g=="toggle"){c=g;h.pop()}}}if(e&&h.length>0){Spry.Utils.addEventListener(d,"click",function(i){e.sort(h,c)},false)}Spry.Utils.removeAttribute(d,"spry:sort")}};Spry.Data.Region.prototype.attachBehaviors=function(){var a=this;Spry.Utils.getNodesByFunc(this.regionNode,function(f){if(!f||f.nodeType!=1){return false}try{var b=Spry.Data.Region.behaviorAttrs;for(var c in b){var h=Spry.Utils.getAttribute(f,c);if(h!=undefined){var d=b[c];if(d&&d.attach){d.attach(a,f,h)}}}}catch(g){}return false})};Spry.Data.Region.prototype.updateContent=function(){var a=true;var d=this.getDataSets();if(!d||d.length<1){Spry.Debug.reportError("updateContent(): Region '"+this.name+"' has no data set!\n");return}for(var b=0;b<d.length;b++){var c=d[b];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(g){var f="";var d=/<!--\s*<\/?spry:content\s*[^>]*>\s*-->/mg;var a=0;var c=0;while(g.length){var b=d.exec(g);if(!b||!b[0]){f+=g.substr(a,g.length-a);break}if(!c&&b.index!=a){f+=g.substr(a,b.index-a)}if(b[0].search(/<\//)!=-1){--c;if(c){Spry.Debug.reportError("Nested spry:content regions are not allowed!\n")}}else{++c;var e=b[0].replace(/.*\bdataref="/,"");f+=e.replace(/".*$/,"")}a=d.lastIndex}return f};Spry.Data.Region.prototype.tokenizeData=function(p){if(!p){return null}var h=new Spry.Data.Region.Token(Spry.Data.Region.Token.LIST_TOKEN,null,null,null);var f=new Array;var a=Spry.Data.Region.processContentPI(p);f.push(h);var t=/((<!--\s*){0,1}<\/{0,1}spry:[^>]+>(\s*-->){0,1})|((\{|%7[bB])[^\}\s%]+(\}|%7[dD]))/mg;var b=0;while(a.length){var k=t.exec(a);var g=null;if(!k||!k[0]){var l=a.substr(b,a.length-b);g=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,l,l);f[f.length-1].addChild(g);break}if(k.index!=b){var l=a.substr(b,k.index-b);g=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,l,l);f[f.length-1].addChild(g)}if(k[0].search(/^({|%7[bB])/)!=-1){var j=k[0];var e=k[0];j=j.replace(/^({|%7[bB])/,"");j=j.replace(/(}|%7[dD])$/,"");var s=null;var r=j.split(/::/);if(r.length>1){s=r[0];j=r[1]}e=e.replace(/^%7[bB]/,"{");e=e.replace(/%7[dD]$/,"}");g=new Spry.Data.Region.Token(Spry.Data.Region.Token.VALUE_TOKEN,s,j,new String(e));f[f.length-1].addChild(g)}else{if(k[0].charAt(0)=="<"){var o=k[0].replace(/^(<!--\s*){0,1}<\/?/,"");o=o.replace(/>(\s*-->){0,1}|\s.*$/,"");if(k[0].search(/<\//)!=-1){if(f[f.length-1].tokenType!=Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN){Spry.Debug.reportError("Invalid processing instruction close tag: "+o+" -- "+k[0]+"\n");return null}f.pop()}else{var i=Spry.Data.Region.PI.instructions[o];if(i){var n=null;var c="";if(k[0].search(/^.*\bselect=\"/)!=-1){c=k[0].replace(/^.*\bselect=\"/,"");c=c.replace(/".*$/,"");if(c){n=Spry.Data.getDataSetByName(c);if(!n){Spry.Debug.reportError("Failed to retrieve data set ("+c+") for "+o+"\n");c=""}}}var d=null;if(k[0].search(/^.*\btest=\"/)!=-1){d=k[0].replace(/^.*\btest=\"/,"");d=d.replace(/".*$/,"");d=Spry.Utils.decodeEntities(d)}var q=null;if(k[0].search(/^.*\bname=\"/)!=-1){q=k[0].replace(/^.*\bname=\"/,"");q=q.replace(/".*$/,"");q=Spry.Utils.decodeEntities(q)}var m=new Spry.Data.Region.Token.PIData(o,c,d,q);g=new Spry.Data.Region.Token(Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN,n,m,new String(k[0]));f[f.length-1].addChild(g);f.push(g)}else{Spry.Debug.reportError("Unsupported region processing instruction: "+k[0]+"\n");return null}}}else{Spry.Debug.reportError("Invalid region token: "+k[0]+"\n");return null}}b=t.lastIndex}return h};Spry.Data.Region.prototype.callScriptFunction=function(d,b){var a=undefined;d=d.replace(/^\s*\{?\s*function::\s*|\s*\}?\s*$/g,"");var c=Spry.Utils.getObjectByName(d);if(c){a=c(this.name,function(){return b.getValueFromDataSet.apply(b,arguments)})}return a};Spry.Data.Region.prototype.evaluateExpression=function(exprStr,processContext){var result=undefined;try{if(exprStr.search(/^\s*function::/)!=-1){result=this.callScriptFunction(exprStr,processContext)}else{result=Spry.Utils.eval(Spry.Data.Region.processDataRefString(processContext,exprStr,null,true))}}catch(e){Spry.Debug.trace("Caught exception in Spry.Data.Region.prototype.evaluateExpression() while evaluating: "+Spry.Utils.encodeEntities(exprStr)+"\n    Exception:"+e+"\n")}return result};Spry.Data.Region.prototype.processTokenChildren=function(f,e,b){var d=e.children;var a=d.length;for(var c=0;c<a;c++){this.processTokens(f,d[c],b)}};Spry.Data.Region.prototype.processTokens=function(l,d,p){var g=0;switch(d.tokenType){case Spry.Data.Region.Token.LIST_TOKEN:this.processTokenChildren(l,d,p);break;case Spry.Data.Region.Token.STRING_TOKEN:l.push(d.data);break;case Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN:if(d.data.name=="spry:repeat"){var h=null;if(d.dataSet){h=d.dataSet}else{h=this.dataSets[0]}if(h){var f=p.getDataSetContext(h);if(!f){Spry.Debug.reportError("processTokens() failed to get a data set context!\n");break}f.pushState();var n=f.getData();var m=n.length;for(g=0;g<m;g++){f.setRowIndex(g);var o=true;if(d.data.jsExpr){o=this.evaluateExpression(d.data.jsExpr,p)}if(o){this.processTokenChildren(l,d,p)}}f.popState()}}else{if(d.data.name=="spry:if"){var o=true;if(d.data.jsExpr){o=this.evaluateExpression(d.data.jsExpr,p)}if(o){this.processTokenChildren(l,d,p)}}else{if(d.data.name=="spry:choose"){var a=null;var k=null;var o=false;var e=0;for(e=0;e<d.children.length;e++){var b=d.children[e];if(b.tokenType==Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN){if(b.data.name=="spry:when"){if(b.data.jsExpr){o=this.evaluateExpression(b.data.jsExpr,p);if(o){k=b;break}}}else{if(b.data.name=="spry:default"){a=b}}}}if(!k&&a){k=a}if(k){this.processTokenChildren(l,k,p)}}else{if(d.data.name=="spry:state"){var o=true;if(!d.data.regionState||d.data.regionState==this.currentState){this.processTokenChildren(l,d,p)}}else{Spry.Debug.reportError("processTokens(): Unknown processing instruction: "+d.data.name+"\n");return""}}}}break;case Spry.Data.Region.Token.VALUE_TOKEN:var h=d.dataSet;var c=undefined;if(h&&h=="function"){c=this.callScriptFunction(d.data,p)}else{if(!h&&this.dataSets&&this.dataSets.length>0&&this.dataSets[0]){h=this.dataSets[0]}if(!h){Spry.Debug.reportError("processTokens(): Value reference has no data set specified: "+d.regionStr+"\n");return""}c=p.getValueFromDataSet(h,d.data)}if(typeof c!="undefined"){l.push(c+"")}break;default:Spry.Debug.reportError("processTokens(): Invalid token type: "+d.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(d,b,c){if(!d||!b){return""}var g="";try{var a=Spry.Utils.getAttribute(d,b);if(a){g=Spry.Utils.encodeEntities(a)}}catch(f){g=""}if(!g){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+'="'+g+'">'};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(e,c){if(!e||!c){return""}var b=Spry.Utils.getAttribute(e,c);if(b){b=b.replace(/\s/g,"")}else{Spry.Debug.reportError(c+" attribute requires a data set name!\n");return""}var d="";var a=Spry.Utils.getAttribute(e,"spry:test");if(a!=undefined){if(a){d=' test="'+Spry.Utils.encodeEntities(a)+'"'}Spry.Utils.removeAttribute(e,"spry:test")}return"<"+Spry.Data.Region.PI.instructions[c].tagName+' select="'+b+'"'+d+">"};Spry.Data.Region.PI.buildOpenTagForContent=function(c,b){if(!c||!b){return""}var f="";try{var a=Spry.Utils.getAttribute(c,b);if(a){f=Spry.Utils.encodeEntities(a)}}catch(d){f=""}if(!f){Spry.Debug.reportError(b+" attribute requires a data reference!\n");return""}return"<"+Spry.Data.Region.PI.instructions[b].tagName+' dataref="'+f+'">'};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){if(!a){return null}return a.match(/{[^}]+}/g)};Spry.Data.Region.processDataRefString=function(j,k,g,a){if(!k){return""}if(!j&&!g){return k}var h="";var m=new RegExp("\\{([^\\}:]+::)?[^\\}]+\\}","g");var i=0;while(i<k.length){var f=m.exec(k);if(!f||!f[0]){h+=k.substr(i,k.length-i);return h}if(f.index!=i){h+=k.substr(i,f.index-i)}var b="";if(f[0].search(/^\{[^}:]+::/)!=-1){b=f[0].replace(/^\{|::.*/g,"")}var l=f[0].replace(/^\{|.*::|\}/g,"");var n=null;var e="";if(j){e=j.getValueFromDataSet(b,l)}else{var d=b?g[b]:g[0];if(d){e=d.getValue(l)}}if(typeof e!="undefined"){e+="";h+=a?Spry.Utils.escapeQuotesAndLineBreaks(e):e}if(i==m.lastIndex){var c=f.index+f[0].length;if(c<k.length){h+=k.substr(c)}break}i=m.lastIndex}return h};Spry.Data.Region.strToDataSetsArray=function(j,f){var h=new Array;var b={};if(!j){return h}j=j.replace(/\s+/g," ");j=j.replace(/^\s|\s$/g,"");var a=j.split(/ /);for(var d=0;d<a.length;d++){if(a[d]&&!Spry.Data.Region.PI.instructions[a[d]]){try{var c=Spry.Data.getDataSetByName(a[d]);if(!b[a[d]]){if(f){h.push(a[d])}else{h.push(c)}b[a[d]]=true}}catch(g){}}}return h};Spry.Data.Region.DSContext=function(c,f){var d=c;var a=f;var g=[{rowIndex:-1}];var b=null;var e=[];var h=function(){return g[g.length-1].rowIndex};this.resetAll=function(){g=[{rowIndex:d.getCurrentRow()}]};this.getDataSet=function(){return d};this.getNumRows=function(i){var j=this.getCurrentState().data;return j?j.length:d.getRowCount(i)};this.getData=function(){var i=this.getCurrentState().data;return i?i:d.getData()};this.setData=function(i){this.getCurrentState().data=i};this.getValue=function(m,j){var i="";var l=this.getCurrentState();var k=l.nestedDS?l.nestedDS:this.getDataSet();if(k){i=k.getValue(m,j)}return i};this.getCurrentRow=function(){if(g.length<2||h()<0){return d.getCurrentRow()}var j=this.getData();var i=h();if(i<0||i>j.length){Spry.Debug.reportError("Invalid index used in Spry.Data.Region.DSContext.getCurrentRow()!\n");return null}return j[i]};this.getRowIndex=function(){var i=h();if(i>=0){return i}return d.getRowNumber(d.getCurrentRow())};this.setRowIndex=function(m){this.getCurrentState().rowIndex=m;var k=this.getData();var l=e.length;for(var j=0;j<l;j++){e[j].syncDataWithParentRow(this,m,k)}};this.syncDataWithParentRow=function(m,p,j){var o=j[p];if(o){nestedDS=d.getNestedDataSetForParentRow(o);if(nestedDS){var l=this.getCurrentState();l.nestedDS=nestedDS;l.data=nestedDS.getData();l.rowIndex=nestedDS.getCurrentRowNumber();l.rowIndex=l.rowIndex<0?0:l.rowIndex;var n=e.length;for(var k=0;k<n;k++){e[k].syncDataWithParentRow(this,l.rowIndex,l.data)}}}};this.pushState=function(){var m=this.getCurrentState();var l=new Object;l.rowIndex=m.rowIndex;l.data=m.data;l.nestedDS=m.nestedDS;g.push(l);var k=e.length;for(var j=0;j<k;j++){e[j].pushState()}};this.popState=function(){if(g.length<2){Spry.Debug.reportError("Stack underflow in Spry.Data.Region.DSContext.popState()!\n");return}var k=e.length;for(var j=0;j<k;j++){e[j].popState()}g.pop()};this.getCurrentState=function(){return g[g.length-1]};this.addChild=function(l){var k=e.length;for(var j=0;j<k;j++){if(e[j]==l){return}}e.push(l)}};Spry.Data.Region.ProcessingContext=function(f){this.region=f;this.dataSetContexts=[];if(f&&f.dataSets){var g=f.dataSets.slice(0);var e=g.length;for(var d=0;d<e;d++){var b=f.dataSets[d];while(b&&b.getParentDataSet){var k=false;b=b.getParentDataSet();if(b&&this.indexOf(g,b)==-1){g.push(b)}}}for(d=0;d<g.length;d++){this.dataSetContexts.push(new Spry.Data.Region.DSContext(g[d],this))}var l=this.dataSetContexts;var h=l.length;for(d=0;d<h;d++){var c=l[d];var b=c.getDataSet();if(b.getParentDataSet){var j=b.getParentDataSet();if(j){var a=this.getDataSetContext(j);if(a){a.addChild(c)}}}}}};Spry.Data.Region.ProcessingContext.prototype.indexOf=function(a,d){if(a){var b=a.length;for(var c=0;c<b;c++){if(a[c]==d){return c}}}return -1};Spry.Data.Region.ProcessingContext.prototype.getDataSetContext=function(b){if(!b){if(this.dataSetContexts.length>0){return this.dataSetContexts[0]}return null}if(typeof b=="string"){b=Spry.Data.getDataSetByName(b);if(!b){return null}}for(var a=0;a<this.dataSetContexts.length;a++){var c=this.dataSetContexts[a];if(c.getDataSet()==b){return c}}return null};Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet=function(){var e="";var d="";if(arguments.length>1){e=arguments[0];d=arguments[1]}else{var c=arguments[0].replace(/\s*{\s*|\s*}\s*/g,"");if(c.search("::")!=-1){e=c.replace(/::.*/,"");d=c.replace(/.*::/,"")}else{d=c}}var b="";var a=this.getDataSetContext(e);if(a){b=a.getValue(d,a.getCurrentRow())}else{Spry.Debug.reportError("getValueFromDataSet: Failed to get "+e+" context for the "+this.region.regionNode.id+" region.\n")}return b};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(e,b,d,c){var a=this;this.tokenType=e;this.dataSet=b;this.data=d;this.regionStr=c;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(b,c,d,e){var a=this;this.name=b;this.data=c;this.jsExpr=d;this.regionState=e};Spry.Utils.addLoadListener(function(){setTimeout(function(){if(Spry.Data.initRegionsOnLoad){Spry.Data.initRegions()}},0)});
