
var wak={};wak.lib={};wak.USER_AGENT=navigator.userAgent.toLowerCase();wak.IE=wak.USER_AGENT.indexOf('msie')!=-1;wak.IE6=wak.IE&&wak.USER_AGENT.indexOf('msie 6')!=-1?true:false;wak.IE7=wak.IE&&wak.USER_AGENT.indexOf('msie 7')!=-1?true:false;wak.FF=!wak.IE;wak.SAFARI=wak.USER_AGENT.indexOf('safari')!=-1;wak.emptyFunction=function(){};wak.idGenerator=1;wak.browserRefresh=function(timeout){var callback=function(){window.location.replace(window.location.href);};if(timeout){window.setTimeout(callback,timeout);}else{callback();}};wak.elem=function(idOrElem,doc){id=idOrElem;if(wak.isString(id)){if(!doc){doc=document;}
var ele=doc.getElementById?doc.getElementById(id):null;if(ele&&(ele.id!=id)&&doc.all){ele=null;var eles=doc.all[id];if(eles){if(eles.length){for(var i=0;i<eles.length;i++){if(eles[i].id==id){ele=eles[i];break;}}}else{ele=eles;}}}
return ele;}
return id;};wak.elemId=function(idOrElem){return typeof(idOrElem)=='string'?idOrElem:idOrElem.id;};wak.assertNonNull=function(aVariable,variableName){if(!variableName)variableName="";else variableName=": '"+variableName+"'";if(!wak.isDefinedNonNull(aVariable))wak.log.error("Assert: required value missing"+variableName);};wak.parseInt=function(num,def){var returnValue=0;var returnDefaultIfPresent=false;if(wak.isDefinedNonNull(num)){returnValue=parseInt(num);if(isNaN(returnValue)){returnDefaultIfPresent=true;}}else{returnDefaultIfPresent=true;}
if(returnDefaultIfPresent&&wak.isDefinedNonNull(def)){return def;}
return returnValue;};wak.toString=function(variable){var returnString=variable?variable.toString():null;if(!wak.IE&&variable instanceof XMLHttpRequest){var status=null;var statusText=null;try{status=variable.status;statusText=variable.statusText;}catch(e){}
returnString="{responseText:"+variable.responseText+", status:"+status+", statusText:"+statusText+"}";}else if(returnString=='[object Object]'){var firstTime=true;returnString='{';for(var key in variable){var keyString=key;if(wak.isString(key)){keyString='"'+key+'"';}
if(firstTime){firstTime=false;}else{returnString+=', ';}
returnString+=keyString;returnString+=':';var value=wak.toString(variable[key]);if(wak.isString(value)){value='"'+value+'"';}
returnString+=value;}
returnString+='}';}
return returnString;};wak.isDefined=function(obj){return typeof(obj)!='undefined';};wak.isDefinedNonNull=function(obj){return((obj!=null)&&(typeof(obj)!='undefined'));};wak.isInstance=function(a,aClass){return(a&&a.constructor&&(a.constructor===aClass));};wak.isString=function(a){return(a&&((typeof a=='string')||(a instanceof String)));};wak.isArray=function(a){return wak.isInstance(a,Array);};wak.isObject=function(a){return(typeof(a)=='object');};wak.keyComparator=function(key){return function(a,b){if(a[key]<b[key])return-1;if(a[key]==b[key])return 0;return 1;};};wak.pad=function(val,len,padWithChar){var valStr=wak.isString(val)?val:val+'';padWithChar=padWithChar||'0';if(valStr.length<len){var amountToPad=len-valStr.length;var arr=[];for(var i=amountToPad;i>0;i--)arr.push(padWithChar);valStr=arr.join('')+valStr;}
return valStr;};Object.extend=function(dst,src){for(var prop in src)dst[prop]=src[prop];return dst;};Object.clone=function(src){return Object.extend({},src);};Object.diff=function(o1,o2){for(var k in o1)if(o1[k]!==o2[k])return true;for(var k in o2)if(o1[k]!==o2[k])return true;return false;};Class={create:function(){return function(){if(this.ctor)this.ctor.apply(this,arguments);}},extend:function(dst,src){return Object.extend(dst,src);}};wak.lib.util=function(){wak.util={clearValues:function(map){for(var k in map)map[k]=null;},keys:function(hash){var arr=[];for(var k in hash)arr.push(k);return arr;}}};wak.lib.util();wak.lib.css=function(){wak.css={visibility:function(idOrElem,show){if(show)wak.css.show(idOrElem);else wak.css.hide(idOrElem);},hide:function(idOrElem,undisplay){var elem=wak.elem(idOrElem);elem.style.visibility='hidden';if(undisplay){wak.css.display(elem,false);}},show:function(idOrElem,display){var elem=wak.elem(idOrElem);elem.style.visibility='visible';if(display){wak.css.display(elem,true);}},display:function(idOrElem,display,dstyle){dstyle=dstyle||'block';$(idOrElem).style.display=display?dstyle:'none';},isDisplayed:function(idOrElem){returnValue=false;var elem=wak.elem(idOrElem);if(elem&&!wak.css.testComputedStyle(elem,'display','none')){returnValue=true;}
return returnValue;},displayToggle:function(){wak.css.display(arguments[0],true);for(var i=1;i<arguments.length;i++){wak.css.display(arguments[i],false);}},toggleDisplay:function(idOrElem){var e=wak.elem(idOrElem);e.style.display=e.style.display=='none'?'':'none';},setVisible:function(idOrElem,visible,display){if(visible){wak.css.show(idOrElem,display);}else{wak.css.hide(idOrElem,display);}},isVisible:function(idOrElem){var returnValue=false;var elem=wak.elem(idOrElem);if(elem&&!wak.css.testComputedStyle(elem,'visibility','hidden'))returnValue=true;return returnValue;},isUserVisible:function(idOrElem){return(wak.css.isVisible(idOrElem)&&wak.css.isDisplayed(idOrElem));},addClass:function(idOrElem,className){var e=wak.elem(idOrElem);if(e)e.className+=' '+className;return e;},removeClass:function(idOrElem,className){var e=wak.elem(idOrElem);e.className=wak.css.getClasses(idOrElem).select(function(val){if(val!=className)return true;}).join(' ');return e;},replaceClass:function(idOrElem,oldClassName,newClassName){var e=wak.elem(idOrElem);wak.css.removeClass(idOrElem,oldClassName);wak.css.addClass(idOrElem,newClassName);return e;},containsClass:function(idOrElem,className){return wak.css.getClasses(idOrElem).indexOf(className)!=-1;},getClasses:function(idOrElem){var e=wak.elem(idOrElem);return e.className.split(/\s+/);},getComputedStyle:function(idOrElem,styleProp,asInt){var styleName=styleProp;var elem=$(idOrElem);var y=null;if(elem!=null){if(elem.currentStyle){y=elem.currentStyle[styleName];}else if(window.getComputedStyle){var cstyle=document.defaultView.getComputedStyle(elem,null);y=cstyle.getPropertyValue(styleName);}else{y=elem.style[styleName];}}
if(y==null)return null
else return asInt?wak.parseInt(y):y;},testComputedStyle:function(idOrElem,styleProp,val){return wak.css.getComputedStyle(idOrElem,styleProp)==val;},setOpacity:function(id,opacity){var s=$(id).style;if(s!=null){s.opacity=(opacity/100);s.MozOpacity=(opacity/100);s.KhtmlOpacity=(opacity/100);s.filter="alpha(opacity="+opacity+")";}}}};wak.lib.css();wak.lib.html=function(){wak.html={setContent:function(idOrElem,html){var elem=wak.elem(idOrElem);if(elem)wak.elem(idOrElem).innerHTML=html;else wak.log.error('wak.html.setContent: invalid idOrElem: '+idOrElem);},replaceContent:function(idOrElem1,idOrElem2){wak.html.setContent(idOrElem1,idOrElem2.innerHTML);},parseHTMLFragment:function(htmlFragment){if(!wak._fragmentDiv){wak._fragmentDiv=document.createElement('div');wak._fragmentDiv.style.display='none';}
var frag=htmlFragment.trim();if(frag.search(/^<tr/)!=-1){frag="<table><tbody>"+frag+"</tbody></table>";}
wak._fragmentDiv.innerHTML=frag;var elem=wak._fragmentDiv.firstChild;if(elem.tagName=='TABLE'){elem=elem.rows[0];}
return elem;},createScriptBlock:function(parentIdOrElem,srcUrl,scriptCodeString){var scriptParentElement=wak.elem(parentIdOrElem);var scriptElement=document.createElement('SCRIPT');scriptElement.setAttribute('type','text/javascript');scriptElement.text=scriptCodeString;scriptElement.src=srcUrl;scriptParentElement.appendChild(scriptElement);return scriptElement;},resetBeaconImgSource:function(idOrElem,url){var beaconImgElem=null;if(!wak.isString(idOrElem)){beaconImgElem=idOrElem;}else{var beaconImgName=idOrElem;var nextBeaconImgName=beaconImgName;if(wak.isDefinedNonNull(wak.html.previousBeaconImgName)){var nameParts=wak.html.previousBeaconImgName.split("_");if(!wak.isDefined(nameParts[1])){nextBeaconImgName=beaconImgName+"_1";}else{var oldIntegerSuffix=wak.parseInt(nameParts[1]);nextBeaconImgName=beaconImgName+"_"+(oldIntegerSuffix+1);}
beaconImgElem=wak.elem(nextBeaconImgName);if(beaconImgElem){beaconImgName=nextBeaconImgName;}}
if(!beaconImgElem)beaconImgElem=wak.elem(beaconImgName);if(!beaconImgElem){nextBeaconImgName=beaconImgName+"_1";beaconImgElem=wak.elem(nextBeaconImgName);if(beaconImgElem){beaconImgName=nextBeaconImgName;}}
wak.html.previousBeaconImgName=beaconImgName;}
if(beaconImgElem){beaconImgElem.src=mira.BLANK_GIF_URL;beaconImgElem.src=url;}},cloneElement:function(idOrElem){var elem=wak.elem(idOrElem);var clonedElem=null;if(elem){clonedElem=document.createElement(elem.tagName);wak.html.setContent(clonedElem,elem.innerHTML);}
return clonedElem;},createDivFromBounds:function(bounds,addlStyles){var div=document.createElement('DIV');div.style.position='absolute';div.style.top=bounds.top+'px';div.style.left=bounds.left+'px';div.style.width=bounds.width+'px';div.style.height=bounds.height+'px';for(var k in addlStyles)div.style[k]=addlStyles[k];document.body.appendChild(div);return div;},sizeToFit:function(toBeSizedDivOrId,sourceOfSizeDivOrId){var toBeSizedDiv=$(toBeSizedDivOrId);var sourceOfSizeDiv=$(sourceOfSizeDivOrId);if(sourceOfSizeDiv){var sourceOfSizeDivIsInDom=wak.dom.isInDocument(sourceOfSizeDiv);var restoreVisibility=sourceOfSizeDiv.style.visibility;if(!sourceOfSizeDivIsInDom){wak.css.hide(sourceOfSizeDiv);document.body.appendChild(sourceOfSizeDiv);}
var newWidth=sourceOfSizeDiv.offsetWidth;var newHeight=sourceOfSizeDiv.offsetHeight;toBeSizedDiv.style.width=newWidth+'px';toBeSizedDiv.style.height=newHeight+'px';this.fixDivWith100PercentTableRow(toBeSizedDivOrId,newWidth,newHeight);if(!sourceOfSizeDivIsInDom){document.body.removeChild(sourceOfSizeDiv);sourceOfSizeDiv.style.visibility=restoreVisibility;}}},fixDivWith100PercentTableRow:function(tableOrDivWithTableChild,desiredDivWidth,desiredDivHeight){var tableToAdjust=null;if(tableOrDivWithTableChild&&(tableOrDivWithTableChild.tagName=='TABLE')){tableToAdjust=tableOrDivWithTableChild;}else if(tableOrDivWithTableChild&&tableOrDivWithTableChild.childNodes){for(var i=0;i<tableOrDivWithTableChild.childNodes.length;i++){var aChild=tableOrDivWithTableChild.childNodes[i];if(aChild.tagName=='TABLE'){tableToAdjust=aChild;break;}}}
if(tableToAdjust){var rows=tableToAdjust.getElementsByTagName("tr");var fixedAccumulatedWidth=0;var fixedAccumulatedHeight=0;var rowToGetWidthAdusted=null;var rowToGetHeightAdusted=null;var parentWidth=tableToAdjust.parentNode.offsetWidth;var parentHeight=tableToAdjust.parentNode.offsetHeight;for(i=0;i<rows.length;i++){var aRow=rows[i];var rowWidth=aRow.offsetWidth;var rowHeight=aRow.offsetHeight;if((rowWidth=='100%')||(rowWidth==parentWidth)||(rowWidth==desiredDivWidth)){rowToGetWidthAdusted=aRow;}else if(rowWidth){fixedAccumulatedWidth+=rowWidth;}
if((rowHeight=='100%')||(rowHeight==parentHeight)||(rowHeight==desiredDivHeight)){rowToGetHeightAdusted=aRow;}else if(rowHeight){fixedAccumulatedHeight+=rowHeight;}}
var needsResize=false;if(rowToGetWidthAdusted){rowToGetWidthAdusted.style.width=(desiredDivWidth-fixedAccumulatedWidth)+'px';needsResize=true;}
if(rowToGetHeightAdusted){rowToGetHeightAdusted.style.height=(desiredDivHeight-fixedAccumulatedHeight)+'px';needsResize=true;}
if(needsResize){tableOrDivWithTableChild.style.width=desiredDivWidth+'px';tableOrDivWithTableChild.style.height=desiredDivHeight+'px';}}},moveTo:function(idOrElem,left,top){var toBeMovedDiv=wak.elem(idOrElem);if(toBeMovedDiv&&toBeMovedDiv.style){if(left)toBeMovedDiv.style.left=left+'px';if(top)toBeMovedDiv.style.top=top+'px';}},moveBy:function(idOrElem,leftDelta,topDelta){var toBeMovedDiv=wak.elem(idOrElem);if(toBeMovedDiv&&toBeMovedDiv.style){if(leftDelta)toBeMovedDiv.style.left=(toBeMovedDiv.offsetLeft+leftDelta)+'px';if(topDelta)toBeMovedDiv.style.top=(toBeMovedDiv.offsetTop+topDelta)+'px';}}}};wak.lib.html();wak.lib.cookie=function(){wak.cookie={SESSION_COOKIE:'__wcS:00',TWO_WEEK_COOKIE:'__wcLT:14',PERMANENT_COOKIE:'__wcP:99999',CURRENT_DATA_VERSION:'002',cachedMaps:{},enabled:function(){return wak.cookie.get(mira.cookietest_key)!=null?true:false;},get:function(name){var cookies=wak.cookie.getAll();return cookies[name];},getAll:function(){var retval={};var cookies=document.cookie.split(';');cookies.each(function(cookie){cookie=cookie.trim();var index=cookie.indexOf('=');var cookieString=cookie.substring(index+1);cookieString=cookieString.replace(/\|/g,",");retval[cookie.substring(0,index)]=cookieString;});return retval;},contains:function(name){var cookies=wak.cookie.get();return wak.isDefined(cookies.name);},set:function(name,value,expireInDays){var expiresStr='';if(!expireInDays){var arr=name.split(':');if(arr.length>1){expireInDays=wak.parseInt(arr[1]);}}
if(expireInDays){var date=new Date();date=date.add('D',expireInDays);expiresStr='; expires='+date.toGMTString();}
var cookieString=name+"="+value+expiresStr+"; path=/";cookieString=cookieString.replace(/,/g,"|");document.cookie=cookieString;},_getCookieMap:function(cookieName){var aCookieMap=wak.cookie.cachedMaps[cookieName];if(!wak.isDefinedNonNull(aCookieMap)){aCookieMap={};var fullCookieString=wak.cookie.get(cookieName);if(fullCookieString){var version=0;if(fullCookieString.length>=3){var versionString=fullCookieString.substring(0,3);version=wak.parseInt(versionString,0);if(version>=wak.cookie.CURRENT_DATA_VERSION){var valuesCookieString=fullCookieString.substring(3);try{eval('aCookieMap = '+valuesCookieString);wak.cookie.cachedMaps[cookieName]=aCookieMap;}catch(anException){wak.log.error('Exception restoring cookie "'+cookieName+'" in _getMapCookie(), with value: '+valuesCookieString);}}}}}
return aCookieMap;},setValue:function(key,value,cookieName){if(!wak.isDefinedNonNull(cookieName)){cookieName=wak.cookie.SESSION_COOKIE;}
var cookieVal=wak.cookie.CURRENT_DATA_VERSION;var aCookieMap=this._getCookieMap(cookieName);if(!value){delete aCookieMap[key];}else{if(key==null){wak.log.error('wak.cookie.seValue() called with null key');}else{aCookieMap[key]=value;}}
cookieVal+=wak.map.toString(aCookieMap);wak.cookie.set(cookieName,cookieVal);return cookieVal;},getValue:function(key,cookieName){if(!wak.isDefinedNonNull(cookieName)){cookieName=wak.cookie.SESSION_COOKIE;}
var aCookieMap=this._getCookieMap(cookieName);return aCookieMap[key];},remove:function(name){wak.cookie.set(name,"");}}};wak.lib.cookie();wak.lib.autohelp=function(){wak.autohelp={constants:{_NOT_FIRED:null,_ALREADY_FIRED:1,_COOKIE_KEY_PREFIX:'wah',_DEFERRED_FIRE:-1,MAX_FIRING_RATE:4},setActionsList:function(actions){wak.autohelp._actions=actions;},pullTrigger:function(action,testFunc,fireFunc,onlyIfDeferred){var fired=false;var debugCondition='';var showDebug=(debugCondition=='all')||(debugCondition==action.name);if(WakModalDialog.openInstance){window.setTimeout(function(){wak.autohelp.pullTrigger(action,testFunc,fireFunc);},6000);}else{var sessionActionName=wak.autohelp.constants._COOKIE_KEY_PREFIX+action.name;if(showDebug)wak.log.debug("PRE-hasFired() test - onlyIfDeferred:"+onlyIfDeferred+", ActionName:"+action.name+", threshold:"+action.threshold+", triggerPullsThisAction:"+triggerPullsThisAction);if(!wak.autohelp.hasFired(action)){if(showDebug)wak.log.debug("&nbsp;&nbsp;&nbsp;&nbsp;PRE-testFunc() test - onlyIfDeferred:"+onlyIfDeferred+", ActionName:"+action.name+", threshold:"+action.threshold+", triggerPullsThisAction:"+triggerPullsThisAction);if(!testFunc||(testFunc&&testFunc())){var triggerPullsThisAction=wak.cookie.getValue(sessionActionName,wak.cookie.SESSION_COOKIE);var actionIsDeferred=(triggerPullsThisAction==wak.autohelp.constants._DEFERRED_FIRE);if(showDebug)wak.log.debug("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PRE-deferred test - onlyIfDeferred:"+onlyIfDeferred+", ActionName:"+action.name+", threshold:"+action.threshold+", triggerPullsThisAction:"+triggerPullsThisAction);if(!onlyIfDeferred||actionIsDeferred){if(actionIsDeferred){triggerPullsThisAction=action.threshold;}
triggerPullsThisAction=triggerPullsThisAction||0;triggerPullsThisAction=wak.parseInt(triggerPullsThisAction)+1;wak.cookie.setValue(sessionActionName,triggerPullsThisAction,wak.cookie.SESSION_COOKIE);if(triggerPullsThisAction>action.threshold){if(action.showOnPages.indexOf(mira.pageId)!=-1){fired=true;wak.autohelp.fire(action,fireFunc);}else{wak.cookie.setValue(sessionActionName,wak.autohelp.constants._DEFERRED_FIRE,wak.cookie.SESSION_COOKIE);}}}}}}
return fired;},fire:function(anAction,fireFunc,canShowAgain){if(!canShowAgain)wak.autohelp.setFired(anAction);if(fireFunc)fireFunc();if(wak.autohelp._actions&&!anAction.noRateLimiting){for(var key in wak.autohelp._actions){var anotherAction=wak.autohelp._actions[key];var anotherActionSessionActionName=wak.autohelp.constants._COOKIE_KEY_PREFIX+anotherAction.name;wak.cookie.setValue(anotherActionSessionActionName,null,wak.cookie.SESSION_COOKIE);}}},setFired:function(anAction){var firingTimeoutCookie=anAction.firingTimeoutCookie||wak.cookie.TWO_WEEK_COOKIE;wak.cookie.setValue(anAction.name,wak.autohelp.constants._ALREADY_FIRED,firingTimeoutCookie);},setUnFired:function(anAction){var firingTimeoutCookie=anAction.firingTimeoutCookie||wak.cookie.TWO_WEEK_COOKIE;wak.cookie.setValue(anAction.name,wak.autohelp.constants._NOT_FIRED,firingTimeoutCookie);},setAllUnFired:function(){for(var key in wak.autohelp._actions){var anAction=wak.autohelp._actions[key];var anActionSessionActionName=wak.autohelp.constants._COOKIE_KEY_PREFIX+anAction.name;wak.cookie.setValue(anActionSessionActionName,null,wak.cookie.SESSION_COOKIE);wak.autohelp.setUnFired(anAction);}},hasFired:function(anAction){var firingTimeoutCookie=anAction.firingTimeoutCookie||wak.cookie.TWO_WEEK_COOKIE;return(wak.cookie.getValue(anAction.name,firingTimeoutCookie)==wak.autohelp.constants._ALREADY_FIRED);}}};wak.lib.autohelp();wak.lib.menu=function(){wak.menu={onTargetOver:function(target,id){if(wak.menu._openTargetId){wak.css.hide(wak.menu._openTargetId+'MenuItems');}
var relBounds=wak.geometry.bounds('refine');var src=$(id+'MenuItems');wak.css.show(src);wak.geometry.positionBelow(src,target,null,null,relBounds);wak.menu._openTargetId=id;wak.geometry.setAncestorsZIndex(src,100);},onTargetOut:function(target,id){wak.menu._fireCloseTimer(id);},onItemsOver:function(target,id){wak.menu._clearCloseTimer();},onItemsOut:function(target,id){wak.menu._fireCloseTimer(id);},hide:function(){if(wak.menu._openTargetId){wak.menu._hide(wak.menu._openTargetId);}},_hide:function(id){id=id+'MenuItems';wak.css.hide(id);wak.geometry.resetAncestorsZIndex(id);wak.menu._openTargetId=null;},_fireCloseTimer:function(id){var fn=function(){wak.menu._hide(id);};wak.menu._targetOutTimer=window.setTimeout(fn,150);},_clearCloseTimer:function(){window.clearTimeout(wak.menu._targetOutTimer);wak.menu._targetOutTimer=null;}}};wak.lib.menu();wak.lib.string=function(){wak.string={isEmpty:function(str){return str==null||typeof(str)=='undefined'||str.trim().length==0;},isEqualSmart:function(str1,str2){if(wak.isString(str1)&&wak.string.isEmpty(str1)&&wak.isString(str2)&&wak.string.isEmpty(str2)){return true;}
return str1==str2;}};Object.extend(String.prototype,{isEmpty:function(){return wak.string.isEmpty(this);},escapeHTML:function(includeWhiteSpace){var s=this;s=s.replace(/\&/g,'&amp;');s=s.replace(/\xA0/g,'&nbsp;');s=s.replace(/\>/g,'&gt;');s=s.replace(/\</g,'&lt;');s=s.replace(/\"/g,'&quot;');if(includeWhiteSpace){s=s.replace(/\r\n/g,'<br>');s=s.replace(/\n/g,'<br>');s=s.replace(/  /g,' &nbsp;');s=s.replace(/&nbsp; /g,'&nbsp;&nbsp;');}
return s;},unescapeHTML:function(){var div=document.createElement('div');div.innerHTML=this.stripTags();return div.childNodes[0]?div.childNodes[0].nodeValue:'';},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'');},startsWith:function(str){return this.indexOf(str)==0;},endsWith:function(str){var lastIndex=this.lastIndexOf(str);return(lastIndex==-1)?false:lastIndex==(this.length-str.length);},contains:function(str){return this.indexOf(str)!=-1;},trim:function(charsString){var trimChars=null;if(wak.isDefinedNonNull(charsString)){trimChars=charsString;}else{trimChars='\\s';}
trimChars='['+trimChars+']';var startRegex=new RegExp('^'+trimChars+'+');var endRegex=new RegExp(trimChars+'+$');var str=this.replace(startRegex,'');str=str.replace(/\r/g,'');return str.replace(endRegex,'');},truncate:function(max,sep){if(!wak.isDefined(sep))sep='...';var retval=this.substring(0,this.length);if(this.length>max){retval=this.substring(0,max)+sep;}
return retval;}});};wak.lib.string();wak.lib.array=function(){Object.extend(Array.prototype,{clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},indexOf:function(object){for(var i=0;i<this.length;i++)
if(this[i]==object)return i;return-1;},removeAt:function(index){this.splice(index,1);return this;},removeObject:function(key,val){var index=-1;for(var i=0;i<this.length;i++){var obj=this[i];if(obj[key]==val){index=i;break;}}
return index!=-1?this.removeAt(index):this;},diff:function(arr2,deepCheck){if(this.length!=arr2.length)return true;var isDiff=false;for(var i=0;i<this.length;i++){var a=this[i];var b=arr2[i];if(!deepCheck){if(a!=b){isDiff=true;break;}}else{for(var key in a){if(a[key]!=b[key]){isDiff=true;break;}}}}
return isDiff;},insertAt:function(object,index){this.splice(index,0,object);return this;},fill:function(startIndex,arr){if(!arr)return this;arr.each(function(obj,index){this[startIndex+index]=obj;}.bind(this));return this;},_each:function(iterator){for(var i=0;i<this.length;i++)
iterator(this[i]);},eachBreak:function(iterator){var retval=null;for(var i=0;i<this.length;i++){if((retval=iterator(this[i])))break;}
return retval;},joinArrays:function(){var results=[];for(var i=0;i<this.length;i++){results.fill(results.length,this[i]);};return results;},invoke:function(fnName,arg1,arg2,arg3){var arr=[];for(var i=0;i<this.length;i++){var item=this[i];if(item[fnName]){var retval=item[fnName](arg1,arg2,arg3);if(retval)arr.push(retval);}};return arr;},invokeBreak:function(fnName,arg1,arg2,arg3){var retval=null;for(var i=0;i<this.length;i++){var item=this[i];if(item[fnName]){retval=item[fnName](arg1,arg2,arg3);if(retval)break;}};return retval;},clone:function(){var retval=[];this.each(function(a){retval.push(Object.clone(a));});return retval;}});Enumerable={each:function(iterator){var index=0;try{this._each(function(value){try{iterator(value,index++);}catch(e){wak.log.error(e+'');throw e;}});}catch(e){wak.log.error(e+'');throw e;}},collect:function(iterator){var results=[];this.each(function(value,index){results.push(iterator(value,index));});return results;},pluck:function(property){var results=[];this.each(function(value,index){results.push(value[property]);});return results;},findAll:function(iterator){var results=[];this.each(function(value,index){if(iterator(value,index))results.push(value);});return results;},compact:function(){var returnArray=[];var i=0;for(var key in this){if(wak.parseInt(key,-1)!=-1){returnArray[i++]=this[key];}}
return returnArray;},select:function(iterator){var results=[];this.each(function(value,index){if(iterator(value,index))results.push(value);});return results;},pick:function(iterator){var result=null;for(var i=0;i<this.length;i++){var item=this[i];if(iterator(item,i)){result=item;break;}}
return result;}}
Object.extend(Array.prototype,Enumerable);};wak.lib.array();wak.lib.hash=function(){Hash={_each:function(iterator){for(key in this){var value=this[key];if(typeof value=='function')continue;var pair=[key,value];pair.key=key;pair.value=value;iterator(pair);}},keys:function(){return this.pluck('key');},values:function(){return this.pluck('value');},isEmpty:function(){return this.keys().length==0;}};};wak.lib.hash();wak.lib.map=function(){wak.map={size:function(mapVariable){var count=0;for(var key in mapVariable)count++;return count;},sizeNonNulls:function(mapVariable){var count=0;for(var key in mapVariable){if(mapVariable[key]!=null)count++;}
return count;},toString:function(mapVariable){return wak.toString(mapVariable);},containsValue:function(mapVariable,value){for(var key in mapVariable){if(mapVariable[key]==value){return true;}};return false;},get:function(mapVariable,key){return key?(wak.isDefined(val=mapVariable[key])?val:null):null;},union:function(baseMap,joinMap,inPlace){var returnMap={};if(!baseMap)baseMap=returnMap;if(!inPlace){for(var key in baseMap){returnMap[key]=baseMap[key];};}else{returnMap=baseMap;}
for(var key in joinMap){returnMap[key]=joinMap[key];};return returnMap;},intersection:function(baseMap,whitelistMapOrString){return wak.map._subset(baseMap,whitelistMapOrString,false);},subtract:function(baseMap,removeMapOrString){return wak.map._subset(baseMap,removeMapOrString,true);},_subset:function(baseMap,compareMapOrString,subtract){var returnMap={};var compareString=null;var testableCompareMap={};if(wak.isString(compareMapOrString)){compareString=compareMapOrString;}else{for(var key in compareMapOrString){testableCompareMap[key]='non-null';}}
for(var key in baseMap){var keyCanStay=true;if(subtract){if(compareString){keyCanStay=!key.contains(compareString);}else{keyCanStay=!testableCompareMap[key];}}else{if(compareString){keyCanStay=key.contains(compareString);}else{keyCanStay=testableCompareMap[key];}}
if((baseMap[key]!=null)&&keyCanStay){var baseMapValue=baseMap[key]
returnMap[key]=baseMapValue;}};return returnMap;}}};wak.lib.map();wak.lib.func=function(){Object.extend(Function.prototype,{bind:function(me){var fn=this;return function(){return fn.apply(me,arguments);}},bindEventListener:function(me){var ticket=wak.baggage.check(this.bind(me));return wak.func._closure(ticket);}});wak.func={};wak.func._closure=function(ticket){return function(evt){var listener=wak.baggage.claim(ticket);return listener(evt);};}};wak.lib.func();wak.lib.baggage=function(){wak.baggage={_bags:{},check:function(bag){var ticket=wak.idGenerator++;wak.baggage._bags[ticket]=bag;return ticket;},claim:function(ticket,remove){var bag=wak.baggage._bags[ticket];if(remove)delete wak.baggage._bags[ticket];return bag;}}};wak.lib.baggage();wak.lib.template=function(){wak.template={};wak.template.onunreplacedtoken=wak.emptyFunction;wak.template._cache={};wak.template.create=function(str,divId){var key=str+divId;var t=wak.template._cache[key];if(t==null){t=new WakTemplate(str,divId);wak.template._cache[key]=t;}
var c=t._clone();return c;};WakTemplate=function(str,divId){this._parsedChunks=[];this._parsedRefs={};this._tokens={};this._blocks={};this._divId=divId;this._nextIterations=[];this._parent=null;this._root=this;this.dateFormatter="%b %e";this.dateFormatterIsLocal=false;if(str)this._parse(str);};WakTemplate.prototype.containsToken=function(token){return typeof(this._tokens[token])!='undefined';};WakTemplate.prototype.replaceToken=function(token,value){if(value instanceof Date)this._tokens[token]=value;else if(typeof(value)=='object')this._replaceRef(token,value);else this._tokens[token]=value;};WakTemplate.prototype.containsBlock=function(block){return typeof(this._blocks[block])!='undefined';};WakTemplate.prototype.replaceBlock=function(block,value){var b=this._blocks[block];if(b==null){wak.log.error("Couldn't find block: "+block);}else{b.value=value;}};WakTemplate.prototype.removeBlock=function(block){this.replaceBlock(arguments[0],null);for(var i=1;i<arguments.length;i++){this.replaceBlock(arguments[i],null);}};WakTemplate.prototype.keepBlock=function(cond,keep,kill){if(cond)this.removeBlock(kill);else this.removeBlock(keep);};WakTemplate.prototype.getBlock=function(block){var retval=null;var b=this._blocks[block];if(b!=null){retval=b.template;}
return retval;};WakTemplate.prototype.next=function(appendText){var str=this._composeToString();this._nextIterations.push(str);if(appendText)this._nextIterations.push(appendText);this._reset();return str;};WakTemplate.prototype.nextHtml=function(html){this._nextIterations.push(html);this._reset();return html;},WakTemplate.prototype.compose=function(){var str;if(this._nextIterations.length==0){str=this._composeToString();}else{str=this._nextIterations.join('');}
this._nextIterations=[];this._reset();if(this._divId)wak.html.setContent(this._divId,str);return str;};WakTemplate.prototype.composeAndAppend=function(parentElement,beforeChild){var elem=wak.html.parseHTMLFragment(this.compose());var pe=$(parentElement);if(!beforeChild)pe.appendChild(elem);else pe.insertBefore(elem,beforeChild);return elem;};WakTemplate.prototype.composeAndReplace=function(node){var elem=wak.html.parseHTMLFragment(this.compose());node.parentNode.replaceChild(elem,node);return elem;};WakTemplate.prototype._replaceRef=function(refName,refObj){var refTokens=this._root._parsedRefs[refName];if(!refTokens){wak.log('invalid reference: '+refName);return;}
var obj={};obj[refName]=refObj;for(var index in refTokens){var token=refTokens[index];var val=null;try{val=eval('obj.'+token);}catch(e){}
if(val!=null)this.replaceToken(token,val);}};WakTemplate.prototype._composeToString=function(){var buff=[];for(var i in this._parsedChunks){var chunk=this._parsedChunks[i];var val='';if(wak.isString(chunk)){val=chunk;}else if(chunk.type=='token'){val=this._getValue(chunk.name);}else if(chunk.type=='block'){var block=this._blocks[chunk.name];var val=block.value;if(val===null)val='';else if(typeof(val)=='undefined'){val=chunk.template.compose();}}
buff.push(val);}
var contents=buff.join('');return contents;};WakTemplate.prototype._getValue=function(tokenName){var val=this._tokens[tokenName];if(val==null&&this._parent!=null){val=this._parent._getValue(tokenName);}else if(val==null){val=wak.template.onunreplacedtoken(tokenName);val=val?val:'';}else if(val instanceof Date){val=val.format(this._getDateFormatter(),this._getDateFormatterIsLocal());}else{val=val+'';}
return val;};WakTemplate.prototype._getDateFormatter=function(){var fmt=this.dateFormatter;if(!this.dateFormatter&&this._parent!=null){fmt=this._parent._getDateFormatter();}
return fmt;};WakTemplate.prototype._getDateFormatterIsLocal=function(){if(this.dateFormatter&&!this._parent){return this.dateFormatterIsLocal;}
return this._parent._getDateFormatterIsLocal();};WakTemplate.prototype._clone=function(){var clone=new WakTemplate(null,this._divId);clone._parsedChunks=this._parsedChunks;clone._parsedRefs=this._parsedRefs;clone._tokens=this._tokens;clone._blocks=this._blocks;return clone;};WakTemplate.prototype._reset=function(){wak.util.clearValues(this._tokens);for(var key in this._blocks){var block=this._blocks[key];block.value=void 0;}};WakTemplate.prototype._parse=function(str){var pattern='@([a-zA-Z0-9_\.]+)@|<!-- +@\\/?([a-zA-Z0-9_\.]+)@ +-->';var re=new RegExp(pattern);var stack=[this];while((match=re.exec(str))!=null){var currTemplate=stack[stack.length-1];if(!wak.SAFARI)currTemplate._parsedChunks.push(RegExp.leftContext);else currTemplate._parsedChunks.push(str.substring(0,match.index));var chunk={};var val=!wak.SAFARI?RegExp.lastMatch:match[0];if(val.indexOf('@')==0){chunk.type='token';chunk.name=match[1];currTemplate._tokens[chunk.name]=null;currTemplate._parsedChunks.push(chunk);var index;if((index=chunk.name.indexOf('.'))>0){var refName=chunk.name.substring(0,index);var refTokens=this._parsedRefs[refName];if(refTokens==null){refTokens=[];this._parsedRefs[refName]=refTokens;}
refTokens.push(chunk.name);}}else{if(val.indexOf('@/')==-1){var template=new WakTemplate();chunk.type='block';chunk.name=match[2];chunk.template=template;currTemplate._parsedChunks.push(chunk);var block={'template':template}
currTemplate._blocks[chunk.name]=block;template._parent=currTemplate;template._root=this;stack.push(template);}else{stack.length--;}}
str=!wak.SAFARI?RegExp.rightContext:str.substring(match.index+match[0].length);}
this._parsedChunks.push(str);};};wak.lib.template();wak.lib.url=function(){wak.url={};wak.url.parse=function(str){var params={};str=str.replace(/.*\?/,'');str=str.replace(/#.*/,'');var arr=str.split('&');for(var i=0;i<arr.length;i++){var pair=arr[i];var index=pair.indexOf('=');if(index<=0)continue;var key=pair.substring(0,index);var val=pair.substring(index+1);if(!wak.string.isEmpty(val)){val=decodeURIComponent(val);}else{val=null;}
params[key]=val;}
return params;};wak.url.build=function(params,url,inUrlParams){var newurl='';var buff=[];if(inUrlParams&&inUrlParams.length>0){inUrlParams.each(function(value){if(url.charAt(url.length-1)!='/'){url=url+'/';}
url+=encodeURIComponent(value);});}
for(var key in params){var val=params[key];if(val==null||wak.isString(val)&&val==''){buff.push(key);buff.push('=&');continue;}
if(wak.isArray(val)){val.each(function(obj,i){buff.push(key+'.'+i);buff.push('=');buff.push(encodeURIComponent(obj));buff.push('&');});}else if(wak.isObject(val)&&!(val instanceof Date)){for(var i in val){var obj=val[i];if(obj!=null){buff.push(key+'.'+i);buff.push('=');buff.push(encodeURIComponent(obj));buff.push('&');}}}else{buff.push(key);buff.push('=');if(val instanceof Date)val=val.formatServer();buff.push(encodeURIComponent(val));buff.push('&');}}
var newurl=buff.join('');newurl=newurl.replace(/&$/,'');if(url){if(!newurl.isEmpty())url+=(url.indexOf('?')==-1)?'?':'&';newurl=url+newurl;}
return newurl;}};wak.lib.url();wak.lib.http=function(){wak.http={};wak.http.MULTIPLE_REQ=1;wak.http.CANCEL_PENDING_REQ=2;wak.http.QUEUE_LAST_REQ=3;wak.http.QUEUE_ALL_REQ=4;WakHttpClient=function(multiReqAction){this.onsend=null;this.onresponse=null;this.baseUrl='';this.multiReqAction=multiReqAction;this.queue=null;};WakHttpClient.prototype.createRequest=function(url,params,method){var req=new WakHttpRequest(url,params,method);return req;};WakHttpClient.prototype.sendNow=function(req,reqUrl,reqBody){var ajaxReq=wak.IE?new ActiveXObject("Msxml2.XMLHTTP"):new XMLHttpRequest();ajaxReq.onreadystatechange=function(){this._processAjaxResponse(ajaxReq,req);}.bind(this);if(this.multiReqAction!=wak.http.MULTIPLE_REQ){this._pendingReq=ajaxReq;}
ajaxReq.open(req.method,reqUrl,true);if(req.method=='POST'){ajaxReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');}
ajaxReq.send(reqBody);}
WakHttpClient.prototype.sendRequest=function(req){var reqUrl=this.baseUrl+req.url;var reqBody='';if(this.onsend)this.onsend(req);if(req.params){if(req.method=='GET'){reqUrl=wak.url.build(req.params,reqUrl);}else{reqBody=wak.url.build(req.params);}}
switch(this.multiReqAction){case wak.http.MULTIPLE_REQ:this.sendNow(req,reqUrl,reqBody);break;case wak.http.CANCEL_PENDING_REQ:if(this._pendingReq){this._pendingReq.abort();this._pendingReq=null;}
this.sendNow(req,reqUrl,reqBody);break;case wak.http.QUEUE_LAST_REQ:if(!this._pendingReq){this.sendNow(req,reqUrl,reqBody);}else{this.queue=req;}
break;case wak.http.QUEUE_ALL_REQ:if(!this._pendingReq){this.sendNow(req,reqUrl,reqBody);}else{if(!this.queue){this.queue=[];}
this.queue.push(req);}
break;}};WakHttpClient.prototype.send=function(url,params,onresponse,method,bag){var req=new WakHttpRequest(url,params,method);req.bag=bag;req.onresponse=onresponse;this.sendRequest(req);};WakHttpClient.prototype._processAjaxResponse=function(ajaxReq,req){if(ajaxReq.readyState!=4)return;var ok=false;var status=null;var jsonRes=null;try{status=ajaxReq.status;}catch(e){}
if(status==null||status==0){return;}
if(status=='200'){ok=true;var jsonResText=ajaxReq.responseText;if(wak.string.isEmpty(jsonResText))jsonResText=null;var jsonResVar="mira._tmpJsonResponse = "+jsonResText+";";try{window.eval(jsonResVar);jsonRes=mira._tmpJsonResponse;}catch(e){ok=false;wak.log.error('exception during eval of json response: '+jsonResText);wak.log.error(e);}}
var drop=false;var res=new WakHttpResponse(req,jsonRes,ok);if(this.onresponse)drop=this.onresponse(res);if(!drop)req.onresponse(res);if(this.onafterresponse)this.onafterresponse(req);switch(this.multiReqAction){case wak.http.MULTIPLE_REQ:break;case wak.http.CANCEL_PENDING_REQ:this._pendingReq=null;break;case wak.http.QUEUE_LAST_REQ:this._pendingReq=null;if(this.queue){var req=this.queue;this.queue=null;this.sendRequest(req);}
break;case wak.http.QUEUE_ALL_REQ:this._pendingReq=null;if(this.queue&&this.queue.length>0){var req=shift(this.queue);this.sendRequest(req);}
break;}};WakHttpRequest=function(url,params,method){this.url=url;this.params=params;this.method=method?method:'GET';this.onresponse=wak.emptyFunction;this.cancelPending=false;};WakHttpRequest.prototype.send=function(){wak.httpMulti.send(this);}
WakHttpResponse=function(req,data,ok){this.req=req;this.json=data;this.ok=ok;};wak.httpMulti=new WakHttpClient(wak.http.MULTIPLE_REQ);wak.httpSingle=new WakHttpClient(wak.http.CANCEL_PENDING_REQ);wak.httpQueueLast=new WakHttpClient(wak.http.QUEUE_LAST_REQ);wak.httpQueueAll=new WakHttpClient(wak.http.QUEUE_ALL_REQ);};wak.lib.http();wak.lib.geometry=function(){wak.geometry={newBounds:function(left,top,width,height){var bounds={};bounds.left=left;bounds.top=top;bounds.width=width;bounds.height=height;return bounds;},bounds:function(idOrElem,relToElem,debug){var origElement=wak.elem(idOrElem);var element=origElement;var valueT=0,valueL=0;i=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;if(debug){wak.log.error('#'+i+++' elemId:'+element.id+'('+element.className+')<br>'
+'&nbsp;&nbsp;&nbsp;top:'+element.offsetTop+' topT:'+valueT+' left:'+element.offsetLeft+' leftT:'+valueL+' position:'+wak.css.getComputedStyle(element,'position'));}}while(element=element.offsetParent);var b={'left':valueL,'top':valueT,'width':origElement.offsetWidth,'height':origElement.offsetHeight};if(relToElem){relToElem=$(relToElem);var rb=wak.geometry.bounds(relToElem);b.top=b.top-rb.top;b.left=b.left-rb.left;}
return b;},setBounds:function(idOrElem,bounds){var origElement=$(idOrElem);if((origElement!=null)&&(bounds!=null)){origElement.style.top=bounds.top+'px';origElement.style.left=bounds.left+'px';origElement.style.width=bounds.width+'px';origElement.style.height=bounds.height+'px';}},centeredBounds:function(innerDivIdOrElem,outerDivIdOrElem,deadCenter){var innerDiv=$(innerDivIdOrElem);var outerDiv=$(outerDivIdOrElem);var outerBounds=null;var innerBounds=wak.geometry.bounds(innerDiv);var centeredBounds=innerBounds;if(outerDiv!=null){outerBounds=wak.geometry.bounds(outerDiv);}else{outerBounds=wak.geometry.visibleBounds();}
if(deadCenter){centeredBounds.top=(outerBounds.top+Math.round(outerBounds.height/2))-Math.round(innerBounds.height/2);}else{centeredBounds.top=outerBounds.top;}
centeredBounds.left=(outerBounds.left+Math.round(outerBounds.width/2))-Math.round(innerBounds.width/2);return centeredBounds;},visibleBounds:function(){var myWidth=0,myHeight=0;if(typeof(window.innerWidth)=='number'){myWidth=window.innerWidth;myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
var bd=document.body;var bounds={left:scrOfX,top:scrOfY,width:myWidth,height:myHeight};return bounds;},screenBounds:function(){var bounds={};bounds.left=0;bounds.top=0;bounds.width=screen.width;bounds.height=screen.height;return bounds;},positionBelow:function(moveElemOrId,relativeToElemOrId,autoWidth,rightAlign,relToBounds){var moveElem=wak.elem(moveElemOrId);var moveElemBounds=wak.geometry.bounds(moveElem);var relativeToElem=wak.elem(relativeToElemOrId);var relativeToElemBounds=wak.geometry.bounds(relativeToElem);var newTop=relativeToElemBounds.top+relativeToElemBounds.height;moveElem.style.top=(!relToBounds?newTop:newTop-relToBounds.top)+'px';var newLeft=!rightAlign?relativeToElemBounds.left:relativeToElemBounds.left+relativeToElemBounds.width-moveElemBounds.width;moveElem.style.left=(!relToBounds?newLeft:newLeft-relToBounds.left)+'px';if(autoWidth){moveElem.style.width=(relativeToElemBounds.width-(wak.FF?2:0))+'px';}
if(!relToBounds){var visibleBounds=wak.geometry.visibleBounds();var right=newLeft+moveElemBounds.width;var delta=visibleBounds.width-right;if(delta<=3){moveElem.style.left=(visibleBounds.width-moveElemBounds.width-35)+'px';}}},positionBelowCenter:function(moveElemOrId,relativeToElemOrId,centerElem,offsets){if(!centerElem)centerElem=relativeToElemOrId;if(!offsets)offsets={};var moveElem=wak.elem(moveElemOrId);var moveElemBounds=wak.geometry.bounds(moveElem);var relativeToElem=wak.elem(relativeToElemOrId);var relativeToElemBounds=wak.geometry.bounds(relativeToElem);var center=wak.elem(centerElem);var centerBounds=wak.geometry.bounds(center);moveElem.style.top=(relativeToElemBounds.top+relativeToElemBounds.height+offsets.top)+'px';moveElem.style.left=(relativeToElemBounds.left+Math.round((centerBounds.width-moveElemBounds.width)/2)-relativeToElemBounds.left)+'px';wak.css.show(moveElem);},positionAbove:function(moveElemOrId,relativeToElemOrId,offsets){var moveElem=wak.elem(moveElemOrId);var relativeToElem=wak.elem(relativeToElemOrId);var relativeToElemBounds=wak.geometry.bounds(relativeToElem);var moveElemBounds=wak.geometry.bounds(moveElem);if(offsets){for(var field in offsets){relativeToElemBounds[field]+=offsets[field];}}
moveElem.style.left=relativeToElemBounds.left+'px';moveElem.style.top=(relativeToElemBounds.top-(moveElemBounds.height+15))+'px';},positionRelative:function(moveElemOrId,offsetParentOrId,relativeToElemOrId,offsets){var moveElem=$(moveElemOrId);var offsetElem=$(offsetParentOrId);var relativeToElem=$(relativeToElemOrId);var offsetBounds=wak.geometry.bounds(offsetElem);var relativeToElemBounds=wak.geometry.bounds(relativeToElem);if(offsets){for(var field in offsets){relativeToElemBounds[field]+=offsets[field];}}
moveElem.style.top=(relativeToElemBounds.top-offsetBounds.top)+'px';moveElem.style.left=(relativeToElemBounds.left-offsetBounds.left)+'px';},setAncestorsZIndex:function(elemOrId,value){if(!wak.IE)return;var elem=$(elemOrId);do{elem.__zIndex=elem.style.zIndex;elem.style.zIndex=value;}while(elem=elem.offsetParent)},resetAncestorsZIndex:function(elemOrId){if(!wak.IE)return;var elem=$(elemOrId);do{if(elem.__zIndex||elem.__zIndex==""){elem.style.zIndex=elem.__zIndex;elem.__zIndex=null;}}while(elem=elem.offsetParent)}}};wak.lib.geometry();wak.lib.form=function(){wak.form={};wak.form.setInputFieldHandlers=function(fieldId,buttonId,handler){var listener=function(){var value=$(fieldId).value;if(!wak.string.isEmpty(value))handler(value);};$(fieldId).focus();wak.event.onreturn(fieldId,listener);$(buttonId).onclick=listener;};wak.form.selectValue=function(selectElemorId,value){var selectOptions=wak.elem(selectElemorId).options;for(var i=0;i<selectOptions.length;i++){var option=selectOptions[i];if(option.value==value){option.selected=true;break;}}};wak.form.value=function(elemOrId){var val=null;var elem=wak.elem(elemOrId);if(!elem)wak.log.error('cant get form value for field: '+elemOrId);var tagName=elem.tagName;if(tagName=="TEXTAREA"||tagName=="INPUT"){if(tagName=="INPUT"){if(elem.type=="checkbox"){val=elem.checked;}else if(elem.type=="radio"){var frm=elem.form;for(var i=0;i<frm[elem.name].length;i++){var rad=frm[elem.name][i];if(rad.checked){val=rad.value;break;}}}else{val=elem.value;}}else{val=elem.value;}}else if(tagName=="SELECT"){var i=elem.selectedIndex;if(i>=0)val=elem.options[elem.selectedIndex].value;}else{wak.log.error('unsupported form tag: '+tagName);}
if(val!=null&&wak.isString(val)){val=val.trim();}
return val;};};wak.lib.form();wak.lib.event=function(){wak.event={};wak.event.KEY_BACKSPACE=8;wak.event.KEY_TAB=9;wak.event.KEY_RETURN=13;wak.event.KEY_ESC=27;wak.event.KEY_LEFT=37;wak.event.KEY_UP=38;wak.event.KEY_RIGHT=39;wak.event.KEY_DOWN=40;wak.event.KEY_DELETE=46;wak.event.create=function(evt){return new WakEvent(evt);};wak.event.onreturn=function(idOrElem,callback){wak.event.onkey(wak.event.KEY_RETURN,idOrElem,callback);};wak.event.onkey=function(keyCode,idOrElem,callback){var elem=wak.elem(idOrElem);var listener=function(e){if(e.keyCode==keyCode){callback();}};wak.event.listen(elem,'keypress',listener);};wak.event.listen=function(idOrElem,eventName,listener){var elem=wak.elem(idOrElem);if(elem.addEventListener){elem.addEventListener(eventName,listener,false);}else if(elem.attachEvent){elem.attachEvent('on'+eventName,listener);}};wak.event._createListenerWrapper=function(listener){return function(evt){listener.apply(this,[wak.event.create(evt)]);}};wak.event.onmouseoverdelay=function(evalStr,delay){delay=delay||200;var fireEvent=function(){eval(evalStr);}
wak.event._overDelayTimer=window.setTimeout(fireEvent,delay);};wak.event.onmouseoutdelay=function(evalStr){if(wak.event._overDelayTimer){window.clearTimeout(wak.event._overDelayTimer);}
wak.event._overDelayTimer=null;if(evalStr)eval(evalStr);};wak.event.onmouseover=function(targetId,onOverCallbackStr,onOutCallbackStr){var target=$(targetId);if(target.__isOver)return;target.__isOver=false;target.__onOut=onOutCallbackStr;var targetOnMouseOver=function(){if(target.__isOver)return;if(typeof(wak)=='undefined')return;var lastTarget=wak.event.__lastOverTarget;if(lastTarget&&lastTarget.__isOver&&lastTarget!=target){lastTarget.__isOver=false;eval(lastTarget.__onOut);}
target.__isOver=true;wak.event.__lastOverTarget=target;eval(onOverCallbackStr);document.body.onmouseover=documentOnMouseOver;};var documentOnMouseOver=function(event){if(typeof(wak)=='undefined')return;var wevt=wak.event.create(event);var stillIn=wak.dom.getAncestorElement(wevt.target,target)?true:false;if(!stillIn){eval(onOutCallbackStr);document.body.onmouseover=null;target.__isOver=false;}}
target.onmouseover=targetOnMouseOver;targetOnMouseOver();};WakEvent=function(evt){this.evt=evt?evt:window.event;if(!this.evt)return;this.target=this.evt.target||this.evt.srcElement;this.relatedTarget=this.evt.relatedTarget;this.keyCode=this.evt.keyCode;};WakEvent.prototype.stop=function(){if(!this.evt)return;if(this.evt.preventDefault){this.evt.preventDefault();this.evt.stopPropagation();}else{this.evt.returnValue=false;this.evt.cancelBubble=true;}};WakEvent.prototype.cancelBubble=function(){if(!this.evt)return;this.evt.cancelBubble=true;}};wak.lib.event();wak.lib.notification=function(){wak.notification={};wak.notification._namedEvents={};wak.notification.listen=function(eventName,listener){var listeners=wak.notification._namedEvents[eventName];if(!listeners){listeners=[];wak.notification._namedEvents[eventName]=listeners;}
listeners.push(listener);};wak.notification.removeListener=function(eventName,listener){var listeners=wak.notification._namedEvents[eventName];if(listeners){var i=0;for(i=0;i<listeners.length;i++){if(listeners[i]===listener){listeners.splice(i,1);break;}}}};wak.notification.send=function(eventName,data){var listeners=wak.notification._namedEvents[eventName];if(listeners){listeners.each(function(listener){listener(eventName,data);});}};};wak.lib.notification();wak.lib.tabs=function(){wak.tabs={};wak.tabs.all={};wak.tabs.create=function(id,tabs,isFloatRight){var widget=new TabWidget(id,tabs,isFloatRight);wak.tabs.all[id]=widget;return widget;},wak.tabs.getActivatedTab=function(tabsetName){var returnVal=null;if(tabsetName&&wak.tabs.all[tabsetName]&&wak.tabs.all[tabsetName].activeTab){returnVal=wak.tabs.all[tabsetName].activeTab;}
return returnVal;},wak.tabs.getActivatedTabId=function(tabsetName){var returnVal=null;if(tabsetName&&wak.tabs.all[tabsetName]&&wak.tabs.all[tabsetName].activeTab&&wak.tabs.all[tabsetName].activeTab.id){returnVal=wak.tabs.all[tabsetName].activeTab.id;}
return returnVal;}
TabWidget=Class.create();TabWidget.prototype={id:null,activeTab:null,tabs:null,tabsById:null,onActivate:null,onBeforeActivate:null,ctor:function(id,tabs,isFloatRight){var me=this;this.id=id;this.tabs=[];this.tabsById={};this.onActivate=wak.emptyFunction;this.onDeactivate=wak.emptyFunction;if(tabs){if(isFloatRight){tabs=tabs.reverse();this.isFloatRight=true;}
tabs.each(function(tab){me.add(tab);});}},getTabContent:function(id){var tabContent=$(id+'tabcontent');if(!tabContent)tabContent=$(id+'tabcontentId');return tabContent;},add:function(tab){this.tabs.push(tab);this.tabsById[tab.id]=tab;},activate:function(id,isClick,event){if(wak.tabs.onActivate&&isClick&&(!this.activeTab||(this.activeTab.id!=id))){wak.tabs.onActivate(id);}
if(this.onBeforeActivate){var tmpId=this.activeTab?this.activeTab.id:null;this.onBeforeActivate(tmpId,id);}
if(this.activeTab){this.deactivate(this.activeTab.id);}
var newTab=this.tabsById[id];this.activeTab=newTab;$(newTab.id+'tab').className+='Active';var tabContent=this.getTabContent(newTab.id);if(tabContent)tabContent.style.display='block';if(newTab.onActivate)newTab.onActivate(!newTab.__loaded);this.onActivate(newTab,!newTab.__loaded);newTab.__loaded=true;},deactivate:function(tabId){this.onDeactivate();var oldTab=this.tabsById[tabId];if(oldTab.ondeactivate){if(oldTab.ondeactivate())return;}
var oldLi=$(oldTab.id+'tab');oldLi.className=oldLi.className.replace('Active','');var content=this.getTabContent(oldTab.id);if(content)content.style.display='none';},getActivatedTabs:function(){return this.tabs.findAll(function(tab){if(tab.__loaded)return tab;});},resetActivatedTabs:function(){this.tabs.each(function(tab){tab.__loaded=false;});},render:function(t,token){var tabsTemplate=wak.template.create(g_wakTabWidget);tabsTemplate.replaceToken('wid',this.id);var tabT=tabsTemplate.getBlock('TabBlock');var total=this.tabs.length;this.tabs.each(function(tab,index){tabT.replaceToken('tab',tab);if(!this.isFloatRight){if(index==0)tabT.replaceToken('pos','first');else if((index+1)==total)tabT.replaceToken('pos','last');else tabT.replaceToken('pos','mid');}else{if(index==0)tabT.replaceToken('pos','last');else if((index+1)==total)tabT.replaceToken('pos','first');else tabT.replaceToken('pos','mid');}
tabT.next();}.bind(this));var html=tabsTemplate.compose();if(t)t.replaceToken(token,html);else wak.html.setContent(token,html);}}};wak.lib.tabs();wak.lib.calendar=function(){wak.calendar={};wak.calendar.all={};wak.calendar.popup={};wak.calendar.MONTHS={0:'January',1:'February',2:'March',3:'April',4:'May',5:'June',6:'July',7:'August',8:'September',9:'October',10:'November',11:'December'};wak.calendar.defaultNoDatesString='mm/dd';WakCalendarPopup=Class.create();WakCalendarPopup.prototype={_id:null,_divId:null,calendar:null,targetAnc:null,targetElem:null,onopen:wak.emptyFunction,onclose:wak.emptyFunction,onselect:wak.emptyFunction,defaultText:null,defaultColor:'#aaaaaa',ctor:function(divId,targetElem,config,defText){this._id='wakcalpop'+wak.idGenerator++;wak.calendar.popup[this._id]=this;this.targetElem=targetElem;this.targetAnc=targetElem+'Link';this.defaultText=defText||wak.calendar.defaultNoDatesString;var defaultConfig={up:1,showOffDays:false,showPastDaysAsOff:true,maxNavDate:Date.removeHMS(new Date()).add('M',12).monthEnd()};if(!config)config={};for(var k in defaultConfig)if(!wak.isDefined(config[k]))config[k]=defaultConfig[k];this.calendar=new WakCalendar(divId,config);this.calendar.render();if($(this.targetAnc)){$(this.targetAnc).onclick=function(evt){var event=wak.event.create(evt);field.focus();event.cancelBubble();}.bindEventListener(this);}
var field=$(this.targetElem);if(!field.value){field.value=this.defaultText;field.style.color=this.defaultColor;}
field.onclick=function(evt){var event=wak.event.create(evt);event.cancelBubble();}.bindEventListener(this);field.onfocus=function(evt){field.select();this.open();}.bindEventListener(this);},open:function(){var field=$(this.targetElem);field.style.color='#666666';field.select();this.onopen(this.calendar);this.calendar.onselect=function(){var retval=this.onselect.apply(window,arguments);this.close();return retval;}.bind(this);wak.css.display(this.calendar.divId,true);wak.geometry.positionBelow(this.calendar.divId,this.targetElem);document.__origOnClick=document.onclick;document.onclick=this.close.bindEventListener(this);this.calendar.setEventHandlers();},close:function(){var isHidden=wak.css.testComputedStyle(this.calendar.divId,'display','none');wak.css.display(this.calendar.divId,false);var field=$(this.targetElem);if(field&&field.value.startsWith("mm"))field.style.color=this.defaultColor;if(!isHidden){document.onclick=document.__origOnClick;return this.onclose(this.calendar);}
return true;},resetField:function(){var field=$(this.targetElem);field.style.color=this.defaultColor;field.value=this.defaultText;}}
WakCalendar=Class.create();WakCalendar.prototype={CELLS:42,ROWS:6,onselect:wak.emptyFunction,onContainerClick:wak.emptyFunction,startDate:null,config:null,divId:null,_id:null,_today:null,_todayYr:null,_dates:null,_titles:null,ctor:function(divId,conf){this.divId=divId;this._id='wakcal'+wak.idGenerator++;wak.calendar.all[this._id]=this;this._today=Date.removeHMS(new Date());this._todayYr=this._today.getFullYear();this._dates={};this._titles={};this.config={up:1,startDate:this._today,showNav:true,showToday:false,showPastDaysAsOff:true,showOffDays:false,minNavDate:this._today,maxNavDate:Date.removeHMS(new Date()).add('M',11).monthEnd(),defaultDayClass:'unavail',defaultDayTitle:'Not Available',defaultDaySelectable:false,interactive:true};if(conf)for(var k in conf)this.config[k]=conf[k];this.startDate=this.config.startDate;this.openStartDate=this.startDate;this.resetDateRanges();if(this.config.interactive){this.setEventHandlers();}else{if($(this.divId)){$(this.divId).onclick=function(rawEvt){this.onContainerClick();}.bindEventListener(this);}}},nextPage:function(rawEvt){this.startDate=this.startDate.addMonth();this.render();wak.event.create(rawEvt).cancelBubble();},prevPage:function(rawEvt){this.startDate=this.startDate.subtract('M');this.render();wak.event.create(rawEvt).cancelBubble();},addDateRange:function(startDate,endDate,className,unselectable,title){startDate=Date.removeHMS(startDate);endDate=Date.removeHMS(endDate);if(unselectable&&className!='unselectable')className+=' unselectable';while(startDate<=endDate){var key=this._getDatesKey(startDate);this._dates[key]=className;this._titles[key]=title;startDate.setDate(startDate.getDate()+1);}},appendDateRange:function(startDate,endDate,className,title){startDate=Date.removeHMS(startDate);endDate=Date.removeHMS(endDate);var availCheckInRegex=/(^|\s)availCheckIn(\s|$)/;var availCheckOutRegex=/(^|\s)availCheckOut(\s|$)/;while(startDate<=endDate){var key=this._getDatesKey(startDate);var value=this._dates[key];var newClassName=null;if(!value)value='';if((className=='selectedDate'||className=='fromDate')&&availCheckInRegex.test(value)){newClassName='selCheckIn';}else if((className=='selectedDate'||className=='toDate')&&availCheckOutRegex.test(value)){newClassName='selCheckOut';}else{newClassName=className;}
if(newClassName&&newClassName.length>0){var regex=new RegExp('(^|\\s)'+newClassName+'(\\s|$)');var space=value==''?'':' ';if(!regex.test(value)){this._dates[key]=value+space+newClassName;}}
if(title)this._titles[key]=title;startDate.setDate(startDate.getDate()+1);}},addAvailabilityData:function(spans,checkInDaysSelectable,checkOutDaysSelectable,selectOnlySpan,travelStartDate){spans.each(function(span,index){var startDate=span.startDate;var endDate=span.endDate;var nextDate=new Date(endDate.getFullYear(),endDate.getMonth(),endDate.getDate()+1);var startDateKey=this._getDatesKey(startDate);var nextDateKey=this._getDatesKey(nextDate);var selectable=!selectOnlySpan||startDate.getTime()==selectOnlySpan.startDate.getTime();var today=Date.removeHMS(new Date());if(selectOnlySpan){if(selectable){this.addDateRange(selectOnlySpan.startDate,travelStartDate,'avail',true,'Available');this.addDateRange(travelStartDate,selectOnlySpan.endDate,'avail',false,'Available');}else{this.addDateRange(startDate,endDate,'avail',true,'Not selectable with chosen start date');}}else{this.addDateRange(startDate,endDate,'avail',!selectable,'Available');}
var value=this._dates[startDateKey];if(!value)value='';if(index>0||startDate>today)this._dates[startDateKey]=value+' availCheckIn';if(!checkInDaysSelectable||!selectable){this._dates[startDateKey]+=' unselectable';}
this._titles[startDateKey]='Available for check-in only';var value=this._dates[nextDateKey];if(!value)value='';this._dates[nextDateKey]=value+' availCheckOut';if(!checkOutDaysSelectable||!selectable){this._dates[nextDateKey]+=' unselectable';}
this._titles[nextDateKey]='Available for check-out only';}.bind(this));},appendAvailRange:function(startDate,endDate,checkInDaysSelectable,checkOutDaysSelectable){var unavailRegex=/(^|\s)unavail(\s|$)/;var availCheckInRegex=/(^|\s)availCheckIn(\s|$)/;var availCheckOutRegex=/(^|\s)availCheckOut(\s|$)/;var prevDate=new Date(startDate.getFullYear(),startDate.getMonth(),startDate.getDate()-1);var nextDate=new Date(endDate.getFullYear(),endDate.getMonth(),endDate.getDate()+1);var prevDateKey=this._getDatesKey(prevDate);var startDateKey=this._getDatesKey(startDate);var nextDateKey=this._getDatesKey(nextDate);this.addDateRange(startDate,endDate,'avail',false,'Available');var classes=this._dates[prevDateKey];if(!classes)classes=this.config.defaultDayClass;if(unavailRegex.test(classes)){this._dates[startDateKey]='avail availCheckIn';this._titles[startDateKey]='Available for check-in only';}else if(availCheckOutRegex.test(this._dates[prevDateKey])){this._dates[startDateKey]='avail availCheckIn';}
classes=this._dates[nextDateKey];if(!classes)classes=this.config.defaultDayClass;if(unavailRegex.test(classes)){this._dates[nextDateKey]+=' availCheckOut';this._titles[nextDateKey]='Available for check-out only';}else if(availCheckInRegex.test(classes)){this._dates[nextDateKey]="avail";this._titles[nextDateKey]='Available';}},appendBookedRange:function(startDate,endDate,checkInDaysSelectable,checkOutDaysSelectable){var availRegex=/(^|\s)avail(\s|$)/;var unavailRegex=/(^|\s)unavail(\s|$)/;var availCheckOutRegex=/(^|\s)availCheckOut(\s|$)/;var prevDate=new Date(startDate.getFullYear(),startDate.getMonth(),startDate.getDate()-1);var nextDate=new Date(endDate.getFullYear(),endDate.getMonth(),endDate.getDate()+1);var prevDateKey=this._getDatesKey(prevDate);var startDateKey=this._getDatesKey(startDate);var nextDateKey=this._getDatesKey(nextDate);this.addDateRange(startDate,endDate,'unavail',false,'Not Available');var prevDayClasses=this._dates[prevDateKey];if(!prevDayClasses)prevDayClasses=this.config.defaultDayClass;var nextDayClasses=this._dates[nextDateKey];if(!nextDayClasses)nextDayClasses=this.config.defaultDayClass;if(unavailRegex.test(prevDayClasses)&&unavailRegex.test(nextDayClasses)){this._dates[nextDateKey]='unavail';this._titles[nextDateKey]='Not available';}else if(availRegex.test(prevDayClasses)){this._dates[startDateKey]=' availCheckOut';this._titles[startDateKey]='Available for check-out Only';}
if(availRegex.test(nextDayClasses)){this._dates[nextDateKey]=' availCheckIn';this._titles[nextDateKey]='Available for check-in Only';}if(availCheckOutRegex.test(nextDayClasses)){this._dates[nextDateKey]=' unavail';this._titles[nextDateKey]='Not Available';}},resetDateRanges:function(){this._dates={};this._strikePastDays();},render:function(){var currDate=this.startDate;var t=wak.template.create(g_wakCalendarWidget,this.divId);t.replaceToken('wid',this._id);t.dateFormatterIsLocal=false;var monthB=t.getBlock('MonthBlock');for(var i=0;i<this.config.up;i++){this._renderMonthHeader(monthB,i,currDate);var monthDate=currDate.monthStart();var monthDays=currDate.monthEnd().getDate();var preOffDays=monthDate.getDay();var preMonth=monthDate.subtract('M');var nextOffDays=this.CELLS-monthDays-preOffDays;var nextMonth=monthDate.addMonth(false);var currMonth=currDate.getMonth();var currYear=currDate.getFullYear();var day=1;var nextDay=1;var weekB=monthB.getBlock('WeekBlock');for(var wi=0;wi<6;wi++){var dayB=weekB.getBlock('DayBlock');for(var di=0;di<7;){if(wi==0&&preOffDays>0){var lastDate=preMonth.monthEnd().getDate()-preOffDays+1;di=preOffDays;while(preOffDays>0){this._renderCell(dayB,lastDate++,currMonth,currYear,true);preOffDays--;}}
if(monthDays>0){this._renderCell(dayB,day++,currMonth,currYear,false);monthDays--;di++;}
if(monthDays==0&&nextOffDays>0){while(nextOffDays>0&&(di<7)){this._renderCell(dayB,nextDay++,currMonth,currYear,true);nextOffDays--;di++;}}}
weekB.next();}
monthB.next();currDate=currDate.addMonth();}
t.compose();},getSpans:function(cls){var spans=[];var startD=null;var endD=null;var td=null;var unavailRegex=new RegExp('(^|\\s)'+cls+'(\\s|$)');var availCheckoutRegex=new RegExp('(^|\\s)'+'availCheckOut'+'(\\s|$)');var cells=$(this.divId).getElementsByTagName("TD");for(var i=0;i<cells.length;i++){if(!cells[i].getAttribute('__date'))continue;if(cells[i].className.contains("past"))continue;td=cells[i];var tdCls=td.className.trim();var hasUnavail=unavailRegex.test(tdCls);var hasAvailCheckout=availCheckoutRegex.test(tdCls);if(!hasUnavail&&!hasAvailCheckout){if(startD==null){startD=new Date(td.getAttribute('__date'));}}else{if(startD!=null){endD=new Date(td.getAttribute('__date')).subtract('D',1);spans.push(startD.formatServer()+' '+endD.formatServer());startD=null;endD=null;}}}
if(startD!=null&&endD==null){endD=new Date(td.getAttribute('__date'));spans.push(startD.formatServer()+' '+endD.formatServer());}
return spans;},_strikePastDays:function(){if(this.config.showPastDaysAsOff){this.addDateRange(this._today.monthStart().subtract('D',7),this._today.subtract('D',1),'past',true,'Past');}},_renderMonthHeader:function(monthB,upCursor,currDate){var monthTitle=wak.calendar.MONTHS[currDate.getMonth()];monthTitle=monthTitle.toUpperCase();if(this._todayYr!=currDate.getFullYear()){monthTitle+=' &nbsp;\''+(currDate.getFullYear()+'').substring(2);}
monthB.replaceToken('monthTitle',monthTitle);if(!this.config.showNav){monthB.replaceToken('hideLeft','hidden');monthB.replaceToken('hideRight','hidden');}else{if(this.config.minNavDate&&this.config.minNavDate.getMonth()==currDate.getMonth()&&this.config.minNavDate.getFullYear()==currDate.getFullYear()){monthB.replaceToken('hideLeft','hidden');}
if(this.config.maxNavDate&&this.config.maxNavDate.getMonth()==currDate.getMonth()&&this.config.maxNavDate.getFullYear()==currDate.getFullYear()){monthB.replaceToken('hideRight','hidden');}
if(this.config.up>1){if(upCursor==0){monthB.replaceToken('hideRight','hidden');}else if((upCursor+1)==this.config.up){monthB.replaceToken('hideLeft','hidden');}else{monthB.replaceToken('hideLeft','hidden');monthB.replaceToken('hideRight','hidden');}}}},_renderCell:function(dayB,day,month,yr,off){if(!off||this.config.showOffDays){dayB.replaceToken('day',day);}else{dayB.replaceToken('day','&nbsp;');}
if(off){dayB.replaceToken('cellClass','off empty unselectable');}else{dayB.replaceToken('date',(month+1)+'/'+day+'/'+yr);if(this.config.showToday&&day==this._today.getDate()&&month==this._today.getMonth()&&yr==this._today.getFullYear()){dayB.replaceToken('today','today');}
var key=this._getDatesKey(null,month,day,yr);var cellClass=this._dates[key];var title=this._titles[key];if(!cellClass){cellClass=this.config.defaultDayClass;title=this.config.defaultDayTitle;}
if(cellClass)dayB.replaceToken('cellClass',cellClass);var debug=false;var classes=debug?'('+cellClass+')':'';dayB.replaceToken('title',title&&title.length>0?title+classes:classes);}
dayB.next();},setEventHandlers:function(){var container=$(this.divId);container.onmouseover=this._onmouseover.bindEventListener(this);container.onmouseout=this._onmouseout.bindEventListener(this);container.onclick=this._onclick.bindEventListener(this);},_onmouseover:function(rawEvt){var evt=wak.event.create(rawEvt);var targetCell=wak.dom.getAncestorWithTag(evt.target,'TD');if(targetCell&&!targetCell.className.contains('unselectable')){wak.css.addClass(targetCell,'over');}},_onmouseout:function(rawEvt){var evt=wak.event.create(rawEvt);var targetCell=wak.dom.getAncestorWithTag(evt.target,'TD');var relatedCell=wak.dom.getAncestorWithTag(evt.relatedTarget,'TD');if(targetCell&&targetCell!==relatedCell){if(!targetCell.className.contains('unselectable')){wak.css.removeClass(targetCell,'over');}}},_onclick:function(rawEvt){this._eventHandler(rawEvt,'click');wak.event.create(rawEvt).cancelBubble();},_eventHandler:function(rawEvt,type){var evt=wak.event.create(rawEvt);if(evt.target.tagName!='TD')return;if(evt.target.className.contains('unselectable'))return;var td=evt.target;if(type=='over'){wak.css.addClass(td,'over');}else if(type=='out'){wak.css.removeClass(td,'over');}else if(type=='click'){var dateStr=td.getAttribute('__date');var date=new Date(dateStr);var clickedOnFirstCal=this.startDate.getMonth()==date.getMonth();if(!this.onselect(date,dateStr,td,clickedOnFirstCal)){wak.css.addClass(td,'click');}
this.render();}},_getDatesKey:function(date,month,day,yr){if(date){return date.getMonth()+'_'+date.getDate()+'_'+date.getFullYear();}else{return month+'_'+day+'_'+yr;}}}};wak.lib.calendar();wak.lib.date=function(){wak.date={};wak.date.DAY='D';wak.date.WEEK='W';wak.date.MONTH='M';wak.date.YEAR='Y';Date.MONTHS=['January','February','March','April','May','June','July','August','September','October','November','December'];Date.ABBR_MONTHS=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];Date.ABBR_MONTHS_LOWER_CASE={'jan':1,'feb':2,'mar':3,'apr':4,'may':5,'jun':6,'jul':7,'aug':8,'sep':9,'oct':10,'nov':11,'dec':12};Date.DAYS=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Date.ABBR_DAYS=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];Date.NUM_DAYS_IN_MONTH=[31,28,31,30,31,30,31,31,30,31,30,31];Date.NUM_DAYS_TO_MONTH=[0,31,59,90,120,151,181,212,243,273,304,334];Date._pad=function(num,doPad){return doPad&&(num<10)?'0'+num:num;};Date.equals=function(date1,date2){return((date1===date2)||((date1&&date2)&&(date1.valueOf()==date2.valueOf())));};Date.parseParamsDate=function(dateString){var returnValue=null;if(dateString){dateString=dateString.replace(/-/g,"/");returnValue=new Date(dateString);}
return returnValue;};Date.parseSimpleDate=function(val,asString){var currDate=new Date();var retval=null;if(val&&!val.isEmpty()&&!val.startsWith('mm')){var matchArray=null;if(matchArray=val.match(/^(\d+)\/(\d+)$/)){retval=new Date(currDate.getFullYear(),matchArray[1]-1,matchArray[2],0,0,0,0);}else if(matchArray=val.match(/^(\d+)\/(\d+)\/(\d\d)$/)){retval=new Date('20'+matchArray[3],matchArray[1]-1,matchArray[2],0,0,0,0);}else if(matchArray=val.match(/^(\w\w\w) (\d\d?)$/)){var month=Date.ABBR_MONTHS_LOWER_CASE[matchArray[1].toLowerCase()];retval=new Date(currDate.getFullYear(),month-1,matchArray[2],0,0,0,0);}else{var date=new Date(val);if(date&&!isNaN(date.valueOf())){retval=Date.removeHMS(date);}}}
if(retval&&asString){retval=retval.formatServer();}
return retval;};Date.removeHMS=function(arg){var date=new Date(arg);date.setHours(0);date.setMinutes(0);date.setSeconds(0);date.setMilliseconds(0);return date;};Date.getLocalDateFromUTCDate=function(date){return new Date(date.getUTCFullYear(),date.getUTCMonth(),date.getUTCDate(),0,0,0,0);};Object.extend(Date.prototype,{formatServer:function(delim){var delim=delim||'-';return this.format('%Y'+delim+'%n'+delim+'%e',false);},getSimpleDateString:function(delim){var delim=delim||'/';return this.format('%n'+delim+'%e'+delim+'%Y',false);},format:function(fmt,isUTC){var str=fmt;str=str.replace(/%a/g,this._getShortDayName(isUTC));str=str.replace(/%A/g,this._getDayName(isUTC));str=str.replace(/%b/g,this._getShortMonthName(isUTC));str=str.replace(/%B/g,this._getMonthName(isUTC));str=str.replace(/%d/g,this._getDate(true,isUTC));str=str.replace(/%e/g,this._getDate(false,isUTC));str=str.replace(/%m/g,this._getMonth(true,isUTC));str=str.replace(/%n/g,this._getMonth(false,isUTC));str=str.replace(/%y/g,this._yearString(isUTC));str=str.replace(/%Y/g,this.getFullYear(isUTC));str=str.replace(/%H/g,this._getHours(true,true,isUTC));str=str.replace(/%I/g,this._getHours(true,isUTC));str=str.replace(/%k/g,this._getHours(false,true,isUTC));str=str.replace(/%l/g,this._getHours(false,isUTC));str=str.replace(/%M/g,this._getMinutes(isUTC));str=str.replace(/%p/g,this._getAmPm(false,isUTC));str=str.replace(/%P/g,this._getAmPm(true,isUTC));str=str.replace(/%S/g,this._getSeconds(isUTC));str=str.replace(/%%/g,'%');return str;},_yearString:function(isUTC){var val=!isUTC?this.getFullYear():this.getUTCFullYear();val=val%100;return Date._pad(val,true);},_getMonth:function(pad,isUTC){var val=!isUTC?this.getMonth():this.getUTCMonth();val+=1;return Date._pad(val,pad);},_getMonthName:function(isUTC){return Date.MONTHS[!isUTC?this.getMonth():this.getUTCMonth()];},_getShortMonthName:function(isUTC){return Date.ABBR_MONTHS[!isUTC?this.getMonth():this.getUTCMonth()];},_getDate:function(pad,isUTC){var val=!isUTC?this.getDate():this.getUTCDate();return Date._pad(val,pad);},_getDayName:function(isUTC){return Date.DAYS[!isUTC?this.getDay():this.getUTCDay()];},_getShortDayName:function(isUTC){return Date.ABBR_DAYS[!isUTC?this.getDay():this.getUTCDay()];},_getAmPm:function(isUpper,isUTC){var val=!isUTC?this.getHours():this.getUTCHours();return(val<12)?(isUpper?'AM':'am'):(isUpper?'PM':'pm');},_getHours:function(pad,isMilitary,isUTC){var val=!isUTC?this.getHours():this.getUTCHours();if(!isMilitary){val%=12;if(val==0)val=12;}
return Date._pad(val,pad);},_getMinutes:function(isUTC){var val=!isUTC?this.getMinutes():this.getUTCMinutes;return Date._pad(val,true);},_getSeconds:function(isUTC){var val=!isUTC?this.getSeconds():this.getUTCSeconds();return Date._pad(val,true);},add:function(field,amount,isUTC){if(!wak.isDefined(amount))amount=1;var newD=new Date(this.getTime());switch(field){case wak.date.MONTH:var newMonth=!isUTC?this.getMonth():this.getUTCMonth();newMonth+=amount;var years=0;if(newMonth<0){while(newMonth<0){newMonth+=12;years-=1;}}else if(newMonth>11){while(newMonth>11){newMonth-=12;years+=1;}}
var dayOfMonth=!isUTC?this.getDate():this.getUTCDate();if(dayOfMonth>Date.NUM_DAYS_IN_MONTH[newMonth]){dayOfMonth=Date.NUM_DAYS_IN_MONTH[newMonth];!isUTC?newD.setDate(dayOfMonth):newD.setUTCDate(dayOfMonth);}
years+=!isUTC?this.getFullYear():this.getUTCFullYear();!isUTC?newD.setMonth(newMonth):newD.setUTCMonth(newMonth);!isUTC?newD.setFullYear(years):newD.setUTCFullYear(years);break;case wak.date.DAY:!isUTC?newD.setDate(this.getDate()+amount):newD.setUTCDate(this.getUTCDate()+amount);break;case wak.date.YEAR:!isUTC?newD.setFullYear(this.getFullYear()+amount):newD.setUTCFullYear(this.getUTCFullYear()+amount);break;case wak.date.WEEK:!isUTC?newD.setDate(this.getDate()+(amount*7)):newD.setUTCDate(this.getUTCDate()+(amount*7));break;}
return newD;},subtract:function(field,amount,isUTC){if(!wak.isDefined(amount))amount=1;return this.add(field,-amount,isUTC);},addMonth:function(amount,isUTC){return this.add('M',amount,isUTC);},subtractMonth:function(amount,isUTC){return this.subtract('M',amount,isUTC);},monthStart:function(isUTC){var date=null;if(!isUTC){date=new Date(this.getFullYear(),this.getMonth(),1);}else{date=new Date(Date.UTC(this.getUTCFullYear(),this.getUTCMonth(),1));}
return date;},monthEnd:function(isUTC){var start=this.monthStart(isUTC);var nextMonth=start.add(wak.date.MONTH,1,isUTC);var end=nextMonth.subtract(wak.date.DAY,1,isUTC);return end;},getDayOfYear:function(isUTC){var month=!isUTC?this.getMonth():this.getUTCMonth();var date=!isUTC?this.getDate():this.getUTCDate();return Date.NUM_DAYS_TO_MONTH[month]+date;}});};wak.lib.date();wak.lib.autocomplete=function(){wak.autocomplete={};wak.autocomplete.all={};wak.autocomplete.create=function(inputId,buttonId,divId,rowTemplate){return new WakAutoCompleteWidget(inputId,buttonId,divId,rowTemplate);};WakAutoCompleteWidget=function(inputId,buttonId,divId,rowTemplate){this._id='acw'+wak.idGenerator++;this._inputId=inputId;this._buttonId=buttonId;this._divId=divId;this._rowTemplate=rowTemplate;this._selectedRow=null;$(inputId).onkeyup=this._onkeypress.bindEventListener(this);$(inputId).onblur=function(){var cb=function(){this._hide();}.bind(this);window.setTimeout(cb,200);}.bindEventListener(this);this.selectClassName='';this.onFetch=wak.emptyFunction;this.onEnter=wak.emptyFunction;this.onSelect=wak.emptyFunction;wak.autocomplete.all[this._id]=this;};WakAutoCompleteWidget.prototype.render=function(matches){if(matches.length==0){this._hide();return;}
var t=wak.template.create(this._rowTemplate,this._divId);matches.each(function(data,index){t.replaceToken('row',data);t.replaceToken('index',index);t.replaceToken('wid',this._id);t.next();}.bind(this));t.compose();this._matches=matches;this._show();};WakAutoCompleteWidget.prototype.onclick=function(index){this.onSelect(this._matches[index]);this._hide();};WakAutoCompleteWidget.prototype._onkeypress=function(evt){evt=new WakEvent(evt);var sterm=wak.form.value(this._inputId);if(wak.string.isEmpty(sterm)){this._hide();return;}
switch(evt.keyCode){case wak.event.KEY_ESC:this._hide();break;case wak.event.KEY_DOWN:this._select('down');break;case wak.event.KEY_UP:this._select('up');break;case wak.event.KEY_RETURN:if(this._selectedRow){var index=this._selectedRow.getAttribute("acIndex");this.onclick(index);}else{this.onEnter(sterm);this._hide();}
break;default:this.onFetch(sterm);}};WakAutoCompleteWidget.prototype._select=function(dir){var div=wak.elem(this._divId);var row=null;if(this._selectedRow){wak.css.removeClass(this._selectedRow,this.selectClassName);row=dir=='down'?this._selectedRow.nextSibling:this._selectedRow.previousSibling;}
if(!row)row=dir=='down'?div.firstChild:div.lastChild;wak.css.addClass(row,this.selectClassName);this._selectedRow=row;};WakAutoCompleteWidget.prototype._hide=function(){wak.css.hide(this._divId);this._selectedRow=null;};WakAutoCompleteWidget.prototype._show=function(){wak.geometry.positionBelow(this._divId,this._inputId,true);wak.css.show(this._divId);};};wak.lib.autocomplete();wak.lib.closures=function(){wak.closures={};var baggage={};var ticketCounter=1;wak.closures.getClosure=function(ticketCounter){return function(){if(typeof(wak)!='undefined')wak.closures.getEvent(ticketCounter)};}
wak.closures.setEvent=function(elemOrId,event,fn){var elem=$(elemOrId);baggage[ticketCounter]=fn;wak.event.listen(elem,event,wak.closures.getClosure(ticketCounter++));}
wak.closures.getEvent=function(ticket){baggage[ticket]();}}
wak.lib.closures();wak.lib.animate=function(){wak.animate={FP:0.15,INTERVAL:30,_faders:{},open:function(elem,onOpened){elem=$(elem);elem.__origOverflow=elem.style.overflow;elem.__origHeight=wak.FF&&!wak.SAFARI?wak.css.getComputedStyle(elem,'height',true):elem.offsetHeight;elem.style.overflow='hidden';currHeight=1;elem.style.height=currHeight+'px';wak.css.show(elem);var fn=function(){currHeight=currHeight+((elem.__origHeight-currHeight)*wak.animate.FP);if(Math.abs(elem.__origHeight-currHeight)<=2){window.clearInterval(timer);elem.style.overflow=elem.__origOverflow;elem.style.height=elem.__origHeight;wak.css.show(elem);if(onOpened)onOpened();}else{elem.style.height=Math.round(currHeight)+'px';}}
var timer=window.setInterval(fn,wak.animate.INTERVAL);},close:function(elem,onClosed){elem=$(elem);elem.__origOverflow=elem.style.overflow;elem.__origHeight=wak.FF&&!wak.SAFARI?wak.css.getComputedStyle(elem,'height',true):elem.offsetHeight;elem.style.overflow='hidden';var currHeight=elem.__origHeight;var fn=function(){currHeight=currHeight-(currHeight*wak.animate.FP);if(Math.abs(currHeight)<=2){window.clearInterval(timer);elem.style.overflow=elem.__origOverflow;elem.style.height=elem.__origHeight+'px';wak.css.hide(elem);if(onClosed)onClosed();}else{elem.style.height=Math.round(currHeight)+'px';}}
var timer=window.setInterval(fn,wak.animate.INTERVAL);},scroll:function(scrollTop){var currTop=document.body.scrollTop;if(currTop==scrollTop)return;if(currTop>scrollTop){var move=function(){currTop=currTop-(currTop*wak.animate.FP);if(Math.abs(currTop-scrollTop)<=2){document.body.scrollTop=scrollTop;window.clearInterval(timer);}else{document.body.scrollTop=Math.round(currTop);}}
var timer=window.setInterval(move,wak.animate.INTERVAL);}else{var move=function(){currTop=currTop+(currTop*wak.animate.FP);if(Math.abs(currTop+scrollTop)<=2){document.body.scrollTop=scrollTop;window.clearInterval(timer);}else{document.body.scrollTop=Math.round(currTop);}}
var timer=window.setInterval(move,wak.animate.INTERVAL);}},fade:function(id,startOpacity,endOpacity,frameMillis){var timer=0;frameMillis=frameMillis||750;var speed=Math.round(frameMillis/100);wak.css.setOpacity(id,startOpacity);if(!wak.animate._faders[id]){wak.animate._faders[id]={'in':{on:false,lastOpacity:null},'out':{on:false,lastOpacity:null}}};var changeOpacityFn=function(id,i,inOrOut,isLast){return function(){if(wak.animate._faders[id][inOrOut].on){wak.css.setOpacity(id,i);}
if(isLast)wak.animate._faders[id][inOrOut].on=false;}};if(startOpacity>endOpacity){wak.animate._faders[id]['out'].on=true;wak.animate._faders[id]['in'].on=false;for(i=startOpacity;i>=endOpacity;i--){window.setTimeout(changeOpacityFn(id,i,'out',i<endOpacity),timer*speed);timer++;}}else if(startOpacity<endOpacity){wak.animate._faders[id]['in'].on=true;wak.animate._faders[id]['out'].on=false;for(i=startOpacity;i<=endOpacity;i++){window.setTimeout(changeOpacityFn(id,i,'in',i>endOpacity),timer*speed);timer++;}}},fade2:function(id,startOpacity,endOpacity,intervalMillis,increment,onFinished){var elem=$(id);var millis=wak.isDefinedNonNull(intervalMillis)?intervalMillis:5;var increment=wak.isDefinedNonNull(increment)?increment:1;wak.css.setOpacity(elem,startOpacity);elem.__currentOpacity=startOpacity;elem.__finalOpacity=endOpacity;var fn=function(){if(elem.__currentOpacity==elem.__finalOpacity){window.clearInterval(timer);if(onFinished)onFinished();}else{if(elem.__currentOpacity>elem.__finalOpacity){elem.__currentOpacity-=increment;elem.__currentOpacity=Math.max(elem.__finalOpacity,elem.__currentOpacity);}else{elem.__currentOpacity+=increment;elem.__currentOpacity=Math.min(elem.__finalOpacity,elem.__currentOpacity);}
wak.css.setOpacity(elem,elem.__currentOpacity);}}
var timer=window.setInterval(fn,millis);return timer;},expand:function(elem,onFinished){elem=$(elem);var elemB=wak.geometry.bounds(elem);elem.style.overflow='hidden';elem.style.clip.top=(elemB.height*.49)+'px';elem.style.clip.bottom=(elemB.height*.51)+'px';elem.style.clip.left=(elemB.width*.49)+'px';elem.style.clip.right=(elemB.width*.51)+'px';elem.__expandCount=1;var fn=function(){if(elem.__expandCount==50){window.clearInterval(timer);if(onFinished)onFinished();}else{elem.__expandCount++;var p1=.50-(elem.__expandCount*.01);var p2=.50+(elem.__expandCount*.01);var top=Math.round(elemB.height*p1);var left=Math.round(elemB.width*p1);var bottom=Math.round(elemB.height*p2);var right=Math.round(elemB.width*p2);var clipString='rect('+top+'px,'+right+'px,'+bottom+'px,'+left+'px)';elem.style.clip=clipString;}}
var timer=window.setInterval(fn,10);},line:function(elem,fromBounds,toBounds,ondone){var topDone=false;var leftDone=false;var div=$(elem);var divBounds=wak.geometry.bounds(div);var currTop=fromBounds.top;var currLeft=fromBounds.left;div.style.top=currTop+'px';div.style.left=currLeft+'px';var topMax=toBounds.top;var leftMax=toBounds.left;var topDir=(currTop>topMax)?'up':'down';var leftDir=(currLeft<leftMax)?'right':'left';wak.css.show(div);var currWidth=divBounds.width;var currHeight=divBounds.height;var widthMax=Math.round(currWidth/3);var heightMax=Math.round(currHeight/3);div.style.overflow='hidden';var lastTop=currTop;var lastLeft=currLeft;var animateFP=wak.animate.FP;var animate=function(){if(topDir=='up'&&currTop>topMax){currTop=Math.round(currTop-((currTop-topMax)*animateFP));div.style.top=currTop+'px';}else if(topDir=='down'&&currTop<topMax){currTop=Math.round(currTop+((topMax-currTop)*animateFP));div.style.top=currTop+'px';}else{topDone=true;}
if(leftDir=='right'&&currLeft<leftMax){currLeft=Math.round(currLeft+((leftMax-currLeft)*animateFP));div.style.left=currLeft+'px';}else if(leftDir=='left'&&currLeft>leftMax){currLeft=Math.round(currLeft-((currLeft-leftMax)*animateFP));div.style.left=currLeft+'px';}else{leftDone=true;}
if(Math.abs(lastTop-currTop)<=1)topDone=true;if(Math.abs(lastLeft-currLeft)<=1)leftDone=true;currHeight=Math.round(currHeight-((currHeight-heightMax)*animateFP));currWidth=Math.round(currWidth-((currWidth-widthMax)*animateFP));if(topDone&&leftDone){clearInterval(timer);div.style.top=topMax+'px';div.style.left=leftMax+'px';if(ondone)window.setTimeout(ondone,0);return;}
lastTop=currTop;lastLeft=currLeft;};var timer=window.setInterval(animate,wak.animate.INTERVAL);}}};wak.lib.animate();wak.lib.open=function(href,name){window.open(href,name).focus();};wak.lib.modaldialog=function(){wak.modaldialog={};WakModalDialog=Class.create();WakModalDialog.namedOpenInstances={};WakModalDialog.openStack=[];WakModalDialog.prototype={_name:null,_contentsElementOrTemplate:null,delegate:null,_desiredPanelTop:null,_neverAnimate:null,_transparentShield:null,_sheild:null,_dialogParentId:null,_dialogDivId:null,_dialogShieldId:null,ctor:function(dialogName,contentsElementOrTemplate,delegate,panelTopCoords,closeOnClickOrKeyAnywhere,closeOnShieldClick,neverAnimate,transparentShield){if(!dialogName)wak.log.error('WakModalDialog::ctor -- no dialogName specified');this._name=dialogName?dialogName:'WMD_SPECIAL_NAME';this._contentsElementOrTemplate=contentsElementOrTemplate;this.delegate=delegate;this._desiredPanelTop=panelTopCoords;this._neverAnimate=neverAnimate;this._transparentShield=transparentShield;var wakId=wak.idGenerator++;this._dialogParentId='cmModelDialogParent'+wakId;this._dialogDivId='cmModelDialogDiv'+wakId;this._dialogShieldId='cmModalDialogShield'+wakId;this.setCloseOnClickOrKeyAnywhere(closeOnClickOrKeyAnywhere);this.setCloseOnShieldClick(closeOnShieldClick);},open:function(withoutAnimation){var animate=!(this._neverAnimate||withoutAnimation||WakModalDialog.openStack.length>0);mira.tempDisableLoadingMessage();WakModalDialog.openInstance=this;WakModalDialog.namedOpenInstances[this._name]=this;WakModalDialog.openStack.push(this);var contentsElement=$(this._contentsElementOrTemplate);var cmModalDialogDivElem=$(this._dialogDivId);if(!cmModalDialogDivElem){var dialogT=wak.template.create(g_cmModalDialog);dialogT.replaceToken('dialogParentId',this._dialogParentId);dialogT.replaceToken('dialogDivId',this._dialogDivId);dialogT.replaceToken('dialogShieldId',this._dialogShieldId);var html=dialogT.compose();var templateDiv=wak.html.parseHTMLFragment(html);document.body.appendChild(templateDiv);cmModalDialogDivElem=$(this._dialogDivId);}
if(contentsElement){if(this.delegate&&this.delegate.onDialogBeforeOpen)this.delegate.onDialogBeforeOpen(contentsElement);cmModalDialogDivElem.appendChild(contentsElement);}else{var t=wak.template.create(this._contentsElementOrTemplate,this._dialogDivId);if(this.delegate&&this.delegate.onDialogBeforeOpen)this.delegate.onDialogBeforeOpen(t);t.compose();}
cmModalDialogDivElem.firstChild.style.zIndex=WakModalDialog.openStack.length*100;if(this.delegate&&this.delegate.onDialogOpen)this.delegate.onDialogOpen();this.showShield(this.createPanel(),!animate);},_closeCallback:function(){var len=WakModalDialog.openStack.length;if(len>0){WakModalDialog.openStack[len-1].close();}},setCloseOnClickOrKeyAnywhere:function(closeOnClickOrKeyAnywhere){if(closeOnClickOrKeyAnywhere&&(document.onclick!=this._closeCallback)){this._closeOnClickOrKeyAnywhere=true;document.__origOnClick=document.onclick;document.onclick=this._closeCallback;document.__origOnKeydown=document.onkeydown;document.onkeydown=this._closeCallback;}else if(!closeOnClickOrKeyAnywhere&&(document.onclick==this._closeCallback)){this._closeOnClickOrKeyAnywhere=false;document.onclick=document.__origOnClick;document.onkeydown=document.__origOnKeydown;}
this.closeOnClickOrKeyAnywhere=closeOnClickOrKeyAnywhere;},setCloseOnShieldClick:function(closeOnShieldClick){var shield=$(this._dialogShieldId);if(shield){if(closeOnShieldClick&&(shield.onclick!=this._closeCallback)){shield.__origOnClick=shield.onclick;shield.onclick=this._closeCallback;}else if(!closeOnShieldClick&&(shield.onclick==this._closeCallback)){shield.onclick=shield.__origOnClick;}}
this._closeOnShieldClick=closeOnShieldClick;},close:function(withoutAnimation){var animate=!(this._neverAnimate||withoutAnimation);this.setCloseOnClickOrKeyAnywhere(false);if(this.delegate&&this.delegate.onDialogClose)this.delegate.onDialogClose();var child=$(this._dialogDivId).firstChild;if(child){if(animate){var startOpacity=this._transparentShield?0:20;var interval=this._transparentShield?0:5;var increment=this._transparentShield?0:5;wak.animate.fade2(this._dialogShieldId,startOpacity,0,interval,increment,function(){var parentNode=child.parentNode;if(parentNode){parentNode.removeChild(child);parentNode.style.display='inline';if(parentNode.parentNode)parentNode.parentNode.style.display='inline';}});wak.animate.fade2(child,100,0,5,5,function(){this.hideShield();WakModalDialog.openInstance=null;delete WakModalDialog.namedOpenInstances[this._name];WakModalDialog.openStack.pop();if(WakModalDialog.openStack.length>0){WakModalDialog.openInstance=WakModalDialog.openStack[WakModalDialog.openStack.length-1];}
document.body.removeChild($(this._dialogParentId));}.bind(this));}else{child.parentNode.removeChild(child);this.hideShield();WakModalDialog.openInstance=null;delete WakModalDialog.namedOpenInstances[this._name];WakModalDialog.openStack.pop();if(WakModalDialog.openStack.length>0){WakModalDialog.openInstance=WakModalDialog.openStack[WakModalDialog.openStack.length-1];}
document.body.removeChild($(this._dialogParentId));}}
Validator.clearFep();},swapContentDiv:function(dialogName,newDivOrId,keepHidden,deadCenter){Validator.clearFep();var oldDiv=$(this._dialogDivId).firstChild;var newDiv=$(newDivOrId);var dialog=WakModalDialog.openStack.pop();delete WakModalDialog.namedOpenInstances[dialog._name];dialog._name=dialogName?dialogName:'WMD_SPECIAL_NAME';WakModalDialog.openStack.push(dialog);WakModalDialog.namedOpenInstances[dialog._name]=dialog;if(newDiv!=null){$(this._dialogDivId).insertBefore(newDiv,oldDiv);wak.geometry.setBounds(newDiv,wak.geometry.centeredBounds(newDiv,oldDiv,deadCenter));newDiv.style.zIndex=WakModalDialog.openStack.length*100;if(!keepHidden){newDiv.style.visibility='visible';}}
var removeOldDiv=function(){$(this._dialogDivId).removeChild(oldDiv);}.bind(this);window.setTimeout(removeOldDiv,1);},createPanel:function(){var panel=$(this._dialogDivId).firstChild;var visibleBounds=wak.geometry.visibleBounds();var panelBounds=wak.geometry.bounds(panel);var panelTop=this._desiredPanelTop||panelBounds.top;if(panelTop<visibleBounds.top){panelTop=visibleBounds.top+100;}
panel.style.top=panelTop+'px';if(panelTop+panelBounds.height>visibleBounds.top+visibleBounds.height){panelTop=visibleBounds.top+visibleBounds.height-panelBounds.height-100;panel.style.top=Math.max(panelTop,50)+'px';}
var lmBody1Bounds=wak.geometry.bounds('lmBody1');panel.style.left=(lmBody1Bounds.left+((lmBody1Bounds.width-panel.offsetWidth)/2))+'px';return panel;},showShield:function(panel,withoutAnimation){wak.assertNonNull(panel,'panel');var useTransparentSheild=this._transparentShield|WakModalDialog.openStack.length>1;var endOpacity=useTransparentSheild?0:20;var interval=useTransparentSheild?0:5;var increment=useTransparentSheild?0:5;var visibleBounds=wak.geometry.visibleBounds();var shield=$(this._dialogShieldId);wak.css.display(this._dialogShieldId,true);var notifyDelegate=function(){if(this.delegate&&this.delegate.onDialogOpenComplete){this.delegate.onDialogOpenComplete();}}.bind(this);if(withoutAnimation){notifyDelegate();wak.css.setOpacity(this._dialogShieldId,endOpacity);}else{wak.animate.fade2(this._dialogShieldId,0,endOpacity,interval,increment,null);}
var shieldBounds=wak.geometry.bounds(shield);var lowestVisibleDivB=wak.geometry.bounds('lowestVisibleDiv');shield.style.top='0px';shield.style.height=Math.max(visibleBounds.height,(lowestVisibleDivB.top+lowestVisibleDivB.height))+'px';shield.style.zIndex=(WakModalDialog.openStack.length*100)-10;this.setCloseOnShieldClick(this._closeOnShieldClick);},hideShield:function(){wak.css.display(this._dialogShieldId,false);this.setCloseOnShieldClick(false);}}};wak.lib.modaldialog();WakModalDialog.showModalDialog=function(dialogName,aDiv,aDelegate,panelTopCoords,closeOnClickOrKeyAnywhere,closeOnShieldClick,neverAnimate,transparentShield){var returnDialog=null;var modalDialogInstance=WakModalDialog.openInstance;if(modalDialogInstance){modalDialogInstance.swapContentDiv(dialogName,aDiv);modalDialogInstance.setCloseOnClickOrKeyAnywhere(closeOnClickOrKeyAnywhere);modalDialogInstance.setCloseOnShieldClick(closeOnShieldClick);returnDialog=modalDialogInstance._dialog;}else{returnDialog=new WakModalDialog(dialogName,aDiv,aDelegate,panelTopCoords,closeOnClickOrKeyAnywhere,closeOnShieldClick,neverAnimate,transparentShield);returnDialog.open();}
return returnDialog;};wak.lib.history=function(){wak.history={};wak.history.enabled=true;wak.history.onBack=function(){};wak.history.onGetBackState=function(){};wak.history._init=false;wak.history._state=null;wak.history._frameUrl=null;wak.history._rewinding=false;wak.history.pageLoadedFromBack=false;wak.history.init=function(frameUrl,initParams){wak.history._init=true;wak.history._frameUrl=frameUrl;var appearsToBeLoadedFromBack=wak.history.enabled&&(wak.history._getRawFrameState()?true:false);if(!appearsToBeLoadedFromBack){wak.history._state=initParams;wak.history._incrHistory();}
if(wak.history.enabled&&!wak.isDefined(frames.dhistory)){wak.history.enabled=false;}
return wak.history._state;};wak.history.push=function(context){if(!wak.history.enabled)return;if(wak.history._backPending)return;var state=wak.history.onGetBackState(false,context);wak.history._state=state;wak.history._incrHistory();};wak.history.setEnabled=function(enabled){wak.history.enabled=enabled;};wak.history.isEnabled=function(){return wak.history.enabled;};wak.history.setOnBack=function(onBackFunction){wak.history.onBack=onBackFunction;};wak.history.setOnGetBackState=function(onGetBackStateFunction){wak.history.onGetBackState=onGetBackStateFunction;};wak.history._incrHistory=function(){if(!wak.history.enabled)return;if(wak.history._backPending)return;var iframe=frames.dhistory;iframe.document.location.href="";iframe.document.location.href="javascript:parent.wak.history._getFrameLoaderHtml();";};wak.history._getFrameLoaderHtml=function(){if(!wak.history.enabled)return null;return"<html><head><script>"
+"location.replace('"+wak.history._frameUrl+"');"
+"</"+"script></head></html>'";};wak.history._iframeLoaded=function(stateQuery){if(!wak.history.enabled)return null;if(wak.history._rewinding){frames.dhistory.history.go(-1);return null;}
if(stateQuery==null)return null;var state=wak.url.parse(stateQuery);if(wak.history._init){wak.history._backPending=true;var rewind=wak.history.onBack(state,true);if(rewind){wak.history._rewinding=true;frames.dhistory.history.go(-1);}
wak.history._backPending=false;}else{wak.history._state=state;wak.history.pageLoadedFromBack=true;}};wak.history._getRawFrameState=function(){if(!wak.history.enabled)return null;var stashedHistoryText=frames.dhistory.document.getElementById('stash');return stashedHistoryText?stashedHistoryText.value:null;};wak.history._getStateQuery=function(){if(!wak.history.enabled)return null;var q=wak.url.build(wak.history._state);return q;};};wak.lib.history();wak.dom={};wak.dom.isInDocument=function(idOrElem){returnValue=false;elem=$(idOrElem);if(elem){if(!elem.id)elem.id='wak-TEMPORARY-TEST';if(document.getElementById(elem.id))returnValue=true;if(elem.id=='wak-TEMPORARY-TEST')elem.id=null;}
return returnValue;};wak.dom.getParentNode=function(idOrElem){elem=$(idOrElem);var returnElement=null;try{returnElement=elem.parentNode;}catch(anException){returnElement=null;}
return returnElement;};wak.dom.getAncestorElement=function(idOrElem,ancestorElement){foundParent=null;elem=$(idOrElem);while(elem&&!foundParent){if(elem==ancestorElement){foundParent=elem;}
elem=wak.dom.getParentNode(elem);}
return foundParent;};wak.dom.getAncestorWithTag=function(idOrElem,aTag){foundParent=null;elem=$(idOrElem);while(elem&&!foundParent){try{if(elem.tagName==aTag){foundParent=elem;}}catch(exc){}
elem=wak.dom.getParentNode(elem);}
return foundParent;};wak.dom.getElementByIdInOrOutOfDom=function(idToFind,parentIdOrElem){var foundId=wak.elem(idToFind,parentIdOrElem);foundId=foundId||wak.elem(foundId);if(!foundId){var parent=$(parentIdOrElem);for(var i=0;!foundId&&(i<parent.childNodes.length);i++){var node=parent.childNodes[i];if(node.id==idToFind)foundId=node;else foundId=wak.dom.getElementByIdInOrOutOfDom(idToFind,node);}}
return foundId;};$=function(idOrElem){return wak.elem(idOrElem);};$A=function(htmlColl){var arr=[];for(var i=0;i<htmlColl.length;i++)arr.push(htmlColl[i]);return arr;};$I=function(idOrElem){return wak.elemId(idOrElem);};$H=function(obj){var hash=Object.extend({},obj||{})
Object.extend(hash,Enumerable);Object.extend(hash,Hash);return hash;};$T=function(str,divId){return wak.template.create(str,divId);};$G=function(stringGlobalVarName){return window[stringGlobalVarName];};$F=function(idOrElem){return wak.form.value(idOrElem);};$FN=function(idOrElem){return Number(wak.form.value(idOrElem));};$FD=function(idOrElem){var s=$F(idOrElem);var date=null;if(s){var d1=Date.parseSimpleDate(s);if(d1&&!isNaN(d1.valueOf())){date=d1;}}
return date;};formatNumber=function(number,numberOfDecimalPlaces,thousandsCharacter,decmimalCharacter,symbolBeforeAmount,symbolAfterAmount,negativeLeftIndicator,negativeRightIndicator){var returnValue=null;if(number){numberOfDecimalPlaces=numberOfDecimalPlaces?numberOfDecimalPlaces:0;thousandsCharacter=thousandsCharacter?thousandsCharacter:"";decmimalCharacter=decmimalCharacter?decmimalCharacter:"";symbolBeforeAmount=symbolBeforeAmount?symbolBeforeAmount:"";symbolAfterAmount=symbolAfterAmount?symbolAfterAmount:"";negativeLeftIndicator=negativeLeftIndicator?negativeLeftIndicator:"";negativeRightIndicator=negativeRightIndicator?negativeRightIndicator:"";var x=Math.round(number*Math.pow(10,numberOfDecimalPlaces));if(x>=0)negativeLeftIndicator=negativeRightIndicator='';var y=(''+Math.abs(x)).split('');var z=y.length-numberOfDecimalPlaces;if(z<0)z--;for(var i=z;i<0;i++)y.unshift('0');y.splice(z,0,decmimalCharacter);while(z>3){z-=3;y.splice(z,0,thousandsCharacter);}
returnValue=symbolBeforeAmount+negativeLeftIndicator+y.join('')+negativeRightIndicator+symbolAfterAmount;}
return returnValue;};var CONSOLE_LOG_OBJECT='wak.log';wak.log=function(msg,extraObj){if(mira.prodMode)return;var extra=null;if(extraObj){extra={};for(var k in extraObj)extra[k]=extraObj[k];}
if(wak.isString(msg))wak.log._messages.push(msg,extra,null);else wak.log._messages.push('',msg,null);wak.log._size+=msg.length;}
wak.log.info=function(msg,extraObj){if(mira.stagingMode||mira.prodMode)return;wak.log.error(msg,extraObj,true);}
wak.log.error=function(msg,extraObj,isInfo){if(mira.prodMode)return;if(msg==null)msg='null';wak.log(msg,extraObj);var actionsHtml="<a style='{color: white; font-weight:bold; position: absolute; top: -1px; right: 25px;}'"+" href='javascript:wak.log._clearPanel()'>clear</a>"+"<a style='{color: white; font-weight:bold; position: absolute; top: -1px; right: 5px;}'"+" href='javascript:wak.log._closePanel()'>x</a>";if(!wak.log._errorDiv){var div=document.createElement("DIV");div.id='errPanel';wak.log._errorDiv=document.body.appendChild(div);var styles={'position':'absolute','textAlign':'left','padding':'5px 10px','top':'80px','right':'50px','width':'400px','overflow':'auto','background':'black','color':'white','fontSize':'11px','fontWeight':'bold','opacity':'.85','zIndex':'50'};wak.util.keys(styles).each(function(k){div.style[k]=styles[k];});div.innerHTML=actionsHtml;}else{if(wak.log._errorDiv.innerHTML==""){wak.log._errorDiv.innerHTML=actionsHtml;}
wak.css.display(wak.log._errorDiv,true);}
var html='';if(isInfo)html='<div style="color:green">&gt; '+msg+'</div>';else html='&gt; '+msg+'<br>';if(wak.isDefinedNonNull(extraObj)){if(extraObj){if(wak.isObject(extraObj)||wak.isArray(extraObj)){for(var k in extraObj){html+=k+': '+extraObj[k]+'<br>';}}else{html+=extraObj+'<br>';}}else{html+=extraObj+'<br>';}}
wak.log._errorDiv.innerHTML+=html;};wak.log.debug=wak.log.error;wak.log._closePanel=function(){wak.css.display(wak.log._errorDiv,false);wak.log._errorDiv.innerHTML="";}
wak.log._clearPanel=function(){wak.log._errorDiv.innerHTML="";}
wak.log._reset=function(){wak.log._messages=[];wak.log._size=0;}
wak.utf8Encode=function(str_data){str_data=str_data.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<str_data.length;n++){var c=str_data.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;},wak.utf8Decode=function(str_data){var string="",i=0,c=c1=c2=0;while(i<str_data.length){c=str_data.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}else if((c>191)&&(c<224)){c2=str_data.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=str_data.charCodeAt(i+1);c3=str_data.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;},wak.base64Encode=function(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,enc='';data=wak.utf8Encode(data);do{o1=data.charCodeAt(i++);o2=data.charCodeAt(i++);o3=data.charCodeAt(i++);bits=o1<<16|o2<<8|o3;h1=bits>>18&0x3f;h2=bits>>12&0x3f;h3=bits>>6&0x3f;h4=bits&0x3f;enc+=b64.charAt(h1)+b64.charAt(h2)+b64.charAt(h3)+b64.charAt(h4);}while(i<data.length);switch(data.length%3){case 1:enc=enc.slice(0,-2)+'==';break;case 2:enc=enc.slice(0,-1)+'=';break;}
return enc;},wak.base64Decode=function(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,enc='';do{h1=b64.indexOf(data.charAt(i++));h2=b64.indexOf(data.charAt(i++));h3=b64.indexOf(data.charAt(i++));h4=b64.indexOf(data.charAt(i++));bits=h1<<18|h2<<12|h3<<6|h4;o1=bits>>16&0xff;o2=bits>>8&0xff;o3=bits&0xff;if(h3==64)enc+=String.fromCharCode(o1);else if(h4==64)enc+=String.fromCharCode(o1,o2);else enc+=String.fromCharCode(o1,o2,o3);}while(i<data.length);enc=wak.utf8Decode(enc);return enc;},wak.log._reset();
