// botTitle: siteUtilites.js.asp var aDOM=0,ieDOM=0,nsDOM=0;var nsDOM=document.getElementsByTagName('body')[0];function xDOM(objectId){return document.getElementById(objectId).style}var AS = new Object();AS.browser = new Object();AS.browser.is_opera=/opera/i.test(navigator.userAgent);AS.browser.is_ie=(/msie/i.test(navigator.userAgent)&&!AS.browser.is_opera);AS.browser.is_ie5=(AS.browser.is_ie&&/msie 5\.0/i.test(navigator.userAgent));AS.browser.is_ie7=(AS.browser.is_ie&&/msie 7\.0/i.test(navigator.userAgent));AS.browser.is_mac_ie=(/msie.*mac/i.test(navigator.userAgent)&&!AS.browser.is_opera);AS.browser.is_khtml=/Konqueror|Safari|KHTML/i.test(navigator.userAgent);AS.browser.is_konqueror=/Konqueror/i.test(navigator.userAgent);AS.browser.is_gecko=/Gecko/i.test(navigator.userAgent);AS.browser.is_webkit=/WebKit/i.test(navigator.userAgent);AS.webkitVersion=AS.browser.is_webkit?parseInt(navigator.userAgent.replace(/.+WebKit\/([0-9]+)\..+/,'$1')):-1;AS.string = new Object();AS.string.trim = function(s){return s.replace(/^\s+|\s+$/g,'');};AS.string.ltrim = function(s){return s.replace(/^\s+/,'');};AS.string.rtrim = function(s){return s.replace(/\s+$/,'');};AS.utils = new Object();AS.utils.getInternetExplorerVersion = function(){var rv=-1;if(navigator.appName=='Microsoft Internet Explorer'){var ua= navigator.userAgent;var re= new RegExp('MSIE ([0-9]{1,}[\.0-9]{0,})');if(re.exec(ua)!=null){rv= parseFloat(RegExp.$1);}}return rv;};AS.utils.getPageScrollY=function(){with(document){if(window.pageYOffset){return window.pageYOffset;}else if(body&&document.body.scrollTop){return body.scrollTop;}else if(documentElement&&documentElement.scrollTop){return documentElement.scrollTop;}return 0;}};AS.utils.getMouseXY = function(e){if(e){if(e.pageX||e.pageY){return new Array(e.pageX,e.pageY);}else if(e.clientX||e.clientY){with(document){return new Array(e.clientX+body.scrollLeft+documentElement.scrollLeft,e.clientY+body.scrollTop+documentElement.scrollTop);}}}};AS.utils.getWindowSize=function(){var iWidth=0;var iHeight=0;if(AS.browser.is_opera){iWidth=document.body.clientWidth||0;iHeight=document.body.clientHeight||0;}else if(AS.browser.is_khtml){iWidth=window.innerWidth||0;iHeight=window.innerHeight||0;}else if(document.compatMode&&document.compatMode=='CSS1Compat'){iWidth=document.documentElement.clientWidth||0;iHeight=document.documentElement.clientHeight||0;}else{iWidth=document.body.clientWidth||0;iHeight=document.body.clientHeight||0;}return{width:iWidth,height:iHeight};};AS.utils.getScrollBarWidth=function(){var o1=document.createElement('p');o1.style.width='100%';o1.style.height='200px';var o2=document.createElement('div');with(o2.style){position='absolute';top='0px';left='0px';visibility='hidden';width='200px';height='150px';overflow='hidden';}o2.appendChild(o1);document.body.appendChild(o2);var w1=o1.offsetWidth; o2.style.overflow='scroll';var w2=o1.offsetWidth;if(w1==w2)w2=o2.clientWidth;document.body.removeChild(o2);return (w1-w2);};AS.utils.isNumber=function(s){if(s==''||isNaN(AS.utils.convertToNumber(s))){return false;}else{return true;}};AS.utils.convertToNumber=function(s){s=s.replace('$','');var oRegExp= new RegExp(',','g');s=s.replace(oRegExp,'');return Number(s);};AS.utils.formatNumber=function(val,places,type){var power=1;if(places>0){power=Math.pow(10,places)}var rnd;switch(type){case 'up':rnd=(Math.ceil(val*power)/power)+'';break;case 'down':rnd=(Math.floor(val*power)/power)+'';break;case 'standard': default:rnd=(Math.round(val*power)/power)+'';break;}var pos=rnd.indexOf('.');if(pos>=0){var diff=places-(rnd.length-(pos+1));}else{var diff=places;if(places>0){rnd+='.'}}for(x=0;x n_docel)))n_result = n_docel;return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;};AS.dom.clientWidth = function(){return AS.dom.filterResults (window.innerWidth ? window.innerWidth : 0,document.documentElement ? document.documentElement.clientWidth : 0,document.body ? document.body.clientWidth : 0);};AS.dom.clientHeight = function(){return AS.dom.filterResults (window.innerHeight ? window.innerHeight : 0,document.documentElement ? document.documentElement.clientHeight : 0,document.body ? document.body.clientHeight : 0);};AS.dom.scrollLeft = function(){return AS.dom.filterResults (window.pageXOffset ? window.pageXOffset : 0,document.documentElement ? document.documentElement.scrollLeft : 0,document.body ? document.body.scrollLeft : 0);};AS.dom.scrollTop = function(){return AS.dom.filterResults (window.pageYOffset ? window.pageYOffset : 0,document.documentElement ? document.documentElement.scrollTop : 0,document.body ? document.body.scrollTop : 0);};AS.dom.documentHeight = function(){with(document){return Math.max(documentElement['clientHeight'],body['scrollHeight'],documentElement['scrollHeight']);}};AS.dom.textboxFocusAndMoveCursorToEnd=function(o){if(typeof o=='string'){o=document.getElementById(o)}setTimeout(function(){o.focus();if(o.setSelectionRange){o.setSelectionRange(o.value.length*2,o.value.length*2);}else{o.value=o.value;}},100);};AS.dom.removeChildrenElements=function(elementOrElementId){var o;if(typeof(elementOrElementId)=='string'){o=document.getElementById(elementOrElementId);}else{o=elementOrElementId;}for(var i=0;i=0){AS.dom.removeChildrenElements(o.childNodes[i]);}o.removeChild(o.childNodes[i]);}};AS.dom.addLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener('DOMContentLoaded',x,false);/*@cc_on@*//*@if(@_win32||@_win64)d.write("<\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();AS.jsr = function(){this.send = function(sI,sU,sE,bC){if(bC==undefined){bC=false}if(!bC){var sD= new Date();sU+=(sU.indexOf('?')==-1)?'?':'&';sU+=encodeURIComponent(sD.getDay()+'a'+sD.getHours()+'b'+sD.getSeconds()+'c'+sD.getMilliseconds());}with(document){if(sE!=undefined){if(typeof sE=='string'){sE=getElementById(sE)}sE.innerHTML="";}if(getElementById(sI)){try{getElementsByTagName('head')[0].removeChild(getElementById(sI));}catch(e){}}var oEs=createElement('script');with(oEs){src=sU;type='text/javascript';id=sI;}getElementsByTagName('head')[0].appendChild(oEs);}};};AS.xhr = function(){this.method=null;this.url=null;this.requestBody=null;this.onLoad=null;this.onLoadArguments=null;this.onError=null;this.contentType=null;this.crossSiteRequest=false;this.timeout=300;this.responseText=null;var objXhr=null;var objThis=this;this.aryRequestHeaders = new Array();this.aryRequestHeaderValues = new Array();this._reqTimer=null;this.setRequestHeader = function(sH,sV){this.aryRequestHeaders[this.aryRequestHeaders.length+1]=sH;this.aryRequestHeaderValues[this.aryRequestHeaderValues.length+1]=sV;};this.elementUpdate = function(sU,sE,bL,bO,bCS){if(bL==undefined){bL=true}if(bO==undefined){bO=true}if(bCS==undefined){bCS=false}if(typeof sE=='string'){sE=document.getElementById(sE)}if(!bO||bO&&sE.innerHTML.indexOf('',0)==-1){if(bL){sE.innerHTML="";this.getHandler(sU,elementUpdate,sE,function(o){sE.innerHTML='AS.xhr Error: '+o.statusText+'. Error #'+o.status},bCS);}else{this.getHandler(sU,elementUpdate,sE,null,bCS);}}};this.get = function(sU,sOL,aOL,oOE,iT){this.getHandler(sU,sOL,aOL,oOE,false,iT);};this.getCrossSite = function(sU,sOL,aOL,oOE,iT){this.getHandler(sU,sOL,aOL,oOE,true,iT);};this.getHandler = function(sU,sOL,aOL,oOE,bCS,iT){this.method='GET';this.url=sU;if(sOL!=undefined){this.onLoad=sOL;}if(aOL!=undefined){this.onLoadArguments=aOL;}if(bCS!=undefined){this.crossSiteRequest=bCS;}if(oOE!=undefined){this.onError=oOE;}if(iT!=undefined){this.timeout=iT;}this.send();};this.post = function(sU,sRB,sOL,aOL,oOE,iT){this.postHandler(sU,sRB,sOL,aOL,oOE,false,iT);};this.postJson = function(sU,sRB,sOL,aOL,oOE,iT){this.contentType='application/json';this.postHandler(sU,sRB,sOL,aOL,oOE,false,iT);};this.postCrossSite = function(sU,sRB,sOL,aOL,oOE){this.postHandler(sU,sRB,sOL,aOL,oOE,true);};this.postHandler = function(sU,sRB,sOL,aOL,oOE,bCS,iT){this.method='POST';this.url=sU;this.requestBody=sRB;if(sOL!=undefined){this.onLoad=sOL;}if(aOL!=undefined){this.onLoadArguments=aOL;}if(bCS!=undefined){this.crossSiteRequest=bCS;}if(oOE!=undefined){this.onError=oOE;}if(iT!=undefined){this.timeout=iT;}this.send();};this.crossSiteRequestClientSupport = function(){objXhr=xhr();if(objXhr.withCredentials==undefined&&typeof window.XDomainRequest=='undefined'){return false;}else{return true;}};this.crossSiteMixedSecurityContextRequestClientSupport = function(){objXhr=xhr();if(objXhr.withCredentials==undefined){return false;}else{return true;}};this.send = function(){if(typeof this.requestBody!='string'&&this.requestBody!=null){this.requestBody=null;}objThis=this;objXhr=xhr();if(this.crossSiteRequest){if(objXhr.withCredentials==undefined){if(typeof window.XDomainRequest=='undefined'){alert('xhr says this browser does not support cross site requests.');}else{if(this.method.toUpperCase()!='GET'){alert('xhr says this browser does not support '+this.method+' method.');}objXhr= new XDomainRequest();objXhr.onload=handlerOnLoad;objXhr.onerror=function(){handlerOnError('window.XDomainRequest.onerror')};objXhr.timeout=function(){handlerOnError('window.XDomainRequest.timeout')};}}else{objXhr.onreadystatechange=handlerOnReadyStateChange;}}else{objXhr.onreadystatechange=handlerOnReadyStateChange;}with(objXhr){switch(this.method.toUpperCase()){case 'GET':open('GET', this.url, true);if(!this.crossSiteRequest){for(var i=1;i=200&&status<300){if(responseText!=null){objThis.responseText=responseText;if(objThis.onLoad!=null){if(objThis._reqTimer!=null){clearTimeout(objThis._reqTimer);}objThis.onLoad(objThis);}}}else if(objThis.onError!=null){objThis.onError({status:status,statusText:statusText});}dispose();}}}}function elementUpdate(obj){obj.onLoadArguments.innerHTML='\n'+obj.responseText;}function xhr(){if(typeof XMLHttpRequest!='undefined'){return new XMLHttpRequest();}else{if(typeof ActiveXObject!='undefined'){var aV = ['Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];for (var i=0;i=sG.length){iX=0;}}return sA+sK.substring(6,sK.length);}function getXMLHttpRequest(){if(typeof XMLHttpRequest!='undefined'){return new XMLHttpRequest()}else{if(typeof ActiveXObject!='undefined'){var aV = ['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];for (var i=0;i<\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();function addDOMunLoadEvent(func){try{var oldonload=window.onbeforeunload;if(typeof window.onbeforeunload!='function'){window.onbeforeunload=func;}else{window.onbeforeunload=function(){oldonload();func()}}}catch(e){}}function doPageHead_updatePrintUrl(strUrl){with(document){if(getElementById('pageHeadPrint')){getElementById('pageHeadPrint').href=strUrl;}if(getElementById('pageHeadPrint')){getElementById('pageHeadPrint2').href=strUrl;}}} function DOMAlert(settings) { var that, modalWindow, iframe, alertWindow, titleBar, title, ricon, licon, contentArea, buttonArea, okButton, cancelButton, defaultCallback, okCallback, cancelCallback; //create version of ourself for use in closures that = this; //Create our settings this.settings = settings; //Create a namespae object to hold our html elements this.html = {}; //ie6 test. this.isIE6 = (document.all && window.external && (typeof document.documentElement.style.maxHeight === 'undefined')) ? true : false; // use the Default skin if none was provided this.settings.skin = this.settings.skin ? this.settings.skin : 'default'; // Set up a default for OK setting if (!this.settings.ok) { defaultCallback = function () { that.close(); }; this.settings.ok = {text: 'Ok', value: true, onclick: defaultCallback}; } //Create our modal background modalWindow = document.createElement('div'); modalWindow.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight : document.documentElement.scrollHeight) + 'px'; modalWindow.style.width = document.documentElement.scrollWidth + 'px'; if (!this.isIE6) { modalWindow.style.background = 'url(/img/oth/overlay.png)'; //transparent png with low opacity. Provides a similar effect as opacy/filter settings, but without the memory leaks } modalWindow.style.position = 'absolute'; modalWindow.style.left = '0px'; modalWindow.style.top = '0px'; modalWindow.style.zIndex = 998; modalWindow.style.visibility = 'hidden'; document.body.appendChild(modalWindow); this.html.modalWindow = modalWindow; //shoehorn an iframe to cover our select elements for ie6. if (this.isIE6) { iframe = document.createElement('iframe'); iframe.style.position = 'absolute'; iframe.style.visibility = 'hidden'; iframe.style.zIndex = 997; iframe.frameBorder = 0; iframe.style.position = 'absolute'; document.body.appendChild(iframe); this.html.iframe = iframe; //also, need to add an alpha image loader for ie6 transparency affect. again, style.filter has a huge memory leak modalWindow.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/oth/overlay.png', sizingMethod='scale', enabled=true)"; } //Create our alert window alertWindow = document.createElement('div'); alertWindow.className = this.settings.skin + '_alertWindow'; alertWindow.style.position = this.isIE6 ? 'absolute' : 'fixed'; alertWindow.style.zIndex = 999; if (this.settings.width) { alertWindow.style.width = this.settings.width + 'px'; } document.body.appendChild(alertWindow); alertWindow.style.visibility = 'hidden'; this.html.alertWindow = alertWindow; //Create out title bar titleBar = document.createElement('div'); titleBar.className = this.settings.skin + '_titleBar'; alertWindow.appendChild(titleBar); this.html.titleBar = titleBar; //Create our right Icon ricon = document.createElement('div'); ricon.className = this.settings.skin + '_titleBarRightIcon'; ricon.style.cssFloat = 'right'; ricon.style.styleFloat = 'right'; titleBar.appendChild(ricon); this.html.ricon = ricon; //Create our Left Icon licon = document.createElement('div'); licon.className = this.settings.skin + '_titleBarLeftIcon'; licon.style.cssFloat = 'left'; licon.style.styleFloat = 'left'; titleBar.appendChild(licon); this.html.licon = licon; //Create our span that goes in our title title = document.createElement('span'); title.innerHTML = this.settings.title; titleBar.appendChild(title); this.html.title = title; //Create our main content area contentArea = document.createElement('div'); contentArea.className = this.settings.skin + '_contentArea'; contentArea.innerHTML = this.settings.text; if (this.settings.height) { contentArea.style.height = this.settings.height + 'px'; } alertWindow.appendChild(contentArea); this.html.contentArea = contentArea; //Create out button area buttonArea = document.createElement('div'); buttonArea.className = this.settings.skin + '_buttonArea'; alertWindow.appendChild(buttonArea); this.html.buttonArea = buttonArea; //Draw an OK button okButton = document.createElement('input'); okButton.type = 'button'; okButton.className = this.settings.skin + '_okButton'; okButton.value = this.settings.ok.text; okCallback = function () { that.settings.ok.onclick(that, that.settings.ok.value); }; okButton.onclick = okCallback; buttonArea.appendChild(okButton); this.html.okButton = okButton; //Draw a cancel button, if present if (this.settings.cancel) { cancelButton = document.createElement('input'); cancelButton.type = 'button'; cancelButton.className = this.settings.skin + '_cancelButton'; cancelButton.value = this.settings.cancel.text || 'Cancel'; cancelCallback = function () { that.settings.cancel.onclick(that, that.settings.cancel.value); }; cancelButton.onclick = cancelCallback; buttonArea.appendChild(cancelButton); this.html.cancelButton = cancelButton; } //Center our alert box on the screen this.center(); } DOMAlert.prototype.show = function (titleText, contentText) { if (contentText) { this.html.title.innerHTML = titleText; this.html.contentArea.innerHTML = contentText; } if (titleText && !contentText) { this.html.contentArea.innerHTML = titleText; } this.html.modalWindow.style.visibility = 'visible'; this.html.alertWindow.style.visibility = 'visible'; if (this.html.iframe) { this.html.iframe.style.height = this.html.alertWindow.offsetHeight; this.html.iframe.style.width = this.html.alertWindow.offsetWidth; this.html.iframe.style.visibility = 'visible'; } if (this.html.cancelButton) { this.html.cancelButton.focus(); } else { this.html.okButton.focus(); } }; DOMAlert.prototype.hide = function () { this.html.modalWindow.style.visibility = 'hidden'; this.html.alertWindow.style.visibility = 'hidden'; if (this.html.iframe) { this.html.iframe.style.visibility = 'hidden'; } }; DOMAlert.prototype.close = function () { var obj, prop; //make sure our DOM objects are deleted and our onclick statements are nulled for (obj in this.html) { if (this.html[obj].parentNode) { if (this.html[obj].onclick) { this.html[obj].onclick = null; } this.html[obj].parentNode.removeChild(this.html[obj]); delete this.html[obj]; } } //remove object properties for (prop in this) { if (this[prop]) { this[prop] = null; delete this[prop]; } } }; DOMAlert.prototype.center = function () { var alertWindow, scrollT, scrollL, iframe; alertWindow = this.html.alertWindow; if (alertWindow.style.position === 'absolute') { scrollT = window.pageYOffset || document.documentElement.scrollTop; scrollL = window.pageXOffset || document.documentElement.scrollLeft; alertWindow.style.left = (self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 + scrollL - alertWindow.offsetWidth / 2 + 'px'; alertWindow.style.top = (self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 + scrollT - alertWindow.offsetHeight / 2 + 'px'; if (this.html.iframe) { this.html.iframe.style.left = alertWindow.style.left; this.html.iframe.style.top = alertWindow.style.top; } } else { alertWindow.style.left = (self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth)) / 2 - alertWindow.offsetWidth / 2 + 'px'; alertWindow.style.top = (self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight)) / 2 - alertWindow.offsetHeight / 2 + 'px'; } }; function DomDisable(settings) { var that, modalWindow, iframe; //create version of ourself for use in closures that = this; //Create our settings this.settings = settings; this.settings.zIndex = this.settings.zIndex ? this.settings.zIndex : 998; //Create a namespae object to hold our html elements this.html = {}; //ie6 test. this.isIE6 = (document.all && window.external && (typeof document.documentElement.style.maxHeight === 'undefined')) ? true : false; //Create our modal background modalWindow = document.createElement('div'); modalWindow.style.height = ((document.documentElement.clientHeight > document.documentElement.scrollHeight) ? document.documentElement.clientHeight : document.documentElement.scrollHeight) + 'px'; modalWindow.style.width = document.documentElement.scrollWidth + 'px'; if (!this.isIE6) { modalWindow.style.background = 'url(/img/oth/overlay.png)'; //transparent png with low opacity. Provides a similar effect as opacy/filter settings, but without the memory leaks } modalWindow.style.position = 'absolute'; modalWindow.style.left = '0px'; modalWindow.style.top = '0px'; modalWindow.style.zIndex = this.settings.zIndex; modalWindow.style.visibility = 'hidden'; document.body.appendChild(modalWindow); this.html.modalWindow = modalWindow; //shoehorn an iframe to cover our select elements for ie6. if (this.isIE6) { iframe = document.createElement('iframe'); iframe.style.position = 'absolute'; iframe.style.visibility = 'hidden'; iframe.style.zIndex = this.settings.zIndex-1; iframe.frameBorder = 0; iframe.style.position = 'absolute'; document.body.appendChild(iframe); this.html.iframe = iframe; //also, need to add an alpha image loader for ie6 transparency affect. again, style.filter has a huge memory leak modalWindow.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/img/oth/overlay.png', sizingMethod='scale', enabled=true)"; } } DomDisable.prototype.show = function (titleText, contentText) { this.html.modalWindow.style.visibility = 'visible'; }; DomDisable.prototype.hide = function () { this.html.modalWindow.style.visibility = 'hidden'; if (this.html.iframe) { this.html.iframe.style.visibility = 'hidden'; } }; DomDisable.prototype.close = function () { var obj, prop; //make sure our DOM objects are deleted and our onclick statements are nulled for (obj in this.html) { if (this.html[obj].parentNode) { this.html[obj].parentNode.removeChild(this.html[obj]); delete this.html[obj]; } } //remove object properties for (prop in this) { if (this[prop]) { this[prop] = null; delete this[prop]; } } }; function PageQuery(q) { if(q.length > 1) this.q = q.substring(1, q.length); else this.q = null; this.keyValuePairs = new Array(); if(q) { for(var i=0; i < this.q.split("&").length; i++) { this.keyValuePairs[i] = this.q.split("&")[i]; } } this.getKeyValuePairs = function() { return this.keyValuePairs; } this.getValue = function(s) { for(var j=0; j < this.keyValuePairs.length; j++) { if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1]; } return false; } this.getParameters = function() { var a = new Array(this.getLength()); for(var j=0; j < this.keyValuePairs.length; j++) { a[j] = this.keyValuePairs[j].split("=")[0]; } return a; } this.getLength = function() { return this.keyValuePairs.length; } } function queryString(key){ var page = new PageQuery(window.location.search); return unescape(page.getValue(key)); } //------------------------------------------------ // drag and drop begin function hookEvent(element, eventName, callback) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(element.addEventListener) { element.addEventListener(eventName, callback, false); } else if(element.attachEvent) element.attachEvent("on" + eventName, callback); } function unhookEvent(element, eventName, callback) { if(typeof(element) == "string") element = document.getElementById(element); if(element == null) return; if(element.removeEventListener) element.removeEventListener(eventName, callback, false); else if(element.detachEvent) element.detachEvent("on" + eventName, callback); } function cancelEvent(e) { e = e ? e : window.event; if(e.stopPropagation) e.stopPropagation(); if(e.preventDefault) e.preventDefault(); e.cancelBubble = true; e.cancel = true; e.returnValue = false; return false; } function Position(x, y) { this.X = x; this.Y = y; this.Add = function(val) { var newPos = new Position(this.X, this.Y); if(val != null) { if(!isNaN(val.X)) newPos.X += val.X; if(!isNaN(val.Y)) newPos.Y += val.Y } return newPos; } this.Subtract = function(val) { var newPos = new Position(this.X, this.Y); if(val != null) { if(!isNaN(val.X)) newPos.X -= val.X; if(!isNaN(val.Y)) newPos.Y -= val.Y } return newPos; } this.Min = function(val) { var newPos = new Position(this.X, this.Y) if(val == null) return newPos; if(!isNaN(val.X) && this.X> val.X) newPos.X = val.X; if(!isNaN(val.Y) && this.Y> val.Y) newPos.Y = val.Y; return newPos; } this.Max = function(val) { var newPos = new Position(this.X, this.Y) if(val == null) return newPos; if(!isNaN(val.X) && this.X