/**
 * JavaScript Wrapper - The wrappers of browser JavaScript objects
 * Copyright (C) 2005-2006 Alexandr Nosov, http://www.alex.4n.com.ua/
 *
 * Licensed under the terms of the GNU Lesser General Public License:
 * 	http://www.opensource.org/licenses/lgpl-license.php
 *
 * This version includes three basic wrappers:
 * 	winWrapper - wrapper of window;
 *	elmWrapper - wrapper of html-element;
 *	evtWrapper - wrapper of event-object;
 * For further information visit:
 * 	http://www.alex.4n.com.ua/js-wrapper/
 *
 * Do not remove this comment if you want to use script!
 * Не удаляйте данный комментарий, если вы хотите использовать скрипт!
 *
 * @author: Alexandr Nosov (alex@4n.com.ua)
 * @version:  02.01.19 Alpha
 * @modified: 2005-07-19 03:50:00
 */
function implement(destObj,srcObj,needCheck){if(destObj&&srcObj){if(srcObj.constructor==Array){for(var i=0;i<srcObj.length;i++){implement(destObj,srcObj[i],needCheck);}}else{for(var p in srcObj){if(!needCheck||!destObj[p])destObj[p]=srcObj[p];}}return destObj;}return null;};var browserVer=(function(w){var d=w.document;var o=new Object();o.aN=w.navigator.appName;o.aV=w.navigator.appVersion;o.uA=w.navigator.userAgent;o.isDOM=d.getElementById?true:false;o.isOpera=o.isOpera5=w.opera&&o.isDOM?true:false;o.isOpera6=o.isOpera&&w.print?true:false;o.isOpera7=o.isOpera&&d.readyState?true:false;o.isOpera8=/\WOpera\s+[^67]/.test(o.uA);o.isMSIE=o.isIE=d.all&&d.all.item&&!o.isOpera?true:false;o.isStrict=d.compatMode=='CSS1Compat';o.isSafari=/\WSafari\W/.test(o.uA);o.isNN=o.isNC=o.aN=="Netscape";o.isNN4=o.isNC4=o.isNN&&!o.isDOM;o.isMozilla=o.isNN6=o.isNN&&o.isDOM;o.identifyBrowser=o.isDOM||o.isNC||o.isMSIE||o.isOpera;var m=(o.isMSIE?/MSIE\s*([\d\.]*)/i:/([\d\.]*)$/i).exec(o.uA);o.ver=m?m[1]:null;return o;})(window);var basicBroadcaster=function(){this._listeners=new Object();};basicBroadcaster.prototype={broadcastMessage:function(){var i,M_Name;var E_Type=arguments[0];var arg=new Array();for(i=1;i<arguments.length;++i){arg[i-1]=arguments[i];}if(this._listeners[E_Type])for(M_Name in this._listeners[E_Type]){this._doMethod(this._listeners[E_Type][M_Name],M_Name,arg);}this._doMethod(this._getListeners(),E_Type,arg);},addListener:function(obj,E_Type,M_Name){this.removeListener(obj,E_Type,M_Name);var param=new Object();this._getListeners(E_Type,M_Name).push([obj,param]);return param;},removeListener:function(obj,E_Type,M_Name){var list=this._getListeners(E_Type,M_Name);for(var i=list.length-1;i>=0;i--){if(list[i][0]==obj||obj==null){list.splice(i,1);break;}}var ql=0;for(var p in this._listeners[E_Type]){ql+=this._listeners[E_Type][p].length;}return ql;},_getListeners:function(E_Type,M_Name){if(!E_Type)E_Type="all";if(!M_Name||E_Type=="all")M_Name=E_Type;if(!this._listeners[E_Type])this._listeners[E_Type]=new Object();if(!this._listeners[E_Type][M_Name])this._listeners[E_Type][M_Name]=new Array();return this._listeners[E_Type][M_Name];},_doMethod:function(list,M_Name,arg){if(list){var i;var l=arg.length;var list_=new Array();for(i=0;i<list.length;i++){if(list[i]&&(typeof(list[i][0][M_Name])=="function"))list_[list_.length]=list[i];}for(i=0;i<list_.length;i++){arg[l]=list_[i][1];try{list_[i][0][M_Name].apply(list_[i][0],arg);}catch(e){var emsg=(e.fileName?"Error in "+e.fileName:"")+(e.lineNumber?" line "+e.lineNumber:"");emsg+=(emsg?"\n":"")+(e.name?e.name+": ":"")+e.message;alert("Can't run method \""+M_Name+"\"!\n\n"+emsg);}}arg.pop();}}};var htmlBroadcaster={iniBroadcaster:function(){this._listenersFunc=new Object();this._BBC=new basicBroadcaster();},broadcastMessage:function(evt){var evtWr;if(evt._wrapper){evtWr=evt._wrapper;evtWr.setElement.call(evtWr,this);}else{try{evtWr=new evtWrapper(evt,this);}catch(e){evtWr={};evtWr.evt=evt;}}this._BBC.broadcastMessage("on"+evtWr.evt.type,evtWr);},addListener:function(obj,EventType,M_Name,useCapture){var E_Type=this.config.SubscriberUse_on?EventType:"on"+EventType;var elm=this.bcElement(E_Type);if(!elm)return null;if(!this._listenersFunc[E_Type]){this._listenersFunc[E_Type]=this.bv.isNN4?this.broadcastMessage:(function(BCobj){return function(e){return BCobj.broadcastMessage.call(BCobj,e);};})(this);if(this.bv.isMSIE)elm.attachEvent(E_Type,this._listenersFunc[E_Type]);else if(this.addEventListener)elm.addEventListener(E_Type.substr(2),this._listenersFunc[E_Type],useCapture?true:false);else elm[E_Type]=this._listenersFunc[E_Type];if(this.bv.isNC4&&E_Type=="onmousemove")(this.doc?this:this.winWr).doc.captureEvents(Event.MOUSEMOVE);}return this._BBC.addListener(obj,E_Type,M_Name);},removeListener:function(obj,EventType,M_Name,useCapture){var E_Type=this.config.SubscriberUse_on?EventType:"on"+EventType;var elm=this.bcElement(E_Type);if(!elm)return;if(!this._BBC.removeListener(obj,E_Type,M_Name)&&this._listenersFunc[E_Type]){if(this.bv.isMSIE)elm.detachEvent(E_Type,this._listenersFunc[E_Type]);else if(this.removeEventListener)elm.removeEventListener(E_Type.substr(2),this._listenersFunc[E_Type],useCapture?true:false);else elm[E_Type]=undefined;this._listenersFunc[E_Type]=null;}}};var evtWrapper=function(e,elmWr){this.evt=e?e:window.event;this.evt._wrapper=this;this.setElement(elmWr);};evtWrapper.prototype={eventStatus:true,bubbleStatus:true,eventDrop:function(doNot){if(!doNot){if(this.bv.isMSIE)this.evt.returnValue=false;else if(this.evt.preventDefault)this.evt.preventDefault();this.eventStatus=false;}},stopBubbling:function(doNot){if(!doNot){if(this.bv.isMSIE)this.evt.cancelBubble=true;else if(this.evt.stopPropagation)this.evt.stopPropagation();this.bubbleStatus=false;}},setElement:function(elmWr){if(elmWr)this.elmWr=elmWr;else{var elm=this.bv.isMSIE?this.evt.srcElement:this.evt.target;if(!elm)return;this.elmWr=new elmWrapper(elm);}var winWr=elmWr.win&&elmWr.doc?elmWr:elmWr.winWr;if(winWr){if(this.bv.isMSIE||this.bv.isOpera7){this.absX=this.evt.clientX+winWr.getScrollX();this.absY=this.evt.clientY+winWr.getScrollY();}else if(this.bv.isOpera){this.absX=this.evt.clientX;this.absY=this.evt.clientY;}else if(this.bv.isNC){this.absX=this.evt.pageX;this.absY=this.evt.pageY;}this.relX=elmWr.elm?this.absX-elmWr.getAbsLeft():this.absX;this.relY=elmWr.elm?this.absY-elmWr.getAbsTop():this.absY;}else this.absX=this.absY=this.relX=this.relY=0;},bv:browserVer};function eventProcessor(elm,evt,obj,method,param){var evtWr;var elmWr=getElmWrapper(elm);if(evt._wrapper){evtWr=evt._wrapper;evtWr.setElement.call(evtWr,elmWr);}else{evtWr=new evtWrapper(evt,elmWr);}if(!obj)obj=window;return obj[method].call(obj,evtWr,param);};var elmWrapper=function(elm,winWr){this.elm=elm;this.winWr=winWr?winWr:window._wrapper;if(this.elm){elm._wrapper=this;if(elm.style!=undefined){var doc=this.winWr.doc;this.style=elm.style;if(this.bv.isMSIE)this.css=elm.currentStyle;else if(this.bv.isDOM&&doc.defaultView&&doc.defaultView.getComputedStyle)this.css=doc.defaultView.getComputedStyle(elm,null);else if(this.bv.isSafari)this.css=elm.style;else this.css=elm.style;}else this.style=this.css={};this.iniBroadcaster();}};elmWrapper.prototype={bcElement:function(E_Type){if(!this.elm&&this.config.DebugMode){alert('Element for event "'+E_Type+"' is not set!");return null;}return this.elm;},getAbsOffset:function(){var bv=this.bv;var left=0;var top=0;var elm=this.elm;if(bv.isMSIE||bv.isOpera||bv.isMozilla){do{left+=elm.offsetLeft;top+=elm.offsetTop;elm=elm.offsetParent;}while(elm);}else if(bv.isMozilla){left+=elm.offsetLeft;top+=elm.offsetTop;}else if(bv.isNN4){left=elm.pageX;top=elm.pageY;}return[left,top];},getAbsLeft:function(){return this.getAbsOffset()[0]-this.winWr.shiftLeft;},getAbsTop:function(){return this.getAbsOffset()[1]-this.winWr.shiftTop;},getRelOffset:function(){var bv=this.bv;var left=0;var top=0;var elm=this.elm;if(bv.isMSIE||(bv.isOpera&&!bv.isOpera8)){left=elm.offsetLeft;top=elm.offsetTop;}else if(bv.isMozilla||bv.isOpera){left=elm.offsetLeft-elm.parentNode.offsetLeft;top=elm.offsetTop-elm.parentNode.offsetTop;}else if(bv.isNN4){left=elm.pageX;top=elm.pageY;}return[left,top];},getRelLeft:function(){return this.getRelOffset()[0];},getRelTop:function(){return this.getRelOffset()[1];},getWidth:function(){var bv=this.bv;if(bv.isMSIE||bv.isMozilla||bv.isOpera7)return this.elm.offsetWidth;if(bv.isOpera)return this.css.pixelWidth;if(bv.isNN4)return this.document.width;},getHeight:function(){var bv=this.bv;if(bv.isMSIE||bv.isMozilla||bv.isOpera7)return this.elm.offsetHeight;if(bv.isOpera)return this.css.pixelHeight;if(bv.isNN4)return this.document.height;},getZIndex:function(){return this.css.zIndex;},getColor:function(type){if(!type)type="color";var clr=this.css[type];var toHex=function(s){var n=parseInt(s);return(n<16?"0":"")+n.toString(16);};if((rArr=/^rgb\((\d+)\,\s*(\d+)\,\s*(\d+)\)$/i.exec(clr)))clr="#"+toHex(rArr[1])+toHex(rArr[2])+toHex(rArr[3]);return clr;},isVisible:function(){return this.css.visibility.toLowerCase().charAt(0)!='h';},isDisplay:function(){return this.css.display!='none';},isShow:function(){return this.isDisplay()&&this.isVisible();},setAbsLeft:function(x,no){var bv=this.bv;x+=this.winWr.shiftLeft;if(bv.isOpera)this.style.pixelLeft=x;else if(bv.isNN4)this.elm.x=x;else this.style.left=x+"px";},setAbsTop:function(y){var bv=this.bv;y+=this.winWr.shiftTop;if(bv.isOpera)this.style.pixelTop=y;else if(bv.isNN4)this.elm.y=y;else this.style.top=y+"px";},moveAbs:function(x,y){this.setAbsLeft(x);this.setAbsTop(y);},moveRel:function(x,y){this.moveAbs(this.getRelLeft()+x,this.getRelTop()+y);},setZIndex:function(z){this.style.zIndex=z;},setVisibility:function(v){this.style.visibility=v?(this.bv.isNN4?"show":"visible"):(this.bv.isNN4?"hide":"hidden");},setDisplay:function(v){if(!v)v="none";else if(v.toString()=="true")v="block";else if(this.bv.isIE&&this.config.ReplaceDisplay4IE&&v!="none")v="block";this.style.display=v;},invVisibility:function(){this.setVisibility(this.isVisible());},invDisplay:function(v){this.setDisplay(this.isDisplay()?"none":(v?v:"block"));},show:function(display){if(display||display==undefined)this.setDisplay(true);else this.setVisibility(true);},hide:function(display){if(display||display==undefined)this.setDisplay(false);else this.setVisibility(false);},write:function(text,pos,noDOM){var bv=this.bv;if(bv.isDOM&&!noDOM){if(!pos){while(this.elm.hasChildNodes())this.elm.removeChild(this.elm.firstChild);}var tNode=this.winWr.doc.createTextNode(text);if(pos<0)this.elm.insertBefore(tNode,this.elm.firstChild);else this.elm.appendChild(tNode);}else if(bv.isNN4){var d=this.elm.document;d.open();d.write(text);d.close();}else{this.elm.innerHTML=pos?(pos>0?this.elm.innerHTML+text:text+this.elm.innerHTML):text;}},setBgColor:function(c){var bv=this.bv;if(bv.isMSIE||bv.isMozilla||bv.isOpera7)this.style.backgroundColor=c;else if(bv.isOpera)this.style.background=c;else if(bv.isNN4)this.style.bgColor=c;},setBgImage:function(url){var bv=this.bv;if(bv.isMSIE||bv.isMozilla||bv.isOpera6)this.style.backgroundImage="url("+url+")";else if(bv.isNN4)this.style.background.src=url;},setClip:function(top,right,bottom,left){var bv=this.bv;if(bv.isMSIE||bv.isMozilla||bv.isOpera7)this.style.clip="rect("+top+"px "+right+"px "+bottom+"px "+left+"px)";else if(bv.isNN4){var c=this.clip;c.top=top;c.right=right;c.bottom=bottom;c.left=left;}},setClass:function(className){this.elm.className=className;},addClass:function(className){this.remoreClass(className);this.setClass((this.elm.className?this.elm.className+" ":"")+className);},remoreClass:function(className){curClass=this.elm.className;if(!curClass||curClass==className)curClass="";else{curClass=curClass.replace(new RegExp("^"+className+"\\s+","gi"),"");curClass=curClass.replace(new RegExp("\\s+"+className+"(?!\\S)","gi"),"");}},bv:browserVer};with(elmWrapper.prototype){implement(elmWrapper.prototype,{getX:getAbsLeft,getY:getAbsTop,moveX:setAbsLeft,moveY:setAbsTop,move:moveAbs,moveZ:setZIndex,clip:setClip});}implement(elmWrapper.prototype,htmlBroadcaster);function getElmWrapper(elm,winWr){return!elm?{}:(elm._wrapper&&elm._wrapper.elm==elm?elm._wrapper:new elmWrapper(elm,winWr));}var winWrapper=function(win){this.win=win;this.doc=this.win.document;this.win._wrapper=this;this.doc._wrapper=this;this.iniBroadcaster();};winWrapper.prototype={shiftLeft:0,shiftTop:0,cookieVal:null,cookieExtra:null,sidVal:null,bcElement:function(E_Type){if(E_Type=="onload"||E_Type=="onunload"){return this.bv.isOpera?this.doc:this.win;}else{var winEvt=["onresize","onscroll","onfocus","onactivate","onblur","onerror","onafterprint","onbeforedeactivate","onbeforeprint","onbeforeunload","oncontrolselect","ondeactivate","onhelp","onresizeend","onresizestart"];for(var i=0;i<winEvt.length;i++)if(E_Type==winEvt[i])return this.win;return this.doc;}},setOnloadListener:function(obj,M_Name){return this.addListener(obj,this.config.SubscriberUse_on?"onload":"load",M_Name);},removeOnloadListener:function(obj,M_Name){this.removeListener(obj,this.config.SubscriberUse_on?"onload":"load",M_Name);},setOnUnloadListener:function(obj,M_Name){return this.addListener(obj,this.config.SubscriberUse_on?"onunload":"unload",M_Name);},checkElement:function(idElm){return this._getElmWrapper(idElm).elm?true:false;},getElement:function(idElm,noErr){var elmWr=this._getElmWrapper(idElm);if(!elmWr.elm&&!noErr&&this.config.DebugMode)alert('Element with ID "'+idElm+'" is not found!');return elmWr;},getForm:function(nameFrm,noErr){if(!nameFrm)nameFrm=0;return this._checkError(this.doc.forms[nameFrm]?this.doc.forms[nameFrm]:null,noErr,'Form ['+nameFrm+'] is not found!');},getFormElement:function(nameFrm,nameElm,noErr){var frm=this.getForm(nameFrm).elm;if(!frm)return null;if(!nameElm)nameElm=0;return this._checkError(frm.elements[nameElm],noErr,'Form element ['+nameElm+'] is not found!');},getImage:function(idImg,noErr){if(!idImg)idImg=0;return this._checkError(this.doc.forms[idImg],noErr,'Image ['+idImg+'] is not found!');},getElmWrapper:function(elm){return getElmWrapper(elm,this);},getDocFrame:function(){return this.bv.isStrict?this.doc.documentElement:this.doc.body;},getWindowLeft:function(){var bv=this.bv;if(bv.isMSIE||bv.isOpera7)return this.win.screenLeft;if(bv.isNN||bv.isOpera)return this.win.screenX;return null;},getWindowTop:function(){var bv=this.bv;if(bv.isMSIE||bv.isOpera7)return this.win.screenTop;if(bv.isNN||bv.isOpera)return this.win.screenY;return null;},getWindowWidth:function(){var bv=this.bv;if(bv.isMSIE)return this.getDocFrame().clientWidth;if(bv.isNN||bv.isOpera)return this.win.innerWidth;return null;},getWindowHeight:function(){var bv=this.bv;if(bv.isMSIE)return this.getDocFrame().clientHeight;if(bv.isNN||bv.isOpera)return this.win.innerHeight;return null;},getDocumentWidth:function(){var bv=this.bv;if(bv.isMSIE||bv.isOpera7)return this.getDocFrame().scrollWidth;if(bv.isNN)return this.doc.width;if(bv.isOpera)return this.doc.body.style.pixelWidth;return null;},getDocumentHeight:function(){var bv=this.bv;if(bv.isMSIE||bv.isOpera7)return this.getDocFrame().scrollHeight;if(bv.isNN)return this.doc.height;if(bv.isOpera)return this.doc.body.style.pixelHeight;return null;},getScrollX:function(){var bv=this.bv;try{if(bv.isMSIE||bv.isOpera7)return this.getDocFrame().scrollLeft;if(bv.isNN||bv.isOpera)return this.win.pageXOffset;}catch(e){}return null;},getScrollY:function(){var bv=this.bv;try{if(bv.isMSIE||bv.isOpera7)return this.getDocFrame().scrollTop;if(bv.isNN||bv.isOpera)return this.win.pageYOffset;}catch(e){}return null;},createStyle:function(selector,style,indx){var ss=this.doc.styleSheets;if(indx==undefined)indx=ss.length-1;else if(indx<0){this.doc.getElementsByTagName('head')[0].appendChild(this.doc.createElement('style'));indx=ss.length-1;}else indx=Number(indx);if(this.bv.isIE)ss[indx].addRule(selector,style,ss[indx].rules.length);else ss[indx].insertRule(selector+"{"+style+"}",ss[indx].cssRules.length);},loadStyle:function(url){var style=this.doc.createElement('link');style.rel='stylesheet';style.type='text/css';style.href=url;this.doc.getElementsByTagName('head')[0].appendChild(style);},getSelection:function(){if(this.doc.getSelection)return this.doc.getSelection();if(this.doc.selection&&this.doc.selection.createRange)return this.doc.selection.createRange().text;return"";},getCookie:function(name){if(!this.cookieVal){var rArr;this.cookieVal=new Object();var re=/\s*(\w*)\=([^;]*)\;?/g;while((rArr=re.exec(this.doc.cookie)))this.cookieVal[rArr[1]]=unescape(rArr[2]);}return(name&&this.cookieVal[name])?this.cookieVal[name]:null;},setCookie:function(name,val,expires,path,secure){var old=this.getCookie(name);if(name&&old!=val){var curCookie=name+"="+escape(val);if(curCookie.length>4000&&this.config.DebugMode)alert("Cookie length exceed 4KB and will be cut!");if(!expires&&!path&&!secure&&this.cookieExtra)curCookie+="; "+this.cookieExtra;else{if(expires)curCookie+="; expires="+expires.toGMTString();if(path||this.config.DefaultCookiePath)curCookie+="; path="+(path?path:this.config.DefaultCookiePath);if(this.config.SubdomainCookie){var rArr=/^(?:www[^.]*\.)?(.*)$/i.exec(this.doc.domain);curCookie+="; domain=."+rArr[1];}if(secure)curCookie+="; secure";}this.doc.cookie=curCookie;this.cookieVal[name]=val;}},deleteCookie:function(name,path){if(this.getCookie(name)){this.setCookie(name,'',new Date(1970,1,1,0,0,1),path);delete this.cookieVal[name];}},getSid:function(){if(!this.sidVal){var sk=this.config.SessionIdKey;if(this.getCookie(sk))this.sidVal=this.getCookie(sk);else{var re=new RegExp("\\?.*?"+sk+"\\=([a-zA-Z0-9]+)");var rArr=re.exec(this.doc.location);if(rArr)this.sidVal=rArr[1];}}return this.sidVal;},setSid:function(val){this.sidVal=val;},_getElmWrapper:function(idElm){var elm;if(this.bv.isDOM)elm=this.doc.getElementById(idElm);else if(this.bv.isMSIE)elm=this.doc.all[idElm];else if(this.bv.isNN4)elm=this.doc.layers[idElm];else elm=null;return this.getElmWrapper(elm);},_checkError:function(elm,noErr,errMsg){var elmWr=this.getElmWrapper(elm);if(!elmWr.elm&&!noErr&&this.config.DebugMode)alert(errMsg);return elmWr;},bv:browserVer};implement(winWrapper.prototype,htmlBroadcaster);

elmWrapper.prototype.config = winWrapper.prototype.config = {
	useDataLoader      : true,  // Add winWrapperDataLoader object to winWrapper.prototype
	SubscriberUse_on   : true,  // Use or not prefix "on" at the event name
	ReplaceDisplay4IE  : true,  // Replace "table", "table-row", etc. on "block" on Display for IE
	DefaultEventReturn : true,  // Return this value after event
	DefaultCookiePath  : "/",   // Default Cookie Path
	SubdomainCookie    : true,  // Enable read set cookie in subdomain too
	SessionIdKey       : "SID", // Session ID key
	DebugMode          : true   // Show or not incorrect calls
};
if (!window._wrapper) new winWrapper(window);
