/* Standard Helpers */
function $(){var es=new Array();for(var i=0;i<arguments.length;i++){var e=arguments[i];if(typeof e=='string')e=document.getElementById(e);if(arguments.length==1)return e;es.push(e);}return es;}
function addEvent(e,et,fn){if(typeof e=='string')e=$(e);if(e.addEventListener){e.addEventListener(et,fn,false);}else if(e.attachEvent){e.attachEvent('on'+et,fn);}}
function $byclass(sc,n,t){var ce=new Array();if(n==null)n=document;if(t==null)t='*';var e=n.getElementsByTagName(t);var el=e.length;var p=new RegExp('(^|\\\\s)'+sc+'(\\\\s|$)');for(i=0,j=0;i<el;i++){if(p.test(e[i].className)){ce[j]=e[i];j++;}}return ce;}
function toggle(e){if(typeof e=='string')e=$(e);if(e.style.display!='none'){e.style.display='none';}else{e.style.display='';}}
function $size(e){if(typeof e=='string'){e=$(e);}return[e.offsetWidth,e.offsetHeight];}
function $pos(e){if(typeof e=='string'){e=$(e);}var cl=ct=0;if(e.offsetParent){do{cl+=e.offsetLeft;ct+=e.offsetTop;}while(e=e.offsetParent);}return [cl,ct];}
function winSize(){var w=h=0;if(self.innerWidth){w=self.innerWidth;h=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientWidth){w=document.documentElement.clientWidth;h=document.documentElement.clientHeight;}else if(document.body){w=document.body.clientWidth;h=document.body.clientHeight;}return[w,h];}
function scrollOffset(){var iebody=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body,l=document.all?iebody.scrollLeft:pageXOffset,t=document.all?iebody.scrollTop:pageYOffset;return [l,t];}
function pageSize(){var xw=yw=0;if(window.innerHeight&&window.scrollMaxY){yw=window.innerHeight+window.scrollMaxY;xw=window.innerWidth+window.scrollMaxX;}else if(document.body.scrollHeight>document.body.offsetHeight){yw=document.body.scrollHeight;xw=document.body.scrollWidth;}else{yw=document.body.offsetHeight;xw=document.body.offsetWidth;}return [xw,yw];}
function setOpacity(id,o){var e=$(id).style;e.o=(o/100);e.opacity=(o/100);e.MozOpacity=(o/100);e.KhtmlOpacity=(o/100);e.filter="alpha(opacity="+o+")"; } 

/* Cookie Functions */
function getCookie(n){var s=document.cookie.indexOf(n+"="),l=s+n.length+1;if((!s)&&(n!=document.cookie.substring(0,n.length))){return null;}if(s==-1)return null;var e=document.cookie.indexOf(';',l);if(e==-1)e=document.cookie.length;return unescape(document.cookie.substring(l,e));}
function setCookie(n,v,e,p,d,s){var t=new Date();t.setTime(t.getTime());if(e){e=e*1000*60*60*24;}var ed=new Date(t.getTime()+(e));document.cookie = n+'='+escape(v ) +((e)?';expires='+ed.toGMTString():'')+((p)?';path='+p:'')+((d)?';domain='+d:'')+((s)?';secure':'');}
function deleteCookie(n,p,d){if(getCookie(n))document.cookie=n+'='+((p)?';path='+p:'')+((d)?';domain='+d:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';}

/* Cool Tooltip */
function AddTooltip(o,d,c){var p=$pos(o),ps=$size(o);var b=document.createElement('div');b.id='_popup'+(Math.random()*131071.333);b.style.visibility='hidden';b.style.position='absolute';b.style.left=(p[0]+ps[0])+'px';b.style.top=(p[1]+ps[1])+'px';b.setAttribute('class', c);b.innerHTML='<div style="text-align: right;"><img src="images/close.png" style="cursor: pointer;" onClick="HideTooltip(\''+b.id+'\')"></div>'+d;document.body.appendChild(b);addEvent(o,'click',function(){$(b.id).style.visibility='visible';});}
function HideTooltip(o){$(o).style.visibility='hidden';}

/*  Ajax Functions  */
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};
ajax={};
ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.sendxml=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseXML)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.get=function(url,func){ajax.send(url,func,'GET')};
ajax.getxml=function(url,func){ajax.sendxml(url,func,'GET')};
ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText};
ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)};
ajax.postxml=function(url,func,args){ajax.sendxml(url,func,'POST',args)};
ajax.update=function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)};
ajax.submit=function(url,elm,frm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.post(url,f,ajax.serialize(frm))};

function gotoUrl(u){window.location.href=u;}
function popupWin(u,w,h){window.open(u,'_popup','width='+w+',height='+h+',scrollbars=yes,resizable=yes');}
