//Browsercheck (needed)
function lib_bwcheck(){ 
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom)?1:0;
  this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6||this.ie7||this.ie8
  this.mac=this.agent.indexOf("Mac")>-1
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie8||this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}

bw = new lib_bwcheck() //Browsercheck object

//Debug function 
function lib_message(txt){alert(txt); return false;}

//Lib objects
function lib_obj(obj,nest){
  //function lib_obj(obj,nest,frm)  
  if(!bw.bw) return lib_message('Old browser :'+bw.ver);
  if(!obj) return
  //if(frm && top.frames.length < 2) return;
  nest = (!nest)?"":'document.'+nest+'.';
  //frm = (!frm)?"":'window.parent.frames["'+frm+'"].';
  this.evnt = (bw.dom)?document.getElementById(obj):(bw.ie4)?document.all[obj]:(bw.ns4)?eval(nest+"document.layers."+obj):0;	
  if(!this.evnt) return lib_message('The layer does not exist ('+obj+')'+'- \nIf your using Netscape please check the nesting of your tags!');

  this.css = (bw.dom||bw.ie4)?this.evnt.style:this.evnt; 
  this.ref = (bw.dom||bw.ie4)?document:this.css.document;
  //
  this.x = parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
  this.y = parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0;
  //
  this.w = this.evnt.offsetWidth||this.css.clip.width/*||this.ref.width*/||this.css.pixelWidth||0;
  this.h = this.evnt.offsetHeight||this.css.clip.height/*||this.ref.height*/||this.css.pixelHeight||0;  
  //
  this.z = this.css.zIndex;
  this.bgC = (bw.dom||bw.ie4)?this.css.backgroundColor:(bw.ns4)?this.ref.bgColor:0;
  this.c = 0; //Clip values
  if((bw.dom || bw.ie4) && this.css.clip){
	this.c = this.css.clip;
	this.c = this.c.slice(5,this.c.length-1);
	//style.clip="rect(0 300 300 0)";
	//rect(t  r   b  l)
	this.c = this.c.split(' ');
	for(var i=0;i<4;i++){
	this.c[i] = parseInt(this.c[i]);
	}
	}
  this.ct = this.css.clip.top||this.c[0]||0; 
  this.cr = this.css.clip.right||this.c[1]||this.w||0;
  this.cb = this.css.clip.bottom||this.c[2]||this.h||0; 
  this.cl = this.css.clip.left||this.c[3]||0;
  this.obj = obj + "Object";
  eval(this.obj + "=this");
  return this
}
// A unit of measure that will be added when setting the position of a layer.
var px = (bw.ns4||window.opera)?"":"px";

if(document.layers){ //NS4 resize fix.
	scrX = innerWidth;
	scrY= innerHeight;
	onresize = function(){
	if(scrX!= innerWidth || scrY!= innerHeight){
	history.go(0);
	}
	};
}


lib_obj.prototype.getP = function(t){
	//t = 'x'||'y'
	v = eval("this."+t+"");
	return v;
	}

lib_obj.prototype.getS = function(t){
	//t = 'w'||'h'
	v = eval("this."+t+"");
	return v;
	}

lib_obj.prototype.getC = function(t){
	//t = 't'||'r'||'b'||'l'
	v = eval("this.c"+t+"");
	return v;
	}

lib_obj.prototype.getZ = function(){
	return this.z;
	}

//Moving object to
lib_obj.prototype.moveIt = function(x,y){
	this.x = x;
	this.y = y;
	this.css.left = x;
	this.css.top = y
	}


//Showing object
lib_obj.prototype.showIt = function(){
	this.css.visibility = "visible";
	}

//Hiding object
lib_obj.prototype.hideIt = function(){
	this.css.visibility = "hidden";
	}


//Writing content to object
lib_obj.prototype.writeIt = function(text,startHTML,endHTML){
	if(bw.ns4){
	if(!startHTML){
	startHTML, endHTML = "";
	}
	this.ref.open("text/html"); 
	this.ref.write(startHTML + text + endHTML); 
	this.ref.close()
	}
	else this.evnt.innerHTML=text
}



//Document size object
function lib_doc_size(d){ 
  this.x = 0;
  this.x2 = bw.ie && document.body.offsetWidth-20||innerWidth||0;
  this.y = 0;
  this.y2 = bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(!this.x2||!this.y2) return message('Document has no width or height') 
  this.x50 = this.x2/2;
  this.y50 = this.y2/2;
  //
  if(d != 0){
  r = [];
  r['w'] = this.x2;
  r['h'] = this.y2;
  return r
  }
  else return this;
  //
}