__cacheKey="20091009.19";var Drag={obj:null,init:function(D,H,F,B,E,A,I,G,J,C){D.onmousedown=Drag.start;D.hmode=I?false:true;D.vmode=G?false:true;D.root=H&&H!=null?H:D;if(D.hmode&&isNaN(parseInt(D.root.style.left))){D.root.style.left="0px"}if(D.vmode&&isNaN(parseInt(D.root.style.top))){D.root.style.top="0px"}if(!D.hmode&&isNaN(parseInt(D.root.style.right))){D.root.style.right="0px"}if(!D.vmode&&isNaN(parseInt(D.root.style.bottom))){D.root.style.bottom="0px"}D.minX=typeof F!="undefined"?F:null;D.minY=typeof E!="undefined"?E:null;D.maxX=typeof B!="undefined"?B:null;D.maxY=typeof A!="undefined"?A:null;D.xMapper=J?J:null;D.yMapper=C?C:null;D.root.onDragStart=new Function();D.root.onDragEnd=new Function();D.root.onDrag=new Function()},start:function(B){var C=Drag.obj=this;B=Drag.fixE(B);var D=parseInt(C.vmode?C.root.style.top:C.root.style.bottom);var A=parseInt(C.hmode?C.root.style.left:C.root.style.right);C.root.onDragStart(A,D);C.lastMouseX=B.clientX;C.lastMouseY=B.clientY;if(C.hmode){if(C.minX!=null){C.minMouseX=B.clientX-A+C.minX}if(C.maxX!=null){C.maxMouseX=C.minMouseX+C.maxX-C.minX}}else{if(C.minX!=null){C.maxMouseX=-C.minX+B.clientX+A}if(C.maxX!=null){C.minMouseX=-C.maxX+B.clientX+A}}if(C.vmode){if(C.minY!=null){C.minMouseY=B.clientY-D+C.minY}if(C.maxY!=null){C.maxMouseY=C.minMouseY+C.maxY-C.minY}}else{if(C.minY!=null){C.maxMouseY=-C.minY+B.clientY+D}if(C.maxY!=null){C.minMouseY=-C.maxY+B.clientY+D}}document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false},drag:function(E){E=Drag.fixE(E);var F=Drag.obj;var C=E.clientY;var D=E.clientX;var H=parseInt(F.vmode?F.root.style.top:F.root.style.bottom);var B=parseInt(F.hmode?F.root.style.left:F.root.style.right);var A,G;if(F.minX!=null){D=F.hmode?Math.max(D,F.minMouseX):Math.min(D,F.maxMouseX)}if(F.maxX!=null){D=F.hmode?Math.min(D,F.maxMouseX):Math.max(D,F.minMouseX)}if(F.minY!=null){C=F.vmode?Math.max(C,F.minMouseY):Math.min(C,F.maxMouseY)}if(F.maxY!=null){C=F.vmode?Math.min(C,F.maxMouseY):Math.max(C,F.minMouseY)}A=B+((D-F.lastMouseX)*(F.hmode?1:-1));G=H+((C-F.lastMouseY)*(F.vmode?1:-1));if(F.xMapper){A=F.xMapper(H)}else{if(F.yMapper){G=F.yMapper(B)}}Drag.obj.root.style[F.hmode?"left":"right"]=A+"px";Drag.obj.root.style[F.vmode?"top":"bottom"]=G+"px";Drag.obj.lastMouseX=D;Drag.obj.lastMouseY=C;Drag.obj.root.onDrag(A,G);return false},end:function(){document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));Drag.obj=null},fixE:function(A){if(typeof A=="undefined"){A=window.event}if(typeof A.layerX=="undefined"){A.layerX=A.offsetX}if(typeof A.layerY=="undefined"){A.layerY=A.offsetY}return A}};Array.prototype.inArray=function(B){var A;for(A=0;A<this.length;A++){if(B==this[A]){return true}}return false};Array.prototype.intersect=function(B){var C,A=Array();for(C=0;C<this.length;C++){if(B.inArray(this[C])){A.push(this[C])}}return A};Array.prototype.groupByField=function(E){var A=Array();var C,B,D;for(var C in this){B=this[C];D=B[E];if(D){if(!A[D]){A[D]=new Array()}A[D].push(B)}}return(A)};Array.prototype.listByField=function(E){var A=Array();var C,B,D;for(var C in this){B=this[C];if(typeof (B)!="function"){A.push(B[E])}}return(A)};Array.expand=function(C){var B=new Object();for(var D=0;D<C;D++){B[D]=D}return(B)};function ky_componentObj(A){this.cName="ky_componentObj";this._meGlobal=A}ky_componentObj.prototype.getFieldObj=function(A,B){var C;var D=A;if(B!=null){D=D+"_"+B}if(typeof (D)=="string"){C=ky_E(D)}if(!C){if(B==null){D=D+"_0";C=ky_E(D)}else{C=ky_E(A)}}if(!C){alertDebug("*** getFieldObj: ["+D+" @ "+B+"] = "+C)}return C};ky_componentObj.prototype.setWKey=function(A){this.wKey=A};ky_componentObj.prototype.onDataCompleted=function(){};ky_componentObj.prototype.onDataLoading=function(){};var dateFormat=function(){var A=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,B=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,D=/[^-+\dA-Z]/g,C=function(F,E){F=String(F);E=E||2;while(F.length<E){F="0"+F}return F};return function(J,V,R){var G=dateFormat;if(arguments.length==1&&(typeof J=="string"||J instanceof String)&&!/\d/.test(J)){V=J;J=undefined}J=J?new Date(J):new Date();if(isNaN(J)){throw new SyntaxError("invalid date")}V=String(G.masks[V]||V||G.masks["default"]);if(V.slice(0,4)=="UTC:"){V=V.slice(4);R=true}var T=R?"getUTC":"get",O=J[T+"Date"](),E=J[T+"Day"](),K=J[T+"Month"](),Q=J[T+"FullYear"](),S=J[T+"Hours"](),N=J[T+"Minutes"](),U=J[T+"Seconds"](),P=J[T+"Milliseconds"](),F=R?0:J.getTimezoneOffset(),I={d:O,dd:C(O),ddd:G.i18n.dayNames[E],dddd:G.i18n.dayNames[E+7],m:K+1,mm:C(K+1),mmm:G.i18n.monthNames[K],mmmm:G.i18n.monthNames[K+12],yy:String(Q).slice(2),yyyy:Q,h:S%12||12,hh:C(S%12||12),H:S,HH:C(S),M:N,MM:C(N),s:U,ss:C(U),l:C(P,3),L:C(P>99?Math.round(P/10):P),t:S<12?"a":"p",tt:S<12?"am":"pm",T:S<12?"A":"P",TT:S<12?"AM":"PM",Z:R?"UTC":(String(J).match(B)||[""]).pop().replace(D,""),o:(F>0?"-":"+")+C(Math.floor(Math.abs(F)/60)*100+Math.abs(F)%60,4),S:["th","st","nd","rd"][O%10>3?0:(O%100-O%10!=10)*O%10]};return V.replace(A,function(H){return H in I?I[H]:H.slice(1,H.length-1)})}}();dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(A,B){return dateFormat(this,A,B)};Date.createFrom14C=function(C){if(C.length==14){var B=new Date(C.substr(0,4),C.substr(4,2)-1,C.substr(6,2),C.substr(8,2),C.substr(10,2),C.substr(12,2));return(B)}else{if(C.length==8){var B=new Date(C.substr(0,4),C.substr(4,2)-1,C.substr(6,2));return(B)}else{if(C.length==6){var A=new Date();B=new Date(A.getFullYear(),A.getMonth(),A.getDate(),C.substr(0,2),C.substr(2,2),C.substr(4,2));return(B)}}}return null};function ky_errorCallout(){this.eleContainer=null;this.eleTop=null;this.eleBody=null;this.faceEle=null;this.relativeContainer=null}ky_errorCallout.prototype.init=function(){this.eleContainer=document.createElement("div");this.eleContainer.id="ky_errorCallout_eleContainer";if(this.relativeContainer){this.relativeContainer.appendChild(this.eleContainer)}else{if(this.faceEle){this.faceEle.appendChild(this.eleContainer)}else{document.body.appendChild(this.eleContainer)}}this.eleTop=document.createElement("div");this.eleTop.id="ky_errorCallout_eleTop";this.eleTop.innerHTML="<a href='javascript://' onClick='closeCallOut(this);'>x</>";this.eleContainer.appendChild(this.eleTop);this.eleBody=document.createElement("div");this.eleBody.id="ky_errorCallout_eleBody";this.eleContainer.appendChild(this.eleBody)};ky_errorCallout.prototype.findPos=function(A){var B=curtop=0;if(A.offsetParent){do{B+=A.offsetLeft;curtop+=A.offsetTop;A=A.offsetParent;if((A)&&(this.relativeContainer)&&(A.id==this.relativeContainer.id)){A=null}}while(A)}return[B,curtop]};ky_errorCallout.prototype.popCallout=function(E,H,B){var D=(B.offsetLeft)?B.offsetLeft:0;var C=(B.offsetTop)?B.offsetTop:0;var A=this.findPos(E);var G=A[1]+C;var F=A[0]+D;if(B.position){if(B.position=="right"){F=F+E.offsetWidth}if(B.position=="top"){}if(B.position=="bottom"){}}G=(G>0)?G:0;this.eleContainer.style.top=G+"px";F=(F>0)?F:0;this.eleContainer.style.left=F+"px";this.eleBody.innerHTML=H;this.eleContainer.style.visibility="visible";this.ele=E;this.callOut=B};ky_errorCallout.prototype.redraw=function(C){var F=this.ele;var B=this.callOut;if(this.eleContainer.style.visibility=="visible"){var E=(B.offsetLeft)?B.offsetLeft:0;var D=(B.offsetTop)?B.offsetTop:0;var A=this.findPos(F);var H=A[1]+D;var G=A[0]+E;if(B.position){if(B.position=="right"){G=G+F.offsetWidth}if(B.position=="top"){}if(B.position=="bottom"){}}H=(H>0)?H:0;H=H-C;this.eleContainer.style.top=H+"px";G=(G>0)?G:0;this.eleContainer.style.left=G+"px"}};ky_errorCallout.prototype.closeForm=function(){if(this.eleBody!=null){this.eleBody.innerHTML=""}if(this.eleContainer!=null){this.eleContainer.style.visibility="hidden"}};function closeCallOut(B){var A=B.parentNode.parentNode;A.style.visibility="hidden"}function ky_faceObj(A){this.cName="ky_faceObj";this._meGlobal=A}function ky_getFile(B,C,A){this.cName="ky_getFile";this._meGlobal=null;this.async=true;this.bustcachevar=1;this.bustcacheparameter="";this.page_request=false;this.loadDone=false;this.xtimer=null;this.DATA="";if(C=="postASget"){this.request="postASget"}else{this.request=(C=="post"?"post":"get")}if(getCookie("rony")&&(this.request=="post")){this.request="postASget";alertDebug("Init post as get ","red")}this.type=B;this.scope=A;this.retryCount=0}ky_getFile.prototype.initialize=function(url,postParam){this.url=url;this.loadDone=false;if(window.ActiveXObject){try{this.page_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{this.page_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}}else{if(window.XMLHttpRequest){this.page_request=new XMLHttpRequest()}else{return false}}var _me=null;eval("_me = "+this._meGlobal);this.page_request.onreadystatechange=function(){if(_me.page_request.readyState==4){try{if((_me.page_request.status==200)||(_me.page_request.status==302)){_me.setData()}else{if((_me.page_request.status==503)||(_me.page_request.status==504)){_me.reCall(url,postParam)}else{if(_me.page_request.status==2){_me.networkException()}else{_me.onResponseError()}}}}catch(e){_me.networkException()}}};if(this.bustcachevar){var t="00"+(new Date().getDate())+(new Date().getHours());this.bustcacheparameter=(url.indexOf("?")!=-1)?"&ky_t="+t:"?ky_t="+t}this._url=url;this._postParam=postParam;if(this.request=="get"){this.page_request.open("GET",url+this.bustcacheparameter,this.async);this.page_request.send(null)}else{if(this.request=="post"){this.page_request.open("POST",url+this.bustcacheparameter,this.async);this.page_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");this.page_request.setRequestHeader("Content-length",postParam.length);this.page_request.setRequestHeader("Connection","close");this.page_request.send(postParam)}else{postParam=postParam+"&ky_cache=true";alertDebug("POST AS GET:"+url+this.bustcacheparameter+"&"+postParam,"cyan");this.page_request.open("GET",url+this.bustcacheparameter+"&"+postParam,this.async);this.page_request.send(null)}}if(!this.async){if(_me.page_request.readyState==4){if((_me.page_request.status==200)||(_me.page_request.status==302)){_me.setData()}else{if((_me.page_request.status==503)||(_me.page_request.status==504)){_me.reCall(url,postParam)}else{_me.onResponseError()}}}}};ky_getFile.prototype.setData=function(){if(this.type=="json"){try{var responseText=this.page_request.responseText;if(responseText.indexOf("__LF__")>-1){responseText=responseText.replace((new RegExp("__LF__","gm")),"\\n")}if(responseText.indexOf("__LRF__")>-1){responseText=responseText.replace((new RegExp("__LRF__","gm")),"")}if(responseText.indexOf("__LR__")>-1){responseText=responseText.replace((new RegExp("__LR__","gm")),"")}this.DATA=eval("("+responseText+")")}catch(e){alertDebug("EXCEPTION: ["+this.request+"]["+this.page_request.status+"]["+this.page_request.readyState+"]:"+e.message,"red");alertDebug("RESPONSE:"+responseText,"red");alertDebug("URL:"+this._url,"red");alertDebug("POST:"+this._postParam,"red");this.DATA=new Object()}}else{if(this.type=="scope"){if(window.execScript){window.execScript(this.scope+" = "+this.page_request.responseText)}else{window.eval("("+this.scope+" = "+this.page_request.responseText+")")}}else{this.DATA=this.page_request.responseText}}this.loadDone=true};ky_getFile.prototype.onResponseError=function(){this.DATA=null;this.loadDone=true};ky_getFile.prototype.reCall=function(A,B){if(this.retryCount>10){alert("Retry Count Exceeded ["+this.page_request.status+"]. It could be from your connection instability.");this.retryCount=0;this.loadDone=true;this.DATA="";return }this.retryCount++;this.DATA="";this.initialize(A,B)};ky_getFile.prototype.networkException=function(){this.retryCount=0;this.loadDone=true;this.DATA="";return };if(!this.JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}if(typeof JSON.encode!=="function"){JSON.encode=JSON.stringify}if(typeof JSON.decode!=="function"){JSON.decode=JSON.parse}if(typeof JSON.eval!=="function"){JSON.eval=function(str){var obj;eval("obj = ("+str+");");return obj}}})();function detachEventListener(E,B,D,A,C){if(typeof E.removeEventListener!="undifined"){if(C){E.removeEventListener(C,D,A)}else{E.removeEventListener(B,D,A)}}else{if(typeof E.detachEvent!="undefined"){E.detachEvent("on",B,D)}else{E["on"+B]=null}}}function attachEventListener(E,B,D,A,C){if(typeof document.attachEvent!="undefined"){E.attachEvent(B,D)}else{if(C){E.addEventListener(C,D,A)}else{E.addEventListener(B,D,A)}}}function AddOnload(A){if(window.addEventListener){window.addEventListener("load",A,false)}else{if(document.addEventListener){document.addEventListener("load",A,false)}else{if(window.attachEvent){window.attachEvent("onload",A)}}}}function ky_getURLParam(E){var D="";var C=window.location.href;if(C.indexOf("#")>-1){C=C.substr(0,C.indexOf("#"))}if(C.indexOf("?")>-1){var B=C.substr(C.indexOf("?"));var F=B.split("&");for(var A=0;A<F.length;A++){if(F[A].indexOf(E+"=")>-1){var G=F[A].split("=");D=G[1];break}}}if(typeof (ky_seo)!="undefined"){if(typeof (ky_seo.params[E])!="undefined"){D=ky_seo.params[E]}}return unescape(D)}function ky_getURLAnchor(){var B=window.location.href;var A="";if(B.indexOf("#")>-1){A=B.substr(B.indexOf("#")+1)}return unescape(A)}function ky_getURLAnchorParam(E){var D=window.location.href;var B="";var C="";if(D.indexOf("#")>-1){B=D.substr(D.indexOf("#")+1);var F=B.split("&");for(var A=0;A<F.length;A++){if(F[A].indexOf(E+"=")>-1){var G=F[A].split("=");C=G[1];break}}}return unescape(C)}function getCookie(C){var D=document.cookie.indexOf(C+"=");var A=D+C.length+1;if((!D)&&(C!=document.cookie.substring(0,C.length))){return null}if(D==-1){return null}var B=document.cookie.indexOf(";",A);if(B==-1){B=document.cookie.length}return unescape(document.cookie.substring(A,B))}function setCookie(B,C,A){var D=new Date();D.setDate(D.getDate()+A);document.cookie=B+"="+escape(C)+((A==null)?"":";expires="+D.toGMTString())}function ky_browser(){var A={os:null,type:null,version:null,render:null};if(document.all){A.type="IE";A.version=7;A.render="IE";if(navigator.userAgent.indexOf("MSIE 8.0")>-1){A.version=8}else{if(navigator.userAgent.indexOf("MSIE 7.0")>-1){A.version=7}else{if(navigator.userAgent.indexOf("MSIE 6.0")>-1){A.version=6}}}}else{if(navigator.userAgent.indexOf("BlackBerry")>-1){A.type="BB";A.render="Gecko"}else{A.type="FF";A.render="Gecko"}}return A}function ky_E(A){return(document.getElementById(A))}function ky_ET(A,B){if(B==null){B=document}return(B.getElementsByTagName(A))}function ky_flattenObjectProperties(B,D,F){if(F==null){F=""}if(D==null){D=new Object()}var C=typeof (B);switch(C){case"object":var E,A;for(E in B){if(typeof (B[E])!="function"){if(F==""){A=E}else{A=F+"["+E+"]"}ky_flattenObjectProperties(B[E],D,A)}}break;default:if(F){D[F]=B}else{D=B}break}if(F==""){return D}}var dumpDebug_str="";function ky_dumpDebug(B,H,A){var G="";if(!H){dumpDebug_str="";H=0}if(A==null){A=999}if(A<H){return G}var F="";for(var C=0;C<H+1;C++){F+="    "}if(typeof (B)=="object"){for(var D in B){var E=B[D];if(typeof (E)=="object"){G+=F+"'"+D+"' ...\n";G+=ky_dumpDebug(E,H+1,A)}else{if(typeof (E)!="function"){G+=F+"'"+D+"' => \""+E+'"\n'}}}}else{G="===>"+B+"<===("+typeof (B)+")"}dumpDebug_str+=(G);return G}function ky_eventKeyPressed(C,A){var B;if(window.event){B=window.event.keyCode}else{B=C.which}if(B==A){return true}else{return false}}function ky_DebugConsole(){this.id="ky_wappConsole";this.state="min"}ky_DebugConsole.prototype.maximize=function(){ky_E(this.id).style.width=document.body.scrollWidth+"px";ky_E(this.id).style.height=document.body.scrollHeight+"px";ky_E(this.id).style.top="0px";ky_E(this.id).style.left="0px";ky_E(this.id).childNodes[1].style.height="985px"};ky_DebugConsole.prototype.minimize=function(){ky_E(this.id).style.width="600px";ky_E(this.id).style.height="400px";ky_E(this.id).style.top="140px";ky_E(this.id).style.left="1024px";ky_E(this.id).childNodes[1].style.height="385px"};ky_DebugConsole.prototype.toggleState=function(){if(this.state=="min"){this.state="max";this.maximize()}else{this.state="min";this.minimize()}};var ky_DC=new ky_DebugConsole();function alertDebug(D,A){var C;var A;if(!A){A="#00ff00"}if(window.location.href.indexOf("wappDebug=1")>-1){C=1;setCookie("wappDebug",C)}else{if(window.location.href.indexOf("wappDebug=0")>-1){C=-1;setCookie("wappDebug",C)}}if(C==null){C=getCookie("wappDebug")}if(ky_browser().type=="BB"){alert(D)}if(C==1){var B=ky_E("ky_wappConsole");if(B){D='<span style="color:'+A+'">'+D+"</span>";B.childNodes[1].innerHTML+="["+(new Date()).format("MM:ss.LL")+"] "+D+"<br>"}else{B=document.createElement("div");B.id="ky_wappConsole";B.style.position="absolute";B.style.width="600px";B.style.height="400px";B.style.left="1024px";B.style.top="140px";B.style.border="2px solid black";B.style.backgroundColor="black";B.style.color="#00ff00";B.style.zIndex="9999";B.style.fontSize="11px";if(document.all){document.body.firstChild.appendChild(B)}else{document.body.appendChild(B)}var F=document.createElement("div");F.style.backgroundColor="#0000ff";F.style.color="white";F.style.cursor="move";var E=document.createElement("div");B.appendChild(F);B.appendChild(E);Drag.init(F,B);strAction='<a style="color:white;font-weight:bold;" href="javascript://" onclick="ky_E(\'ky_wappConsole\').childNodes[1].innerHTML=\'\';">clear</a>';strAction+=' | <a style="color:white;font-weight:bold;" href="javascript://" onclick="ky_E(\'ky_wappConsole\').style.display=\'none\';">close</a>';strAction+=" | <a style=\"color:white;font-weight:bold;\" href=\"javascript://\" onclick=\"setCookie('wappDebug',-1);ky_E('ky_wappConsole').style.display='none';\">kill</a>";strAction+=' | <a style="color:white;font-weight:bold;" href="javascript://" onclick="ky_DC.minimize();">[-]</a>';strAction+=' | <a style="color:white;font-weight:bold;" href="javascript://" onclick="ky_DC.maximize();">[+]</a>';F.innerHTML="Debug Console - ["+__v+"#"+__cacheKey+']<span style="margin-left:110px;">'+strAction+"</span><br>";F.ondblclick=function(){ky_DC.toggleState()};E.style.overflow="scroll";E.style.width="auto";E.style.height="385px";E.style.backgroundColor="black"}}}function ky_mergeObjects(C,B){var A;if(B==null){return(C)}if(C==null){C=new Object()}for(A in B){C[A]=B[A]}return(C)}var timerDebug;if(window.location.href.indexOf("timerDebug=1")>-1){timerDebug=1;setCookie("timerDebug",timerDebug)}else{if(window.location.href.indexOf("timerDebug=0")>-1){timerDebug=-1;setCookie("timerDebug",timerDebug)}}if(timerDebug==null){timerDebug=getCookie("timerDebug")}var arrSetTimer=new Array();function ky_setInterval(A,B){if(timerDebug==1){var D=arrSetTimer.length;A="ky_monitorInterval("+D+");"+A}var C=setInterval(A,B);if(timerDebug==1){arrSetTimer[D]={call:A,time:B,timer:C,count:0}}return C}function ky_clearInterval(A){clearInterval(A);if(timerDebug==1){}}function ky_monitorInterval(A){arrSetTimer[A].count++;alertDebug("ky_monitorInterval ["+arrSetTimer[A].call+"]=["+arrSetTimer[A].count+"]","red");if((arrSetTimer[A].count%20==0)&&(arrSetTimer[A].count>0)){alert("ky_monitorInterval:"+arrSetTimer[A].call)}}function ky_compileMethod(obj,strFunc){if(strFunc){var strEval='obj["onItemClick"]='+strFunc+";";eval(strEval)}}var __cacheKey=(__cacheKey)?__cacheKey:"00000000";function ky_lod(){this.cName="ky_lod";this.arrStatus=new Array();this.arrCallBacks=new Array();this.cacheKey=window.__cacheKey;var A="00"+(new Date().getDate())+(new Date().getHours());this.cacheKey=this.cacheKey+"."+A}ky_lod.prototype.addJSScriptBySrc=function(E,B,D){var C=(document.all)?"ie":"gecko";if(typeof (E)=="object"){if(typeof (E.common)!="undefined"){var A=this;this.loadJSScript(E.common,B,function(G,F){A.loadJSScript(E[C],F,D)});return }E=E[C]}this.loadJSScript(E,B,D)};ky_lod.prototype.loadJSScript=function(F,D,E){var C=F;if(this.arrStatus[D]==2){E();return }if(typeof (this.arrCallBacks[D])=="undefined"){this.arrCallBacks[D]=new Array()}this.arrCallBacks[D].push(E);if(this.arrStatus[D]==1){return }this.arrStatus[D]=1;F=F+"?v="+this.cacheKey;var B=document.getElementsByTagName("head").item(0);var A=document.createElement("script");A.src=F;A.type="text/javascript";A.id=D;A.onerror=function(){ky_wappMsg["LOD-"+D]="Error ["+D+"]loading "+this.src};var G=this;if(!document.all){A.onload=function(){var H;for(H=0;H<G.arrCallBacks[D].length;H++){G.arrCallBacks[D][H]()}G.arrStatus[D]=2}}else{A.onreadystatechange=function(){if((A.readyState=="loaded"||A.readyState=="complete")){var J=ky_browser();if(J.version>=6){var I=C.substring(C.lastIndexOf("/")+1,C.lastIndexOf("."));if((typeof (ky_wappManager.arrInst[0][I])=="undefined")&&(I.indexOf("hook")==0||I.indexOf("render")==0)){G.arrStatus[D]=0;G.loadJSScript(C,D,E);return }}var H;for(H=0;H<G.arrCallBacks[D].length;H++){G.arrCallBacks[D][H]()}G.arrStatus[D]=2}}}B.appendChild(A)};ky_lod.loadCss=function(D,C){var B=D.getElementsByTagName("head").item(0);var A=D.createElement("link");A.href=C;A.rel="stylesheet";A.type="text/css";B.appendChild(A)};function ky_maskObj(){this.cName="ky_maskObj";this._meGlobal=null;this.ky_maskMsg=new ky_getFile("json")}ky_maskObj.prototype.initialize=function(A){this.url=_ky_wapp_folder+"ky_maskMsg.js";this._meGlobal=A;this.ky_maskMsg._meGlobal=A+".ky_maskMsg";this.ky_maskMsg.initialize(this.url)};ky_maskObj.prototype.req=function(C){var A,B="default";var D=new Array();if(C.length){if((C[0].nodeName=="INPUT")&&(C[0].type=="radio")){D=C;B="radio"}}else{if((C.nodeName=="INPUT")&&(C.type=="radio")){D.push(C);B="radio"}}if((C.nodeName=="INPUT")&&(C.type=="checkbox")){if(!C.checked){return false}else{return true}}else{if(B=="radio"){for(A=0;A<D.length;A++){if(D[A].checked){return true}}return false}else{if(C.value==""){return false}else{return true}}}};ky_maskObj.prototype.ky_minLen=function(B){if(B.value==""){return true}var C=(arguments[1])?arguments[1]:null;if(C){var A=C.len}else{A=0}if(B.value.length<A){return false}return true};ky_maskObj.prototype.ky_maxLen=function(B){if(B.value==""){return true}var C=(arguments[1])?arguments[1]:null;if(C){var A=C.len}else{A=0}if(B.value.length>A){return false}return true};ky_maskObj.prototype.ky_alphanum=function(B){if(B.value==""){return true}var A;A=B.value.search("[^A-Za-z0-9]");if(A>-1){return false}return true};ky_maskObj.prototype.ky_alphanumspace=function(B){if(B.value==""){return true}var A;A=B.value.search("[^A-Za-z0-9s ]");if(A>-1){return false}return true};ky_maskObj.prototype.ky_alphanumfree=function(B){if(B.value==""){return true}var A;A=B.value.search("[^A-Za-z0-9s .:_,-]");if(A>-1){return false}return true};ky_maskObj.prototype.ky_password=function(B){if(B.value==""){return true}var A;A=B.value.search("[^A-Za-z0-9-_~]");if(A>-1){return false}var C=(arguments[1])?arguments[1]:null;C.len=6;return this.ky_minLen(B,C)};ky_maskObj.prototype.ky_username=function(B){if(B.value==""){return true}var A;A=B.value.search("[^A-Za-z0-9-_.]");if(A>-1){return false}var C=(arguments[1])?arguments[1]:null;C.len=4;return this.ky_minLen(B,C)};ky_maskObj.prototype.ky_int=function(C){if(C.value==""){return true}var D=C.value;var A=D;var E=D.length;if((!this.isRequired)&&(this.isEmpty)){return true}if(E==0){return false}for(var B=0;B<E;B++){achar=A.substring(B,B+1);if(achar<"0"||achar>"9"){if(!(((achar=="+")||(achar=="-"))&&(B==0))){return false}}}return true};ky_maskObj.prototype.ky_email=function(F){if(F.value==""){return true}var I=F.value.toLowerCase();var R=1;var U=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;var Q=/^(.+)@(.+)$/;var O='\\(\\)><@,;:\\\\\\"\\.\\[\\]';var J="[^\\s"+O+"]";var C='("[^"]*")';var P=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var A=J+"+";var N="("+A+"|"+C+")";var K=new RegExp("^"+N+"(\\."+N+")*$");var E=new RegExp("^"+A+"(\\."+A+")*$");var B=I.match(Q);if(B==null){return false}var S=B[1];var T=B[2];for(L=0;L<S.length;L++){if(S.charCodeAt(L)>127){return false}}for(L=0;L<T.length;L++){if(T.charCodeAt(L)>127){return false}}if(S.match(K)==null){return false}var H=T.match(P);if(H!=null){for(var L=1;L<=4;L++){if(H[L]>255){return false}}return true}var G=new RegExp("^"+A+"$");var D=T.split(".");var M=D.length;for(L=0;L<M;L++){if(D[L].search(G)==-1){return false}}if(R&&D[D.length-1].length!=2&&D[D.length-1].search(U)==-1){return false}if(M<2){return false}return true};ky_maskObj.prototype.ky_telephone=function(B){if(B.value==""){return true}var D=B.value;var C=/^[0-9]+\([0-9]+\)[0-9]+$/;var A=C.test(D);if((!this.isRequired)&&(this.isEmpty)){return true}if(A){return true}return false};ky_maskObj.prototype.ky_zip=function(C){if(C.value==""){return true}var B=C.value;if((!this.isRequired)&&(this.isEmpty)){return true}if(B.length!=5&&B.length!=10){return false}var A=(B.length==5)?B:B.substring(0,5)+B.substring(6,10);if(isNaN(A)){return false}return true};ky_maskObj.prototype.ky_zipPostal=function(C){if(C.value==""){return true}var A=C.value;if((!this.isRequired)&&(this.isEmpty)){return true}if(A.length==6){var B=new RegExp("^[a-zA-Z][0-9][a-zA-Z][0-9][a-zA-Z][0-9]$");if(B.test(A)){return true}return false}if(A.length==7){var B=new RegExp("^[a-zA-Z][0-9][a-zA-Z] [0-9][a-zA-Z][0-9]$");if(B.test(A)){return true}return false}if(A.length==5){var B=new RegExp("^[0-9]{5}$");if(B.test(A)){return true}return false}else{return false}};ky_maskObj.prototype.ky_url=function(D){if(D.value==""){return true}var C=D.value;var B=new RegExp("^^(((http|https)://){0,1})((([a-zA-Z0-9]+){0,1}[.](.[a-zA-Z0-9]+)+[.][A-Za-z]{2,3}(:[A-Za-z0-9]{0,4})*)|([12]?[0-9]?[0-9](.[12]?[0-9]?[0-9]){3}(:[A-Za-z0-9]{0,4})*))(/[/w.-~%]*)*$");var A=new RegExp("^([a-zA-Z0-9](|-|_)*){2,}[.][a-zA-Z0-9]{2,3}$");if(!B.test(C)&&!A.test(C)){return false}return true};ky_maskObj.prototype.ky_date_mm_dd_yyyy=function(B){if(B.value==""){return true}var A=B.value;var C=new RegExp("^[0-9]{2,2}[-]{1,1}[0-9]{2,2}[-]{1}[0-9]{4,4}$");if(!C.test(A)){return false}else{return true}};ky_maskObj.prototype.ky_CEP=function(C){if(C.value==""){return true}var B=C.value;var A=new RegExp("^[0-9]{5,5}[-]{1,1}[0-9]{3,3}$");if(!A.test(B)){return false}else{return true}};ky_maskObj.prototype.ky_CPF=function(J){if(J.value==""){return true}var E=J.value;var I=new RegExp("[^0-9]","gmi");var C=new RegExp("[0-9]{11,11}","gmi");E=E.replace(I,"");alertDebug(" #### ky_CPF:"+E);var G=false;if(E.match(C)){alertDebug("matched");var A=d2=0;var B,D;for(B=0;B<E.length-2;B++){D=parseInt(E.charAt(B));A=A+(10-B)*D;d2=d2+(11-B)*D;alertDebug("digitoCPF="+D+" d1="+A+" d2="+d2)}A=11-(A%11);if(A>=10){A=0}d2+=2*A;d2=11-(d2%11);if(d2>=10){d2=0}var H=A+""+d2;alertDebug("nDigResult="+H);var F=E.substr(E.length-2,2);alertDebug("nDigVerific="+F);G=(H==F)}alertDebug(" #### ky_CPF return :"+G);return G};ky_maskObj.prototype.ky_numberFormat=function(D){var F=(arguments[1])?arguments[1]:null;var A=[];if((F!=null)&&(F.formats)&&(typeof (F.formats.length)=="number")){A=F.formats}if(D.value==""){return true}var E=D.value;if((!this.isRequired)&&(this.isEmpty)){return true}var B=function(J){var I="";var H,K,G;for(H=0;H<J.length;H++){K=J.charAt(H);G=parseInt(K);if(K=="#"){I+="[0-9]+"}else{if(G){I+="[0-9]{"+K+","+K+"}"}else{I+="\\"+K}}}I="^"+I+"$";return I};var C;for(C=0;C<A.length;C++){phonePattern=new RegExp(B(A[C]));if(phonePattern.test(E)){return true}}return false};String.prototype.numberFormat=function(C,K,E){var F=this;var B=F,A=C;var H=function(Q,P){var O=Math.pow(10,P);return(Math.round(Q*O)/O).toString()};B=!isFinite(+B)?0:+B;A=!isFinite(+A)?0:Math.abs(A);var N=(typeof E==="undefined")?",":E;var D=(typeof K==="undefined")?".":K;var M=(A>0)?H(B,A):H(Math.round(B),A);var L=H(Math.abs(B),A);var J,G;if(L>=1000){J=L.split(/\D/);G=J[0].length%3||3;J[0]=M.slice(0,G+(B<0))+J[0].slice(G).replace(/(\d{3})/g,N+"$1");M=J.join(D)}else{M=M.replace(".",D)}var I=M.indexOf(D);if(A>=1&&I!==-1&&(M.length-I-1)<A){M+=new Array(A-(M.length-I-1)).join(0)+"0"}else{if(A>=1&&I===-1){M+=D+new Array(A).join(0)+"0"}}return M};String.prototype.htmlEntities=function(){var B=new Array("&","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Ø","Ù","Ú","Û","Ü","Ý","Þ","€",'"',"ß","<",">","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","’","▪","˜");var C=new Array("amp","agrave","aacute","acirc","atilde","auml","aring","aelig","ccedil","egrave","eacute","ecirc","euml","igrave","iacute","icirc","iuml","eth","ntilde","ograve","oacute","ocirc","otilde","ouml","oslash","ugrave","uacute","ucirc","uuml","yacute","thorn","yuml","Agrave","Aacute","Acirc","Atilde","Auml","Aring","AElig","Ccedil","Egrave","Eacute","Ecirc","Euml","Igrave","Iacute","Icirc","Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde","Ouml","Oslash","Ugrave","Uacute","Ucirc","Uuml","Yacute","THORN","euro","quot","szlig","lt","gt","cent","pound","curren","yen","brvbar","sect","uml","copy","ordf","laquo","not","shy","reg","macr","deg","plusmn","sup2","sup3","acute","micro","para","middot","cedil","sup1","ordm","raquo","frac14","frac12","frac34","rsquo","#9642","tilde");newString=this;for(var A=0;A<B.length;A++){myRegExp=new RegExp();myRegExp.compile(B[A],"g");newString=newString.replace(myRegExp,"&"+C[A]+";")}return newString};String.prototype.htmlEntitiesDecode=function(){var C=new Array("&","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ø","ù","ú","û","ü","ý","þ","ÿ","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Ø","Ù","Ú","Û","Ü","Ý","Þ","€",'"',"ß","<",">","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","’","▪","˜");var D=new Array("amp","agrave","aacute","acirc","atilde","auml","aring","aelig","ccedil","egrave","eacute","ecirc","euml","igrave","iacute","icirc","iuml","eth","ntilde","ograve","oacute","ocirc","otilde","ouml","oslash","ugrave","uacute","ucirc","uuml","yacute","thorn","yuml","Agrave","Aacute","Acirc","Atilde","Auml","Aring","AElig","Ccedil","Egrave","Eacute","Ecirc","Euml","Igrave","Iacute","Icirc","Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde","Ouml","Oslash","Ugrave","Uacute","Ucirc","Uuml","Yacute","THORN","euro","quot","szlig","lt","gt","cent","pound","curren","yen","brvbar","sect","uml","copy","ordf","laquo","not","shy","reg","macr","deg","plusmn","sup2","sup3","acute","micro","para","middot","cedil","sup1","ordm","raquo","frac14","frac12","frac34","rsquo","#9642","tilde");newString=this;var A=(navigator.userAgent.toLowerCase().indexOf("opera")>-1);if(A){for(var B=0;B<C.length;B++){myRegExp=new RegExp();myRegExp.compile("&"+D[B]+";","g");while(newString.toLowerCase().indexOf("&"+D[B]+";")>-1){newString=newString.replace(myRegExp,C[B])}}}else{for(var B=0;B<C.length;B++){myRegExp=new RegExp();myRegExp.compile("&"+D[B]+";","g");newString=newString.replace(myRegExp,C[B])}}return newString};String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"")};String.prototype.ltrim=function(){return this.replace(/^\s*/g,"")};String.prototype.rtrim=function(){return this.replace(/\s*$/g,"")};String.prototype.truncate=function(A,B){if(B==null){B="..."}if(!A||(this.length<A)){return this}else{return(this.substr(0,A-B.length))+B}};String.prototype.wordWrap=function(D,F){if(F==null){F="..."}if(!D||(this.length<D)){return this}else{alertDebug("wrap orig:["+D+"]:["+this+"]");var B,C=this.substr(0,D-F.length+1);alertDebug("wrap pre:["+C+"]");B=C.length-1;var E=[".",",",";"," "];var A=false;while(!A){if(!E.inArray(C.charAt(B))){B--}else{A=true}if(B<0){A=true}}var A=false;while(!A){if(E.inArray(C.charAt(B))){B--}else{A=true}if(B<0){A=true}}C=C.substr(0,B+1)+F;alertDebug("wrap post:["+C+"]");return(C)}};String.prototype.utf8html=function(){var A=this;A=A.replace((new RegExp("\u007f","gi")),"&#127;");A=A.replace((new RegExp("\u0080","gi")),"&#128;");A=A.replace((new RegExp("\u0082","gi")),"&#130;");A=A.replace((new RegExp("\u0083","gi")),"&#131;");A=A.replace((new RegExp("\u0084","gi")),"&#132;");A=A.replace((new RegExp("\u0085","gi")),"&#133;");A=A.replace((new RegExp("\u0086","gi")),"&#134;");A=A.replace((new RegExp("\u0087","gi")),"&#135;");A=A.replace((new RegExp("\u0088","gi")),"&#136;");A=A.replace((new RegExp("\u0089","gi")),"&#137;");A=A.replace((new RegExp("\u008a","gi")),"&#138;");A=A.replace((new RegExp("\u008b","gi")),"&#139;");A=A.replace((new RegExp("\u008c","gi")),"&#140;");A=A.replace((new RegExp("\u008e","gi")),"&#142;");A=A.replace((new RegExp("\u0091","gi")),"&#145;");A=A.replace((new RegExp("\u0092","gi")),"&#146;");A=A.replace((new RegExp("\u0093","gi")),"&#147;");A=A.replace((new RegExp("\u0094","gi")),"&#148;");A=A.replace((new RegExp("\u0095","gi")),"&#149;");A=A.replace((new RegExp("\u0096","gi")),"&#150;");A=A.replace((new RegExp("\u0097","gi")),"&#151;");A=A.replace((new RegExp("\u0098","gi")),"&#152;");A=A.replace((new RegExp("\u0099","gi")),"&#153;");A=A.replace((new RegExp("\u009a","gi")),"&#154;");A=A.replace((new RegExp("\u009b","gi")),"&#155;");A=A.replace((new RegExp("\u009c","gi")),"&#156;");A=A.replace((new RegExp("\u009e","gi")),"&#158;");A=A.replace((new RegExp("\u009f","gi")),"&#159;");A=A.replace((new RegExp("\u00a0","gi")),"&#160;");A=A.replace((new RegExp("\u00a2","gi")),"&#162;");return(A)};String.prototype.nl2tag=function(D){var E=this.replace(/\r/g,"\n");var C=E.split("\n");var B="";for(var A=0;A<C.length;A++){if(C[A]!=""){B+="<"+D+">"+C[A]+"</"+D+">"}}return B};String.prototype.addSlashes=function(){var A=this;A=A.replace(/\'/g,"\\'");A=A.replace(/\"/g,'\\"');return A};String.prototype.attAddSlashes=function(){var A=this;A=A.replace(/\'/g,"\\'");A=A.replace(/\"/g,"\\&quot;");return A};String.prototype.attFixQuote=function(){var A=this;A=A.replace(/\"/g,"&quot;");return A};String.prototype.stripSlashes=function(){var A=this;A=A.replace(/\\'/g,"'");A=A.replace(/\\"/g,'"');return A};function cookieFunction(H,C){var J=H;var F=C;var K=new Date();K.setFullYear(K.getFullYear()+1);xDeleteCookie(J);document.cookie=J+"=test; expires="+K.toGMTString()+"; domain="+F;var G=document.cookie||"";var I=G.split(/\s*;\s*/);var B=0;for(var E in I){var A=I[E];var D=A.toString().split(/\s*=\s*/);if(D[0]==J){B=1;break}}xDeleteCookie(J);return(B)}function xDeleteCookie(A){var B=new Date(1970,1,1);document.cookie=A+"=0; expires="+B.toGMTString()}function ky_SWAjax_checkAjaxLoaded(){var A;for(A=0;A<arrky_SWAjax.length;A++){if(!arrky_SWAjax[A].bLoaded){var B=new Date();arrky_SWAjax[A].checkReload()}}}if(arrky_SWAjax==null){var arrky_SWAjax=new Array()}function ky_SWAjax(){this.debug=false;this.isSafari=(navigator.userAgent.toLowerCase().indexOf("safari")>-1);this.isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")>-1);this.type="text";this.onConnect=null;this.onLoaded=null;this.id=arrky_SWAjax.length;this.bLoaded=false;this.reloadCount=0;this.bTempSession=false;this.formMethod="POST";this.setType=function(A){this.type=A};this.setMethod=function(A){this.formMethod=A};this.forkSession=function(){this.bTempSession=true};this.checkReload=function(){if(this.reloadCount>10){var A=this.scriptObj.src;this.scriptObj.src=A;this.reloadCount=0}else{this.reloadCount++}};this.createIframe=function(G,C){var A;var D=false;A=document.getElementById(G+"_"+this.id);if(!this.debug){A=null}if(!A){A=document.createElement("IFRAME");D=true}A.style.display="";A.style.position="absolute";A.style.border="2px solid red";var F=new Date();A.style.zIndex="100";A.style.top="200px";var I=80;var B=true;A.style.left=(this.id*I+4)+"px";if(B){A.style.top="-1000px";A.style.left="-1000px";A.style.display=""}if(this.debug||window.location.toString().indexOf("kyube_debug=1")>-1){A.style.top="150px";A.style.left="150px";A.style.display="";A.style.position="relative";A.style.zIndex="100";I=500}A.style.height=I+"px";A.style.width=I+"px";A.frameborder="1";A.id=G+"_"+this.id;try{if(D){try{if(document.all){if(document.forms.length>0){document.forms[0].appendChild(A)}else{document.body.appendChild(A)}}else{document.body.appendChild(A)}}catch(E){}}var H=(A.contentWindow)?A.contentWindow.document:window.frames[G+"_"+this.id].document;H.open();H.write("[loading] ["+C+"]"+this.id);H.close();A.contentWindow.arrky_SWAjax=arrky_SWAjax}catch(E){H=null}return(H)};this.sendViaScript=function(A,B){var F="1";var D=null;try{F="3";if((this.isSafari)||(this.isOpera)){D=A.getElementsByTagName("body").item(0)}else{D=A.getElementsByTagName("head").item(0)}F="4"}catch(G){alert("System Error adding script in sendViaScript:"+G.message+" at "+F);if((this.isSafari)||(this.isOpera)){alert(D)}}var C=A.createElement("SCRIPT");var E=(document.all)?document.charset:document.characterSet;E=E.toLowerCase();C.src=B+"&SW_SWAjaxId="+this.id+"&ky_encoding="+E;this.scriptObj=C;if(D){D.appendChild(C)}};this.getBaseUrl=function(B){var A="";var C=B.indexOf("responseHook.php");A=B.substring(0,C);return(A)};this.sendViaForm=function(A,B,H){var E="1";try{H=H+"&SW_SWAjaxId="+this.id;H=H+"&SW_UK="+this.SW_UK;var F=A.createElement("FORM");var D=A.createElement("INPUT");D.value=H;D.type="hidden";D.name="__ws__";E="2";F.action=B;F.method=this.formMethod;E="3";F.appendChild(D);D.value=H;var C=A.getElementsByTagName("body").item(0);C.appendChild(F);E="4";F.submit();E="5";ky_SWAjax.arrInterval[this.id]=ky_setInterval("ky_SWAjax.monitorRequest("+this.id+")",100)}catch(G){alert("System Error in sendViaForm:"+G.message+" at "+E)}};this.readUrlParam=function(C,B){var A;var D=C.indexOf("&"+B+"=");if(D>-1){A=C.substr(D+7,32)}else{A=""}return(A)};this.openf=function(A,C){try{if(this.onConnect!=null){this.onConnect()}this.SW_UK=(new Date()).getTime();oDoc=this.createIframe("transFrm","sendRequest");if(oDoc){this.oDoc=oDoc;this.baseUrl=A;this.sendViaForm(oDoc,A,C)}else{this.onRequestError()}}catch(B){}};this.readystate=function(B){var A=this;this.urlLoaded=function(C,F){var E=new RegExp("&amp;","gi");if(this.type=="xml"){this.response=C.xml}else{this.response=C.text}this.response=this.response.replace(E,"&");this.bLoaded=true;ky_SWAjax.clearResponseInterval(F);if(this.response.indexOf("<error>")>-1){this.onError(this.response)}else{try{B(this.response,F)}catch(D){alert("ky_SWAjax Error Passing Response : "+D.message)}}}};this.onError=function(A){};this.onRequestError=function(){};this.onResponseTimeout=function(){};this.getresponse=function(){return this.response};this.sendnull=function(){};this.getResponseFromServer=function(){var A="";A=_ky_wappServ_url+"responseHook.php?SW_UK="+this.SW_UK+"&SW_Type="+this.type;this.responseCount=0;oDoc=this.createIframe("respFrm","readResponse");if(oDoc){ky_SWAjax.arrInterval[this.id]=ky_setInterval("ky_SWAjax.monitorResponse("+this.id+")",150);this.sendViaScript(oDoc,A)}else{alert("System Error: Cannot Create Response Doc")}};arrky_SWAjax[arrky_SWAjax.length]=this}ky_SWAjax.monitorResponse=function(C){var B=new Date();arrky_SWAjax[C].responseCount++;if(arrky_SWAjax[C].responseCount>5){arrky_SWAjax[C].onResponseTimeout();try{arrky_SWAjax[C].clearResponseInterval(C)}catch(A){}}};ky_SWAjax.clearResponseInterval=function(B){var A=new Date();ky_clearInterval(ky_SWAjax.arrInterval[B])};ky_SWAjax.monitorRequest=function(F){var D=document.getElementById("transFrm_"+F);var E="[error]";var A=0;var B="";if(D==null){ky_clearInterval(ky_SWAjax.arrInterval[F]);return }try{E=D.contentWindow.document.body.innerHTML}catch(C){A=1;B=C.toString()}if(E.indexOf("[loading]")>-1){}else{if(ky_SWAjax.arrInterval[F]>0){ky_clearInterval(ky_SWAjax.arrInterval[F])}if(!arrky_SWAjax[F].bLoaded){arrky_SWAjax[F].bLoaded=true;arrky_SWAjax[F].getResponseFromServer()}}};ky_SWAjax.getAjaxObject=function(A){return(arrky_SWAjax[A])};ky_SWAjax.arrInterval=new Array();function ky_SWgetFile(B,C,A){this.cName="ky_SWgetFile";this._meGlobal=null;this.async=true;this.bustcachevar=0;this.bustcacheparameter="";this.page_request=false;this.loadDone=false;this.xtimer=null;this.DATA="";this.request=(C=="post"?"post":"get");this.type=B;this.scope=A}ky_SWgetFile.prototype.initialize=function(B,C){this.url=B;this.loadDone=false;this.page_request=new ky_SWAjax();this.page_request.openf(B,C);var A=this;this.page_request.readystate(function(D){A.setData(D)});this.page_request.sendnull();this.page_request.onError=function(D){A.onResponseError()};this.page_request.onRequestError=function(){A.onResponseError()}};ky_SWgetFile.prototype.setData=function(responseText){if(this.type=="json"){if(responseText.indexOf("__LF__")>-1){responseText=responseText.replace((new RegExp("__LF__","gm")),"\\n")}if(responseText.indexOf("__LRF__")>-1){responseText=responseText.replace((new RegExp("__LRF__","gm")),"")}if(responseText.indexOf("__LR__")>-1){responseText=responseText.replace((new RegExp("__LR__","gm")),"")}this.DATA=eval("("+responseText+")")}else{if(this.type=="scope"){alert(this.scope+" = ");if(window.execScript){window.execScript(this.scope+" = "+responseText)}else{window.eval("("+this.scope+" = "+responseText+")")}}else{this.DATA=responseText}}this.loadDone=true};ky_SWgetFile.prototype.onResponseError=function(){this.DATA=null;this.loadDone=true};function ky_wappManagerObj(A){this.cName="ky_wappManagerObj";this.arrInst=new Array();this.count=0;this._meGlobal=A;this.arrInstNF=new Array();this.countNF=0;this.wkey=null;this.formCount=0}ky_wappManagerObj.prototype.isStarted=function(A){var B=A.getAttribute("ky_index");if(B==null){return false}else{return true}};ky_wappManagerObj.prototype.start=function(){if(this.formCount==document.forms.length){return }else{this.formCount=document.forms.length}var A;for(var B=0;B<document.forms.length;B++){A=document.forms[B];try{if((A.getAttribute("ky_wapp")=="on")&&(!this.isStarted(A))){alertDebug("-------------------------------------------------------------------");alertDebug("new wapp ["+B+"]["+this.count+"] ["+typeof (this.arrInst[this.count])+"]["+document.forms.length+"]:"+A.id);this.arrInst[this.count]=new ky_wappObj(this._meGlobal+".arrInst["+this.count+"]");this.arrInst[this.count].iIndex=this.count;A.setAttribute("ky_index",this.arrInst[this.count].iIndex);if(A.getAttribute("ky_wkey")){this.arrInst[this.count].wKey=A.getAttribute("ky_wkey")}else{if(this.wkey==null){this.wkey=new ky_getFile();this.wkey.async=false;this.wkey._meGlobal=this._meGlobal+".wkey";this.wkey.initialize(_ky_wapp_folder+"ky_wkey.js")}if(this.wkey.DATA){this.arrInst[this.count].wKey=this.wkey.DATA}}A.style.margin="0px";A.style.padding="0px";A.onsubmit=function(){return false};alertDebug("pre start formID ["+B+"]["+this.count+"] ["+document.forms.length+"]:"+A.id);if(this.arrInst[this.count].wKey){alertDebug("isStarted:"+this.arrInst[this.count].wKey);this.arrInst[this.count].start(A,A.id);alertDebug("post start formID ["+B+"]["+this.count+"] ["+document.forms.length+"]:"+this.arrInst[this.count].formID)}else{ky_wappMsg[this.cName+"-start"]="unable to find wkey, skipping: "+A.id}this.count++}}catch(C){alertDebug("At Start Exception: ["+this.count+"]["+A.id+"] with ["+C.message+"]","red")}}};ky_wappManagerObj.prototype.startNF=function(A,C,B){this.arrInstNF[this.countNF]=new ky_wappObj(this._meGlobal+".arrInstNF["+this.countNF+"]");this.arrInstNF[this.countNF].iIndex=this.countNF;this.arrInstNF[this.countNF].wKey=C;this.arrInstNF[this.countNF].startNF(A,B);this.countNF++};ky_wappManagerObj.prototype.beforeLoad=function(){};ky_wappManagerObj.prototype.action=function(C,D,B){var A=this.getFormIndex(C);if(A>-1){this.arrInst[A].action(C,D,B)}};ky_wappManagerObj.prototype.getFormIndex=function(C){var A=C.parentNode;var D=0;var B=-1;while(A!=null){if((A.nodeName=="FORM")&&(A.getAttribute("ky_wapp")=="on")){for(D=0;D<this.arrInst.length;D++){if(this.arrInst[D].formID==A.id){B=D;break}}}A=A.parentNode}return B};ky_wappManagerObj.prototype.getFormIndexByID=function(C){var B=0;var A=-1;for(B=0;B<this.arrInst.length;B++){if(this.arrInst[B].formID==C){A=B;break}}return A};ky_wappManagerObj.prototype.fieldAction=function(C,D,B){var A=this.getFormIndex(C);if(A>-1){this.arrInst[A].fieldAction(C,D,B)}};if(typeof (kyQuery)=="undefined"){kyQuery={}}(function(){var theEval=eval;var theString=String;var theArray=Array;if(kyQuery==null){kyQuery=new Object()}if(kyQuery.TEST==null){kyQuery.TEST=new Object()}var arrayUniq=function(arr){var result=[];for(var i=0;i<arr.length;i++){if(arrayInclude(result,arr[i])==false){result.push(arr[i])}}return result};var arrayInclude=function(arr,val){for(var j=0;j<arr.length;j++){if(arr[j]==val){return true}}return false};var arrayCompact=function(arr){var result=[];for(var i=0;i<arr.length;i++){if(arr[i]!=null){result.push(arr[i])}}return result};var simpleJson=function(fields,values){var json=["{"];for(var i=0;i<fields.length;i++){if(i>0){json.push(",")}json.push(fields[i]);json.push(":");if(values[i]){json.push('"');json.push(values[i].replace(/(["\\])/g,"\\$1").replace(/\r/g,"").replace(/\n/g,"\\n"));json.push('"')}else{json.push(null)}}json.push("}");return json.join("")};var hashKeys=function(object){var keys=[];for(var property in object){keys.push(property)}return keys};var hashValues=function(object){var values=[];for(var property in object){values.push(object[property])}return values};var strip=function(str){return str.replace(/^\s+/,"").replace(/\s+$/,"")};kyQuery.makeQueryLang_etc={};kyQuery.makeQueryLang_etc.Error=function(message,stmt){this.message=message;this.stmt=stmt};kyQuery.makeQueryLang_etc.Error.prototype.toString=function(){return("kyQuery query Error in "+(this.stmt!=null?this.stmt:"[unknown]")+": "+this.message)};var TODO=function(){throw"currently unsupported"};var USAGE=function(){throw"incorrect keyword usage"};var QueryLang=function(){};kyQuery.makeQueryLang=function(tableInfos,etc){if(etc==null){etc=kyQuery.makeQueryLang_etc}var aliasArr=[];var aliasReg=function(aliasKey,scope,obj){if(scope[aliasKey]!=null){throw new etc.Error("alias redefinition: "+aliasKey)}aliasArr.push({aliasKey:aliasKey,scope:scope,orig:scope[aliasKey]});scope[aliasKey]=obj;return obj};var queryLang=new QueryLang();var checkArgs=function(args,minLength,maxLength,name,typeCheck){args=cleanArray(args);if(minLength==null){minLength=1}if(args==null||args.length<minLength){throw new etc.Error("not enough arguments for "+name)}if(maxLength!=null&&args.length>maxLength){throw new etc.Error("too many arguments for "+name)}if(typeCheck!=null){for(var k in args){if(typeof (args[k])!="function"&&args[k] instanceof typeCheck==false){throw new etc.Error("wrong type for "+args[k]+" to "+name)}}}return args};var sql_date_to_js_date=function(data){if(typeof data=="string"&&data.match(/\d{4}-\d{1,2}-\d{1,2}/)){var dateArr=data.match(/\d{4}-\d{1,2}-\d{1,2}/)[0].split("-");var date=new Date(parseInt(dateArr[0],10),(parseInt(dateArr[1],10)-1),parseInt(dateArr[2],10));return date}return data};var data_insertion=function(table_info,field_name,data,column_ref){if(table_info[field_name]){var data=eval(data);if(table_info[field_name].type&&table_info[field_name].type=="Number"){data=Number(data,10)}else{if(table_info[field_name].type&&table_info[field_name].type=="Date"){data=sql_date_to_js_date(data)}}column_ref[field_name]=data}};var NodeType={select:function(args){var columns=[];var nodes={from:null,where:null,groupBy:null,having:null,orderBy:null,limit:null};for(var i=0;i<args.length;i++){var arg=args[i];var argIsNode=false;for(var nodeTypeName in nodes){if(arg instanceof NodeType[nodeTypeName]){if(nodes[nodeTypeName]!=null){throw new etc.Error("too many "+nodeTypeName.toUpperCase()+" clauses")}nodes[nodeTypeName]=arg;argIsNode=true;break}}if(argIsNode==false){columns.push(arg)}}columns=checkArgs(columns,1,null,"COLUMNS");if(nodes.from==null){throw new etc.Error("missing FROM clause")}var joinDriver=null;var joinFilter=null;var whereFilter=null;var columnConvertor=null;var orderByComparator=null;var groupByCalcValues=null;var havingFilter=null;var typeConverter=function(results){for(var i=0;i<results.length;i++){var result=results[i];for(var attr in result){var value=result[attr];if(value instanceof Date){results[i][attr]=dateToString(value)}}}};this.prepareFilter=function(){if(joinDriver==null){joinDriver=compileJoinDriver(nodes.from.tables)}if(joinFilter==null){joinFilter=compileFilter(compileFilterForJoin,nodes.from.tables)}if(whereFilter==null){whereFilter=compileFilter(compileFilterForWhere,nodes.from.tables,nodes.where!=null?nodes.where.exprs:null)}if(groupByCalcValues==null&&nodes.groupBy!=null){groupByCalcValues=compileGroupByCalcValues(nodes.from.tables,nodes.groupBy.exprs)}if(havingFilter==null&&nodes.having!=null){havingFilter=compileFilter(compileFilterForWhere,[],nodes.having.exprs,{aliasOnly:true})}if(columnConvertor==null){columnConvertor=compileColumnConvertor(nodes.from.tables,columns)}if(orderByComparator==null&&nodes.orderBy!=null){orderByComparator=compileOrderByComparator(nodes.orderBy.exprs)}};this.filter=function(dataTables,bindings,params){this.prepareFilter();if(bindings==null){bindings={}}if(params==null){params={}}var resultOfFromWhere=joinDriver(dataTables,joinFilter,whereFilter,bindings);if(groupByCalcValues!=null){for(var i=0;i<resultOfFromWhere.length;i++){resultOfFromWhere[i].groupByValues=groupByCalcValues.apply(null,resultOfFromWhere[i])}resultOfFromWhere.sort(groupByComparator)}if(params.return_reference){return resultOfFromWhere}var groupByAccum={};var groupByFuncs={SUM:function(key,val){groupByAccum[key]=zeroDefault(groupByAccum[key])+zeroDefault(val);return groupByAccum[key]},COUNT:function(key){groupByAccum[key]=zeroDefault(groupByAccum[key])+1;return groupByAccum[key]},AVG:function(key,val){return groupByFuncs.SUM(key,val)/groupByFuncs.COUNT("_COUNT"+key)}};var result=[],prevItem=null,currItem;for(var i=0;i<resultOfFromWhere.length;i++){currItem=resultOfFromWhere[i];currItem[0]=groupByFuncs;if(prevItem!=null&&groupByComparator(prevItem,currItem)!=0){if(havingFilter==null||havingFilter(prevItem.record)==true){result.push(prevItem.record)}groupByAccum={}}currItem.record=columnConvertor.apply(null,currItem.concat([params.with_table]));prevItem=currItem}if(prevItem!=null&&(havingFilter==null||havingFilter(prevItem.record)==true)){result.push(prevItem.record)}if(orderByComparator!=null){result.sort(orderByComparator)}if(nodes.limit!=null){if(nodes.limit.total==0){return[]}var start=(nodes.limit.offset!=null?nodes.limit.offset:0);result=result.slice(start,start+(nodes.limit.total>0?nodes.limit.total:result.length))}typeConverter(result);return result};setSSFunc(this,function(){var sqlArr=["SELECT",map(columns,toSqlWithAlias).join(", "),nodes.from.toSql()];if(nodes.where!=null){sqlArr.push(nodes.where.toSql())}if(nodes.groupBy!=null){sqlArr.push(nodes.groupBy.toSql())}if(nodes.having!=null){sqlArr.push(nodes.having.toSql())}if(nodes.orderBy!=null){sqlArr.push(nodes.orderBy.toSql())}if(nodes.limit!=null){sqlArr.push(nodes.limit.toSql())}return sqlArr.join(" ")});for(var i=0;i<aliasArr.length;i++){var aliasItem=aliasArr[i];aliasItem.scope[aliasItem.aliasKey]=aliasItem.orig}aliasArr=[]},insert:function(args){var table_info=args[0];var object=args[1];this.filter=function(dataTables,bindings){var table_name=table_info[".name"];if(!dataTables[table_name]){dataTables[table_name]=[]}dataTables[table_name].push({});for(var field_name in object){data_insertion(table_info,field_name,object[field_name],dataTables[table_name][dataTables[table_name].length-1])}return true};setSSFunc(this,function(){var sqlArr=["INSERT INTO",table_info.toSql(),"("+hashKeys(object).join(", ")+")","VALUES","("+hashValues(object).join(", ")+")"];return sqlArr.join(" ")})},update:function(args){var from_node=args[0];var assignments=args[1];var where_node=args[2];this.filter=function(dataTables,bindings){var table_info=from_node.tables[0];var resultOfFromWhere=queryLang.SELECT(from_node,where_node,1).filter(dataTables,null,{return_reference:true});for(var i=0;i<resultOfFromWhere.length;i++){var object=resultOfFromWhere[i][1];for(var field in assignments){var fieldSplit=field.split(".");var field_name=field;if(fieldSplit.length==2){field_name=fieldSplit[1]}data_insertion(table_info,field_name,assignments[field],object)}}return true};setSSFunc(this,function(){var sqlArr=["UPDATE",from_node.toSql()];var assignmentsArr=[];for(var attr in assignments){assignmentsArr.push(attr+"="+assignments[attr])}sqlArr.push(assignmentsArr.join(", "));if(where_node!=null){sqlArr.push(where_node.toSql())}return sqlArr.join(" ")})},destroy:function(args){var select_node=args[0];this.filter=function(dataTables,bindings){var resultOfFromWhere=select_node.filter(dataTables,null,{return_reference:true});for(var i=0;i<resultOfFromWhere.length;i++){var record=resultOfFromWhere[i];for(var j=1;j<record.length;j++){var object=record[j];for(var attr in object){delete object[attr]}}}for(var table_name in dataTables){var table=dataTables[table_name];for(var i=0;i<table.length;i++){if(hashKeys(table[i]).length==0){delete table[i]}}}for(var table_name in dataTables){dataTables[table_name]=arrayCompact(dataTables[table_name])}return true};setSSFunc(this,function(){var sqlArr=["DELETE",select_node.toSql()];return sqlArr.join(" ").replace(/SELECT\s/,"")})},from:function(tables){this.tables=checkArgs(tables,1,null,"FROM",NodeType.tableDef)},where:function(exprs){this.exprs=checkArgs(exprs,1,null,"WHERE",NodeType.expression)},groupBy:function(exprs){this.exprs=checkArgs(exprs,1,null,"GROUP_BY")},having:function(exprs){this.exprs=checkArgs(exprs,1,null,"HAVING",NodeType.expression)},orderBy:function(exprs){this.exprs=checkArgs(exprs,1,null,"ORDER_BY")},expression:function(args,name,opFix,sqlText,minArgs,maxArgs,jsText,alias){var theExpr=this;this.args=checkArgs(args,minArgs,maxArgs,name);this[".name"]=name;this[".alias"]=alias!=null?alias:name;this.opFix=opFix;this.sqlText=sqlText!=null?sqlText:this[".name"];this.jsText=jsText!=null?jsText:this.sqlText;this.AS=function(aliasArg){this[".alias"]=this.ASC[".alias"]=this.DESC[".alias"]=aliasArg;return aliasReg(aliasArg,queryLang,this)};this.ASC=setSSFunc({".name":name,".alias":theExpr[".alias"],order:"ASC"},function(){return theExpr[".alias"]+" ASC"});this.DESC=setSSFunc({".name":name,".alias":theExpr[".alias"],order:"DESC"},function(){return theExpr[".alias"]+" DESC"});this.COLLATE=TODO},aggregate:function(){NodeType.expression.apply(this,arguments)},limit:function(offset,total){if(total==null){this.total=cleanString(offset)}else{this.total=cleanString(total);this.offset=cleanString(offset)}},tableDef:function(name,columnInfos,alias){this[".name"]=name;this[".alias"]=alias!=null?alias:name;this[".allColumns"]=[];for(var columnName in columnInfos){this[columnName]=new NodeType.columnDef(columnName,columnInfos[columnName],this);this[".allColumns"].push(this[columnName])}setSSFunc(this,function(){return name});this.AS=function(alias){return aliasReg(alias,queryLang,new NodeType.tableDef(name,columnInfos,alias))};this.ALL=new NodeType.columnDef("*",null,this);this.ALL.AS=null},columnDef:function(name,columnInfo,tableDef,alias){var theColumnDef=this;this[".name"]=name;this[".alias"]=alias!=null?alias:name;this.tableDef=tableDef;setSSFunc(this,function(flags){if(flags!=null&&flags.aliasOnly==true){return this[".alias"]}return tableDef!=null?((tableDef[".alias"])+"."+name):name});this.AS=function(aliasArg){return aliasReg(aliasArg,queryLang,new NodeType.columnDef(name,columnInfo,tableDef,aliasArg))};if(columnInfo&&columnInfo.type){this.type=columnInfo.type}else{this.type="String"}this.ASC=setSSFunc({".name":name,".alias":theColumnDef[".alias"],tableDef:tableDef,order:"ASC"},function(){return theColumnDef.toSql()+" ASC"});this.DESC=setSSFunc({".name":name,".alias":theColumnDef[".alias"],tableDef:tableDef,order:"DESC"},function(){return theColumnDef.toSql()+" DESC"});this.COLLATE=TODO},join:function(joinType,tableDef){var theJoin=this;this.joinType=joinType;this.fromSeparator=" "+joinType+" JOIN ";for(var k in tableDef){this[k]=tableDef[k]}this.ON=function(){theJoin.ON_exprs=checkArgs(arguments,1,null,"ON");return theJoin};this.USING=function(){theJoin.USING_exprs=cleanArray(arguments,false);return theJoin};this.fromSuffix=function(){if(theJoin.ON_exprs!=null){return(" ON "+map(theJoin.ON_exprs,toSql).join(" AND "))}if(theJoin.USING_exprs!=null){return(" USING ("+theJoin.USING_exprs.join(", ")+")")}return""}}};var setSSFunc=function(obj,func){obj.toSql=obj.toJs=obj.toString=func;return obj};setSSFunc(NodeType.from.prototype,function(){var sqlArr=["FROM "];for(var i=0;i<this.tables.length;i++){if(i>0){var sep=this.tables[i].fromSeparator;if(sep==null){sep=", "}sqlArr.push(sep)}sqlArr.push(toSqlWithAlias(this.tables[i]));if(this.tables[i].fromSuffix!=null){sqlArr.push(this.tables[i].fromSuffix())}}return sqlArr.join("")});setSSFunc(NodeType.where.prototype,function(){return"WHERE "+map(this.exprs,toSql).join(" AND ")});setSSFunc(NodeType.orderBy.prototype,function(){return"ORDER BY "+map(this.exprs,toSql).join(", ")});setSSFunc(NodeType.groupBy.prototype,function(){return"GROUP BY "+map(this.exprs,toSql).join(", ")});setSSFunc(NodeType.having.prototype,function(){return"HAVING "+map(this.exprs,toSql,{aliasOnly:true}).join(" AND ")});setSSFunc(NodeType.limit.prototype,function(){return"LIMIT "+(this.total<0?"ALL":this.total)+(this.offset!=null?(" OFFSET "+this.offset):"")});var makeToFunc=function(toFunc,opText){return function(flags){if(flags!=null&&flags.aliasOnly==true&&this[".alias"]!=this[".name"]){return this[".alias"]}if(this.opFix<0){return this[opText]+" ("+map(this.args,toFunc,flags).join(") "+this[opText]+" (")+")"}if(this.opFix>0){return"("+map(this.args,toFunc,flags).join(") "+this[opText]+" (")+") "+this[opText]}return"("+map(this.args,toFunc,flags).join(") "+this[opText]+" (")+")"}};NodeType.expression.prototype.toSql=makeToFunc(toSql,"sqlText");NodeType.expression.prototype.toJs=makeToFunc(toJs,"jsText");NodeType.aggregate.prototype=new NodeType.expression([],null,null,null,0);NodeType.aggregate.prototype.toJs=function(flags){if(flags!=null&&flags.aliasOnly==true&&this[".alias"]!=this[".name"]){return this[".alias"]}return this.jsText+" ('"+this[".alias"]+"', ("+map(this.args,toJs).join("), (")+"))"};NodeType.join.prototype=new NodeType.tableDef();NodeType.whereSql=function(sql){this.exprs=[new NodeType.rawSql(sql)]};NodeType.whereSql.prototype=new NodeType.where([new NodeType.expression([0],null,0,null,0,null,null,null)]);NodeType.havingSql=function(sql){this.exprs=[new NodeType.rawSql(sql)]};NodeType.havingSql.prototype=new NodeType.having([new NodeType.expression([0],null,0,null,0,null,null,null)]);NodeType.rawSql=function(sql){this.sql=sql};NodeType.rawSql.prototype.toSql=function(flags){return this.sql};NodeType.rawSql.prototype.toJs=function(flags){var js=this.sql;js=js.replace(/ AND /g," && ");js=js.replace(/ OR /g," || ");js=js.replace(/ = /g," == ");js=js.replace(/ IS NULL/g," == null");js=js.replace(/ IS NOT NULL/g," != null");js=js.replace(/ NOT /g," ! ");var LIKE_regex=/(\S+)\sLIKE\s'(\S+)'/g;var matchArr;while(matchArr=LIKE_regex.exec(js)){matchArr[2]=matchArr[2].replace(/%/,".*");js=js.replace(LIKE_regex,"$1.match(/"+matchArr[2]+"/)")}var DATE_regex=/'(\d{4})-(\d{1,2})-(\d{1,2})'/g;while(matchArr=DATE_regex.exec(js)){var dateArr=[parseInt(matchArr[1],10).toString(),(parseInt(matchArr[2],10)-1).toString(),parseInt(matchArr[3],10).toString()];var replacement="(new Date("+dateArr.join(", ")+").valueOf())";js=js.replace(matchArr[0],replacement)}return js};var keywords={INSERT:function(){return new NodeType.insert(arguments)},UPDATE:function(){return new NodeType.update(arguments)},DESTROY:function(){return new NodeType.destroy(arguments)},SELECT_ALL:function(){return new NodeType.select(arguments)},SELECT_DISTINCT:TODO,ALL:USAGE,FROM:function(){return new NodeType.from(arguments)},WHERE:function(){return new NodeType.where(arguments)},AND:function(){return new NodeType.expression(arguments,"AND",0,null,1,null,"&&")},OR:function(){return new NodeType.expression(arguments,"OR",0,null,1,null,"||")},NOT:function(){return new NodeType.expression(arguments,"NOT",-1,null,1,1,"!")},EQ:function(){return new NodeType.expression(arguments,"EQ",0,"=",2,2,"==")},NEQ:function(){return new NodeType.expression(arguments,"NEQ",0,"!=",2,2)},LT:function(){return new NodeType.expression(arguments,"LT",0,"<",2,2)},GT:function(){return new NodeType.expression(arguments,"GT",0,">",2,2)},LTE:function(){return new NodeType.expression(arguments,"LTE",0,"<=",2,2)},GTE:function(){return new NodeType.expression(arguments,"GTE",0,">=",2,2)},IS_NULL:function(){return new NodeType.expression(arguments,"IS_NULL",1,"IS NULL",1,1,"== null")},IS_NOT_NULL:function(){return new NodeType.expression(arguments,"IS_NOT_NULL",1,"IS NOT NULL",1,1,"!= null")},ADD:function(){return new NodeType.expression(arguments,"ADD",0,"+",2,null)},SUBTRACT:function(){return new NodeType.expression(arguments,"SUBTRACT",0,"-",2,null)},NEGATE:function(){return new NodeType.expression(arguments,"NEGATE",-1,"-",1,1)},MULTIPLY:function(){return new NodeType.expression(arguments,"MULTIPLY",0,"*",2,null)},DIVIDE:function(){return new NodeType.expression(arguments,"DIVIDE",0,"/",2,null)},PAREN:function(){return new NodeType.expression(arguments,"PAREN",0,"",1,1)},LIKE:function(){return new NodeType.expression(arguments,"LIKE",0,"LIKE",2,2,"match")},BETWEEN:TODO,AVG:function(){return new NodeType.aggregate(arguments,"AVG",-1,null,1,1)},AVG_ALL:TODO,AVG_DISTINCT:TODO,SUM:function(){return new NodeType.aggregate(arguments,"SUM",-1,null,1,1)},SUM_ALL:TODO,SUM_DISTINCT:TODO,COUNT:function(){return new NodeType.aggregate(arguments,"COUNT",-1,null,1,1)},COUNT_ALL:TODO,COUNT_DISTINCT:TODO,AS:USAGE,IN:TODO,UNION:TODO,UNION_ALL:TODO,EXCEPT:TODO,EXCEPT_ALL:TODO,INTERSECT:TODO,INTERSECT_ALL:TODO,CROSS_JOIN:function(tableDef){return tableDef},INNER_JOIN:function(tableDef){return new NodeType.join("INNER",tableDef)},LEFT_OUTER_JOIN:function(tableDef){return new NodeType.join("LEFT OUTER",tableDef)},RIGHT_OUTER_JOIN:TODO,FULL_OUTER_JOIN:TODO,ON:USAGE,USING:USAGE,GROUP_BY:function(){return new NodeType.groupBy(arguments)},HAVING:function(){return new NodeType.having(arguments)},ORDER_BY:function(){return new NodeType.orderBy(arguments)},LIMIT:function(offset,total){return new NodeType.limit(offset,total)},LIMIT_ALL:function(offset){return queryLang.LIMIT(-1,offset)},OFFSET:USAGE,ANY_SELECT:TODO,ALL_SELECT:TODO,EXISTS:TODO,WHERE_SQL:function(sql){return new NodeType.whereSql(sql)},HAVING_SQL:function(sql){return new NodeType.havingSql(sql)}};keywords.SELECT=keywords.SELECT_ALL;for(var k in keywords){queryLang[k]=keywords[k]}for(var tableName in tableInfos){queryLang[tableName]=new NodeType.tableDef(tableName,tableInfos[tableName])}return queryLang};var compileJoinDriver=function(tables){var funcText=["var kyQuery_query_tmpJD = function(dataTables, joinFilter, whereFilter, bindings) {","var result = [], filterArgs = [ bindings ];"];for(var i=0;i<tables.length;i++){funcText.push("var T"+i+" = dataTables['"+tables[i][".name"]+"'] || [];")}for(var i=0;i<tables.length;i++){funcText.push("for (var t"+i+" = 0; t"+i+" < T"+i+".length; t"+i+"++) {");funcText.push("var resultLength"+i+" = result.length;");funcText.push("filterArgs["+(i+1)+"] = T"+i+"[t"+i+"];")}funcText.push("if ((joinFilter == null || joinFilter.apply(null, filterArgs) == true) && ");funcText.push("    (whereFilter == null || whereFilter.apply(null, filterArgs) == true))");funcText.push("result.push(filterArgs.slice(0));");for(var i=tables.length-1;i>=0;i--){funcText.push("}");if(i>=1&&tables[i].joinType=="LEFT OUTER"){funcText.push("if (resultLength"+(i-1)+" == result.length) {");for(var j=i;j<tables.length;j++){funcText.push("filterArgs["+(j+1)+"] = ")}funcText.push("{}; if (whereFilter == null || whereFilter.apply(null, filterArgs) == true) result.push(filterArgs.slice(0)); }")}}funcText.push("return result; }; kyQuery_query_tmpJD");return theEval(funcText.join(""))};var compileFilter=function(bodyFunc,tables,whereExpressions,flags){var funcText=["var kyQuery_query_tmpWF = function(_BINDINGS"];for(var i=0;i<tables.length;i++){funcText.push(", "+tables[i][".alias"])}funcText.push("){ with(_BINDINGS) {");bodyFunc(funcText,tables,whereExpressions,flags);funcText.push("return true; }}; kyQuery_query_tmpWF");return theEval(funcText.join(""))};var compileFilterForJoin=function(funcText,tables,whereExpressions,flags){for(var i=0;i<tables.length;i++){if(tables[i].joinType!=null){if(tables[i].ON_exprs!=null||tables[i].USING_exprs!=null){funcText.push("if (!(");if(tables[i].ON_exprs!=null&&tables[i].ON_exprs[0].exprs!=null){funcText.push(tables[i].ON_exprs[0].exprs[0].toJs())}else{if(tables[i].ON_exprs!=null){funcText.push(map(tables[i].ON_exprs,toJs).join(" && "))}}if(tables[i].USING_exprs!=null){funcText.push(map(tables[i].USING_exprs,function(col){return"("+tables[i-1][".alias"]+"."+col+" == "+tables[i][".alias"]+"."+col+")"}).join(" && "))}funcText.push(")) return false;")}}}};var compileFilterForWhere=function(funcText,tables,whereExpressions,flags){if(whereExpressions!=null){funcText.push("if (!((");for(var i=0;i<whereExpressions.length;i++){if(i>0){funcText.push(") && (")}funcText.push(toJs(whereExpressions[i],flags))}funcText.push("))) return false;")}};var compileColumnConvertor=function(tables,columnExpressions){var funcText=["var kyQuery_query_tmpCC = function(_BINDINGS, "];var table_aliases=[];for(var i=0;i<tables.length;i++){table_aliases.push(tables[i][".alias"])}funcText.push(arrayUniq(table_aliases).join(", "));funcText.push(", with_table){ with(_BINDINGS) {");funcText.push("var _RESULT = {};");funcText.push("if(with_table) {");compileColumnConvertorHelper(funcText,columnExpressions,true);funcText.push("} else {");compileColumnConvertorHelper(funcText,columnExpressions,false);funcText.push("}");funcText.push("return _RESULT; }}; kyQuery_query_tmpCC");return theEval(funcText.join(""))};var test=function(stuff){var i};var compileColumnConvertorHelper=function(funcText,columnExpressions,with_table){for(var i=0;i<columnExpressions.length;i++){var columnExpression=columnExpressions[i];if(columnExpression[".name"]=="*"){compileColumnConvertorHelper(funcText,columnExpression.tableDef[".allColumns"],with_table)}else{funcText.push("_RESULT['");if(with_table==true){funcText.push(columnExpression.toString())}else{funcText.push(columnExpression[".alias"])}funcText.push("'] = (");funcText.push(toJs(columnExpression));funcText.push(");")}}};var dateToString=function(date){if(typeof date=="object"){return[date.getFullYear(),"-",(date.getMonth()+1),"-",date.getDate()].join("")}if(date==null){return null}};var compileOrderByComparator=function(orderByExpressions){var funcText=["var kyQuery_query_tmpOC = function(A, B) { var a, b; "];for(var i=0;i<orderByExpressions.length;i++){var orderByExpression=orderByExpressions[i];if(orderByExpression.tableDef){funcText.push("a = A['"+orderByExpression[".alias"]+"'] || A['"+orderByExpression.tableDef[".alias"]+"."+orderByExpression[".alias"]+"'] || '';");funcText.push("b = B['"+orderByExpression[".alias"]+"'] || B['"+orderByExpression.tableDef[".alias"]+"."+orderByExpression[".alias"]+"'] || '';")}else{funcText.push("a = A['"+orderByExpression[".alias"]+"'] || '';");funcText.push("b = B['"+orderByExpression[".alias"]+"'] || '';")}var sign=(orderByExpression.order=="DESC"?-1:1);funcText.push("if (a.valueOf() < b.valueOf()) return "+(sign*-1)+";");funcText.push("if (a.valueOf() > b.valueOf()) return "+(sign*1)+";")}funcText.push("return 0; }; kyQuery_query_tmpOC");return theEval(funcText.join(""))};var compileGroupByCalcValues=function(tables,groupByExpressions){var funcText=["var kyQuery_query_tmpGC = function(_BINDINGS"];for(var i=0;i<tables.length;i++){funcText.push(", "+tables[i][".alias"])}funcText.push("){ var _RESULT = [];");for(var i=0;i<groupByExpressions.length;i++){funcText.push("_RESULT.push(");funcText.push(toJs(groupByExpressions[i]));funcText.push(");")}funcText.push("return _RESULT; }; kyQuery_query_tmpGC");return theEval(funcText.join(""))};var groupByComparator=function(a,b){return arrayCompare(a.groupByValues,b.groupByValues)};var arrayCompare=function(x,y){if(x==null||y==null){return -1}for(var i=0;i<x.length&&i<y.length;i++){if(x[i]<y[i]){return -1}if(x[i]>y[i]){return 1}}return 0};var toSqlWithAlias=function(obj,flags){var res=toSql(obj,flags);if(obj[".alias"]!=null&&obj[".alias"]!=obj[".name"]){return res+" AS "+obj[".alias"]}return res};var toSql=function(obj,flags){return toX(obj,"toSql",flags)};var toJs=function(obj,flags){return toX(obj,"toJs",flags)};var toX=function(obj,funcName,flags){if(typeof (obj)=="object"&&obj[funcName]!=null){return obj[funcName].call(obj,flags)}return theString(obj)};var zeroDefault=function(x){return(x!=null?x:0)};var map=function(arr,func,arg2){for(var result=[],i=0;i<arr.length;i++){result.push(func(arr[i],arg2))}return result};var cleanArray=function(src,quotes){for(var result=[],i=0;i<src.length;i++){result.push(cleanString(src[i],quotes))}return result};var cleanString=kyQuery.TEST.cleanString=function(src,quotes){if(src instanceof theString||typeof (src)=="string"){src=theString(src).replace(/\\/g,"\\\\").replace(/'/g,"\\'");if(quotes!=false){src="'"+src+"'"}}return src};var findClause=function(str,regexp){var clauseEnd=str.search(regexp);if(clauseEnd<0){clauseEnd=str.length}return str.substring(0,clauseEnd)};QueryLang.prototype.parseSQL=function(sqlQueryIn,paramsArr){var sqlQuery=sqlQueryIn.replace(/\n/g," ").replace(/\r/g,"");if(paramsArr!=null){if(paramsArr instanceof theArray==false){paramsArr=[paramsArr]}var sqlParts=sqlQuery.split(" ?");for(var i=0;i<sqlParts.length-1;i++){sqlParts[i]=sqlParts[i]+" "+cleanString(paramsArr[i],true)}sqlQuery=sqlParts.join("")}sqlQuery=sqlQuery.replace(/ AS ([_a-zA-z0-9]+)/g,".AS('$1')");var err=function(errMsg){throw ("[ERROR: "+errMsg+" in query: "+sqlQueryIn+"]")};var query_type=sqlQuery.split(/\s+/)[0];if(query_type=="DELETE"){query_type="DESTROY"}if(!arrayInclude(["SELECT","DESTROY","UPDATE","INSERT"],query_type)){err("not a valid query type")}var strip_whitespace=function(str){return str.replace(/\s+/g,"")};if(query_type=="SELECT"||query_type=="DESTROY"){var fromSplit=sqlQuery.substring(7).split(" FROM ");if(fromSplit.length!=2){err("missing a FROM clause")}var columnsClause=fromSplit[0].replace(/\.\*/g,".ALL");var remaining=fromSplit[1];var fromClause=findClause(remaining,/\sWHERE\s|\sGROUP BY\s|\sHAVING\s|\sORDER BY\s|\sLIMIT/);var fromTableClause=findClause(fromClause,/\sLEFT OUTER JOIN\s/);var fromTables=strip_whitespace(fromTableClause).split(",");remaining=remaining.substring(fromClause.length);var fromClauseSplit=fromClause.split(" LEFT OUTER JOIN ");var fromClauseParts=[fromClauseSplit[0]];var leftJoinComponents;for(var i=1;i<fromClauseSplit.length;i++){leftJoinComponents=/(\w+)\sON\s(.+)/.exec(fromClauseSplit[i]);fromTables.push(leftJoinComponents[1]);fromClauseParts.push("("+leftJoinComponents[1]+').ON(WHERE_SQL("'+leftJoinComponents[2]+'"))')}fromClause=fromClauseParts.join(", LEFT_OUTER_JOIN");if(strip_whitespace(columnsClause)=="*"){var new_columns=[];for(var i=0;i<fromTables.length;i++){new_columns.push(fromTables[i]+".ALL")}columnsClause=columnsClause.replace(/\*/,new_columns.join(", "))}var whereClause=findClause(remaining,/\sGROUP BY\s|\sHAVING\s|\sORDER BY\s|\sLIMIT/);remaining=remaining.substring(whereClause.length);var groupByClause=findClause(remaining,/\sHAVING\s|\sORDER BY\s|\sLIMIT /);remaining=remaining.substring(groupByClause.length);var havingClause=findClause(remaining,/\sORDER BY\s|\sLIMIT /);remaining=remaining.substring(havingClause.length);var orderByClause=findClause(remaining,/\sLIMIT /).replace(/\sASC/g,".ASC").replace(/\sDESC/g,".DESC");remaining=remaining.substring(orderByClause.length);var limitClause=remaining;var tql=["SELECT(FROM(",fromClause,"), ",columnsClause];if(whereClause.length>0){tql.push(', WHERE_SQL("'+whereClause.substring(7)+'")')}if(groupByClause.length>0){tql.push(", GROUP_BY("+groupByClause.substring(10)+")")}if(havingClause.length>0){tql.push(', HAVING_SQL("'+havingClause.substring(8)+'")')}if(orderByClause.length>0){tql.push(", ORDER_BY("+orderByClause.substring(10)+")")}if(limitClause.length>0){tql.push(", LIMIT("+limitClause.substring(7)+")")}tql.push(")")}else{if(query_type=="INSERT"){var intoSplit=sqlQuery.substring(6).split(" INTO ");if(intoSplit.length!=2){err("missing an INTO clause")}var insertion_regex=/^\s*(\w+)\s*\((.+)\)\s+VALUES\s+\((.+)\)/;var parsed_sql=intoSplit[1].match(insertion_regex);var table_name=parsed_sql[1];var fields=strip_whitespace(parsed_sql[2]).split(",");var values=parsed_sql[3].split(",");if(fields.length!=values.length){err("values and fields must have same number of elements")}tql=["INSERT(",table_name,",",simpleJson(fields,values),")"]}else{if(query_type=="UPDATE"){var setSplit=sqlQuery.substring(7).split(" SET ");if(setSplit.length!=2){err("missing a SET clause")}var fromClause=setSplit[0];var remaining=setSplit[1];var assignmentClause=findClause(remaining,/\sWHERE\s/);remaining=remaining.substring(assignmentClause.length);var whereClause=remaining;var assignmentArray=assignmentClause.split(",");var fields=[];var values=[];for(var i=0;i<assignmentArray.length;i++){var components=assignmentArray[i].split("=");fields.push(strip(components[0]));values.push(strip(components[1]))}var update_regex=/^UPDATE\s+(\w+)\s+SET\s+(\w+\s*=\s*\w+)/;var parsed_sql=sqlQuery.match(update_regex);var tql=["UPDATE(FROM(",fromClause,"), ",simpleJson(fields,values)];tql.push(', WHERE_SQL("'+whereClause.substring(7)+'")');tql.push(")")}}}if(query_type=="DESTROY"){tql.unshift("DESTROY(");tql.push(")")}with(this){return eval(tql.join(""))}}})();if(typeof (kyTemplate)=="undefined"){kyTemplate={}}(function(){if(kyTemplate.evalEx==null){kyTemplate.evalEx=function(src){return eval(src)}}var UNDEFINED;if(Array.prototype.pop==null){Array.prototype.pop=function(){if(this.length===0){return UNDEFINED}return this[--this.length]}}if(Array.prototype.push==null){Array.prototype.push=function(){for(var i=0;i<arguments.length;++i){this[this.length]=arguments[i]}return this.length}}kyTemplate.parseTemplate=function(tmplContent,optTmplName,optEtc){if(optEtc==null){optEtc=kyTemplate.parseTemplate_etc}var funcSrc=parse(tmplContent,optTmplName,optEtc);var func=kyTemplate.evalEx(funcSrc,optTmplName,1);if(func!=null){return new optEtc.Template(optTmplName,tmplContent,funcSrc,func,optEtc)}return null};var exceptionDetails=function(e){return(e.toString())+";\n "+(e.message)+";\n "+(e.name)+";\n "+(e.stack||"no stack trace")+";\n "+(e.description||"no further description")+";\n "+(e.fileName||"no file name")+";\n "+(e.lineNumber||"no line number")};try{String.prototype.process=function(context,optFlags){var template=kyTemplate.parseTemplate(this,null);if(template!=null){return template.process(context,optFlags)}return this}}catch(e){}kyTemplate.parseTemplate_etc={};kyTemplate.parseTemplate_etc.statementTag="forelse|for|if|elseif|else|var|macro|hMacro";kyTemplate.parseTemplate_etc.statementDef={"if":{delta:1,prefix:"if (",suffix:") {",paramMin:1},"else":{delta:0,prefix:"} else {"},elseif:{delta:0,prefix:"} else if (",suffix:") {",paramDefault:"true"},"/if":{delta:-1,prefix:"}"},"for":{delta:1,paramMin:3,prefixFunc:function(stmtParts,state,tmplName,etc){if(stmtParts[2]!="in"){throw new etc.ParseError(tmplName,state.line,"bad for loop statement: "+stmtParts.join(" "))}var iterVar=stmtParts[1];var listVar="__LIST__"+iterVar;return["var ",listVar," = ",stmtParts[3],";","var __LENGTH_STACK__;","if (typeof(__LENGTH_STACK__) == 'undefined' || !__LENGTH_STACK__.length) __LENGTH_STACK__ = new Array();","__LENGTH_STACK__[__LENGTH_STACK__.length] = 0;","if ((",listVar,") != null) { ","var ",iterVar,"_ct = 0;","for (var ",iterVar,"_index in ",listVar,") { ",iterVar,"_ct++;","if (typeof(",listVar,"[",iterVar,"_index]) == 'function') {continue;}","__LENGTH_STACK__[__LENGTH_STACK__.length - 1]++;","var ",iterVar," = ",listVar,"[",iterVar,"_index];"].join("")}},forelse:{delta:0,prefix:"} } if (__LENGTH_STACK__[__LENGTH_STACK__.length - 1] == 0) { if (",suffix:") {",paramDefault:"true"},"/for":{delta:-1,prefix:"} }; delete __LENGTH_STACK__[__LENGTH_STACK__.length - 1];"},"var":{delta:0,prefix:"var ",suffix:";"},macro:{delta:1,prefixFunc:function(stmtParts,state,tmplName,etc){var macroName=stmtParts[1].split("(")[0];return["var ",macroName," = function",stmtParts.slice(1).join(" ").substring(macroName.length),"{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; "].join("")}},hMacro:{delta:1,prefixFunc:function(stmtParts,state,tmplName,etc){var macroName=stmtParts[1].split("(")[0];return["window['",macroName,"'] = function",stmtParts.slice(1).join(" ").substring(macroName.length),"{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; "].join("")}},"/macro":{delta:-1,prefix:" return _OUT_arr.join(''); };"},"/hMacro":{delta:-1,prefix:" return _OUT_arr.join(''); };"}};kyTemplate.parseTemplate_etc.modifierDef={eat:function(v){return""},escape:function(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},capitalize:function(s){return String(s).toUpperCase()},htmlEntities:function(s){return s.htmlEntitiesDecode()},htmlEntitiesEncode:function(s){return s.htmlEntities()},unescape:function(s){return unescape(s)},"default":function(s,d){return s!=null?s:d},dateFormat:function(s,f){if(s){s=s.replace(new RegExp("[-: ]","gi"),"")}var d=Date.createFrom14C(s);if(d){return(d.format(f))}else{return("")}},numberFormat:function(s,f,p,c){if(s){return(s.toString().numberFormat(f,p,c))}else{return("")}},truncate:function(s,l,d){if(s){return s.truncate(l,d)}else{return("")}},utf8html:function(s){if(s){return s.utf8html()}else{return("")}},nl2li:function(s){if(s){return s.nl2tag("li")}else{return("")}},br_CPF:function(s){if(s){return s.replace(new RegExp("([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{2})"),"$1.$2.$3-$4")}else{return("")}},br_CEP:function(s){if(s){return s.replace(new RegExp("([0-9]{5})([0-9]{3})"),"$1-$2")}else{return("")}},br_phone:function(s){if(s){return s.replace(new RegExp("([0-9]{2})([0-9]{7,8})"),"$1-$2")}else{return("")}},addSlashes:function(s){if(s){return s.addSlashes()}else{return("")}},stripSlashes:function(s){if(s){return s.stripSlashes()}else{return("")}},attFixQuote:function(s){if(s){return s.attFixQuote()}else{return("")}},attAddSlashes:function(s){if(s){return s.attAddSlashes()}else{return("")}},wordWrap:function(s,l,d){if(s){return s.wordWrap(l,d)}else{return("")}}};kyTemplate.parseTemplate_etc.modifierDef.h=kyTemplate.parseTemplate_etc.modifierDef.escape;kyTemplate.parseTemplate_etc.Template=function(tmplName,tmplContent,funcSrc,func,etc){this.process=function(context,flags){if(context==null){context={}}if(context._MODIFIERS==null){context._MODIFIERS={}}if(context.defined==null){context.defined=function(str){return(context[str]!=undefined)}}for(var k in etc.modifierDef){if(context._MODIFIERS[k]==null){context._MODIFIERS[k]=etc.modifierDef[k]}}if(flags==null){flags={}}var resultArr=[];var resultOut={write:function(m){resultArr.push(m)}};try{func(resultOut,context,flags)}catch(e){if(flags.throwExceptions==true){throw e}var result=new String(resultArr.join("")+"[ERROR: template: <pre>"+exceptionDetails(e)+"</pre>]");result.exception=e;return result}return resultArr.join("")};this.name=tmplName;this.source=tmplContent;this.sourceFunc=funcSrc;this.toString=function(){return"kyTemplate.Template ["+tmplName+"]"}};kyTemplate.parseTemplate_etc.ParseError=function(name,line,message){this.name=name;this.line=line;this.message=message};kyTemplate.parseTemplate_etc.ParseError.prototype.toString=function(){return("kyTemplate template ParseError in "+this.name+": line "+this.line+", "+this.message)};var parse=function(body,tmplName,etc){body=cleanWhiteSpace(body);var funcText=["var kyTemplate_Template_TEMP = function(_OUT, _CONTEXT, _FLAGS) { with (_CONTEXT) {"];var state={stack:[],line:1};var endStmtPrev=-1;while(endStmtPrev+1<body.length){var begStmt=endStmtPrev;begStmt=body.indexOf("{",begStmt+1);while(begStmt>=0){var endStmt=body.indexOf("}",begStmt+1);var stmt=body.substring(begStmt,endStmt);var blockrx=stmt.match(/^\{(cdata|minify|eval)/);if(blockrx){var blockType=blockrx[1];var blockMarkerBeg=begStmt+blockType.length+1;var blockMarkerEnd=body.indexOf("}",blockMarkerBeg);if(blockMarkerEnd>=0){var blockMarker;if(blockMarkerEnd-blockMarkerBeg<=0){blockMarker="{/"+blockType+"}"}else{blockMarker=body.substring(blockMarkerBeg+1,blockMarkerEnd)}var blockEnd=body.indexOf(blockMarker,blockMarkerEnd+1);if(blockEnd>=0){emitSectionText(body.substring(endStmtPrev+1,begStmt),funcText);var blockText=body.substring(blockMarkerEnd+1,blockEnd);if(blockType=="cdata"){emitText(blockText,funcText)}else{if(blockType=="minify"){emitText(scrubWhiteSpace(blockText),funcText)}else{if(blockType=="eval"){if(blockText!=null&&blockText.length>0){funcText.push("_OUT.write( (function() { "+blockText+" })() );")}}}}begStmt=endStmtPrev=blockEnd+blockMarker.length-1}}}else{if(body.charAt(begStmt-1)!="$"&&body.charAt(begStmt-1)!="\\"){var offset=(body.charAt(begStmt+1)=="/"?2:1);if(body.substring(begStmt+offset,begStmt+10+offset).search(kyTemplate.parseTemplate_etc.statementTag)==0){break}}}begStmt=body.indexOf("{",begStmt+1)}if(begStmt<0){break}var endStmt=body.indexOf("}",begStmt+1);if(endStmt<0){break}emitSectionText(body.substring(endStmtPrev+1,begStmt),funcText);emitStatement(body.substring(begStmt,endStmt+1),state,funcText,tmplName,etc);endStmtPrev=endStmt}emitSectionText(body.substring(endStmtPrev+1),funcText);if(state.stack.length!=0){throw new etc.ParseError(tmplName,state.line,"unclosed, unmatched statement(s): "+state.stack.join(","))}funcText.push("}}; kyTemplate_Template_TEMP");return funcText.join("")};var emitStatement=function(stmtStr,state,funcText,tmplName,etc){var parts=stmtStr.slice(1,-1).split(" ");var stmt=etc.statementDef[parts[0]];if(stmt==null){emitSectionText(stmtStr,funcText);return }if(stmt.delta<0){if(state.stack.length<=0){throw new etc.ParseError(tmplName,state.line,"close tag does not match any previous statement: "+stmtStr)}state.stack.pop()}if(stmt.delta>0){state.stack.push(stmtStr)}if(stmt.paramMin!=null&&stmt.paramMin>=parts.length){throw new etc.ParseError(tmplName,state.line,"statement needs more parameters: "+stmtStr)}if(stmt.prefixFunc!=null){funcText.push(stmt.prefixFunc(parts,state,tmplName,etc))}else{funcText.push(stmt.prefix)}if(stmt.suffix!=null){if(parts.length<=1){if(stmt.paramDefault!=null){funcText.push(stmt.paramDefault)}}else{for(var i=1;i<parts.length;i++){if(i>1){funcText.push(" ")}funcText.push(parts[i])}}funcText.push(stmt.suffix)}};var emitSectionText=function(text,funcText){if(text.length<=0){return }var nlPrefix=0;var nlSuffix=text.length-1;while(nlPrefix<text.length&&(text.charAt(nlPrefix)=="\n")){nlPrefix++}while(nlSuffix>=0&&(text.charAt(nlSuffix)==" "||text.charAt(nlSuffix)=="\t")){nlSuffix--}if(nlSuffix<nlPrefix){nlSuffix=nlPrefix}if(nlPrefix>0){funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');var s=text.substring(0,nlPrefix).replace("\n","\\n");if(s.charAt(s.length-1)=="\n"){s=s.substring(0,s.length-1)}funcText.push(s);funcText.push('");')}var lines=text.substring(nlPrefix,nlSuffix+1).split("\n");for(var i=0;i<lines.length;i++){emitSectionTextLine(lines[i],funcText);if(i<lines.length-1){funcText.push('_OUT.write("\\n");\n')}}if(nlSuffix+1<text.length){funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');var s=text.substring(nlSuffix+1).replace("\n","\\n");if(s.charAt(s.length-1)=="\n"){s=s.substring(0,s.length-1)}funcText.push(s);funcText.push('");')}};var emitSectionTextLine=function(line,funcText){var endMarkPrev="}";var endExprPrev=-1;while(endExprPrev+endMarkPrev.length<line.length){var begMark="${",endMark="}";var begExpr=line.indexOf(begMark,endExprPrev+endMarkPrev.length);if(begExpr<0){break}if(line.charAt(begExpr+2)=="%"){begMark="${%";endMark="%}"}var endExpr=line.indexOf(endMark,begExpr+begMark.length);if(endExpr<0){break}emitText(line.substring(endExprPrev+endMarkPrev.length,begExpr),funcText);var exprArr=line.substring(begExpr+begMark.length,endExpr).replace(/\|\|/g,"#@@#").split("|");for(var k in exprArr){if(exprArr[k].replace){exprArr[k]=exprArr[k].replace(/#@@#/g,"||")}}funcText.push("_OUT.write(");emitExpression(exprArr,exprArr.length-1,funcText);funcText.push(");");endExprPrev=endExpr;endMarkPrev=endMark}emitText(line.substring(endExprPrev+endMarkPrev.length),funcText)};var emitText=function(text,funcText){if(text==null||text.length<=0){return }text=text.replace(/\\/g,"\\\\");text=text.replace(/\n/g,"\\n");text=text.replace(/"/g,'\\"');funcText.push('_OUT.write("');funcText.push(text);funcText.push('");')};var emitExpression=function(exprArr,index,funcText){var expr=exprArr[index];if(index<=0){funcText.push(expr);return }var parts=expr.split(":");if(parts[0]=="dateFormat"){var parts=[];var p=expr.indexOf(":");if(p>-1){parts[0]=expr.substring(0,p);parts[1]=expr.substring(p+1)}else{parts[0]=expr}}funcText.push('_MODIFIERS["');funcText.push(parts[0]);funcText.push('"](');emitExpression(exprArr,index-1,funcText);if(parts.length>1){funcText.push(",");funcText.push(parts[1]);if(parts.length>2){funcText.push(",");funcText.push(parts[2])}}funcText.push(")")};var cleanWhiteSpace=function(result){result=result.replace(/\t/g,"    ");result=result.replace(/\r\n/g,"\n");result=result.replace(/\r/g,"\n");result=result.replace(/^(\s*\S*(\s+\S+)*)\s*$/,"$1");return result};var scrubWhiteSpace=function(result){result=result.replace(/^\s+/g,"");result=result.replace(/\s+$/g,"");result=result.replace(/\s+/g," ");result=result.replace(/^(\s*\S*(\s+\S+)*)\s*$/,"$1");return result};kyTemplate.parseDOMTemplate=function(elementId,optDocument,optEtc){if(optDocument==null){optDocument=document}var element=optDocument.getElementById(elementId);var content=element.value;if(content==null){content=element.innerHTML}content=content.replace(/&lt;/g,"<").replace(/&gt;/g,">");return kyTemplate.parseTemplate(content,elementId,optEtc)};kyTemplate.processDOMTemplate=function(elementId,context,optFlags,optDocument,optEtc){return kyTemplate.parseDOMTemplate(elementId,optDocument,optEtc).process(context,optFlags)}})();ky_wappObj.prototype.addParam2URL=function(A,B){if(A.indexOf("?")>-1){A+="&"+B}else{A+="?"+B}return A};ky_wappObj.prototype.getContainerValue=function(A){if(typeof (this.arrContainer[A])!="undefined"){return(this.arrContainer[A])}else{return null}};ky_wappObj.prototype.setContainerValue=function(A,B){this.arrContainer[A]=B};ky_wappObj.prototype.resetContainerValue=function(A,B){this.arrContainer=new Object()};ky_wappObj.prototype.getParam=function(){var C="";var B=window.location.href;var A=this._parseParam(B);C=this.getFormParam(this.formEle,A);return C};ky_wappObj.prototype.getURLParams=function(){var B=window.location.href;var A=this._parseParam(B);return A};ky_wappObj.prototype.getFormParamHash=function(A,D,C){var F="";if(D==null){D=new Object()}if(A){for(var B=0;B<A.elements.length;B++){if(document.all){if((A.elements[B].type=="textarea")&&(A.elements[B].getAttribute("_tpl")=="yes")){continue}}if((A.elements[B].type=="checkbox")||(A.elements[B].type=="radio")){if(A.elements[B].checked){D[A.elements[B].name]=escape(encodeURI(A.elements[B].value));if(C){C[A.elements[B].name]=escape(encodeURI(A.elements[B].value))}}}else{if(A.elements[B].type=="select-multiple"){for(var E=0;E<A.elements[B].options.length;E++){if(A.elements[B].options[E].selected){D[A.elements[B].name]=escape(encodeURI(A.elements[B].options[E].value))}}}else{D[A.elements[B].name]=escape(encodeURI(A.elements[B].value));if(C){C[A.elements[B].name]=escape(encodeURI(A.elements[B].value))}}}}}return D};ky_wappObj.prototype.getFormParam=function(A,C,B){C=this.getFormParamHash(A,C,B);param=this._hashParam2str(C);return param};ky_wappObj.prototype._parseParam=function(C){var D,B,A,E=new Array();var F="";if(C.indexOf("?")>-1){F=C.substr(C.indexOf("?")+1)}else{F=C}A=F.split("&");for(D=0;D<A.length;D++){B=A[D].split("=");if(B[0]!=""){E[B[0]]=B[1]}}return E};ky_wappObj.prototype._hashParam2str=function(C,B){B=(B==null)?false:B;var A,D="";C=ky_flattenObjectProperties(C);for(A in C){if(B){C[A]=encodeURIComponent(C[A])}if(D!=""){D=D+"&"}D=D+A+"="+C[A]}return D};ky_wappObj.prototype.guessSiblingWappID=function(A){var C=this.formID.lastIndexOf("_");var B=A.lastIndexOf("_");A=A.substring(0,B)+"_"+this.formID.substring(C+1,this.formID.length);return(A)};ky_wappObj.prototype.getSiblingWapp=function(A){var D;var C=null;var B=ky_wappManager.getFormIndexByID(A);if(B>-1){C=ky_wappManager.arrInst[B]}else{D=this.guessSiblingWappID(A);B=ky_wappManager.getFormIndexByID(D);if(B>-1){C=ky_wappManager.arrInst[B]}}return(C)};ky_wappObj.prototype.evalJSONProperty=function(E,G,B,A,F){var C=null;if((typeof (E)=="undefined")||(E==null)){return null}try{if(typeof (E[G])=="function"){C=E[G].call(this,B,A,F)}else{if(typeof (E[G])!="undefined"){C=E[G]}}}catch(D){}return C};ky_componentObj.prototype.evalJSONProperty=ky_wappObj.prototype.evalJSONProperty;ky_wappObj.prototype.prepareParamForPost=function(A,E,H){var D,C=0,B=["post","formpost"];if(H){B=H}var G={};for(D=0;D<B.length;D++){switch(B[D].toLowerCase()){case"formpost":G=ky_mergeObjects(G,this.getFormParamHash(A,{},this.hookDATA));break;case"post":G=ky_mergeObjects(G,E);break;case"get":G=ky_mergeObjects(G,this.getURLParams());break}}var F=this._hashParam2str(G);return(F)};ky_wappObj.prototype.action=function(D,G,C){if(this.isBlocked){alertDebug("**** wapplication ["+this.formID+"] is blocked","red");return }var A=false;var E=false;this.actionHooks=new Array();var B=this.inpuMask.DATA[this.currentFace][G];if(!B){if((typeof (G)=="object")&&(G!=null)){B=this.inpuMask.DATA[this.currentFace][G[0]]}else{if(typeof (G)=="undefined"){if((this.inpuMask.DATA[this.currentFace].action)&&(this.inpuMask.DATA[this.currentFace].action.length>0)){B=this.inpuMask.DATA[this.currentFace][this.inpuMask.DATA[this.currentFace].action[0]]}}}}if((B)&&(typeof (B.noValidate)!="undefined")){A=this.evalJSONProperty(B,"noValidate")}this.faces[this.currentFace].buttonEle=D;if(B){E=this.evalJSONProperty(B,"resetValidate")}if(E){this.resetValidateFace()}if((!A||typeof (A)=="object")&&(!this.validateFace(A))){return false}this.actionFace=this.currentFace;if(!G){var F=this.inpuMask.DATA[this.currentFace];if((F.action)&&(F.action.length>0)){this.actionLOD(-1,false,G,C)}}else{if(typeof (G)=="object"){this.actionHooks=G;if((this.actionHooks)&&(this.actionHooks.length>0)){this.multiActionLOD(-1,false,G,C)}}else{this.triggerHook(G,D,C,"nothingTodo",-1,"checkHookAction",false)}}};ky_wappObj.prototype.delayedAction=function(A,C,D,B){var E=ky_setInterval(this._meGlobal+".action("+C+',"'+D+'","'+B+'")',A)};ky_wappObj.prototype.triggerSTACK=new Array();ky_wappObj.prototype.nothingTodo=function(H,A,F,D,B){alertDebug("nothingTodo : ["+H+"] ["+this.currentFace+"] ["+F+"]["+A+"] :");try{if(this.hookResponse.loadDone==true){ky_clearInterval(this.xtimer)}else{if(this.hookResponse.loadDone==false){return }}}catch(G){ky_clearInterval(this.xtimer)}var E=new Object();try{E=this.inpuMask.DATA[this.currentFace][F].response}catch(G){}alertDebug("nothingTodo : hookResponse=["+E+"] ");if(typeof (E)!="object"){E=new Object()}try{if((typeof (this.hookResponse)!="undefined")&&(this.hookResponse.DATA)&&(this.hookResponse.DATA.response==1)){alertDebug("nothingTodo : true SERVER=["+E+"] ");this.hookResponse=E["true"]}else{if(!A&&B!=null){alertDebug("nothingTodo : "+B+" CLIENT=["+E+"] ");this.hookResponse=E[B]}else{alertDebug("nothingTodo : false=["+E+"] ");this.hookResponse=E["false"]}}}catch(G){alertDebug("nothingTodo : exception="+G.message,"red");alertDebug("nothingTodo : catch=["+E+"] ","yellow");this.hookResponse=E["false"]}if(typeof (this.hookResponse)!="object"){this.hookResponse=new Array()}var C;if(this.hookResponse.length>0){this.triggerHook(this.hookResponse[0],this.faces[this.currentFace].buttonEle,D,"nothingTodo",-1,"checkHookAction",false)}};ky_wappObj.prototype.actionLOD=function(C,A,E,B){try{alertDebug("actionLOD ["+C+"] ["+E+"] :"+B);if(this.actionFace==this.currentFace){var D=this.inpuMask.DATA[this.currentFace];C++;if(C<D.action.length){this.triggerHook(D.action[C],this.faces[this.currentFace].buttonEle,B,"actionLOD",C,"checkHookAction",A)}}}catch(F){alertDebug("***** Exception actionLOD ["+C+"] ["+E+"]["+this.currentFace+"] :"+D.action,"red")}};ky_wappObj.prototype.multiActionLOD=function(C,A,E,B){alertDebug("multiActionLOD ["+C+"] ["+E+"] :"+B);try{alertDebug("multiActionLOD 1["+C+"] ["+E+"] :"+B);if(this.actionFace==this.currentFace){var D=this.inpuMask.DATA[this.currentFace];var G=this.actionHooks;C++;if(C<G.length){this.triggerHook(G[C],this.faces[this.currentFace].buttonEle,B,"multiActionLOD",C,"checkHookAction",A)}}}catch(F){alertDebug("***** Exception multiActionLOD ["+C+"] ["+E+"]["+this.currentFace+"] :"+G,"red")}};ky_wappObj.prototype.blockNeededWapps=function(C){alertDebug("---- blockNeededWapps ["+C+"]","red");if(!C){return }var A=this.inpuMask.DATA[this.currentFace][C];if(A){if(A.wappBlock){var B,D;for(B=0;B<A.wappBlock.length;B++){D=this.getSiblingWapp(A.wappBlock[B]);if(D){D.block()}if(!this.wappBlocked[C]){this.wappBlocked[C]=new Array()}this.wappBlocked[C][B]=A.wappBlock[B]}}}};ky_wappObj.prototype.unblockNeededWapps=function(C){alertDebug("---- unblockNeededWapps ["+C+"]","red");if(!C){return }var A=this.inpuMask.DATA[this.currentFace][C];if(A){if(A.wappBlock){var B,D;for(B=0;B<A.wappBlock.length;B++){D=this.getSiblingWapp(A.wappBlock[B]);if(D){D.unblock()}}this.wappBlocked[C]=null}}};ky_wappObj.prototype.triggerHook=function(hook,buttonEle,strJSON,callbackMethod,callbackIndex,responseMethodName,isServerHook){var face=this.inpuMask.DATA[this.currentFace];var hookNAME;if(face[hook]){hookNAME=(face[hook].hook?face[hook].hook:hook);if(typeof (this["hook"+(face[hook].hook?face[hook].hook:hook)])=="function"){if(face[hook].type=="server"){if(!isServerHook){alertDebug("function server ["+callbackMethod+"]["+responseMethodName+"] triggerHook:"+hookNAME+" hook="+hook+" respo:"+response);this.blockNeededWapps(hook);var response=this["hook"+hookNAME](hook,hookNAME,this.formEle,buttonEle,strJSON,callbackIndex,responseMethodName,true)}else{ky_wappMsg[this.cName+"-triggerHook"]="skipping hook [hook"+hookNAME+"]. only 1 server side hook is allowed"}}else{var response=this["hook"+hookNAME](hook,hookNAME,this.formEle,buttonEle,strJSON,callbackIndex,responseMethodName,isServerHook);if(typeof (response)=="undefined"){response=null}alertDebug("function client ["+callbackMethod+"]["+responseMethodName+"] triggerHook:"+hookNAME+" hook="+hook+" respo:"+response);this[callbackMethod](callbackIndex,isServerHook,hook,strJSON,response)}}else{var _me=null;eval("_me = "+this._meGlobal);lod.loadJSScript(this.getHooksURL(face[hook].loc)+"hook"+hookNAME+".js",hookNAME,function(){_me.triggerHook(hook,buttonEle,strJSON,callbackMethod,callbackIndex,responseMethodName,isServerHook)});return }}else{alertDebug(this.formID+"-triggerHook = hook ["+hook+"], does not exist in faceJSON: "+this.currentFace,"red");ky_wappMsg[this.cName+"-triggerHook"]="hook ["+hook+"], does not exist in faceJSON: "+this.currentFace}};ky_wappObj.prototype.runHook=function(postParam,hook,hookName,callbackIndex,responseMethodName,isServerHook){postParam=this.assurePostParam(postParam,hook,hookName);var hookURL=this.getHookURL(hook,hookName);if(hookURL==""){return }var proxy,protocol=this.getTransProtocol(hookURL);if(protocol=="ky_SWgetFile"){if(proxy=this.checkProxy()){var URL=this.getHookURL(hook,hookName,true);var hookURL=_ky_wapp_folder+"ky_wapp."+proxy+"?proxy=1&hp="+URL;var protocol="ky_getFile"}else{this.faces[this.currentFace].async=true}}var method="post";try{if(this.inpuMask.DATA[this.currentFace][hook]["cache"]){method="postASget";alertDebug("runHook Method as "+method,"white")}}catch(e){alertDebug("*** runHook Method Exception "+e.message,"red")}this.hookResponse=eval("new "+protocol+'("json", "'+method+'")');this.hookResponse.async=this.faces[this.currentFace].async;this.hookResponse._meGlobal=this._meGlobal+".hookResponse";this.hookResponse.initialize(hookURL,postParam);if(this.faces[this.currentFace].async){this.xtimer=ky_setInterval(this._meGlobal+"."+responseMethodName+"('"+hook+"', "+callbackIndex+", "+isServerHook+")",30)}else{this[responseMethodName](hook,callbackIndex,isServerHook)}};ky_wappObj.prototype.checkHookAction=function(B,C,A){this.checkHook(B,C,A,"actionLOD")};ky_wappObj.prototype.checkHookResponse=function(B,C,A){this.checkHook(B,C,A,"checkHookResponseLOD")};ky_wappObj.prototype.checkResponseMode=function(B){var A="NEW";if(typeof (this.inpuMask.DATA[this.currentFace][B].responseMode)=="string"){A=this.inpuMask.DATA[this.currentFace][B].responseMode}alertDebug(this.currentFace+" | "+B+" | "+A,"yellow");if(A=="NEW"){this.hookDATA=this.hookResponse.DATA.msg}if(A=="APPEND"){var C;for(C in this.hookResponse.DATA.msg){this.hookDATA[C]=this.hookResponse.DATA.msg[C]}}};ky_wappObj.prototype.checkHook=function(D,E,A,B){if(this.hookResponse.loadDone){ky_clearInterval(this.xtimer)}else{return }alertDebug("checkHook ["+this.currentFace+"] for ["+D+"]");this.unblockNeededWapps(D);this.faces[this.currentFace].responseDATA=this.hookResponse.DATA;if(A){this.checkResponseMode(D)}var C=this.inpuMask.DATA[this.currentFace][D].response;this.gotoNextResponseHooks(C);alertDebug("checkHook ["+D+"]["+this.hookResponse.length+"]["+B+"]");if(this.hookResponse.length>0){this.checkHookResponseLOD(-1,false,B)}else{this[B](E,A,D,null)}};ky_wappObj.prototype.checkHookResponseLOD=function(D,A,F,C,B){D++;if(D<this.hookResponse.length){this.triggerHook(this.hookResponse[D],this.faces[this.currentFace].buttonEle,null,"checkHookResponseLOD",D,"checkHookResponse",A)}else{var E=this.inpuMask.DATA[this.currentFace];if((B!=null)&&(E[F])&&(E[F].response)&&(E[F].response[B])&&(E[F].response[B].length>0)){this.triggerHook(E[F].response[B][0],null,C,"checkHookResponseLOD",--D,"checkHookResponse",A)}}};ky_wappObj.prototype.assurePostParam=function(E,D,A){var F;if(window.location.href.indexOf("?")>-1){F=window.location.href.substr(0,window.location.href.indexOf("?"))}else{F=window.location.href}var C="hookJSON="+this.formID+"&face="+this.currentFace+"&hook="+D+"&hookName="+A;C+="&ky_wkey="+this.wKey;C+="&siteURL="+_ky_site_folder;C+="&ky_referer="+F;C+="&ky_fullReferer="+escape(window.location.href);var B=(document.all)?document.charset:document.characterSet;B=B.toLowerCase();C+="&ky_encoding="+B;if(E==""){E+=""+C}else{if((E.substr(E.lenght-1))=="&"){E+=C}else{E+="&"+C}}return E};ky_wappObj.prototype.getInpuMask=function(){if(this.inpuMask.loadDone){ky_clearInterval(this.xtimer)}else{return }this.assurance();if(this.inpuMask.DATA.startup){this.currentFace=this.inpuMask.DATA.startup;this.getFace()}else{ky_wappMsg[this.cName+"-getInpuMask"]="Error in faceJSON, unable to find a startup face"}};ky_wappObj.prototype.getFace=function(A){alertDebug("getFace: "+this.currentFace);if(this.inpuMask.DATA[this.currentFace]){this.faces[this.currentFace]=new ky_faceObj(this._meGlobal+".faces["+this.currentFace+"]");this.faces[this.currentFace].faceIndex=-1;this.faces[this.currentFace].async=true;for(var B=0;B<this.formEle.childNodes.length;B++){if(this.formEle.childNodes[B].id==this.currentFace){this.faces[this.currentFace].faceEle=this.formEle.childNodes[B];break}}if(!this.faces[this.currentFace].faceEle){ky_wappMsg[this.cName+"-getFace"]="Error in wapplication form, face ["+this.currentFace+"] is not there";return }else{this.initializeFace(A)}}else{alertDebug("*** getFace: Error in faceJSON ["+this._meGlobal+"], face ["+this.currentFace+"] is not there","red");ky_wappMsg[this.cName+"-getFace"]="Error in faceJSON, face ["+this.currentFace+"] is not there";return false}return true};ky_wappObj.prototype.initializeFace=function(A){var B=this.inpuMask.DATA[this.currentFace];this.actionFace=this.currentFace;if((B.initialize)&&(B.initialize.length>0)){this.initializeFaceLOD(-1,false,null,A,null)}else{this.renderFace(null)}};ky_wappObj.prototype.initializeFaceLOD=function(D,A,F,C,B){var E=this.inpuMask.DATA[this.currentFace];alertDebug("initializeFaceLOD:currentFace="+this.currentFace+"actionFace="+this.actionFace+" initializeIndex:"+D+" isServerHook:"+A+" strJSON:"+C+" hook:"+F+" response:"+B,"orange");if(E.initialize){D++;if(D<E.initialize.length){this.triggerHook(E.initialize[D],null,C,"initializeFaceLOD",D,"renderFaceAfterInitializeServerHook",A)}else{if((B!=null)&&(E[F])&&(E[F].response)&&(E[F].response[B])&&(E[F].response[B].length>0)){this.triggerHook(E[F].response[B][0],null,C,"initializeFaceLOD",--D,"renderFaceAfterInitializeServerHook",A)}else{this.renderFace(null)}}}};ky_wappObj.prototype.renderFaceAfterInitializeServerHook=function(D,B,A){if(this.hookResponse.loadDone){ky_clearInterval(this.xtimer)}else{return }this.unblockNeededWapps(D);this.faces[this.currentFace].responseDATA=this.hookResponse.DATA;this.checkResponseMode(D);var C=this.inpuMask.DATA[this.currentFace][D].response;if(C){this.gotoNextResponseHooks(C);if(this.hookResponse.length>0){this.checkHookInitializeResponseLOD(-1,false,D,null,null)}}if(B==200){this.renderFace(null)}else{this.initializeFaceLOD(B,A,D,null,null)}};ky_wappObj.prototype.gotoNextResponseHooks=function(A){if(this.hookResponse.DATA.response==1){this.hookResponse=this.getNextFlow(A,"true")}else{this.hookResponse=this.getNextFlow(A,"false")}};ky_wappObj.prototype.getNextFlow=function(D,B){var C=null;if(typeof (this.hookResponse.DATA.state)=="object"){C=this.hookResponse.DATA.state.hookName}var A=[];if((D[B])&&(C)&&(D[B][C])){A=D[B][C];alertDebug("getNextFlow["+B+"]["+C+"]:"+ky_dumpDebug(A),"yellow")}else{if((D[B])&&(D[B]["_DEFAULT_"])){A=D[B]["_DEFAULT_"];alertDebug("getNextFlow["+B+"][_DEFAULT_]:"+ky_dumpDebug(A),"yellow")}else{if(D[B]){A=D[B];alertDebug("getNextFlow["+B+"]:"+ky_dumpDebug(A),"yellow")}else{alertDebug("getNextFlow:"+ky_dumpDebug(A),"yellow")}}}if(typeof (A.length)!="number"){A=[]}return(A)};ky_wappObj.prototype.checkHookInitializeResponseLOD=function(D,A,F,C,B){alertDebug("checkHookInitializeResponseLOD ["+this.currentFace+"] ["+F+"] = ["+B+"]");D++;if(D<this.hookResponse.length){this.triggerHook(this.hookResponse[D],this.faces[this.currentFace].buttonEle,null,"checkHookInitializeResponseLOD",D,"renderFaceAfterInitializeServerHook",A)}else{var E=this.inpuMask.DATA[this.currentFace];if((B!=null)&&(E[F])&&(E[F].response)&&(E[F].response[B])&&(E[F].response[B].length>0)){this.triggerHook(E[F].response[B][0],null,C,"checkHookInitializeResponseLOD",--D,"renderFaceAfterInitializeServerHook",A)}}};ky_wappObj.prototype.renderFace=function(tempTEXT){this.status="rendering";var faceEle=this.faces[this.currentFace].faceEle;if(this.hookDATA!=""){if(tempTEXT==null){this.getfaceTemplate(faceEle,this.currentFace,"renderFace");return }if(this.hookDATA&&this.hookDATA.render){if(typeof (this["render"+this.hookDATA.render])=="function"){this["render"+this.hookDATA.render](tempTEXT,faceEle);this.status="ready"}else{var _me=null;eval("_me = "+this._meGlobal);lod.loadJSScript(this.getRendersURL(this.hookDATA.renderLoc)+"render"+this.hookDATA.render+".js",this.hookDATA.render,function(){_me.renderFace(tempTEXT)});return }}else{if(this.faces[this.currentFace].render){this.hookDATA.render=this.faces[this.currentFace].render.name;this.hookDATA.renderLoc=this.faces[this.currentFace].render.loc;this.renderFace(tempTEXT);return }this.runkyTemplate(tempTEXT,faceEle,this.hookDATA,true)}}else{if((faceEle)&&(faceEle.innerHTML.indexOf("${")>-1)){ky_wappMsg[this.cName+"-renderFace"]="Warning in face ["+this.currentFace+"], no hookDATA"}}var bDisplay=true;if(!faceEle){ky_wappMsg[this.cName+"-renderFace-"+this.formID+"-"+this.currentFace+"-faceEle"]="faceEle  ["+this.currentFace+"] is["+typeof (faceEle)+"]";this.status="ready";return }var hasDollar=(faceEle.innerHTML.indexOf("${")>-1);if((tempTEXT==null)&&(hasDollar)&&(typeof (this.hookDATA)=="string")){bDisplay=false}alertDebug("faceEle:"+faceEle.id+" currentFace:"+this.currentFace+" hasDollar:"+hasDollar+" typeof hookDATA:"+typeof (this.hookDATA)+" tempTEXT:"+tempTEXT+" bDisplay:"+bDisplay);if(bDisplay){faceEle.style.display="block";this.initializeFields()}this.status="ready"};ky_wappObj.prototype.initializeFields=function(){alertDebug("initializeFields");var A=this.inpuMask.DATA[this.currentFace].fields;var H,F;var E=0;if(A){var C;for(E=0;E<A.length;E++){if(this.formEle.elements[A[E].field]){H=A[E];F=this.formEle.elements[A[E].field];if(document.all){if(!F.name){F.name=F.id;F.value=""}}if(H.enterClicked){F.onkeypress=function(I){if(document.all){I=window.event}if(I.keyCode==13){ky_wappManager.action(F,H.enterClicked)}}}var B=null;if(H.defaultValue){if(typeof (H.defaultValue)=="function"){B=H.defaultValue()}else{B=H.defaultValue}}else{if(H.defaultCookie){B=unescape(getCookie(H.defaultCookie))}else{if(H.defaultGet){B=ky_getURLParam(H.defaultGet)}}}if(B!=null){F.value=B}else{try{var D=F.getAttribute("ky_default");B=D;if(B!=null){F.value=B}if((B==null)&&(F.value!="")){B=F.value}}catch(G){}}}else{ky_wappMsg[this.cName+"-initializeFields"]="field ["+A[E].field+"] does not exist in form: "+this.formID}C=null;if(A[E]["component"]){C=A[E].component}if(C){alertDebug("**** field ["+E+"] component.serverLoad:"+C.serverLoad,"white");if((C.serverHook)&&(C.serverLoad!=false)){A[E]._defValue=B;this.loadFieldValuesFromServer(E)}else{if(C.clientHook){A[E]._defValue=B}else{if(C.name){A[E]._defValue=B;this.initializeFieldRows(A,E)}}}}}}return true};ky_wappObj.prototype.loadFieldValuesFromServer=function(B){var A=this.inpuMask.DATA[this.currentFace].fields;alertDebug("loadFieldValuesFromServer ["+this.currentFace+"] fields["+B+"] :"+A[B].field);if(this.inpuMask.DATA[this.currentFace].fields[B].hookResponse){this.checkFieldValuesFromServerResponse(A[B].component.serverHook,B,true,this.currentFace)}else{var C="";if(A[B].component.post){C=this._hashParam2str(A[B].component.post);alertDebug("Sending post param for ["+A[B].field+"] component:"+C,"orange")}this.inpuMask.DATA[this.currentFace].fields[B].hookResponse=this.runFieldHook(C,A[B].component.serverHook,"AnyHookName_"+A[B].field,B,"checkFieldValuesFromServerResponse",true,this._meGlobal+".inpuMask.DATA['"+this.currentFace+"'].fields["+B+"].hookResponse")}};ky_wappObj.prototype.checkFieldValuesFromServerResponse=function(hook,i,isServerHook,rFace){var zFace=this.currentFace;var fields=this.inpuMask.DATA[zFace].fields;if(typeof (fields)=="undefined"){alertDebug("checkFieldValuesFromServerResponse:: fields is undefined","yellow");return }if(typeof (fields.length)=="undefined"){alertDebug("checkFieldValuesFromServerResponse:: fields.length is undefined","red");return }if(typeof (fields[i])=="undefined"){alertDebug("checkFieldValuesFromServerResponse:: fields[i] is undefined","red");return }if(typeof (fields[i].hookResponse)=="undefined"){alertDebug("checkFieldValuesFromServerResponse::["+zFace+"] ["+rFace+"]["+fields[i].field+"]  fields["+i+"].hookResponse is undefined","yellow");var _badField=null;var _fieldMeGlobal=this._meGlobal+".inpuMask.DATA['"+rFace+"'].fields["+i+"]";eval("_badField = "+_fieldMeGlobal);if(_badField.hookResponse.xtimer!=null){ky_clearInterval(_badField.hookResponse.xtimer);_badField.hookResponse.xtimer=null;alertDebug("checkFieldValuesFromServerResponse::["+zFace+"] ["+fields[i].field+"]["+i+"].hookResponse WAS CLEARED!!","red")}return }alertDebug("checkFieldValuesFromServerResponse ["+hook+"]["+i+"]["+fields[i].field+"]["+isServerHook+"]:");if(fields[i].hookResponse.loadDone){if(fields[i].hookResponse.xtimer!=null){ky_clearInterval(fields[i].hookResponse.xtimer);fields[i].hookResponse.xtimer=null;if(fields[i].component.callBack){fields[i].hookResponse.DATA.msg=fields[i].component.callBack(fields[i].hookResponse.DATA.msg)}}}else{alertDebug("checkFieldValuesFromServerResponse:: not loaded");return }var x;this.initializeFieldRows(fields,i);fields[i].componentObj.onDataCompleted()};ky_wappObj.prototype.initializeFieldRows=function(B,C){var F=this.hookDATA.rows;try{if(B[C].component.dataLocation){F=F[B[C].component.dataLocation];alertDebug("*** valid datalocation:"+B[C].component.dataLocation,"red")}}catch(E){}if(F){var A,D;if((typeof (F.length)=="number")&&(F.length>1)){for(A=0;A<F.length;A++){if(typeof (F[A][B[C].field])!="undefined"){D=F[A][B[C].field]}else{D=B[C]._defValue}this.renderComponent(B[C],D,A,F[A],C)}}else{if(typeof (F.length)=="number"){try{if(typeof (F[0][B[C].field])!="undefined"){D=F[0][B[C].field]}else{D=B[C]._defValue}}catch(E){D=B[C]._defValue}this.renderComponent(B[C],D,null,F[0],C)}else{if(typeof (F[B[C].field])!="undefined"){D=F[B[C].field]}else{D=B[C]._defValue}this.renderComponent(B[C],D,null,F,C)}}}else{this.renderComponent(B[C],B[C]._defValue,null,null,C)}};ky_wappObj.prototype.renderComponent=function(J,K,D,F,G){var A,H,B,K,C=null;A=J.component.name;try{H=J.hookResponse.DATA.msg.rows}catch(I){}if(J.component.settings){C=J.component.settings}B=J.field;if((A==null)||(B==null)){alertDebug("*** renderComponent:"+A+","+B+","+K+",{"+F+"},{"+H+"},{"+C+"}")}J.componentObj=new ky_componentObj(this._meGlobal+".inpuMask.DATA['"+this.currentFace+"'].fields["+G+"].componentObj");J.componentObj.setWKey(this.wKey);if(typeof (J.componentObj["component"+A])=="function"){J.componentObj["component"+A](B,K,D,H,F,C)}else{var E=this;lod.loadJSScript(this.getComponentsURL(null)+"component"+A+".js","component"+A,function(){try{J.componentObj["component"+A](B,K,D,H,F,C)}catch(L){}})}};ky_wappObj.prototype.runFieldHook=function(postParam,hook,hookName,callbackIndex,responseMethodName,isServerHook,_meGlobal){postParam=this.assurePostParam(postParam,hook,hookName);var hookURL=this.getHookURL(hook,hookName);if(hookURL==""){return }var proxy,protocol=this.getTransProtocol(hookURL);if(protocol=="ky_SWgetFile"){if(proxy=this.checkProxy()){var URL=this.getHookURL(hook,hookName,true);var hookURL=_ky_wapp_folder+"ky_wapp."+proxy+"?proxy=1&hp="+URL;var protocol="ky_getFile"}else{this.faces[this.currentFace].async=true}}var hookResponse=eval("new "+protocol+'("json", "post")');eval(_meGlobal+" = hookResponse");hookResponse.async=this.faces[this.currentFace].async;hookResponse._meGlobal=_meGlobal;hookResponse.initialize(hookURL,postParam);if(this.faces[this.currentFace].async){if(hookResponse.xtimer){ky_clearInterval(hookResponse.xtimer)}hookResponse.xtimer=ky_setInterval(this._meGlobal+"."+responseMethodName+"('"+hook+"', "+callbackIndex+", "+isServerHook+", '"+this.currentFace+"')",300)}else{this[responseMethodName](hook,callbackIndex,isServerHook)}return hookResponse};window.arrTimers=new Object();ky_wappObj.prototype.fieldAction=function(C,F,B){var A=this.inpuMask.DATA[this.currentFace].fields;for(var D=0;D<A.length;D++){if(A[D].field==F){alertDebug("FOUND @ fieldAction v2.1:"+F+" with i="+D,"red");break}}A[D].component.post=B.post;if(this.inpuMask.DATA[this.currentFace].fields[D].hookResponse){if(typeof (this.inpuMask.DATA[this.currentFace].fields[D].hookResponse.xtimer)=="number"){ky_clearInterval(this.inpuMask.DATA[this.currentFace].fields[D].hookResponse.xtimer)}this.inpuMask.DATA[this.currentFace].fields[D].hookResponse=false}try{if(typeof (A[D].componentObj)!="undefined"){A[D].componentObj.onDataLoading()}}catch(E){alertDebug(E.message,"red")}this.loadFieldValuesFromServer(D)};function ky_wappObj(A){this.cName="ky_wappObj";this._meGlobal=A;this.iIndex=-1;this.xtimer=null;this.faces=new Object();this.arrContainer=new Object();this.status="ready";this.actionFace=null;this.isBlocked=false;this.wappBlocked=new Object()}ky_wappObj.prototype.block=function(){alertDebug("--- blocking ["+this.formID+"]","red");this.isBlocked=true};ky_wappObj.prototype.unblock=function(){alertDebug("--- unblocking ["+this.formID+"]","red");this.isBlocked=false};ky_wappObj.prototype.start=function(A,B){this.formEle=A;this.formID=B;this.inpuMask=new ky_getFile("json");this.inpuMask._meGlobal=this._meGlobal+".inpuMask";this.inpuMask.initialize(_ky_wapp_folder+"faceJSON/"+this.formID+".js");this.hookDATA="";this.xtimer=ky_setInterval(this._meGlobal+".getInpuMask()",30)};ky_wappObj.prototype.startNF=function(B,A){this.formID=B;this.formEle=null;this.inpuMask=new ky_getFile("json");this.inpuMask.async=false;this.inpuMask._meGlobal=this._meGlobal+".inpuMask";this.inpuMask.initialize(_ky_wapp_folder+"faceJSON/"+this.formID+".js");this.hookDATA="";if(this.inpuMask.DATA.startup){this.currentFace=this.inpuMask.DATA.startup;this.faces[this.currentFace]=new ky_faceObj(this._meGlobal+".faces["+this.currentFace+"]");this.faces[this.currentFace].faceIndex=-1;this.faces[this.currentFace].async=false;this.action(null,null,A,false)}else{ky_wappMsg[this.cName+"-getInpuMaskNF"]="Error in faceJSON, unable to find a startup face"}};ky_wappObj.prototype.getInpuMaskNF=function(A){if(this.inpuMask.loadDone){ky_clearInterval(this.xtimer)}else{return }this.assurance();if(this.inpuMask.DATA.startup){this.currentFace=this.inpuMask.DATA.startup;this.faces[this.currentFace]=new ky_faceObj(this._meGlobal+".faces["+this.currentFace+"]");this.faces[this.currentFace].faceIndex=-1;this.action(null,null,A)}else{ky_wappMsg[this.cName+"-getInpuMaskNF"]="Error in faceJSON, unable to find a startup face"}};ky_wappObj.prototype.getfaceTemplate=function(A,B,F){var D;D=document.getElementById(this.formID+"_"+B);if(D){}else{D=document.createElement("TEXTAREA");D.id=this.formID+"_"+B;D.name=this.formID+"_"+B;D.style.display="none";D.setAttribute("_tpl","yes");if(document.all){document.forms[this.formID].appendChild(D)}else{document.body.appendChild(D)}if(document.all){var E;E=A.innerHTML;E=this.kyTemplateFakeIEBug(E);E=unescape(E);D.value=E}else{D.value=unescape(A.innerHTML)}}var C=this.inpuMask.DATA[this.currentFace];if(C.experiment){if(C.experiment.method){this.runExperiment(C.experiment,F,this.formID+"_"+B)}}else{this[F](D)}};ky_wappObj.prototype.runExperiment=function(experiment,callback,tempTEXTID){var experimentURL=this.getExperimentURL();if(experimentURL==""){return }var proxy,protocol=this.getTransProtocol(experimentURL);if(protocol=="ky_SWgetFile"){if(proxy=this.checkProxy()){var URL=this.getExperimentURL(true);var experimentURL=_ky_wapp_folder+"ky_wapp."+proxy+"?proxy=1&hp="+URL;var protocol="ky_getFile"}}var postParam="loc="+experiment.loc+"&method="+experiment.method;postParam+="&ky_wkey="+this.wKey;postParam+="&siteURL="+_ky_site_folder;postParam+="&ky_referer="+window.location.href.substr(0,window.location.href.indexOf("?"));this.experimentResponse=eval("new "+protocol+'("json", "post")');this.experimentResponse._meGlobal=this._meGlobal+".experimentResponse";this.experimentResponse.initialize(experimentURL,postParam);this.xtimer=ky_setInterval(this._meGlobal+".experimentCallBack('"+callback+"', '"+tempTEXTID+"')",30)};ky_wappObj.prototype.experimentCallBack=function(C,A){if(this.experimentResponse.loadDone){ky_clearInterval(this.xtimer)}else{return }var B=document.getElementById(A);B.value=this.experimentResponse.DATA.HTML.htmlEntitiesDecode();this[C](B)};ky_wappObj.prototype.getJSURL=function(B){var C=document.getElementById("_ky_wapp_ro");if(C){var A=C.src}else{return""}A=A.replace("js/ky_wapplication.js",B);return A};ky_wappObj.prototype.getRendersURL=function(A){if(A){return(_ky_wappServ_url+"js/client/"+A+"renders/")}else{return(_ky_wappServ_url+"js/renders/")}};ky_wappObj.prototype.getComponentsURL=function(A){if(A){return(_ky_wappServ_url+"js/client/"+A+"components/")}else{return(_ky_wappServ_url+"js/components/")}};ky_wappObj.prototype.getMasksURL=function(A){return(_ky_wappServ_url+"js/masks/")};ky_wappObj.prototype.getHooksURL=function(A){if(A){return(_ky_wappServ_url+"js/client/"+A+"hooks/")}else{return(_ky_wappServ_url+"js/hooks/")}};ky_wappObj.prototype.getExperimentURL=function(E){var C=null;var B=_ky_wappServ_url;if(typeof (this.inpuMask.DATA.port)=="string"){C=this.inpuMask.DATA.port;B=B.replace(".com/",".com:"+C+"/")}var F=(B+"runExperiment.php");var D=window.location.href;var A="";if(D.indexOf("?")>-1){A=D.substr(D.indexOf("?")+1);if(A.indexOf("#")>-1){A=A.substr(0,A.indexOf("#"))}if(F.indexOf("?")>-1){F+="&"+A}else{if(E){F+="&"+A}else{F+="?"+A}}}return F};ky_wappObj.prototype.getHookURL=function(H,G,F){var C=null;var B=_ky_wappServ_url;if(typeof (this.inpuMask.DATA.port)=="string"){C=this.inpuMask.DATA.port;B=B.replace(".com/",".com:"+C+"/")}alertDebug("getHookURL wappServ_url :"+B,"cyan");hookURL=(B+"runHook.php");var E=window.location.href;var A="";if(E.indexOf("?")>-1){A=E.substr(E.indexOf("?")+1);if(A.indexOf("#")>-1){A=A.substr(0,A.indexOf("#"))}if(hookURL.indexOf("?")>-1){hookURL+="&"+A}else{if(F){hookURL+="&"+A}else{hookURL+="?"+A}}}var D;if(typeof (ky_seo)!="undefined"){D=this._hashParam2str(ky_seo.params)}if(D){if(hookURL.indexOf("?")>-1){hookURL+="&"+D}else{if(F){hookURL+="&"+D}else{hookURL+="?"+D}}}return hookURL};ky_wappObj.prototype.getTransProtocol=function(B){var C;var A="";if(typeof (this.inpuMask.DATA.port)=="string"){A=this.inpuMask.DATA.port}alertDebug("getTransProtocol :"+B,"orange");alertDebug("getTransProtocol port :"+A,"orange");alertDebug("getTransProtocol host :"+window.location.host,"orange");if((B.indexOf(window.location.host)==-1)||(window.location.port!=A)){C="ky_SWgetFile"}else{C="ky_getFile"}alertDebug("getTransProtocol proto :"+C,"orange");return C};ky_wappObj.prototype.checkProxy=function(){var C="_ky_proxy_"+__cacheKey;var B=getCookie(C);var A=["php","aspx"];if(B=="nothere"){return false}else{if(A.inArray(B)){return B}}var D;for(D=0;D<A.length;D++){this.proxy=new ky_getFile("txt","get");this.proxy._meGlobal=this._meGlobal+".proxy";this.proxy.async=false;this.proxy.initialize(_ky_wapp_folder+"ky_wapp."+A[D]+"?check=1");if((this.proxy.page_request.readyState==4)&&(this.proxy.page_request.status==200)&&(this.proxy.page_request.responseText==1)){setCookie(C,A[D],60);alertDebug("proxy FOUND ["+A[D]+"]");return A[D]}}alertDebug("proxy NOT FOUND ");setCookie(C,"nothere",60);return false};ky_wappObj.prototype.assurance=function(){var A=null;try{A=this.inpuMask.DATA[this.inpuMask.DATA.startup]}catch(B){alertDebug("*** faceJSON not loaded for ["+this.formID+"].","red")}if(A){if(typeof (A.initialize)=="undefined"){A.initialize=new Array()}}else{alertDebug("*** No startup face for ["+this.formID+"].","red")}};ky_wappObj.prototype.mask_callOut=function(M){var J=this.inpuMask.DATA[this.currentFace].fields;var Q,C;var I,H,F;var L="";var E;var G=true;var O=true;var A;var N;var B=null;var K=0;if(J){if((this.inpuMask.DATA[this.currentFace].callOut)&&(this.inpuMask.DATA[this.currentFace].callOut.relativeContainer)){B=(ky_E(this.inpuMask.DATA[this.currentFace].callOut.relativeContainer))}for(I=0;I<J.length;I++){L="";G=true;if((typeof (M)=="object")&&(M.inArray(J[I].field))){alertDebug("mask_callOut skipping:"+J[I].field,"yellow");continue}if(this.formEle.elements[J[I].field]){Q=J[I];C=this.formEle.elements[J[I].field];if(Q.maskControl){for(H=0;H<Q.maskControl.length;H++){if(Q.maskControl[H].mask){if(typeof (ky_mask[Q.maskControl[H].mask])=="function"){E=ky_mask[Q.maskControl[H].mask](C,Q.maskControl[H])}else{ky_wappMsg[this.cName+"-validateFace"]="mask method ["+Q.maskControl[H].mask+"], does not exist";E=false}if(!E){F="";if(Q.maskControl[H].Msg){F=Q.maskControl[H].Msg}else{if(Q.maskControl[H].callOutMsg){F=Q.maskControl[H].callOutMsg}else{if(this.inpuMask.DATA.maskMsg){F=this.inpuMask.DATA.maskMsg[Q.maskControl[H].mask]}}}if(F==""){F=ky_mask.ky_maskMsg.DATA[Q.maskControl[H].mask]}var D=false;if(Q.maskControl[H].hideLen){D=true}if((Q.maskControl[H].len)&&(!D)){L+=((L)?"<br>":"")+F+Q.maskControl[H].len}else{L+=((L)?"<br>":"")+F}}G=G&&E}}}if(Q.confirmField){if(this.formEle.elements[Q.confirmField.field]){if(C.value!=this.formEle.elements[Q.confirmField.field].value){if(Q.confirmField.Msg){L+=Q.confirmField.Msg+"<br>"}else{if(Q.confirmField.callOutMsg){L+=Q.confirmField.callOutMsg+"<br>"}}G=false}}else{ky_wappMsg[this.cName+"-validateFace"]="confirmField ["+Q.confirmField.field+"] does not exist in form: "+this.formID}}A=this.faces[this.currentFace][Q.field+"CO"];if(!G){if(!A){A=new ky_errorCallout();A.faceEle=this.faces[this.currentFace].faceEle;if(B){A.relativeContainer=B}A.init();Drag.init(A.eleContainer)}N=(Q.callOut?Q.callOut:this.inpuMask.DATA[this.currentFace].callOut);if(Q.label){L="<b>"+Q.label+"</b>: "+L}else{L="<b>"+Q.field+"</b>: "+L}var P=C;if(N.field){P=ky_E(N.field)}alertDebug("callOutField ["+Q.field+"] is "+P.id,"cyan");A.popCallout(P,L,N);this.faces[this.currentFace][Q.field+"CO"]=A;if((K==0)&&(P.focus)){P.focus()}K++}else{if(A){A.closeForm()}}}else{ky_wappMsg[this.cName+"-validateFace"]="field ["+J[I].field+"] does not exist in form: "+this.formID}O=O&&G}}return O};ky_wappObj.prototype.maskReset_callOut=function(){var A=this.inpuMask.DATA[this.currentFace].fields;var D,B;var C;if(A){for(i=0;i<A.length;i++){if(this.formEle.elements[A[i].field]){var D=A[i];var C=this.faces[this.currentFace][D.field+"CO"];if(C){C.closeForm()}}}}return true};ky_wappObj.prototype.mask_inLine=function(M){var K=this.inpuMask.DATA[this.currentFace].fields;var P,D;var I,H,F;var L="";var C="";var E;var G=true;var O=true;var A;var N;if(K){for(I=0;I<K.length;I++){L="";G=true;if((typeof (M)=="object")&&(M.inArray(K[I].field))){alertDebug("mask_inLine skipping:"+K[I].field,"yellow");continue}if(this.formEle.elements[K[I].field]){P=K[I];D=this.formEle.elements[K[I].field];if(P.maskControl){for(H=0;H<P.maskControl.length;H++){if(P.maskControl[H].mask){if(typeof (ky_mask[P.maskControl[H].mask])=="function"){E=ky_mask[P.maskControl[H].mask](D,P.maskControl[H])}else{ky_wappMsg[this.cName+"-validateFace"]="mask method ["+P.maskControl[H].mask+"], does not exist";E=false}if(!E){F="";if(P.maskControl[H].Msg){F=P.maskControl[H].Msg}else{if(this.inpuMask.DATA.maskMsg){F=this.inpuMask.DATA.maskMsg[P.maskControl[H].mask]}}if(F==""){F=ky_mask.ky_maskMsg.DATA[P.maskControl[H].mask]}if(P.maskControl[H].len){L+=((L)?"<br>":"")+F+P.maskControl[H].len}else{L+=((L)?"<br>":"")+F}if(this.inpuMask.DATA[this.currentFace].inLineBorder){D.style.border=this.inpuMask.DATA[this.currentFace].inLineBorder}else{if(this.inpuMask.DATA.inLineBorder){D.style.border=this.inpuMask.DATA.inLineBorder}}}G=G&&E}}}if(P.confirmField){if(this.formEle.elements[P.confirmField.field]){if(D.value!=this.formEle.elements[P.confirmField.field].value){L+=P.confirmField.Msg+"<br>";G=false;if(this.inpuMask.DATA[this.currentFace].inLineBorder){D.style.border=this.inpuMask.DATA[this.currentFace].inLineBorder}else{if(this.inpuMask.DATA.inLineBorder){D.style.border=this.inpuMask.DATA.inLineBorder}}}}else{ky_wappMsg[this.cName+"-validateFace"]="confirmField ["+P.confirmField.field+"] does not exist in form: "+this.formID}}if(!G){if(P.label){L="<b>"+P.label+"</b>: "+L}else{L="<b>"+P.field+"</b>: "+L}C+=((C)?"<br>":"")+L}else{if(typeof (D.tagName)!="undefined"){D.style.border=""}else{alertDebug("mask_inLine for field["+K[I].field+"] is not supported","red")}}}else{ky_wappMsg[this.cName+"-validateFace"]="field ["+K[I].field+"] does not exist in form: "+this.formID}O=O&&G}if(!O){var J="";if(this.inpuMask.DATA[this.currentFace].inLineErrDivID){J=this.inpuMask.DATA[this.currentFace].inLineErrDivID}else{if(this.inpuMask.DATA.inLineErrDivID){J=this.inpuMask.DATA.inLineErrDivID}}if(J){var B=document.getElementById(J);if(B){B.style.display="block";B.innerHTML=C}}}else{B.style.display="none"}}return O};ky_wappObj.prototype.maskReset_inLine=function(){var A=this.inpuMask.DATA[this.currentFace].fields;var D,B;var C;if(A){for(i=0;i<A.length;i++){if(this.formEle.elements[A[i].field]){var B=this.formEle.elements[A[i].field];if(B){if(typeof (B.tagName)!="undefined"){B.style.border=""}}}}}return true};ky_wappObj.prototype.validateFace=function(C){var B="callOut";var A=true;if(C==null){C=[]}if(this.inpuMask.DATA[this.currentFace].maskType){if(this.inpuMask.DATA[this.currentFace].maskType=="inLine"){B="inLine"}}else{if(this.inpuMask.DATA.maskType){if(this.inpuMask.DATA.maskType=="inLine"){B="inLine"}}}A=this["mask_"+B](C);return A};ky_wappObj.prototype.resetValidateFace=function(){var A="callOut";if(this.inpuMask.DATA[this.currentFace].maskType){if(this.inpuMask.DATA[this.currentFace].maskType=="inLine"){A="inLine"}}else{if(this.inpuMask.DATA.maskType){if(this.inpuMask.DATA.maskType=="inLine"){A="inLine"}}}this["maskReset_"+A]()};ky_wappObj.prototype.runkyTemplate=function(F,G,E,D){var C,H,B;C=kyTemplate.parseDOMTemplate(F.id);if(typeof (this.arrContainer)=="object"){if(typeof (E)!="object"){E=new Object()}for(var A in this.arrContainer){E[A]=this.arrContainer[A]}}H=C.process(E);if(document.all){H=this.kyTemplateUnfakeIEBug(H)}if(D){G.innerHTML=H}else{G.innerHTML+=H}};ky_wappObj.IEFixKey="_Xx_ _yY_";ky_wappObj.prototype.kyTemplateFakeIEBug=function(F){var D=ky_wappObj.IEFixKey;var A=F;while(A.indexOf("value=${")>-1){var C=A.indexOf("value=${");var B=A.indexOf("}",C);var E=A.substr(C+8,B-C-8);A=A.replace("value=${"+E+"}",'value="'+D+"${"+E+'}"')}return A};ky_wappObj.prototype.kyTemplateUnfakeIEBug=function(B){var A=ky_wappObj.IEFixKey;while(B.indexOf(A)!=-1){B=B.replace('value="'+A,'value="')}return(B)};var _ky_wapp_folder;var _ky_site_folder;var _ky_wappServ_url;var ky_wappMsg=new Object();var ky_wappManager=new ky_wappManagerObj("ky_wappManager");var ky_mask=new ky_maskObj();var lod=new ky_lod();var _ky_wapp_browser;function ky_fixRelativePath(B,A){c=B.split("../");l=c.length-1;x=A.lastIndexOf("/");for(i=0;i<l;i++){A=A.substr(0,A.lastIndexOf("/",x-1))}if((A.charAt(A.length-1))!="/"){A=A+"/"}if(c[l]){A=A+c[l]}return(A)}function ky_wappFolder(){try{var B=document.getElementById("_ky_wapp_rw").src;B=B.replace("ky_wapplication.js","");var F=null;if(document.all){F=B.replace("ky_wapp.wapps/","")}else{F=B.replace("ky_wapp.wapps/","")}var A=document.getElementById("_ky_wapp_ro").src;A=A.replace("js/ky_wapplication.js","");var G=A.indexOf("?");if(G>-1){A=A.substring(0,G)}}catch(E){alert(E.message)}_ky_wapp_folder=B;_ky_wapp_browser=ky_browser();if((document.all)&&(_ky_wapp_browser.version!=8)){var C="";if(window.location.port){C=":"+window.location.port}var D=window.location.protocol+"//"+window.location.hostname+C+window.location.pathname;D=D.substring(0,D.lastIndexOf("/")+1);if(document.getElementsByTagName("base")&&document.getElementsByTagName("base")[0]){D=document.getElementsByTagName("base")[0].getAttribute("href")}_ky_site_folder=ky_fixRelativePath(F,D)}else{_ky_site_folder=F}if(location.href.indexOf("https:")>-1){_ky_wappServ_url=A.replace("http:","https:")}else{_ky_wappServ_url=A}ky_mask.initialize("ky_mask")}function ky_wappStart(){if(window.ky_onCreate==0){ky_wappStop();window.ky_onCreate=-1;return }else{if(window.ky_onCreate==1){if((ky_wappManager)&&(typeof (ky_wappManager.start)=="function")){ky_wappManager.start()}}}}function ky_wappAction(B,C,A){ky_wappManager.action(B,C,A)}function ky_wappFieldAction(B,C,A){ky_wappManager.fieldAction(B,C,A)}function AddOnCreate(){window.ky_onCreate=1;window.ky_sTimer=ky_setInterval("ky_wappStart()",10);window.ky_dTimer=null}var bAjaxSRLoaded=true;function ky_wappStop(){var A=new Date();bAjaxSRLoaded=true;if(typeof (sf_FileLoader)!="undefined"){if(sf_FileLoader.pendingCount>0){bAjaxSRLoaded=false}}if(!bAjaxSRLoaded){if(window.ky_dTimer){clearTimeout(window.ky_dTimer)}window.ky_dTimer=setTimeout("ky_wappStop()",100);return }if(window.ky_dTimer){clearTimeout(window.ky_dTimer);window.ky_dTimer=null}if((window.ky_onCreate==1)&&(bAjaxSRLoaded)){ky_wappStart();ky_clearInterval(window.ky_sTimer);window.ky_onCreate=0}alertDebug("PAGE LOADED","cyan")}ky_wappFolder();AddOnCreate();AddOnload(ky_wappStop);function _ky_seo(){if(typeof (ky_seo)!="undefined"){if(ky_seo.SEOFolders){ky_seo.url=window.location.href;ky_seo.params=[];var C=0;for(C=0;C<ky_seo.SEOFolders.length;C++){if(ky_seo.url.indexOf(ky_seo.SEOFolders[C].folder)>-1){ky_seo.folder=ky_seo.SEOFolders[C].folder;if(ky_seo.SEOFolders[C].param){ky_seo.param=ky_seo.SEOFolders[C].param}break}}if(ky_seo.folder){var F=ky_seo.url.substr(ky_seo.url.indexOf(ky_seo.folder)+ky_seo.folder.length);var A=F.split("/");var B=0;var D=0;for(C=0;C<A.length;C++){try{if(A[C]!=""){if(ky_seo.param&&ky_seo.param[D]){ky_seo.params[ky_seo.param[D]]=A[C];D++}else{ky_seo.params["p"+B]=A[C];if(ky_seo.param.length>0){ky_seo.param[ky_seo.param.length]="p"+B}B++;D++}}}catch(E){alert("seo exception ["+C+"]"+E.message);break}}}}}}_ky_seo();__v="Fri Oct  9 19:37:51 EEST 2009-n";