////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Common JavaScript Document Object Model Library                           //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

//detecting the browser type & wrap it into an object
function gB(){

	//setup container
	var d=document;

	//setup the object
	this.agt=navigator.userAgent.toLowerCase();
	this.major=parseInt(navigator.appVersion);
	this.dom=(d.getElementById)?1:0;
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major >=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=this.agt.indexOf('opera')!=-1;
	this.ie=(d.all);
	this.ie4=(d.all&&!this.dom)?1:0;
	this.ie4up=(this.ie && this.major >= 4);
	this.ie5=(d.all&&this.dom);
	this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
	this.mac=(this.agt.indexOf("mac")!=-1);

}

//detect and save browser data
var B=new gB();

//get any object from the specified container or current document
function gO(i,d){

	//define variables
	var c,o;

	//detect document
	if(!d){d=document;}

	//locate object with recusrion when necessary
	if(!(o=d[i])&&d.all){o=d.all[i];}
	if(d.forms){for(c=0;!o&&c<d.forms.length;c++){o=d.forms[c][i];}}
	if(d.layers){for(c=0;!o&&d.layers&&c<d.layers.length;c++){o=gO(i,d.layers[c].document);}}
	if(!o&&d.getElementById){o=d.getElementById(i);}

	//return the value
	return(o);

}

//operate with x-axis
function gX(o){var x=(B.ns)?o.left:(B.op)?o.style.pixelLeft:o.offsetLeft;return(x);}
function sX(o,x){(B.ns)?o.left=x:(B.op)?o.style.pixelLeft=x:o.style.left=x;}

//operate with y-axis
function gY(o){var y=(B.ns)?o.top:(B.op)?o.style.pixelTop:o.offsetTop;return(y);}
function sY(o,y){(B.ie||B.dom)?o.style.top=y:(B.ns)?o.top=y:o.style.pixelTop=y;}

//operate with width
function gW(o){var w=0;if(B.ns){w=(o.width)?o.width:o.clip.width;return(w);}w=(B.op)?o.style.pixelWidth:o.offsetWidth;return(w);}
function sW(o,w){if(B.ns){if(o.clip){o.clip.right=w;}}else if(B.op){o.style.pixelWidth=w;}else{o.style.width=w;}}

//operate with height
function gH(o){var h=0;if(B.ns){h=(o.height)?o.height:o.clip.height;return(h);}h=(B.op)?o.style.pixelHeight:o.offsetHeight;return(h);}
function sH(o,h){if(B.ns){if(o.clip){o.clip.bottom=h;}}else if(B.op){o.style.pixelHeight=h;}else{o.style.height=h;}}

//getting the coordinates
function gPX(o){if(B.ns){var x=(o.pageX)?o.pageX:o.x;return(x);}else if(B.op){var x=0;while(eval(o)){x+=o.offsetLeft;o=o.offsetParent;}return(x);}else{var x=0;while(eval(o)){x+=o.offsetLeft;o=o.offsetParent;}return(x);}}
function gPY(o){if(B.ns){var y=(o.pageY)?o.pageY:o.y;return(y);}else if(B.op){var y=0;while(eval(o)){y+=o.offsetTop;o=o.offsetParent;}return(y);}else{var y=0;while(eval(o)){y+=o.offsetTop;o=o.offsetParent;}return(y);}}

//movement
function mA(m){var aW=gO("width-anchor");var aH=gO("height-anchor");if(aW&&m&&(gPX(m)+gW(m)>gPX(aW))){mT(m,gPX(aW)-gW(m)+12,gPY(m));}if(aH&&m&&(gPY(m)+gH(m)>gPY(aH))){mT(m,gPX(m),gPY(aH)-gH(m)-12);}}
function mT(o,x,y){sX(o,x);sY(o,y);}
function mB(o,x,y,a){sX(o,gPX(o)+x);sY(o,gPY(o)+y);}

//operate with z-index
function sZ(o,z){if(B.ns){o.zIndex=z;}else{o.style.zIndex=z;}}

//show & hide object with display style
function sO(o,s){(B.ns)?'':(!s)?o.style.display="inline":o.style.display=s;(B.ns)?o.visibility='show':o.style.visibility='visible';sZ(o,65535);}
function hO(o,s){(B.ns)?'':(arguments.length!=2)?o.style.display="none":'';(B.ns)?o.visibility='hide':o.style.visibility='hidden';}

//operate with styles
function gS(o,s){if(B.ie5||B.dom){return(eval("o.style."+s));}}
function sS(o,s,v){if(B.ie5||B.dom){eval("o.style."+s+"='"+v+"'");}}

//write HTML
function wH(o,h){if(B.ns){var d=o.document;d.write(h);d.close();return(false);}else if(o.innerHTML){o.innerHTML=h;}}

//goto uri
function go(u){

	//opening
	document.location.href=u;

	//go back
	return(false);

}

//operate with cookies
function sC(c,v,d){var n=new Date();if(d){n.setDate(n.getDate()+d);}document.cookie=c+'='+v+";expires="+n.toGMTString()+";";}
function gC(c){var n=document.cookie.length;var c=c+"=";var l=c.length;var i=0;while (i<=n){var j=(i+l);if(document.cookie.substring(i,j)==c){e=document.cookie.indexOf(";",j);return unescape(document.cookie.substring(j,(e==-1)?document.cookie.length:e));}i=document.cookie.indexOf(" ",i)+1;if(i==0)return("");}}

//setup encodings
function mE(c,v){

	//set cookie
	sC(c,v,365);

	//reload document
	document.location.reload();

	//go back
	return(false);

}