
WL.Objects={};WL.Objects.Event=WL.Class(Object,function()
{this.invocationList=[];},function(type)
{var current=null;var stack=[];this.cancel=function(){current.cancel();}
type.add=function(ctx,func,afterRemove)
{this.invocationList.push({context:ctx,method:func,remove:afterRemove});}
type.remove=function(func)
{this.invocationList.removeIf(function(it){return it.method==func;});}
type.clear=function()
{this.invocationList.clear();}
type.doAfterRemove=function()
{this.invocationList.removeIf(function(it){return it.remove;});}
type.isEmpty=function(){return this.invocationList.length==0;}
type.cancel=function(){this._iscancel=true;}
type.invoke=function(sender,e)
{this._iscancel=false;if(this.invocationList.length!=0)
{stack.push(current);current=this;for(var i=0;i<this.invocationList.length;++i)
this.invocationList[i].method.call(this.invocationList[i].context,sender,e||{});this.doAfterRemove();current=stack.pop();}
this.timer=0;return!this._iscancel;}
type.raise=function(sender,e,timeout)
{if(timeout==null)timeout=0;var copy=this.clone();var method=(function()
{this.doAfterRemove();copy.invoke(sender,e);}).bind(this);if(this.timer)window.clearTimeout(this.timer);this.timer=window.setTimeout(method,timeout);}
type.clone=function()
{var clone=new Event();for(var i=0;i<this.invocationList.length;++i)
clone.invocationList[i]=this.invocationList[i];return clone;}});WL.Objects.Guid=WL.Class(Object,function(str)
{if(!str){this.a=this.b=this.c=this.d=this.e=0;return;}
WL.Objects.Guid.regexp.lastIndex=0;var items=WL.Objects.Guid.regexp.exec(str);this.a=parseInt(items[1],16);this.b=parseInt(items[2],16);this.c=parseInt(items[3],16);this.d=parseInt(items[4],16);this.e=parseInt(items[5],16);},function(type)
{this.regexp=/\b([0-9|a-f]{8})\-([0-9|a-f]{4})\-([0-9|a-f]{4})\-([0-9|a-f]{4})\-([0-9|a-f]{12})\b/ig;this.newGuid=function()
{var guid=new WL.Objects.Guid();guid.a=Math.floor(Math.random()*0xFFFFFFFF);guid.b=Math.floor(Math.random()*0xFFFF);guid.c=Math.floor(Math.random()*0xFFFF);guid.d=Math.floor(Math.random()*0xFFFF);guid.e=Math.floor(Math.random()*0xFFFFFFFFFFFF);return guid;}
type.equals=function(guid)
{return this.a==guid.a&&this.b==guid.b&&this.c==guid.c&&this.d==guid.d&&this.e==guid.e;}
type.toString=function()
{var guid=[];guid.push(this.a.toHexString(8));guid.push(this.b.toHexString(4));guid.push(this.c.toHexString(4));guid.push(this.d.toHexString(4));guid.push(this.e.toHexString(12));return"{"+guid.join('-')+"}";}
type.isNull=function()
{return this.a==0&&this.b==0&&this.c==0&&this.d==0;}
type.write=function(writer){writer.write(this.toString())}});WL.Objects.Guid.Null=new WL.Objects.Guid("00000000-0000-0000-0000-000000000000");WL.Objects.Unit=function(str)
{WL.Objects.Unit.regexp.lastIndex=0;var items=WL.Objects.Unit.regexp.exec(str);this.value=items[1]=="-"?-parseInt(items[2]):parseInt(items[2]);this.unit=items[3];}
WL.Objects.Unit.regexp=/([+|-]*)(\d+)(\D+)/ig;WL.Objects.Cookie=WL.Class(Object,function(key,expires)
{this.key=key||"";this.expires=expires||"";},function(type)
{type.set=function(name,value)
{document.cookie=String.format("{0}{1}={2}; expires={3}",this.key,name,escape(value),this.expires);}
type.get=function(name)
{var name=this.key+name;var cookies=document.cookie.split("; ");for(var i=0;i<cookies.length;++i)
{var crumb=cookies[i].split("=");if(name==crumb[0])
return crumb.length>1?unescape(crumb[1]):"";}
return null;}
type.remove=function(name)
{document.cookie=String.format("{0}{1}=; expires=Fri, 31 Dec 1999 23:59:59 GMT;",this.key,name);}});WL.Objects.XmlWriter=WL.Class(Object,function()
{this.body=new Array();this.tagStack=new Array();this.state=0;},function(type)
{var LT="<";var GT=">";var EQ="=";var CL="</";var SP=" ";var QU='"';type.writeStartElement=function(tagName)
{if(this.state==1)
this.body.push(GT);this.body.push(LT);this.body.push(tagName);this.tagStack.push(tagName);this.state=1;}
type.writeAttributeString=function(name,value)
{if(this.state==0)
{throw("tag not open can't add attributes");return;}
this.body.push(SP);this.body.push(name);this.body.push(EQ);this.body.push(QU);this.body.push(value);this.body.push(QU);}
type.writeElementString=function(tagName,value)
{this.writeStartElement(tagName);this.write(value==null?"":value.toString().escapeXML());this.writeEndElement();}
type.write=function(value)
{if(this.state==1)
{this.body.push(GT);this.state=0;}
this.body.push(value);}
type.writeEndElement=function()
{if(this.state==1)
{this.body.push(GT);this.state=0;}
this.body.push(CL);this.body.push(this.tagStack.pop());this.body.push(GT);}
type.writeObject=function(tagName,object)
{this.writeStartElement(tagName);object.write(this);this.writeEndElement(tagName);}
type.writeArray=function(tagName,subTagName,array)
{if(tagName)this.writeStartElement(tagName);for(var i=0;i<array.length;++i)
this.writeElementString(subTagName,array[i]);if(tagName)this.writeEndElement(tagName);}
type.writeObjectArray=function(tagName,subTagName,array)
{if(tagName)this.writeStartElement(tagName);for(var i=0;i<array.length;++i)
this.writeObject(subTagName,array[i]);if(tagName)this.writeEndElement(tagName);}
type.writeBinHex=function(tagName,binhex,itemSize)
{var is=(itemSize||1)*2;var data=new Array(binhex.length);for(var i=0;i<binhex.length;++i)
data[i]=binhex[i].toHexString(is);this.writeElementString(tagName,data.join(''));}
type.writeBoolean=function(tagname,value)
{this.writeElementString(tagname,value?"true":"false");}
type.writeDate=function(tagname,value)
{this.writeElementString(tagname,value.valueOf());}
type.writeTime=function(tagname,value)
{this.writeElementString(tagname,value.time);}
type.toString=function()
{return this.body.join("");}});WL.Objects.XmlReader=WL.Class(Object,function(xmlNode)
{WL.Utils.assert(xmlNode==null,"xml node is null in XmlReader ctor");this.xmlNode=xmlNode;},function(type)
{type.getXmlNode=function(tagName)
{return!tagName?this.xmlNode:this.selectSingleNode(tagName);}
var getNodeValue=function(n,dv){return(n&&n.firstChild)?n.firstChild.nodeValue:dv;}
if(WL.browser.ie)
{type.selectSingleNode=function(tagName)
{return this.xmlNode.selectSingleNode(tagName);}
type.selectNodes=function(tagName)
{return this.xmlNode.selectNodes(tagName);}}
else
{type.selectSingleNode=function(tagName)
{var nodes=this.xmlNode.childNodes;for(var i=0;i<nodes.length;++i)
if(nodes[i].tagName==tagName)return nodes[i];return null;}
type.selectNodes=function(tagName)
{var nodes=[];selectInnerNodes(this.xmlNode,tagName.split('/'),nodes,0);nodes.__innerIndex=0;nodes.nextNode=function(){return this[this.__innerIndex++];}
return nodes;}
var selectInnerNodes=function(node,tags,list,index)
{var nodes=node.childNodes;for(var i=0;i<nodes.length;++i)
if(nodes[i].tagName==tags[index])
{if(index==tags.length-1)list.push(nodes[i]);else
selectInnerNodes(nodes[i],tags,list,index+1);}}}
type.select=function(tagName)
{var node=this.selectSingleNode(tagName);return node?new WL.Objects.XmlReader(node):null;}
type.readNodeValue=function(defaultValue){return getNodeValue(this.xmlNode,defaultValue);}
type.readString=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);return getNodeValue(node,defaultValue||"");}
type.readInt=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);return parseInt(getNodeValue(node,defaultValue||0));}
type.readFloat=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);return parseFloat(getNodeValue(node,defaultValue||0));}
type.readBoolean=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);var str=getNodeValue(node,null);return str?(str.toLowerCase()=="true"?true:false):(defaultValue||false);}
type.readGuid=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);var str=getNodeValue(node,null);return str?new Guid(str):(defaultValue||Guid.Null);}
type.readDate=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);var str=getNodeValue(node,null);if(!str)return defaultValue||new Date(1970,0,1,0,0,0);return new Date(parseInt(str));}
type.readTime=function(tagName,defaultValue)
{var node=this.selectSingleNode(tagName);return new WL.Objects.Time(parseInt(getNodeValue(node,0)).NaN0());}
type.readObject=function(tagName,obj)
{var node=this.selectSingleNode(tagName);if(node)obj.read(new WL.Objects.XmlReader(node));}
type.readObject2=function(tagName,obj_type)
{var obj=new obj_type();this.readObject(tagName,obj);return obj;}
type.readStringArray=function(tagName)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
collection.push(getNodeValue(xmlNode,""));return collection;}
type.readIntArray=function(tagName)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
collection.push(parseInt(getNodeValue(xmlNode,0)));return collection;}
type.readFloatArray=function(tagName)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
collection.push(parseFloat(getNodeValue(xmlNode,0)));return collection;}
type.readGuidArray=function(tagName)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
collection.push(new WL.Objects.Guid(getNodeValue(xmlNode,"")));return collection;}
type.readObjectArray=function(tagName,objClass)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
{var obj=new objClass();obj.read(new WL.Objects.XmlReader(xmlNode));collection.push(obj);}
return collection;}
type.readObjectArray2=function(tagName,objCreator)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
{var obj=objCreator.createObject();obj.read(new WL.Objects.XmlReader(xmlNode));collection.push(obj);}
return collection;}
type.readAttributeString=function(attrName,defaultValue)
{return this.xmlNode.getAttribute(attrName)||(defaultValue||"");}
type.readAttributeInt=function(attrName,defaultValue)
{var attribute=this.xmlNode.getAttribute(attrName);return attribute?parseInt(attribute):(defaultValue||0);}
type.readAttributeGuid=function(attrName,defaultValue)
{var attribute=this.xmlNode.getAttribute(attrName);return attribute?new WL.Objects.Guid(attribute):(defaultValue||Guid.Null);}
type.readClassObject=function()
{var guid=this.readAttributeGuid("clsid");var obj=new WL.ClassFactory[guid]();obj.read(this);return obj;}
type.readClassObjectArray=function(tagName)
{var xmlNodes=this.selectNodes(tagName);var collection=[];while((xmlNode=xmlNodes.nextNode())!=null)
{var obj=(new WL.Objects.XmlReader(xmlNode)).readClassObject();collection.push(obj);}
return collection;}
type.readBinHex=function(tagName,itemSize)
{var is=(itemSize||1)*2;var string=this.readString(tagName);var count=Math.floor(string.length/is);var ret=new Array(count);for(var i=0;i<count;++i)
ret[i]=parseInt(string.substr(i*is,is),16);return ret;}});WL.Objects.Size=WL.Class(Object,function(cx,cy)
{this.cx=cx||0;this.cy=cy||0;},function(type)
{type.isNull=function(){return this.cx==0||this.cy==0;}
type.setNull=function(){this.cx=0;this.cy=0;}
type.clone=function(){return new WL.Objects.Size(this.cx,this.cy);}});WL.Objects.Point=WL.Class(Object,function(x,y)
{this.x=x||0;this.y=y||0;},function(type)
{});WL.Objects.Range=WL.Class(Object,function(from,to)
{this.from=from||0;this.to=to!=null?to:this.from;},function(type)
{type.isInclude=function(value){return this.from<=value&&value<=this.to;}
type.write=function(writer)
{writer.writeElementString("f",this.from);writer.writeElementString("t",this.to);}
type.read=function(reader)
{this.from=reader.readInt("f");this.to=reader.readInt("t");}});WL.Objects.RangeArray=WL.Class(Object,function(ranges)
{this.ranges=ranges||[];},function(type)
{type.add=function(range)
{var index=this.binarySearch(range);if(index!=-1&&range.from<=this.ranges[index].to+1)
{range.from=this.ranges[index].from;if(range.to<this.ranges[index].to)
range.to=this.ranges[index].to;this.ranges.removeAt(index--);}
for(var i=index+1;i<this.ranges.length;++i)
if(range.to+1>=this.ranges[i].from)
{var r=this.ranges[i];this.ranges.removeAt(i--);if(range.to<r.to)
{range.to=r.to;break;}}
else break;this.ranges.insert(index+1,range);}
type.remove=function(range)
{var index=this.binarySearch(range);if(index!=-1&&range.from<=this.ranges[index].to)
{if(this.ranges[index].from>=range.from)
{if(range.to<this.ranges[index].to)
this.ranges[index].from=range.to+1;else
this.ranges.removeAt(index--);}
else
{if(range.to<this.ranges[index].to)
this.ranges.insert(index+1,new WL.Objects.Range(range.to+1,this.ranges[index].to));this.ranges[index].to=range.from-1;}}
for(var i=index+1;i<this.ranges.length;++i)
if(range.to>=this.ranges[i].from)
{if(range.to<this.ranges[i].to)
{this.ranges[i].from=range.to+1;break;}
else
this.ranges.removeAt(i--);}
else break;}
type.addValue=function(v){this.add(new WL.Objects.Range(v,v));}
type.removeValue=function(v){this.remove(new WL.Objects.Range(v,v));}
type.binarySearch=function(range)
{var count=this.ranges.length;var l=0,r=count-1,m;var res;while(l<=r)
{m=(l+r)>>1;if(m+1<count)
{if(range.from>=this.ranges[m].from)
{if(range.from<this.ranges[m+1].from)res=0;else res=-1;}
else res=1;}
else
{if(range.from>=this.ranges[m].from)res=0;else res=-1;}
if(res==0)return m;if(res<0)l=m+1;else r=m-1;}
return-1;}
type.clear=function(){this.ranges.clear();}
type.isInclude=function(range)
{var index=this.binarySearch(range);if(index!=-1)
if(this.ranges[index].to>=range.from)return true;if(index+1<this.ranges.length)
if(this.ranges[index+1].from<=range.to)return true;return false;}
type.binaryValueSearch=function(value)
{var l=0,r=this.ranges.length-1,m;while(l<=r)
{m=(l+r)>>1;if(this.ranges[m].isInclude(value))return m;if(this.ranges[m].to<value)l=m+1;else r=m-1;}
return~l;}
type.isValueInclude=function(value)
{return this.binaryValueSearch(value)>=0;}
type.isStrictInclude=function(range)
{var index=this.binarySearch(range);return index!=-1&&this.ranges[index].from<=range.from&&this.ranges[index].to>=range.to;}
type.trim=function(range)
{if(range.from>0)this.remove(new WL.Objects.Range(0,range.from-1));if(range.to<WL.minusOne)this.remove(new WL.Objects.Range(range.to+1,WL.minusOne));}
type.toIndexes=function()
{var indexes=[];var r;for(var i=0;i<this.ranges.length;++i)
{r=this.ranges[i];for(var j=r.from;j<=r.to;++j)indexes.push(j);}
return indexes;}
type.getCount=function()
{var count=0;var r;for(var i=0;i<this.ranges.length;++i)
{r=this.ranges[i];count+=r.to-r.from+1;}
return count;}
type.write=function(writer)
{writer.writeObjectArray("Ranges","r",this.ranges);}
type.read=function(reader)
{this.ranges=reader.readObjectArray("Ranges/r",WL.Objects.Range);}});WL.Objects.Time=WL.Class(Object,function(t)
{this.time=t||0;},function(type)
{type.reset=function(d,h,m,s)
{d=d||0;h=h||0;m=m||0;s=s||0;this.time=d*86400+h*3600+m*60+s;}
type.clearDays=function(){this.time=this.time%86400;}
type.getTotalDays=function(){return Math.floor(this.time/86400);}
type.getTotalHours=function(){return Math.floor(this.time/3600);}
type.getTotalMinutes=function(){return Math.floor(this.time/60);}
type.getTotalSeconds=function(){return this.time;}
type.getHour=function(){return Math.floor((this.time%86400)/3600);}
type.getMin=function(){return Math.floor((this.time%3600)/60);}
type.getSec=function(){return this.time%60;}
type.toString=function(format)
{if(!format)format="H:mm:ss";return format.replace(/dd?|DD?|hh?|HH?|mm?|MM?|ss?/g,formatter.bind(this));}
var p=function(s){return(s.toString().length==1)?"0"+s:s;}
var formatter=function(format)
{switch(format)
{case"hh":return p(this.getHour());case"h":return this.getHour();case"HH":return p(this.getTotalHours());case"H":return this.getTotalHours();case"mm":return p(this.getMin());case"m":return this.getMin();case"MM":return p(this.getTotalMinutes());case"M":return this.getTotalMinutes();case"ss":return p(this.getSec());case"s":return this.getSec();case"DD":case"dd":return p(this.getTotalDays());case"D":case"d":return this.getTotalDays();}}});WL.Objects.ElementsPool=WL.Class(Object,function()
{var pool=WL.Utils.$e("div");pool.style.display="none";pool.style.width=pool.style.height="1px";document.forms[0].insertBefore(pool,document.forms[0].firstChild);this.p_id=WL.uniqueID(pool);},function(type)
{type.put=function(element)
{if(element.parentNode)
element.parentNode.removeChild(element);WL.Utils.$(this.p_id).appendChild(element);}
type.get=function(elementID)
{var element=WL.Utils.$(elementID);element.parentNode.removeChild(element);return element;}
type.putChildren=function(parent)
{while(parent.firstChild)this.put(parent.firstChild);}});WL.queryElementsPool=function()
{if(window.elementsPool==null)
window.elementsPool=new WL.Objects.ElementsPool();return window.elementsPool;}