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