
WL.Utils={};WL.Utils_={};if(WL.Debug)
{WL.Utils.assert=function(condition,message)
{if(condition&&window.confirm(String.format("Debug Information.\nError: {0}.\n\nGo to debugger?",message))){debugger;}}
WL.attachListener(document,"keydown",function(e)
{e=WL.getEvent(e);if(e.keyCode==68&&e.ctrlKey&&e.altKey){debugger;}});}
else
{WL.Utils.assert=function(){}}
WL.attachListener(document,"keydown",function(e)
{e=WL.getEvent(e);if(e.keyCode==8)
{var target=e.target;if(target&&target.tagName&&target.tagName.match(/INPUT|TEXTAREA/i))return;return WL.returnEvent(e,false,true);}});WL.Utils.getXmlDoc=function(xmlstring)
{if(window.DOMParser)
{return(new DOMParser()).parseFromString(xmlstring,"text/xml");}
else
if(window.ActiveXObject)
{var xmldoc=new ActiveXObject("Microsoft.XMLDOM");xmldoc.loadXML(xmlstring);return xmldoc;}
return null;}
if(WL.browser.ie)
{WL.Utils.getMouseCoords=function(e)
{var body=WL.Utils.getBody();return{x:e.clientX+body.scrollLeft-body.clientLeft,y:e.clientY+body.scrollTop-body.clientTop};}}
else
{WL.Utils.getMouseCoords=function(e){return{x:e.pageX,y:e.pageY};}}
WL.Utils.getEventElementOffset=function(e,element)
{var p=WL.Utils.getMouseCoords(e);var o=WL.Utils.getElementOffset(element);return{left:p.x-o.left,top:p.y-o.top,right:o.left+o.width-p.x-1,bottom:o.top+o.height-p.y-1};}
WL.Utils.isVisibleElement=function(element)
{while(element!=null)
{if(WL.currentStyle(element).display=="none")return false;if(WL.currentStyle(element).visibility=="hidden")return false;element=element.parentNode;}
return true;}
WL.Utils.isPointInRange=function(x,y,left,top,right,bottom)
{return top<=y&&y<=bottom&&left<=x&&x<=right;}
WL.Utils.attachClickEvent=function(element,clickHandler,dblClickHandler,timeout)
{if(!timeout)timeout=WL.ClickTimeout;if(clickHandler)WL.attachListener(element,"click",WL.Utils_.attachClickEventHelper1.bindWA(window,clickHandler,timeout));WL.attachListener(element,"dblclick",WL.Utils_.attachClickEventHelper3.bindWA(window,dblClickHandler));}
WL.Utils_.attachClickEventHelper1=function(clickHandler,timeout,e)
{e=WL.getEvent(e);var f=WL.Utils_.attachClickEventHelper2.bindWA(window,{target:e.target,x:e.x,y:e.y,offsetX:e.offsetX,offsetY:e.offsetY,ctrlKey:e.ctrlKey},clickHandler);e.target.clearClick=window.setTimeout(f,timeout);return WL.returnEvent(e,false,true);}
WL.Utils_.attachClickEventHelper2=function(e,clickHandler)
{clickHandler(e);e.target=null;}
WL.Utils_.attachClickEventHelper3=function(dblClickHandler,e)
{e=WL.getEvent(e);if(e.target.clearClick)
{window.clearTimeout(e.target.clearClick);e.target.clearClick=null;}
if(dblClickHandler)dblClickHandler(e);return WL.returnEvent(e,false,true);}
WL.Utils.serialize=function(obj,tagname)
{var writer=new WL.Objects.XmlWriter();writer.writeObject(tagname||"object",obj);return writer.toString();}
WL.Utils.serialize2=function(obj,tagname)
{var writer=new WL.Objects.XmlWriter();if(typeof(obj)=="object")writer.writeObject(tagname||"object",obj);else writer.writeElementString(tagname||"value",obj);return writer.toString();}
WL.Utils.enter_action=function(el,action){WL.attachListener(el,"keypress",WL.Utils_.enter_action.bindWA(window,action));}
WL.Utils_.enter_action=function(action,e){e=WL.getEvent(e);if(e.keyCode==13){if(action)action(e);return WL.returnEvent(e,false,true);}}
if(WL.browser.ie)
{WL.Utils.select_action=function(el,action){WL.attachListener(el,"selectstart",WL.Utils_.select_action.bindWA(window,action));}
WL.Utils_.select_action=function(action,e){e=WL.getEvent(e);if(action)action();return WL.returnEvent(e,false);}}
else
{WL.Utils.select_action=function(el)
{el.__preventSelection=false;WL.attachListener(el,"mousemove",WL.Utils_.select_action_mousemove.bind(WL.uniqueID(el)));WL.attachListener(el,"mousedown",WL.Utils_.select_action_mousedown.bind(WL.uniqueID(el)));}
WL.Utils_.select_action_mousedown=function(e){var el=WL.Utils.$(this);if(el)el.__preventSelection=!WL.getEvent(e).target.tagName.match(/INPUT|TEXTAREA/i);}
WL.Utils_.select_action_mousemove=function(e){var el=WL.Utils.$(this);if(el&&el.__preventSelection)WL.Utils.clear_selection();}}
WL.Utils.clear_container=function(c){while(c.firstChild)c.removeChild(c.firstChild);}
WL.Utils.select_content=function(el,start,length)
{if(start==null)start=0;if(length==null)length=el.value.length-start;if(el.createTextRange){var range=el.createTextRange();range.moveStart("character",start);range.moveEnd("character",length-el.value.length);range.select();}else if(el.setSelectionRange){el.setSelectionRange(start,length);}}
WL.Utils.clear_selection=function()
{if(window.getSelection){window.getSelection().removeAllRanges();}
else if(document.selection&&document.selection.clear)document.selection.clear();}
WL.Utils.getRadioValue=function(group)
{var buttons=document.forms[0][group];if(buttons!=null)
{if(typeof(buttons.length)!="undefined")
{for(var i=0;i<buttons.length;++i)
if(buttons[i].checked)return buttons[i].value;}
else
{if(buttons.checked)return buttons.value;}}
return null;}
WL.Utils.setRadioValue=function(group,value)
{var buttons=document.forms[0][group];if(buttons!=null)
{if(typeof(buttons.length)!="undefined")
{for(var i=0;i<buttons.length;++i)
buttons[i].checked=buttons[i].value==value;}
else
{buttons.checked=buttons.value==value;}}}
WL.Utils.requestErrorHandler=function(returner)
{var args=[];for(var i=1;i<arguments.length;++i)args.push(arguments[i]);return function(errorInfo)
{if(returner)
{if(args.length==0)
args.push({});args[0].error=true;args[0].errorInfo=errorInfo;returner.apply(this,args);}
else
WL.Utils.assert(errorInfo,errorInfo);}}
WL.Utils.webRequest=function(returner,request,response,errorHandler,nullResult,hidden)
{if(returner===undefined)
{WL.Utils.assert(true,"call sync method");return response.call(this,window.xmlCallback.doWebSyncRequest(request,errorHandler()));}
window.xmlCallback.doWebRequest(request,this,function(reader)
{if(returner)returner(response.call(this,reader));},errorHandler?errorHandler(returner,nullResult):null,hidden);}
WL.Utils.setNew=function(obj,prop,value)
{if(obj[prop]!=value)obj[prop]=value;}
if(WL.browser.ie)
{WL.Utils._quickCssElements={};WL.Utils.quickCss=function(obj,cssClass)
{if(obj["className"]==cssClass)return;if(WL.Utils._quickCssElements[cssClass]==null)
{}}}
else
{WL.Utils.quickCss=function(obj,cssClass){WL.Utils.setNew(obj,"className",cssClass);}}
WL.Utils.enableDrag=function(element,ondragstart,ondragend)
{element.__dragHelper=WL.Utils_.dragHelper.bindWA(WL.uniqueID(element),ondragstart,ondragend);WL.attachListener(element,"mousedown",element.__dragHelper);}
WL.Utils.clearDrag=function(element)
{if(element.__dragHelper)
{WL.detachListener(element,"mousedown",element.__dragHelper);element.__dragHelper=null;}}
WL.Utils_.dragHelper=function(ondragstart,ondragend,e)
{e=WL.getEvent(e);if(WL.browser.ie){if(e.button!=1)return;}
else{if(e.button!=0)return;}
var id=this;window.dragHtmlElement=e.target.cloneNode(true);window.dragHtmlElement.style.position="absolute";var created=false;var mousemove=function(e)
{if(!created){if(!ondragstart()){dragend();return;}
created=true;document.forms[0].appendChild(window.dragHtmlElement);}
var pos=WL.Utils.getMouseCoords(WL.getEvent(e));window.dragHtmlElement.style.left=pos.x+5+"px";window.dragHtmlElement.style.top=pos.y-10+"px";}
var dragend=function()
{WL.detachListener(document,"mouseup",dragend);WL.detachListener(document,"mousemove",mousemove);if(created){document.forms[0].removeChild(window.dragHtmlElement);ondragend();}}
WL.attachListener(document,"mouseup",dragend);WL.attachListener(document,"mousemove",mousemove);}
WL.Utils.getRequestParams=function()
{if(!window.dialogArguments)window.dialogArguments={}
if(window.location.search!="")
{var p=window.location.search.substring(1).split('&');for(var i=0;i<p.length;++i)
{var param=p[i].split('=');window.dialogArguments[param[0]]=param[1];}}
return window.dialogArguments;}
if(WL.browser.ie)
{WL.Utils.$=document.getElementById;WL.Utils.$e=document.createElement;}
else
{WL.Utils.$=function(id){return document.getElementById(id);}
WL.Utils.$e=function(tag){return document.createElement(tag);}}
WL.Utils.$$=function(id){return WL.Utils.$(id).control;}
WL.Utils.$$$=function(){return WL.Utils.$(Array.prototype.slice.call(arguments).join('_'));}
WL.Utils.$$$$=function(id){return WL.Utils.$$$(id).control;}
WL.Utils.$$e=function(type,tag,parent){var cont=WL.Utils.$e(tag);parent.appendChild(cont);var c=new type();c.generate2(cont);return c;}
WL.Utils.$idmap=function(id){return this.idmap[id]?WL.Utils.$(this.idmap[id]):null;}
WL.Utils.$$idmap=function(id){return this.idmap[id]?WL.Utils.$$(this.idmap[id]):null;}
WL.Utils.$table=function(rows,cols,cellCreator)
{var table=WL.Utils.$e("TABLE");var tbody=WL.Utils.$e("TBODY");var tr,td;for(var i=0;i<rows;++i)
{tr=WL.Utils.$e("TR");for(var j=0;j<cols;++j)
{td=WL.Utils.$e("TD");if(cellCreator)cellCreator(i,j,td);tr.appendChild(td);}
tbody.appendChild(tr);}
table.appendChild(tbody);return table;}
WL.Utils.isLoading=function()
{var progress=WL.Utils.$("progress");if(progress)return WL.currentStyle(progress).visibility=="visible";return false;}
WL.Utils.isCss=function(element,css)
{return element.className.split(' ').indexOf(css)!=-1;}
WL.Utils.addCss=function(element,css)
{var classes=element.className.split(' ');if(classes.indexOf(css)!=-1)return;classes.push(css);element.className=classes.join(' ');}
WL.Utils.removeCss=function(element,css)
{var classes=element.className.split(' ');var i=classes.indexOf(css);if(i!=-1){classes.removeAt(i);element.className=classes.join(' ');}}
WL.Utils.replaceCss=function(element,css,newCss)
{var classes=element.className.split(' ');var i=classes.indexOf(css);if(i!=-1)classes.removeAt(i);var i=classes.indexOf(newCss);if(i==-1)classes.push(newCss);element.className=classes.join(' ');}
WL.inputMasks=[];WL.mask_detach=function(el)
{if(el.__mask_onkeypress)
{WL.detachListener(el,"keypress",el.__mask_onkeypress);WL.detachListener(el,"blur",el.__mask_onblur);WL.detachListener(el,"focus",el.__mask_onfocus);el.__mask_onkeypress=null;el.__mask_onblur=null;el.__mask_onfocus=null;}}
WL.mask_attach=function(el,mask_obj,def_value)
{WL.mask_detach(el);if(typeof(mask_obj)=="string")mask_obj=WL.inputMasks.find(WL.__mask_finder.bind(mask_obj));WL.Utils.assert(!mask_obj,"Input mask undefined");if(!mask_obj)return;if(el.value=="")el.value=def_value||mask_obj.getDefault();el.__mask_onkeypress=WL.__mask_onkeypress.bind(mask_obj);WL.attachListener(el,"keypress",el.__mask_onkeypress);el.__mask_onfocus=WL.__mask_onfocus.bind(mask_obj);WL.attachListener(el,"focus",el.__mask_onfocus);el.__mask_onblur=WL.__mask_onblur.bind(mask_obj);WL.attachListener(el,"blur",el.__mask_onblur);}
WL.__mask_finder=function(it){return this==it.getName();}
WL.__mask_onkeypress=function(e)
{e=WL.getEvent(e);var el=e.target;if(e.which==0)return true;var key=e.which?e.which:e.keyCode;if(e.ctrlKey||e.altKey||(key<41&&key!=32))return true;if(document.selection&&document.selection.createRange){var rng=document.selection.createRange();var rng0=rng.text.length;rng.moveStart('character',-1000000);el.selectionEnd=rng.text.length;el.selectionStart=el.selectionEnd-rng0;}
var str=el.value.substr(0,el.selectionStart)+String.fromCharCode(key)+el.value.substr(el.selectionEnd);if(!this.check(str))
return WL.returnEvent(e,false,true);}
WL.__mask_onfocus=function(e){this.focus(WL.getEvent(e).target);}
WL.__mask_onblur=function(e){e=WL.getEvent(e);e.target.value=this.validate(e.target.value);}
WL.InputDouble=WL.Class(Object,function(name,v,min,max)
{this.name=name;this._v=v;this.min=min;this.max=max;},function(type)
{type.getName=function(){return this.name;}
type.getDefault=function(){return Math.max(0,this.min);}
type.focus=function(e){if(e.value=="0")e.value="";}
type.check=function(v){if(this._v.indexOf(v)!=-1)return true;var i=Number(v);if(isNaN(i))return false;return Math.middle(this.min,i,this.max)==i;}
type.validate=function(v){return Math.middle(this.min,parseFloat(v)||0,this.max);}});WL.InputInt=WL.Class(Object,function(name,v,min,max)
{this.name=name;this.min=min;this.max=max;this._v=v;},function(type)
{type.getName=function(){return this.name;}
type.getDefault=function(){return Math.max(this.min,0);}
type.focus=function(e){if(e.value=="0")e.value="";}
type.check=function(v){if(this._v.indexOf(v)!=-1)return true;var i=parseInt(v);return i.toString()==v&&Math.middle(this.min,i,this.max)==i;}
type.validate=function(v){return Math.middle(this.min,parseInt(v)||0,this.max);}});WL.InputMoney=WL.Class(Object,function(name,v,min,max)
{this.name=name;this._v=v;this.min=min;this.max=max;},function(type)
{type.getName=function(){return this.name;}
type.getDefault=function(){return Math.max(0,this.min).toMoney();}
type.focus=function(e)
{var v=Number.fromMoney(e.value);if(e.value!=v){if(WL.browser.ie){var rng=document.selection.createRange();rng.moveStart('textedit',-1);var caret=rng.text.length;var pos=rng.text.split(',').length-1;}
e.value=v;if(WL.browser.ie){rng.move('character',caret-pos);rng.select();}}}
type.check=function(v){if(this._v.indexOf(v)!=-1)return true;var i=Number(v.split(CultureInfo.Currency.groupSeparator).join(''));if(isNaN(i))return false;return Math.middle(this.min,i,this.max)==i;}
type.validate=function(v){return Math.middle(this.min,Number.fromMoney(v)||0,this.max).toMoney();}});WL.inputMasks.push(new WL.InputDouble("double",["","-",CultureInfo.Number.decimalSeparator],-2147483648,2147483647));WL.inputMasks.push(new WL.InputDouble("+double",["",CultureInfo.Number.decimalSeparator],0,2147483647));WL.inputMasks.push(new WL.InputInt("int",["","-"],-2147483648,2147483647));WL.inputMasks.push(new WL.InputInt("+int",[""],0,2147483647));WL.inputMasks.push(new WL.InputInt("natural",[""],1,2147483647));WL.inputMasks.push(new WL.InputMoney("money",["",CultureInfo.Currency.decimalSeparator],0,2147483647));WL.inputMasks.push(new WL.InputMoney("-money",["",CultureInfo.Currency.decimalSeparator],-2147483648,2147483647));WL.Utils.floatToString=function(number,fraction,showZero,showSeparator,separatorChar,dotChar)
{function separate(input,separator)
{var output=[];var len=input.length;for(var i=0;i<len;++i)
{if(i!=0&&(len-i)%3==0)output.push(separator);output.push(input.charAt(i));}
return output.join("");}
if(fraction==null)fraction=0;if(showZero==null)showZero=false;if(showSeparator==null)showSeparator=false;if(separatorChar==null)separatorChar='\'';if(dotChar==null)dotChar='.';var nums=number.toFixed(fraction).split('.');if(showSeparator)nums[0]=separate(nums[0],separatorChar);if(!showZero)nums[1].trimRight('0');return nums.join(dotChar);}
WL.Utils.setBit=function(flags,bit,state){return state?(flags|bit):(flags&~bit);}
WL.Utils.cloneObject=function(obj)
{if(obj==null)return null;if(typeof(obj.clone)=="function")return obj.clone();return WL.Utils.cloneMethod.call(obj);}
WL.Utils.cloneMethod=function(){return WL.Utils.copyObject(this,new this.constructor());}
WL.Utils.copyObject=function(obj,toObj)
{if(obj==null)return null;if(toObj==null)toObj=new obj.constructor();if(typeof(obj.copyTo)=="function")obj.copyTo(toObj);else WL.Utils.copyMethod.call(obj,toObj);return toObj;}
WL.Utils.copyMethod=function(toObj)
{for(var p in this)
{switch(typeof(this[p]))
{case"object":toObj[p]=WL.Utils.cloneObject(this[p]);break;case"string":case"number":case"boolean":toObj[p]=this[p];break;case"function":toObj[p]=this[p];break;default:WL.Utils.assert(true,"WL.Utils.cloneMethod, type: "+typeof(this[p]));break;}}}
WL.PageLayout=WL.Class(Object,function(page)
{this.page=page||window.page;this.page.__obs=0;},function(type)
{type.activate=function()
{if(this.page.currentLayout!=this)
{if(this.page.currentLayout)
this.page.currentLayout.deactivate();this.page.__obs++;this.onactivate();this.page.currentLayout=this;}}
type.deactivate=function(){this.ondeactivate();}
type.onactivate=function(){}
type.ondeactivate=function(){}
type.checkChanges=function(e,handler)
{if(handler)handler.call(this);return false;}
type.checkUnloadChanges=function(e){}
type.getObsoleteCookie=function(){return this.page.__obs;}
type.isObsolete=function(cookie){return this.page.__obs!=cookie;}
type.obsolete=function(){this.page.__obs++;}});WL.Utils.testEmail=function(email)
{if(!email)return false;WL.Utils_.testEmailRegex.lastIndex=0;return WL.Utils_.testEmailRegex.exec(email)!=null;}
WL.Utils_.testEmailRegex=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ig;if(WL.browser.opera)
{WL.Utils.getBody=WL.Utils.getScrollBody=function(){return document.body;}}
else
if(WL.browser.safari)
{WL.Utils.getBody=function(){return document.documentElement.clientHeight<document.body.clientHeight?document.documentElement:document.body;}
WL.Utils.getScrollBody=function(){return document.body;}}
else
{WL.Utils.getBody=WL.Utils.getScrollBody=function(){return document.compatMode&&document.compatMode!="BackCompat"?document.documentElement:document.body;}}
WL.Utils.tryInvoke=function(method,checker,period)
{var func=function(){if(checker())method();else window.setTimeout(func,period||50);}
func();}
WL.Utils.registerServerTime=function(serverTimeValue)
{window.serverTimeValue=serverTimeValue+((new Date()).valueOf()-window.localTimePoint);window.localTimePoint=(new Date()).valueOf();}
WL.Utils.getServerTime=function(){return new Date(window.serverTimeValue+((new Date()).valueOf()-window.localTimePoint));}
WL.Utils.resolve=function(template,evaluators)
{return template.replace(/@@(.+?)@@/ig,function($0,$1){var k=$1.toUpperCase();for(var i=0;i<evaluators.length;++i){var v=evaluators[i].evaluate(k);if(v!=null)return v;}return $0;});}
if(WL.browser.ie)
{WL.Utils.getElementOffset=function(e)
{var offset=new Object();offset.top=0;offset.left=0;offset.width=e.offsetWidth;offset.height=e.offsetHeight;while(e.offsetParent)
{offset.left+=e.offsetLeft+(parseInt(e.currentStyle.borderLeftWidth)).NaN0();offset.top+=e.offsetTop+(parseInt(e.currentStyle.borderTopWidth)).NaN0();if(e.scrollLeft)offset.left-=e.scrollLeft;if(e.scrollTop)offset.top-=e.scrollTop;e=e.offsetParent;}
offset.left+=e.offsetLeft;offset.top+=e.offsetTop;return offset;}}
else
if(WL.browser.opera)
{WL.Utils.getElementOffset=function(e)
{var offset=new Object();offset.top=0;offset.left=0;offset.width=e.offsetWidth;offset.height=e.offsetHeight;var el=e;while(el.parentNode&&el.tagName!="BODY"&&el.tagName!="HTML")
{if(el.tagName!="TR")
{if(el.scrollLeft)offset.left-=el.scrollLeft;if(el.scrollTop)offset.top-=el.scrollTop;}
el=el.parentNode;}
el=e;while(el.offsetParent)
{offset.left+=el.offsetLeft;offset.top+=el.offsetTop;el=el.offsetParent;}
var docBody=WL.Utils.getBody();offset.left+=el.offsetLeft-(parseInt(docBody.clientLeft)).NaN0();offset.top+=el.offsetTop-(parseInt(docBody.clientTop)).NaN0();return offset;}}
else
if(WL.browser.safari)
{WL.Utils.getElementOffset=function(e)
{var offset=new Object();offset.top=0;offset.left=0;offset.width=e.offsetWidth;offset.height=e.offsetHeight;var el=e;while(el.parentNode&&el.tagName!="BODY"&&el.tagName!="HTML")
{if(el.scrollLeft)offset.left-=el.scrollLeft;if(el.scrollTop)offset.top-=el.scrollTop;el=el.parentNode;}
el=e;while(el.offsetParent)
{offset.left+=el.offsetLeft;if(el.tagName=="TD")offset.top+=el.parentNode.offsetTop;else offset.top+=el.offsetTop;el=el.offsetParent;}
var docBody=WL.Utils.getBody();offset.left+=el.offsetLeft-(parseInt(docBody.clientLeft)).NaN0();offset.top+=el.offsetTop-(parseInt(docBody.clientTop)).NaN0();return offset;}}
else
{WL.Utils.getElementOffset=function(e)
{var offset=new Object();offset.top=0;offset.left=0;offset.width=e.offsetWidth;offset.height=e.offsetHeight;var el=e;while(el.parentNode&&el.tagName!="BODY"&&el.tagName!="HTML")
{if(el.tagName!="TR")
{if(el.scrollLeft)offset.left-=el.scrollLeft;if(el.scrollTop)offset.top-=el.scrollTop;}
el=el.parentNode;}
el=e;while(el.offsetParent)
{offset.left+=el.offsetLeft+(parseInt(WL.currentStyle(el).borderLeftWidth)).NaN0();offset.top+=el.offsetTop+(parseInt(WL.currentStyle(el).borderTopWidth)).NaN0();el=el.offsetParent;}
var docBody=WL.Utils.getBody();offset.left+=el.offsetLeft-(parseInt(docBody.clientLeft)).NaN0();offset.top+=el.offsetTop-(parseInt(docBody.clientTop)).NaN0();return offset;}}