
wl.Controls={};wl.Controls.Control=wl.Class(Object,function()
{this.constructor=function()
{this._disabled=false;wl.attachEvent(window,"unload",this.unload.bind(this));}
this.getContainer=function(){return wl.$(this.c_id);}
this.generate=function(container)
{if(typeof(container)=="string")
container=document.getElementById(container.split('$').join('_'));this.c_id=wl.uniqueID(container);container.control=this;this.ongenerate(container);}
this.ongenerate=function(c){}
this.unload=function()
{var c=wl.$(this.c_id);if(c!=null)
{this.onunload();c.control=null;}}
this.onunload=function(){}
this.disable=function(disable)
{if(this._disabled==disable)return;if(!wl.fireEvent(this,"disabling",{disable:disable}).isFalse)
{this._disabled=disable;wl.fireEvent(this,"disable",{disable:disable});this.ondisabled(disable);}}
this.ondisabled=function(disabled){}
this.isDisabled=function(){return this._disabled;}
this.show=function(bShow)
{var c=wl.$(this.c_id);if(c!=null)wl.Utils.setNew(c.style,"display",bShow?"":"none");}});wl.TreeAction={None:0x000,Select:0x001,Expand:0x002,Collapse:0x004};wl.TreeAction.Toggle=wl.TreeAction.Expand|wl.TreeAction.Collapse;wl.Controls.TreeView=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);this.showRoot=false;this.oneExpand=false;this.multiSelect=false;this._loadcount=0;this.root=null;this.selectedNodes=[];}
this.ongenerate=function()
{var c=wl.$(this.c_id);wl.Utils.addCss(c,"tree-view");wl.Utils.select_action(c,null);if(c.tabIndex==-1)c.tabIndex=0;wl.attachEvent(c,"keydown",downkeys.bind(this));wl.attachEvent(c,"keyup",processkeys.bind(this));}
this.isLoading=function(){return this._loadcount!=0;}
this.setRoot=function(root)
{if(this.root)
this.root.clear();this.clearSelection();this.root=root;this.root.tree=this;this.root.parent=null;if(this.root.actionClick==null)
this.root.actionClick=wl.TreeAction.Select;this.root._create(0,wl.$(this.c_id));wl.$(this.root.c_id).style.display="block";}
this.clearSelection=function(p)
{if(!p)p={skipInvoke:false};if(this.selectedNodes.length!=0)
{for(var i=0;i<this.selectedNodes.length;++i)
this.selectedNodes[i].setSelected(false);this.selectedNodes.clear();}}
this.selectNode=function(node,p)
{if(node==null)return false;if(this.isNodeSelected(node))return true;if(node==this.root&&!this.showRoot)return false;if(!p)p={skipInvoke:false};if(!p.skipInvoke&&wl.fireEvent(this,"nodeselecting",{node:node}).isFalse)return false;if(!this.multiSelect)this.clearSelection({skipInvoke:true});this.selectedNodes.push(node);node.setSelected(true);node.focus();if(!p.skipInvoke)wl.fireEvent(this,"nodeselect",{node:node});return true;}
this.unselectNode=function(node,p)
{if(node==null)return;if(this.selectedNodes.length!=0)
{if(!p)p={skipInvoke:false,checkChildren:false};unselectNode.call(this,node,p);}}
var unselectNode=function(node,p)
{for(var i=0;i<this.selectedNodes.length;++i)
if(this.selectedNodes[i].equals(node))
{node.setSelected(false);this.selectedNodes.removeAt(i);break;}
if(p.checkChildren)
{for(var i=0;i<node.children.length&&this.selectedNodes.length!=0;++i)
unselectNode.call(this,node.children[i],p);}}
this.isNodeSelected=function(node,p)
{if(!p)p={checkChildren:false};for(var i=0;i<this.selectedNodes.length;++i)
if(this.selectedNodes[i].equals(node))return true;if(p.checkChildren)
{for(var i=0;i<node.children.length;++i)
if(this.isNodeSelected(node.children[i],p))return true;}
return false;}
this.getSelectedNode=function(){if(!this.multiSelect&&this.selectedNodes.length>0)return this.selectedNodes[0];return null;}
this.getSelectedNodes=function(){return this.selectedNodes;}
this.selectFirstNode=function(p)
{if(!p)p={skipInvoke:false};return try_select.call(this,this.root);}
var try_select=function(node,p)
{if(this.selectNode(node,p))return true;for(var i=0;i<node.children.length;++i)
if(try_select.call(this,node.children[i],p))return true;return false;}
this.updateCheckNode=function(node,check,p)
{var changeNodes=[];findCheckNodes.call(node,changeNodes,check);if(changeNodes.length==0)return false;if(!p)p={skipInvoke:false};if(!p.skipInvoke&&wl.fireEvent(this,"checking",{nodes:changeNodes,check:check}).isFalse)return false;for(var i=0;i<changeNodes.length;++i)
{changeNodes[i]._checked=check;changeNodes[i].setupCheck();}
var updatedNodes=[];for(var i=0;i<changeNodes.length;++i)
{var n=changeNodes[i].parent;while(n){if(updatedNodes.indexOf(n)==-1){n.setupCheck();updatedNodes.push(n);}n=n.parent;}}
updatedNodes.clear();if(!p.skipInvoke)wl.fireEvent(this,"check",{nodes:changeNodes,check:check});return true;}
var findCheckNodes=function(changeNodes,check)
{if(this.children.length!=0)
{for(var i=0;i<this.children.length;++i)
findCheckNodes.call(this.children[i],changeNodes,check);}
else if(this._checked!=check)changeNodes.push(this);}
var downkeys=function(e)
{if(this.multiSelect)return;e=wl.getEvent(e);switch(e.keyCode)
{case 40:case 38:case 109:case 37:case 107:case 39:e.stop();return false;}}
var processkeys=function(e)
{if(this.multiSelect)return;e=wl.getEvent(e);var node=this.getSelectedNode();switch(e.keyCode)
{case 40:if(!node)this.selectFirstNode();else this.selectNode(this.getNextSibling(node));break;case 38:if(!node)this.selectFirstNode();else this.selectNode(this.getPrevSibling(node));break;case 109:case 37:if(!node){this.selectFirstNode();node=this.getSelectedNode();}
if(node)node.collapse();break;case 107:case 39:if(!node){this.selectFirstNode();node=this.getSelectedNode();}
if(node)node.expand();break;}}
this.getNextSibling=function(node)
{if(node==null)
return null;if(node._loaded&&node.children.length>0&&!node.isCollapsed())
return node.children[0];return this.getNextVisible(node);}
this.getNextVisible=function(node)
{if(node==null||node.parent==null)
return null;var idx=node.parent.children.indexOf(node);if(idx+1<node.parent.children.length)
return node.parent.children[idx+1];else
return this.getNextVisible(node.parent);}
this.getPrevSibling=function(node)
{if(node==null||node.parent==null||node.isTopNode())
return null;var idx=node.parent.children.indexOf(node);if(idx>0)
return this.getLastVisibleElement(node.parent.children[idx-1]);return node.parent;}
this.getLastVisibleElement=function(node)
{if(node.children.length<1||!node._loaded||node.isCollapsed())
return node;return this.getLastVisibleElement(node.children[node.children.length-1]);}});wl.TreeNode=wl.Class(Object,function(base)
{this.constructor=function()
{base.constructor.call(this);this.tree=null;this.parent=null;this.children=[];this.actionClick=null;this._loaded=false;this._checked=false;}
this.insertNode=function(index,node)
{node.tree=this.tree;node.parent=this;if(node.actionClick==null)
node.actionClick=this.actionClick;this.children.insert(index,node);node._create(index,wl.$(this.c_id));if(index>0)this.children[index-1].setupActive();if(index<this.children.length-1)this.children[index+1].setupActive();}
this.addNode=function(node){this.insertNode(this.children.length,node);}
this.isFirst=function(){if(this.parent){return this.parent.children[0]==this;}return true;}
this.isLast=function(){if(this.parent){return this.parent.children[this.parent.children.length-1]==this;}return true;}
this.findNode=function(finder,p)
{if(!p)p={skipCurrent:false};if(p.skipCurrent)p.skipCurrent=false;else if(finder(this))return this;for(var i=0;i<this.children.length;++i)
{var node=this.children[i].findNode(finder,p);if(node!=null)return node;}
return null;}
this.foreachNodes=function(functor,thisp)
{functor.call(thisp||this,this);for(var i=0;i<this.children.length;++i)
this.children[i].foreachNodes(functor,thisp);}
this._create=function(index,p)
{var e=this.createElement();var c=this.createContainer();if(this.parent==null||index==this.parent.children.length-1)
{p.appendChild(e);p.appendChild(c);}
else
{var nextEl=wl.$(this.parent.children[index+1].e_id);p.insertBefore(e,nextEl);p.insertBefore(c,nextEl);}
this.bindEvents();this.updateElement();}
this.createElement=function()
{var e=wl.$e("li");e.className="tree-node";this.e_id=wl.uniqueID(e);if(this!=this.tree.root)
{var activeIcon=wl.$e("img");activeIcon.src=wl.pixel;activeIcon.className="tree-active";this.a_id=wl.uniqueID(activeIcon);e.appendChild(activeIcon);}
if(this.isCheckable())
{var checkIcon=wl.$e("img");checkIcon.src=wl.pixel;checkIcon.className="tree-check";this.ch_id=wl.uniqueID(checkIcon);checkIcon.onclick=this.check_click.bind(this);e.appendChild(checkIcon);}
var itemIcon=wl.$e("img");itemIcon.src=wl.pixel;itemIcon.className="tree-icon";this.i_id=wl.uniqueID(itemIcon);e.appendChild(itemIcon);var e_name=wl.$e("span");e_name.treeNode=this;e_name.className="tree-text";this.n_id=wl.uniqueID(e_name);e.appendChild(e_name);return e;}
this.bindEvents=function()
{var nameElement=wl.$(this.n_id);nameElement.onclick=this.click.bind(this);nameElement.onmouseover=mouseenter.bind(this);nameElement.onmouseout=onmouseleave.bind(this);}
this.updateElement=function()
{this.setupActive();this.setupCheck();this.setupIcon();var n=wl.$(this.n_id);if(n)
{var h=this.getHref();if(h&&h!="#")
{n=wl.$e("a",n,true);n.href=wl.resolvePath(h);n.target=this.getTarget()||"";}
n.innerHTML=this.getName();}}
this.focus=function()
{try{wl.$(this.e_id).focus();}catch(e){}}
this.click=function()
{if(this.actionClick)
{if(this.actionClick&wl.TreeAction.Select)
{if(!this.tree.multiSelect||!this.tree.isNodeSelected(this))this.select();else this.unselect();}
if(this.isCollapsed())
{if(this.actionClick&wl.TreeAction.Expand)this.expand();}
else{if(this.actionClick&wl.TreeAction.Collapse)this.collapse();}}}
this.check_click=function()
{if(this.isChecked())this.uncheck();else this.check();}
var dragstart=function()
{if(this.createDragNode==null)
return false;window.dragObject=this.createDragNode();if(window.dragObject!=null)
{this.tree.selectNode(this);return true;}
return false;}
var dragend=function(){window.dragObject=null;}
var mouseenter=function(){wl.Utils.addCss(wl.$(this.e_id),"tree-hover");}
var onmouseleave=function(){wl.Utils.removeCss(wl.$(this.e_id),"tree-hover");}
this.setSelected=function(selected)
{if(selected)
{var n=this;while(n.parent!=null&&wl.$(n.e_id).offsetWidth==0){n=n.parent;n.expand();}}
var e=wl.$(this.e_id);if(e!=null){if(selected)wl.Utils.addCss(e,"tree-selected");else wl.Utils.removeCss(e,"tree-selected");}}
this.clear=function()
{for(var i=0;i<this.children.length;++i)
this.children[i].clear();this.children.clear();if(this.c_id!=null)
wl.Utils.clear_container(wl.$(this.c_id));}
this.reload=function(p)
{if(!p)p={updateSelection:true};if(p.updateSelection==null)p.updateSelection=true;this.clear();if(!this.isCollapsed())wl.attachOnceEvent(this,"load",this.expand.bind(this));if(p.updateSelection)wl.attachOnceEvent(this,"load",this.updateSelection.bind(this));this._loaded=false;this.load();}
this.remove=function()
{this.clear();var prev,next;if(this.parent)
{var idx=this.parent.children.indexOf(this);var isFirst=idx==0;var isLast=idx==this.parent.children.length-1;prev=isFirst?null:this.parent.children[idx-1];next=isLast?null:this.parent.children[idx+1];this.parent.children.remove(this);var p=wl.$(this.parent.c_id);p.removeChild(wl.$(this.e_id));p.removeChild(wl.$(this.c_id));if(isLast&&prev!=null)
prev.setupActive();if(isFirst&&next!=null)
next.setupActive();if(this.parent.parent)
this.parent.setupActive();}
else
{wl.$(this.e_id).parentNode.removeChild(wl.$(this.e_id));wl.$(this.c_id).parentNode.removeChild(wl.$(this.c_id));}
this.c_id=this.e_id=null;if(this.tree.isNodeSelected(this,{checkChildren:true}))
{this.tree.unselectNode(this,{checkChildren:true});var node=prev?prev:(next?next:this.parent);if(node!=this.tree.root||this.tree.showRoot)
this.tree.selectNode(node);}}
this.isTopNode=function()
{return this==this.tree.root||(this.parent==this.tree.root&&!this.tree.showRoot&&this.isFirst());}
this.setupActive=function()
{var e=wl.$(this.e_id);var c=wl.$(this.c_id);if(this==this.tree.root)
{if(this.tree.showRoot)
{wl.Utils.setNew(e.style,"backgroundImage","none");wl.Utils.setNew(e.style,"display","block");}
else
wl.Utils.setNew(e.style,"display","none");wl.Utils.setNew(c.style,"backgroundImage","none");wl.Utils.setNew(c.style,"paddingLeft","0px");}
else
{if(this.isLast())
{wl.Utils.setNew(c.style,"backgroundImage",String.format("url('{0}')",wl.pixel));wl.Utils.setNew(e.style,"backgroundPosition",this.isTopNode()?"left 0%":"left 66%");}
else
{wl.Utils.setNew(c.style,"backgroundImage","");wl.Utils.setNew(e.style,"backgroundPosition",this.isTopNode()?"left 33%":"left 100%");}
var icon=wl.$(this.a_id);if(icon!=null)
{var isFolder=this.isFolder()&&(this.children.length!=0||!this._loaded);if(isFolder)
{wl.Utils.setNew(icon.style,"visibility","visible");wl.Utils.setNew(icon.style,"backgroundPosition",this.isCollapsed()?"left top":"right top");if(icon.onclick==null)
icon.onclick=this.toggle.bind(this);}
else
{wl.Utils.setNew(c.style,"display","none");wl.Utils.setNew(icon.style,"visibility","hidden");icon.onclick=null;}}}}
this.setupCheck=function()
{if(this.isCheckable())
{var checked=this.isChecked();var x=checked==null?"100%":(checked?"50%":"0%");var check=wl.$(this.ch_id);wl.Utils.setNew(check.style,"backgroundPosition",x+" center");}}
this.setupIcon=function()
{var icon=wl.$(this.i_id);wl.Utils.setNew(icon,"className","tree-icon "+this.getImageCss());wl.Utils.setNew(icon.style,"backgroundPosition",this.getImagePosition());}
this.select=function(){this.tree.selectNode(this);}
this.unselect=function(){this.tree.unselectNode(this);}
this.check=function(){this.tree.updateCheckNode(this,true);}
this.uncheck=function(){this.tree.updateCheckNode(this,false);}
this.toggle=function()
{if(!this.isFolder())
return;if(this.isCollapsed())
this.expand();else
this.collapse();}
this.isCollapsed=function(){return wl.$(this.c_id).style.display=="none";}
this.expand=function()
{if(!this.isFolder())return;wl.$(this.c_id).style.display="block";if(!this._loaded)
{if(this.children.length==0)this.load();else this.reload();}
if(this.tree.oneExpand)
this.collapseChildren(this);this.setupActive();this.setupIcon();}
this.collapse=function()
{if(!this.isFolder())return;wl.$(this.c_id).style.display="none";this.setupActive();this.setupIcon();}
this.collapseChildren=function(node)
{if(node.parent==null)return;var it;for(var i=0;i<node.parent.children.length;++i)
{it=node.parent.children[i];if(it!=node&&it.c_id!=null&&wl.$(it.c_id).style.display!="none")
{it.clear();it.collapse();it._loaded=false;}}
this.collapseChildren(node.parent);}
this.createContainer=function()
{var c=wl.$e("ul");c.className="tree-content";c.style.display="none";this.c_id=wl.uniqueID(c);return c;}
this.isLoaded=function(){return this._loaded;}
this.createWaiter=function()
{var waiter=wl.$e("div");waiter.className="tree-waiter";var c=wl.$(this.c_id);c.insertBefore(waiter,c.firstChild);}
this.removeWaiter=function()
{var c=wl.$(this.c_id);if(c.firstChild)c.removeChild(c.firstChild);}
this.onstartload=function()
{this.clear();this.createWaiter();this.tree._loadcount++;return true;}
this.onloadcomplete=function()
{this._loaded=true;this.tree._loadcount--;this.removeWaiter();for(var i=0;i<this.children.length;++i)
if(this.children[i].autoExpand())this.children[i].expand();wl.fireEvent(this,"load");this.setupActive();this.setupCheck();}
this.updateSelection=function()
{var updateNodes=[];updateSelectedNodes.call(this.tree,this,updateNodes);for(var i=0;i<updateNodes.length;++i)
this.tree.selectedNodes.push(updateNodes[i]);}
var updateSelectedNodes=function(node,updateNodes)
{for(var i=0;i<this.selectedNodes.length;++i)
if(this.selectedNodes[i]!=node&&this.selectedNodes[i].equals(node))
{this.selectedNodes[i].setSelected(false);updateNodes.push(node);node.setSelected(true);this.selectedNodes.removeAt(i--);}
for(var i=0;i<node.children.length&&this.selectedNodes.length!=0;++i)
updateSelectedNodes.call(this,node.children[i],updateNodes);}
this.autoExpand=function(){return false;}
this.isFolder=function(){return false;}
this.getName=function(){return"";}
this.equals=function(n){return this==n;}
this.getHref=function(){return null;}
this.getTarget=function(){return null;}
this.getImageCss=function(){return"tree-icons";}
this.getImagePosition=function(){return this.isFolder()?(this.isCollapsed()?"0% top":"50% top"):"100% top";}
this.isCheckable=function(){return false;}
this.isChecked=function()
{if(this.children.length==0)return this._checked;var checked=this.children[0].isChecked();for(var i=1;i<this.children.length;++i)
if(this.children[i].isChecked()!==checked)
return null;return checked;}});wl.PreloadTreeNode=wl.Class(wl.TreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this);this._preloaded=false;this.preloadHandlers=[];this._preloadCookie=0;}
this.isPreloaded=function(){return this._preloaded;}
this.reload=function(p)
{this._preloaded=false;base.reload.call(this,p);}
this.preload=function(handler)
{if(!this._preloaded)
{if(handler)this.preloadHandlers.push(handler);clearAddTreeNodeProcess.call(this);this.onpreload();}
else
if(handler)handler({error:false});}
this.preloadComplete=function(result)
{for(var i=0;i<this.preloadHandlers.length;++i)
this.preloadHandlers[i](result);this.preloadHandlers.clear();this._preloaded=true;}
this.load=function()
{if(this.onstartload())this.preload(on_load.bind(this));}
var on_load=function(result)
{if(!result.error)
{clearAddTreeNodeProcess.call(this);addTreeNodeProcess.call(this);this._loaded=true;}
else
this.onloadcomplete();}
var addTreeNodeProcess=function()
{if(this.addNodesProcess(this.children.length))this.onloadcomplete();else
{this._preloadCookie=window.setTimeout(addTreeNodeProcess.bind(this),200);}}
var clearAddTreeNodeProcess=function()
{if(this._preloadCookie!=0)
{window.clearTimeout(this._preloadCookie);this._preloadCookie=0;}}});wl.Controls.Button=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);}
this.ongenerate=function()
{var c=wl.$(this.c_id);if(c.firstChild==null)c.appendChild(wl.$e("b"));if(c.firstChild.firstChild==null)c.firstChild.appendChild(wl.$e("b"));if(c.firstChild.firstChild.firstChild==null)c.firstChild.firstChild.appendChild(wl.$e("b"));c.onclick=this.click.bind(this);if(c.tagName=="BUTTON"&&wl.browser.ie&&wl.browser.v<=7&&c.form)
{var submit=c.form.onsubmit;c.form.onsubmit=function(){if(c.__allowSubmited)c.value=c.innerText;else c.disabled=true;if(typeof(submit)=="function")return submit();}}
preloadButtonImages(c);}
var returnTrue=function(){return true;}
this.setCssClass=function(cssClass)
{var c=wl.$(this.c_id);if(c){wl.Utils.setNew(c,"className","button "+cssClass);preloadButtonImages(c);}}
var bigbtn=false;var preloadButtonImages=function(c)
{var a=[];if(a.length)wl.Utils.preloadImages(null,a);}
this.setLicon=function(icon){getLiconContainer(wl.$(this.c_id),true).lastChild.className=icon;}
this.setRicon=function(icon){getRiconContainer(wl.$(this.c_id),true).lastChild.className=icon;}
var getLiconContainer=function(c,bCreate)
{var b=c.firstChild.firstChild.firstChild;var c_icon=b.firstChild;if(bCreate&&(!c_icon||c_icon.tagName!="SPAN"||c_icon.className!="button-licon"||!c_icon.lastChild||!c_icon.lastChild.tagName!="IMG"))
{c_icon=wl.$e("SPAN");c_icon.className="button-licon";var icon=wl.$e("IMG");icon.src=wl.pixel;c_icon.appendChild(icon);b.insertBefore(c_icon,b.firstChild);}
return c_icon&&c_icon.tagName=="SPAN"&&c_icon.className=="button-licon"&&c_icon.lastChild&&c_icon.lastChild.tagName=="IMG"?c_icon:null;}
var getRiconContainer=function(c,bCreate)
{var b=c.firstChild.firstChild.firstChild;var c_icon=b.lastChild;if(bCreate&&(!c_icon||c_icon.tagName!="SPAN"||c_icon.className!="button-ricon"||!c_icon.lastChild||!c_icon.lastChild.tagName!="IMG"))
{c_icon=wl.$e("SPAN");c_icon.className="button-ricon";var icon=wl.$e("IMG");icon.src=wl.pixel;c_icon.appendChild(icon);b.appendChild(c_icon);}
return c_icon&&c_icon.tagName=="SPAN"&&c_icon.className=="button-ricon"&&c_icon.lastChild&&c_icon.lastChild.tagName=="IMG"?c_icon:null;}
this.setText=function(text,title)
{var c=wl.$(this.c_id);if(c)
{if(typeof(title)=="number")title=wl.S(title);if(typeof(text)=="number")
{var b=c.firstChild.firstChild;if(b.attributes["localeID"]==null)
b.setAttribute("localeID",0);b.attributes["localeID"].nodeValue=text;text=wl.S(text);}
var licon=getLiconContainer(c,false);var ricon=getRiconContainer(c,false);var b=c.firstChild.firstChild.firstChild;b.innerHTML=text;c.title=title||b.textContent||b.innerText||"";if(licon)b.insertBefore(licon,b.firstChild);if(ricon)b.appendChild(ricon);}}
this.click=function(e)
{var cancel=true;if(!this.isDisabled()&&!wl.fireEvent(this,"check").isFalse&&!wl.fireEvent(this,"click").isFalse)cancel=false;try
{var c=wl.$(this.c_id);if(c.href&&c.href.indexOf("#")>=0)cancel=true;c.blur();}catch(ex){}
if(cancel)return false;this.doPostBack();}
this.doPostBack=function(){var c=wl.$(this.c_id);if(c.tagName=="BUTTON"){c.__allowSubmited=true;var pb=this.doPostBack;this.doPostBack=empty;c.click();this.doPostBack=pb;}}
var empty=function(){}
this.ondisabled=function(state)
{var c=wl.$(this.c_id);if(c)wl.Utils.updateCss(c,"disabled",state);}});CALENDAR_MODE={Normal:0,SelectDay:1};CALENDAR_ITEM_TYPE={ThisDay:1,ThisMonth:2,OutMonth:3,OutPeriod:4};wl.Controls.Calendar=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);this.mode=CALENDAR_MODE.Normal;this.showTime=false;this.timeInterval=1;this.current=new Date();this.from=new Date();this.to=new Date();this.modes={};this.modes[CALENDAR_MODE.Normal]={};this.modes[CALENDAR_MODE.SelectDay]={current:new Date(2001,0,1),from:new Date(2001,0,1),to:new Date(2001,0,31)};this.datePanel=new wl.Controls.Calendar.DatePanel(this);this.dateMatrix=new wl.Controls.Calendar.DateMatrix(this);this.timePanel=new wl.Controls.Calendar.TimePanel(this);}
this.ongenerate=function()
{var c=wl.$(this.c_id);wl.Utils.clean_container(c);wl.Utils.addCss(c,"calendar");wl.Utils.select_action(c,null);if(c.tBodies.length==0)c.appendChild(wl.$e("tbody"));var tbody=c.tBodies[0];wl.Utils.clean_container(tbody);this.datePanel.create(tbody);this.dateMatrix.create(tbody);this.timePanel.create(tbody);this.update();}
this.setCurrent=function(current)
{var old=this.current;this.current=new Date(Math.middle(this.from.valueOf(),current.valueOf(),this.to.valueOf()));if(this.current.getMonth()!=old.getMonth()||this.current.getFullYear()!=old.getFullYear())this.update();this.dateMatrix.selectItem(this.current);if(this.current.valueOf()!=old.valueOf()){wl.$h(this.c_id+"_current",this.current.valueOf(),wl.$(this.c_id));wl.fireEvent(this,"change");}}
this.getCurrent=function(){return this.current.clone();}
this.resetCurrent=function(y,m,d,h,min)
{if(y==null)y=this.current.getFullYear();if(m==null)m=this.current.getMonth();if(d==null)d=this.current.getDate();if(h==null)h=this.current.getHours();if(min==null)min=this.current.getMinutes();this.setCurrent(new Date(y,m,d,h,min));}
this.setPeriod=function(from,to){if(from)this.from=from;if(to)this.to=to;this.update();}
this.isInPeriod=function(date)
{return this.from.valueOf()<=date.valueOf()&&date.valueOf()<=this.to.valueOf();}
this.update=function()
{this.datePanel.update();this.dateMatrix.update();this.timePanel.update();wl.$(this.timePanel.c_id).style.display=(!this.showTime||this.mode==CALENDAR_MODE.SelectDay)?"none":"";}
this.setMode=function(mode)
{if(this.mode!=mode)
{this.modes[this.mode].current=this.current;this.modes[this.mode].from=this.from;this.modes[this.mode].to=this.to;this.current=this.modes[mode].current;this.from=this.modes[mode].from;this.to=this.modes[mode].to;wl.$h(this.c_id+"_current",this.current.valueOf(),wl.$(this.c_id));wl.$(this.datePanel.c_id).style.display=mode==CALENDAR_MODE.SelectDay?"none":"";this.dateMatrix.weekdaysContainer.style.display=mode==CALENDAR_MODE.SelectDay?"none":"";wl.$(this.timePanel.c_id).style.display=(!this.showTime||mode==CALENDAR_MODE.SelectDay)?"none":"";this.mode=mode;this.update();}};(function(){var set_input_value=function(c,value){if(c&&c.value!=value){c.value=value;wl.fireEvent(c,"change");}}
var currentLinkedID=null;this.linkControl=function(c,options)
{if(!options)options={};options.i_id=wl.uniqueID(c);if(!options.c_id)options.c_id=this.c_id;if(!options.format)options.format=CultureInfo.Date.formatPatterns.shortDate;if(options.initValue==null)options.initValue=this.getCurrent();on_change.call(this,options);if(!c.value&&options.initValue)set_input_value(c,options.initValue.toString(options.format));wl.attachEvent(this,"change",on_change.bind(this,options));wl.attachEvent(c,"click",show_calendar.bind(this,options));}
var on_change=function(options,e)
{var c=currentLinkedID&&wl.$(currentLinkedID);if(c==null)
{var cont=wl.$(options.c_id);if(cont)cont.style.display="none";return;}
if(c.tagName=="INPUT")set_input_value(c,this.getCurrent().toString(options.format));else
{c.innerHTML="";c.appendChild(document.createTextNode(this.getCurrent().toString(options.format)));}}
var show_calendar=function(options)
{currentLinkedID=options.i_id;var c=wl.$(options.i_id);if(c.tagName=="INPUT")
{var d=Date.parseExact(c.value,options.format);if(d!=null)this.setCurrent(d);else set_input_value(c,this.getCurrent().toString(options.format));}
wl.popup_show(wl.$(options.c_id),{closeWithClick:true,opacity:0,relativeElement:c});}}).call(this);this.linkDateToCalendar=function(calendar)
{wl.attachEvent(this,"change",(function(){calendar.setPeriod(this.getCurrent(),null);calendar.setCurrent(calendar.getCurrent());}).bind(this));wl.attachEvent(calendar,"change",(function(){this.setPeriod(null,calendar.getCurrent());this.setCurrent(this.getCurrent());}).bind(this));this.setPeriod(null,calendar.getCurrent());calendar.setPeriod(this.getCurrent(),null);}});wl.Controls.Calendar.DatePanel=wl.Class(Object,function()
{this.constructor=function(calendar)
{this.control=calendar;}
this.create=function(container)
{var row=wl.$e("tr");var cell=wl.$e("td");var panel=wl.$e("table");this.c_id=wl.uniqueID(panel);panel.style.tableLayout="fixed";panel.style.width="100%";panel.cellPadding="0px";panel.cellSpacing="0px";var tbody=wl.$e("tbody");var prow=wl.$e("tr");var pcell=wl.$e("td");var table1=wl.$e("table");table1.style.tableLayout="fixed";table1.style.width="100%";table1.cellPadding="0px";table1.cellSpacing="0px";var tbody1=wl.$e("tbody");var row1=wl.$e("tr");var col11=wl.$e("td");col11.className="calendar-prev";col11.onclick=prev_click.bind(this.control);col11.appendChild(wl.$e("div"));var col21=wl.$e("td");col21.style.width="8px";var col31=wl.$e("td");col31.className="calendar-current";var col41=wl.$e("td");col41.style.width="8px";var col51=wl.$e("td");col51.textAlign="top";col51.className="calendar-next";col51.onclick=next_click.bind(this.control);col51.appendChild(wl.$e("div"));row1.appendChild(col11);row1.appendChild(col21);row1.appendChild(col31);row1.appendChild(col41);row1.appendChild(col51);tbody1.appendChild(row1);table1.appendChild(tbody1);pcell.appendChild(table1);prow.appendChild(pcell);tbody.appendChild(prow);prow=wl.$e("tr");pcell=wl.$e("td");var table2=wl.$e("table");table2.style.width="100%";table2.cellPadding="0px";table2.cellSpacing="0px";var tbody2=wl.$e("tbody");var row2=wl.$e("tr");var col12=wl.$e("td");col12.style.width="70%";var col22=wl.$e("td");col22.style.width="8px";var col32=wl.$e("td");col32.style.width="30%";row2.appendChild(col12);row2.appendChild(col22);row2.appendChild(col32);tbody2.appendChild(row2);table2.appendChild(tbody2);pcell.appendChild(table2);prow.appendChild(pcell);tbody.appendChild(prow);panel.appendChild(tbody);cell.appendChild(panel);row.appendChild(cell);container.appendChild(row);var select_month=wl.$e("select");select_month.className="input";select_month.style.width="100%";var select_year=wl.$e("select");select_year.className="input";select_year.style.width="100%";var in_month=wl.$e("span");this.m_id=wl.uniqueID(select_month);this.y_id=wl.uniqueID(select_year);this.n_id=wl.uniqueID(in_month);col31.appendChild(in_month);col12.appendChild(select_month);col32.appendChild(select_year);select_month.onchange=update_month.bind(this.control);select_year.onchange=update_year.bind(this.control);}
var update_month=function(e){this.resetCurrent(null,parseInt(wl.getEvent(e).target.value),null);this.update();}
var update_year=function(e){this.resetCurrent(parseInt(wl.getEvent(e).target.value),null,null);this.update();}
var create_option=function(t,v){var o=wl.$e("option");o.innerHTML=t;o.value=v;return o;}
var prev_click=function(){var date=this.current.clone();date.addMonths(-1);this.resetCurrent(date.getFullYear(),date.getMonth());}
var next_click=function(){var date=this.current.clone();date.addMonths(+1);this.resetCurrent(date.getFullYear(),date.getMonth());}
this.update=function()
{if(this.control.mode==CALENDAR_MODE.SelectDay)return;var select_month=wl.$(this.m_id);var select_year=wl.$(this.y_id);var yfrom=this.control.from.getFullYear();var yto=this.control.to.getFullYear();var i=yfrom;if(select_year.options.length>0)
{while(yfrom>parseInt(select_year.options[0].value))
select_year.removeChild(select_year.options[0]);var first=select_year.options[0];var yto2=Math.min(yto,parseInt(first.value)-1);for(;i<=yto2;++i)
select_year.insertBefore(create_option(i,i),first);while(yto<parseInt(select_year.options[select_year.options.length-1].value))
select_year.removeChild(select_year.options[select_year.options.length-1]);i=parseInt(select_year.options[select_year.options.length-1].value)+1;}
for(;i<=yto;++i)select_year.appendChild(create_option(i,i));var cur=this.control.current.toUserZone();var mfrom=(yfrom==cur.getFullYear())?this.control.from.toUserZone().getMonth():0;var mto=(yto==cur.getFullYear())?this.control.to.toUserZone().getMonth():11;var i=mfrom;if(select_month.options.length>0)
{if(mfrom>parseInt(select_month.options[select_month.options.length-1].value))
wl.Utils.clear_container(select_month);else
{while(mfrom>parseInt(select_month.options[0].value))
select_month.removeChild(select_month.options[0]);var first=select_month.options[0];var mto2=Math.min(mto,parseInt(first.value)-1);for(;i<=mto2;++i)
select_month.insertBefore(create_option(CultureInfo.Date.monthNames[i],i),first);while(mto<parseInt(select_month.options[select_month.options.length-1].value))
select_month.removeChild(select_month.options[select_month.options.length-1]);i=parseInt(select_month.options[select_month.options.length-1].value)+1;}}
for(;i<=mto;++i)select_month.appendChild(create_option(CultureInfo.Date.monthNames[i],i));wl.$(this.n_id).innerHTML=String.format("{0}, {1}",CultureInfo.Date.monthNames[cur.getMonth()],cur.getFullYear());select_month.value=cur.getMonth();select_year.value=cur.getFullYear();}});wl.Controls.Calendar.DateMatrix=wl.Class(Object,function()
{this.constructor=function(calendar)
{this.control=calendar;}
this.create=function(container)
{var row=wl.$e("tr");var cell=wl.$e("td");var table=wl.$e("table");table.cellSpacing="0px";table.cellPadding="0px";var tbody=wl.$e("tbody");table.className="calendar-matrix";var title_row=wl.$e("tr");for(var j=0;j<7;++j)
{var week_day=wl.$e("td");week_day.className="calendar-week-day";week_day.innerHTML=CultureInfo.Date.shortestDayNames[j];title_row.appendChild(week_day);}
this.weekdaysContainer=title_row;tbody.appendChild(title_row);this.matrix=new Array(6);for(var i=0;i<6;++i)
{var week_row=wl.$e("tr");this.matrix[i]=new Array(7);for(var j=0;j<7;++j)
{var day=wl.$e("td");this.matrix[i][j]=new wl.Controls.Calendar.DateMatrix.Item(this.control);this.matrix[i][j].create(day);week_row.appendChild(day);}
tbody.appendChild(week_row);}
for(var i=0;i<7;++i)
this.matrix[0][i].item.style.borderTopWidth="1px";table.appendChild(tbody);cell.appendChild(table);row.appendChild(cell);container.appendChild(row);}
this.update=function()
{var i=0,j=0;var date=this.control.current.toUserZone();date.moveToFirstDayOfMonth(1);var firstWeekDay=date.getDay();if(firstWeekDay!=0)
{date.addMonths(-1);date.set({day:date.getDaysInMonth()-firstWeekDay+1});for(j=0;date.getDate()!=1;++j,date.addDays(1))
{this.matrix[0][j].setValue(date.fromUserZone(),CALENDAR_ITEM_TYPE.OutMonth);}}
for(;j<7;++j,date.addDays(1))
this.matrix[0][j].setValue(date.fromUserZone(),CALENDAR_ITEM_TYPE.ThisMonth);var torow=Math.floor((date.getDaysInMonth()-date.getDate())/7);for(var i=1;i<=torow;++i)
for(j=0;j<7;++j,date.addDays(1))
this.matrix[i][j].setValue(date.fromUserZone(),CALENDAR_ITEM_TYPE.ThisMonth);for(i=torow+1,j=0;date.getDate()!=1&&j<7;++j,date.addDays(1))
this.matrix[i][j].setValue(date.fromUserZone(),CALENDAR_ITEM_TYPE.ThisMonth);for(;i<6;++i,j=0)
for(;j<7;++j,date.addDays(1))
this.matrix[i][j].setValue(date.fromUserZone(),CALENDAR_ITEM_TYPE.OutMonth);this.selectItem(this.control.current);}
this.selectItem=function(date)
{if(this.selectedItem)
this.selectedItem.setStyle();for(var i=0;i<6;++i)
for(var j=0;j<7;++j)
if(wl.Utils.Comparers.date(date,this.matrix[i][j].getValue())==0)
{this.selectedItem=this.matrix[i][j];this.selectedItem.setStyle(CALENDAR_ITEM_TYPE.ThisDay);}}});wl.Controls.Calendar.DateMatrix.Item=wl.Class(Object,function()
{this.constructor=function(calendar)
{this.control=calendar;}
this.create=function(container)
{this.item=container;wl.attachEvent(container,"click",this.click.bind(this));}
this.click=function(){this.control.resetCurrent(this.item.value.getFullYear(),this.item.value.getMonth(),this.item.value.getDate());}
this.setValue=function(date,type)
{this.item.innerHTML=date.toUserZone().getDate();this.item.value=date;this.item.type=this.control.isInPeriod(date)?type:CALENDAR_ITEM_TYPE.OutPeriod;this.setStyle();}
this.getValue=function(){return this.item.value;}
this.setStyle=function(type)
{if(type==null)type=this.item.type;switch(type)
{case CALENDAR_ITEM_TYPE.ThisDay:this.item.className="calendar-day-current";break;case CALENDAR_ITEM_TYPE.ThisMonth:this.item.className="calendar-day";break;case CALENDAR_ITEM_TYPE.OutMonth:this.item.className="calendar-day-outmonth";break;case CALENDAR_ITEM_TYPE.OutPeriod:this.item.className="calendar-day-outperiod";break;}}});wl.Controls.Calendar.TimePanel=wl.Class(Object,function()
{this.constructor=function(calendar)
{this.control=calendar;}
this.create=function(container)
{var row=wl.$e("tr");var cell=wl.$e("td");var panel=wl.$e("table");this.c_id=wl.uniqueID(panel);panel.style.tableLayout="fixed";panel.style.width="100%";panel.cellPadding="0px";panel.cellSpacing="0px";var tbody=wl.$e("tbody");var prow=wl.$e("tr");var pcell=wl.$e("td");var table2=wl.$e("table");table2.style.width="100%";table2.cellPadding="0px";table2.cellSpacing="0px";var tbody2=wl.$e("tbody");var row2=wl.$e("tr");var col12=wl.$e("td");col12.style.width="50%";var col22=wl.$e("td");col22.style.width="8px";col22.innerHTML=":";var col32=wl.$e("td");col32.style.width="50%";row2.appendChild(col12);row2.appendChild(col22);row2.appendChild(col32);tbody2.appendChild(row2);table2.appendChild(tbody2);pcell.appendChild(table2);prow.appendChild(pcell);tbody.appendChild(prow);panel.appendChild(tbody);cell.appendChild(panel);row.appendChild(cell);container.appendChild(row);var select_hour=wl.$e("select");select_hour.className="input";select_hour.style.width="100%";var select_minute=wl.$e("select");select_minute.className="input";select_minute.style.width="100%";this.h_id=wl.uniqueID(select_hour);this.m_id=wl.uniqueID(select_minute);col32.appendChild(select_minute);col12.appendChild(select_hour);for(var i=0;i<24;++i)
select_hour.appendChild(create_option(i.toString(),i));for(var i=0;i<60;i+=this.control.timeInterval)
select_minute.appendChild(create_option(i.toString(),i));select_hour.onchange=update_hours.bind(this.control);select_minute.onchange=update_minutes.bind(this.control);}
var update_minutes=function(e)
{var cur=this.current.toUserZone();cur.set({minute:parseInt(wl.getEvent(e).target.value)});this.setCurrent(cur.fromUserZone());this.update();}
var update_hours=function(e)
{var cur=this.current.toUserZone();cur.set({hour:parseInt(wl.getEvent(e).target.value)});this.setCurrent(cur.fromUserZone());this.update();}
var create_option=function(t,v){var o=wl.$e("option");o.innerHTML=t;o.value=v;return o;}
this.update=function()
{if(this.control.mode==CALENDAR_MODE.SelectDay)return;var cur=this.control.current.toUserZone();wl.Utils.selectNumberValue(wl.$(this.h_id),cur.getHours());wl.Utils.selectNumberValue(wl.$(this.m_id),cur.getMinutes());}});var InquiryScoreBar=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);}
this.ongenerate=function()
{var c=wl.$(this.c_id);c.className="score-bar";var i=wl.$e("span",c,true);i.className="l";i.innerHTML="0";var i=wl.$e("span",c);i.className="r";i.innerHTML="100";var i=wl.$e("span",c);i.className="g";i.innerHTML="70 (Good)";var i=wl.$e("div",c);i.className="p";this.i_id=wl.uniqueID(i);var i=wl.$e("div",c);i.className="f";var i=wl.$e("div",c);i.className="s";}
this.value=function(v)
{var i=wl.$(this.i_id);if(i)
{i.style.left=v+"%";i.innerHTML=v+"%";}}});var LeftMenuRootTreeNode=wl.Class(wl.TreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this);}
this.isFolder=function(){return true;}
this.getName=function(){return"Root";}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuActivitiesTreeNode());this.addNode(new LeftMenuPaymentsTreeNode());this.addNode(new LeftMenuCustomersTreeNode());if(window.userGroupID==USER_GROUP.Users)this.addNode(new LeftMenuUsersTreeNode());if(wl.S(3400))this.addNode(new LeftMenuAffiliatesTreeNode());this.addNode(new LeftMenuReportsTreeNode());this.addNode(new LeftMenuSettingsTreeNode());this.children.each(function(i){i.load();});this.onloadcomplete();var path=window.location.href.substring(wl.baseUrl.length);var node=null;this.foreachNodes(function(n)
{if(n.href&&path.indexOf(n.href)==0)
if(!node||node.href.length<n.href.length)node=n;});if(node)this.tree.selectNode(node,{skipInvoike:true});}}});var LeftMenuLeafTreeNode=wl.Class(wl.TreeNode,function(base)
{this.constructor=function(name,href,image)
{base.constructor.call(this);this.name=typeof(name)=="number"?wl.SHTML(name):name;this.href=href;this.image=image!=null?image:-1;}
this.isFolder=function(){return false;}
this.getName=function(){return this.name;}
this.onloadcomplete=function()
{this.children.each(function(i){if(i.isFolder())i.load();});base.onloadcomplete.apply(this,arguments);}
this.click=function(){if(!this.href)this.toggle();}
this.setupActive=function()
{base.setupActive.apply(this,arguments);if(!this.parent.parent)
wl.Utils.setNew(wl.$(this.a_id).style,"display","none");}
this.setupIcon=function()
{if(this.parent.parent)
wl.Utils.setNew(wl.$(this.i_id).style,"display","none");else base.setupIcon.apply(this,arguments);}
this.getHref=function(){return this.href||null;}
this.getImageCss=function(){return this.image>=0?"tree-left-menu-icons":base.getImageCss.apply(this,arguments);}
this.getImagePosition=function(){return this.image>=0?((this.image*10)+"% top"):base.getImagePosition.apply(this,arguments);}});var LeftMenuJwlsTreeNode=wl.Class(LeftMenuLeafTreeNode,function(base)
{this.constructor=function()
{base.constructor.apply(this,arguments);}
this.getTarget=function(){return"_blank";}});var LeftMenuFolderTreeNode=wl.Class(LeftMenuLeafTreeNode,function(base)
{this.constructor=function(name,href,image)
{base.constructor.call(this,name,href,image);}
this.isFolder=function(){return true;}});var LeftMenuActivitiesTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,"Activities",null,0);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode(2700,"transactions"));this.addNode(new LeftMenuInquiriesTreeNode());this.addNode(new LeftMenuLeafTreeNode(1002,"shipment"));this.addNode(new LeftMenuLeafTreeNode(2650,"einvoices"));this.addNode(new LeftMenuLeafTreeNode(2670,"einvoices/withdrawal"));this.onloadcomplete();}}});var LeftMenuInquiriesTreeNode=wl.Class(LeftMenuLeafTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,1070,"inquiries");}
this.isFolder=function(){return true;}
this.load=function()
{if(this.onstartload())
{if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.RiskBasic))this.addNode(new LeftMenuLeafTreeNode(1085,"inquiries/create/riskbasic"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.RiskReport))this.addNode(new LeftMenuLeafTreeNode(1099,"inquiries/create/riskreport"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.IDInterview))this.addNode(new LeftMenuLeafTreeNode(1091,"inquiries/create/idinterview"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.IDQuiz))this.addNode(new LeftMenuLeafTreeNode(1101,"inquiries/create/idquiz"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.Address))this.addNode(new LeftMenuLeafTreeNode(1095,"inquiries/create/address"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.AddressChange))this.addNode(new LeftMenuLeafTreeNode(1093,"inquiries/create/addresschange"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.EFTCheck))this.addNode(new LeftMenuLeafTreeNode(1097,"inquiries/create/eftcheck"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.EFTCheckWithID))this.addNode(new LeftMenuLeafTreeNode(1084,"inquiries/create/eftcheckid"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.IDInternational))this.addNode(new LeftMenuLeafTreeNode(1103,"inquiries/create/idinternational"));if(!INQUIRY_TYPE.isDisabled(INQUIRY_TYPE.IDBusiness))this.addNode(new LeftMenuLeafTreeNode(1082,"inquiries/create/idbusiness"));this.onloadcomplete();}}});var LeftMenuPaymentsTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,"Payments",null,1);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode("Billing Statements","invoices"));this.addNode(new LeftMenuLeafTreeNode("Payments","payments"));this.onloadcomplete();}}});var LeftMenuCustomersTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,"Customers",null,2);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode(2722,"customers/reviews"));this.onloadcomplete();}}});var LeftMenuUsersTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,"Users",null,3);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode("Sub Users","profile/subusers"));this.onloadcomplete();}}});var LeftMenuAffiliatesTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,3401,null,4);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode(3408,"affiliates"));this.addNode(new LeftMenuLeafTreeNode(3400,"affiliates/referrals"));this.addNode(new LeftMenuLeafTreeNode(3403,"affiliates/rewards"));this.addNode(new LeftMenuLeafTreeNode(3404,"affiliates/requests"));this.onloadcomplete();}}});var LeftMenuReportsTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,"Reports",null,5);}
this.load=function()
{if(this.onstartload())
{if(window.isAdmin)this.addNode(new LeftMenuLeafTreeNode(3333,"reports/dashboard"));this.addNode(new LeftMenuLeafTreeNode(3321,"reports/summary"));if(window.isAdmin)this.addNode(new LeftMenuLeafTreeNode(1642,"reports/accounting"));this.onloadcomplete();}}});var LeftMenuSettingsTreeNode=wl.Class(LeftMenuFolderTreeNode,function(base)
{this.constructor=function()
{base.constructor.call(this,2922,null,6);}
this.load=function()
{if(this.onstartload())
{this.addNode(new LeftMenuLeafTreeNode(2926,"profile/panel"));this.addNode(new LeftMenuLeafTreeNode(2514,"forms"));this.addNode(new LeftMenuLeafTreeNode(2925,"profile/price"));this.addNode(new LeftMenuLeafTreeNode(1017,"profile"));this.addNode(new LeftMenuLeafTreeNode(1008,"profile/login"));this.addNode(new LeftMenuLeafTreeNode(1007,"profile/billing"));this.addNode(new LeftMenuLeafTreeNode(1005,"profile/addressbook"));this.addNode(new LeftMenuLeafTreeNode(2923,"profile/security_image"));this.addNode(new LeftMenuLeafTreeNode(2924,"profile/secret_question"));this.addNode(new LeftMenuLeafTreeNode(3326,"resources"));this.onloadcomplete();}}});var LiveSupportControl=wl.Class(Object,function(base)
{this.constructor=function()
{base.constructor.call(this);}
this.init=function()
{if(this.$("btn_request_support"))wl.attachEvent(this.$$("btn_request_support"),"click",this.requestSupport.bind(this));if(this.$("check_invite_customer"))
{wl.attachEvent(this.$("check_invite_customer"),"change",update_invite_customer.bind(this));update_invite_customer.call(this);}}
var update_invite_customer=function()
{if(this.$req("support_cust_phone"))
this.$req("support_cust_phone").style.visibility=this.$("check_invite_customer").checked?"":"hidden";this.$("divCustomerPhoneNumber").style.display=this.$("check_invite_customer").checked?'':'none';}
this.requestSupport=function()
{wl.$css("input",this.$("divLiveSupportData"),true).each(function(c){if(c.type=="text")c.value=c.value.trim();});this.$("c_submit_error").style.display="none";this.$("c_submit_success").style.display="none";var err=[];wl.Utils.checkRequired(this.$("divLiveSupportData"),function(id,v,m)
{err.push(m);return true;});if(err.length)
{this.$("c_submit_error").style.display="";this.$("submit_error").innerHTML=err.join("<br />");return false;}
var liveSupport={};if(!window.isCustomerLoggedIn)
{var liveSupport={vendorPhone:this.$("support_phone_country_code").value+this.$("support_phone").value,customerPhone:this.$("support_cust_phone_country_code").value+this.$("support_cust_phone").value}}
else
{var liveSupport={vendorPhone:this.$("check_invite_merchant").vendorPhone,customerPhone:this.$("support_phone_country_code").value+this.$("support_phone").value}}
this.$("btn_request_support").disabled=true;wl.liveSupportManager.createLiveSupportCall(liveSupport,on_requestSupport.bind(this));}
var on_requestSupport=function(result)
{this.$("btn_request_support").disabled=false;if(result.errCode)
{this.$("c_submit_error").style.display="";this.$("submit_error").innerHTML=result.error;return wl.alert(result.error);}
else
{if(result.liveSupport.status==SUPPORT_STATUS.NotAvailable)
this.showError("Service is not available at the moment.<br>Error code is "+result.liveSupport.result+". Please try again later.");else if(result.liveSupport.status==SUPPORT_STATUS.Success)
this.showSuccess("Your request for support was received.<br>We will be calling you within a few minutes.");}}
this.showError=function(error)
{this.$("c_submit_error").style.display="";this.$("submit_error").innerHTML=error;}
this.showSuccess=function(message)
{this.$("c_submit_success").style.display="";this.$("submit_success").innerHTML=message;}});wl.Controls.Pager=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);this.pagesCount=0;this.pagesPerLine=10;this.currentPage=-1;this.href="#";}
this.ongenerate=function()
{var c=wl.$(this.c_id);for(var i=c.childNodes.length-1;i>=0;--i)
if(c.childNodes[i].nodeType!=1)c.removeChild(c.childNodes[i]);}
this.setCssClass=function(cssClass)
{var c=wl.$(this.c_id);if(c)wl.Utils.setNew(c,"className",cssClass);}
this.linkTo=function(pc)
{this.pagesPerLine=pc.pagesPerLine;this.href=pc.href.indexOf("#")>=0?pc.href:pc.href+'#';wl.attachEvent(pc,"pageselect",(function(e){this.selectPage(e.page,{skipInvoke:true});}).bind(this));wl.attachEvent(pc,"pagecountchange",(function(e){this.setPagesCount(e.pages,{skipInvoke:true});}).bind(this));wl.attachEvent(this,"pageselect",function(e){pc.selectPage(e.page);});this.setPagesCount(pc.pagesCount,{skipInvoke:true});this.selectPage(pc.currentPage,{skipInvoke:true});}
this.setPagesCount=function(pagesCount,p)
{if(this.pagesCount==pagesCount)return;if(!p)p={skipInvoke:false};this.pagesCount=pagesCount;if(!p.skipInvoke)wl.fireEvent(this,"pagecountchange",{pages:pagesCount});if(this.currentPage==-1){this.selectPage(Math.min(0,this.pagesCount-1),p);return;}
if(this.currentPage>=this.pagesCount){this.selectPage(this.pagesCount-1,p);return;}
this.update();}
this.update=function()
{var c=wl.$(this.c_id);resizeChildren.call(this,c,Math.min(this.pagesCount,this.pagesPerLine));if(this.pagesCount==0)return;var handler=pageSelect.bind(this);var pi=0;var shl=Math.floor((this.pagesPerLine-2)/2);var p=Math.max(0,Math.min(this.pagesCount-this.pagesPerLine,this.currentPage-shl));updatePage.call(this,c.childNodes[pi++],0,p++>0?"1":null,handler);var prev=p-this.pagesPerLine+shl+3;if(prev>0)
updatePage.call(this,c.childNodes[pi++],prev,"&lt;",handler);else
updatePage.call(this,c.childNodes[pi++],p,null,handler);p++;for(;pi<c.childNodes.length-2;++pi,++p)
updatePage.call(this,c.childNodes[pi],p,null,handler);if(p<this.pagesCount-2)
updatePage.call(this,c.childNodes[pi++],p,"&gt;",handler);else
updatePage.call(this,c.childNodes[pi++],p,null,handler);p++;updatePage.call(this,c.childNodes[pi++],this.pagesCount-1,p<this.pagesCount-1?this.pagesCount:null,handler);}
this.selectPage=function(pageNumber,p)
{if(this.currentPage==pageNumber||this.isDisabled())return false;if(!p)p={skipInvoke:false};this.currentPage=pageNumber;if(!p.skipInvoke)wl.fireEvent(this,"pageselect",{page:pageNumber});this.update();return true;}
this.selectLastPage=function(p){this.selectPage(Math.max(0,this.pagesCount-1),p);}
var resizeChildren=function(el,size)
{var dist=size-el.childNodes.length;if(dist>0)while(dist-->0)
{var a=wl.$e("a");el.appendChild(a);}
else
if(dist<0)while(dist++<0)el.removeChild(el.lastChild);}
var updatePage=function(a,number,text,handler)
{if(!a)return;a.href=String.format(this.href,number+1);a.onclick=handler;a.pageNumber=number;a.title=number+1;a.innerHTML=text||(number+1).toString();wl.Utils.setNew(a,"className",number==this.currentPage?"page-current":"");}
var pageSelect=function(e)
{e=wl.getEvent(e);var cancel=!this.selectPage(e.target.pageNumber);if(e){try
{if(e.target.href.indexOf("#")>=0)cancel=true;e.target.blur();}catch(ex){}
if(cancel)return false;}}});wl.Controls.TabControlBase=wl.Class(wl.Controls.Control,function(base)
{this.constructor=function()
{base.constructor.call(this);this.items=[];}
this.clear=function(){this.items.clear();}
this.$=function(id)
{for(var i=0;i<this.items.length;++i)
if(this.items[i].id==id)return this.items[i].getContainer();return null;}
this.$$=function(id)
{for(var i=0;i<this.items.length;++i)
if(this.items[i].id==id)return this.items[i];return null;}
this.render=function()
{if(this.tc_id!=null)
{var pool=wl.queryElementsPool();for(var i=0;i<this.items.length;++i)
pool.put(this.items[i].getElement());var tabs=wl.$(this.tabs_id);wl.Utils.clear_container(tabs);for(var i=0;i<this.items.length;++i)
if(!this.items[i].data.hidden)
tabs.appendChild(pool.get(this.items[i].e_id));if(tabs.firstChild)
tabs.style.lineHeight=tabs.clientHeight+Math.max(0,tabs.clientHeight-tabs.firstChild.offsetHeight)+"px";}
if(this._onresize)this._onresize();}
this.selectItem=function(item,p)
{if(!p)p={skipInvoke:false};if(this.isDisabled()||item==null||item.data.hidden||item==this.selectedItem)return false;if(!p.skipInvoke&&wl.fireEvent(this,"selecting",{item:item}).isFalse)return false;var prevItem=this.selectedItem;if(this.selectedItem)
this.selectedItem._activate(false);this.selectedItem=item;item._activate(true);if(!p.skipInvoke)wl.fireEvent(this,"select",{item:item,prevItem:prevItem});this.onselected();return true;}
this.onselected=function(){}
this.getIndex=function(item){for(var i=0;i<this.items.length;++i)if(this.items[i]==item||this.items[i].id==item)return i;return-1;}
this.selectItemByIndex=function(index){return this.selectItem(this.items[index]);}
this.selectFirstItem=function()
{for(var i=0;i<this.items.length;++i)
if(!this.items[i].data.hidden)
return this.selectItem(this.items[i]);}
this.findItem=function(finder,includeHidden)
{for(var i=0;i<this.items.length;++i)
if(!includeHidden||!this.items[i].data.hidden)
if(finder(this.items[i]))return this.items[i];return null;}
this.unselect=function()
{if(this.selectedItem)
{this.selectedItem._activate(false);this.selectedItem=null;}}
this.ondisabled=function(state)
{for(var i=0;i<this.items.length;++i)
this.items[i].getElement().disabled=state;}
this.resize_engine=function()
{if(this.tc_id&&this._onresize)
wl.resizeManager.attachEvent(wl.$(this.c_id),{check:"width"},this._onresize.bind(this));}});wl.Controls.TabControl=wl.Class(wl.Controls.TabControlBase,function(base)
{this.constructor=function()
{base.constructor.call(this);}
this.ongenerate=function()
{if(this.tc_id!=null)
{var tcrow=wl.$(this.tc_id).rows[0];this.tabs_id=wl.uniqueID(tcrow.cells[0].firstChild);this.ul_id=tcrow.cells[3].firstChild?wl.uniqueID(tcrow.cells[3]):null;setupArrows.call(this);}}
this.createTabItem=function(id,data,c_id){return new wl.Controls.TabControl.Item(this.c_id,id,data,c_id);}
var calcContainerWidth=function(c)
{var w=0,ct=null;for(var i=0;i<c.childNodes.length;++i)
{var n=c.childNodes[i];if(n.nodeType==1&&n.style.display!="none")
w+=n.offsetWidth+parseInt(window.getComputedStyle(n,null).marginLeft).NaN0()+parseInt(window.getComputedStyle(n,null).marginRight).NaN0()+1;if(n.nodeType==3)
{if(!ct){ct=wl.$e("span",c);ct.style.whiteSpace="nowrap";}
ct.innerHTML="";ct.appendChild(n.cloneNode(true));w+=ct.offsetWidth+3;}}
if(ct)c.removeChild(ct);return w;}
var setupArrows=function()
{var r=wl.$(this.tc_id).rows[0];var lArrow=r.cells[1];var rArrow=r.cells[2];lArrow.firstChild.onmousedown=startItemsScroll.bind(this,-10);rArrow.firstChild.onmousedown=startItemsScroll.bind(this,10);this.la_id=wl.uniqueID(lArrow);this.ra_id=wl.uniqueID(rArrow);}
this._onresize=function()
{if(this.tc_id!=null)
{var tabsWidth=calcContainerWidth(wl.$(this.tabs_id));var userLayoutWidth=this.ul_id?calcContainerWidth(wl.$(this.ul_id)):0;var width=wl.$(this.c_id).offsetWidth-2;var display=tabsWidth+userLayoutWidth>=width?"":"none";wl.Utils.setNew(wl.$(this.la_id).style,"display",display);wl.Utils.setNew(wl.$(this.ra_id).style,"display",display);if(this.ul_id)wl.$(this.ul_id).style.width=Math.middle(100,width-wl.$(this.la_id).firstChild.offsetWidth-wl.$(this.ra_id).firstChild.offsetWidth-100,userLayoutWidth)+"px";}}
var startItemsScroll=function(dx,e)
{var arrow_id=wl.uniqueID(wl.getEvent(e).target);var cookie=window.setInterval((function(){wl.$(this).scrollLeft+=dx;dx*=1.1;}).bind(this.tabs_id),50);var stopItemsScroll=function()
{wl.$(arrow_id).style.backgroundPositionX="left";window.clearInterval(cookie);wl.detachEvent(document,"mouseup",stopItemsScroll);};wl.$(arrow_id).style.backgroundPositionX="right";wl.attachEvent(document,"mouseup",stopItemsScroll);}});wl.Controls.TabControl.Item=wl.Class(Object,function()
{this.constructor=function(tabcontrol_id,id,data,c_id)
{this.tc_id=tabcontrol_id;this.id=id;this.data=data;this.c_id=c_id;this.generate();}
this.getContainer=function(){return wl.$(this.c_id);}
this.getElement=function(){return wl.$(this.e_id);}
this.generate=function()
{var element=wl.$e("a");element.href="#";element.className="tab-item";this.e_id=wl.uniqueID(element);var n=wl.$e("b",element);this.n_id=wl.uniqueID(n);if(this.data.title)element.title=this.data.title;if(this.data.name||this.data.icon)
{var t=wl.$e("b",n);if(this.data.icon)
{var ico=wl.$e("img",t);ico.src=wl.pixel;ico.className=this.data.icon;}
if(this.data.name)wl.$t(this.data.name,t);}
element.onclick=this.select.bind(this);wl.queryElementsPool().put(element);}
this.select=function(p){wl.$$(this.tc_id).selectItem(this,p);return false;}
this.getID=function(){return this.id;}
this.setName=function(name){this.data.name=name;var t=wl.$(this.n_id).firstChild;t.innerHTML="";t.appendChild(document.createTextNode(name));}
this.getName=function(){return this.data.name;}
this._activate=function(state)
{wl.$(this.e_id).className=state?"tab-item tab-item-active":"tab-item";var c=wl.$(this.c_id);if(c){var width=Math.middle(200,c.offsetWidth,2000);wl.Utils.setNew(c.style,"visibility",state?"visible":"hidden");wl.Utils.setNew(c.style,"left",state?"":-(width+100)+"px");wl.Utils.setNew(c.style,"width",state?"":width+"px");wl.Utils.setNew(c.style,"overflow",state?"":"hidden");wl.Utils.setNew(c.style,"position",state?"static":"absolute");}}
this.hide=function(bHide,bUpdate)
{this.data.hidden=bHide;if(bUpdate)wl.$$(this.tc_id).render();}});
