/************************************************************************************
Simple reusable DHTML library made by Thomas Brattli from www.bratta.com
Tutorial availble at 
http://www.bratta.com/dhtml/scripts.asp?url=howtos/dhtmllib.asp

More scripts and tutorial availble at DHTML Scriptomania:
http://www.bratta.com/dhtml/scripts.asp

Please keep this notice in the code if you use it. Thanks.

bratta-dhtml-lib ver 1
************************************************************************************/
function lib_doc_size(){ 
	this.x=0;this.x2=bw.ie && document.body.offsetWidth||innerWidth||0;
	this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;
  if(bw.opera5) this.x2+=20
	if(!this.x2||!this.y2) return message('Document has no width or height') 
	this.x50=this.x2/2;     this.y50=this.y2/2;
	this.x10=(this.x2*10)/100;this.y10=(this.y2*10)/100
	this.x15=(this.x2*15)/100;this.y15=(this.y2*15)/100
	return this;
}
function lib_message(txt){ 
	alert(txt)
	return false
}
function lib_moveIt(x,y){ 

	this.x=x; this.css.left=x; 
	if(y!=-1){this.y=y; this.css.top=y}
}
function lib_moveBy(x,y){ 
	x=this.x+x
	y=y==0?-1:this.y+y

	this.moveIt(x,y)
}
function lib_showIt(){ 
	this.css.visibility="visible"
}
function lib_hideIt(){ 
	this.css.visibility="hidden"
}
function lib_bg(color){ 

	if(bw.opera5) this.css.background=color
	else if(bw.dom || bw.ie4) this.css.backgroundColor=color
	else if(bw.ns4) this.css.bgColor=color  
}
function lib_bg2(color){
	if(bw.dom || bw.ie4){
		if(this.win.ifr.document){
			this.win.ifr.document.body.style.backgroundColor=color
			if(bw.ns6) this.bg(color)
	}
	}else if(bw.ns4){
		this.win.ref.bgColor=color	
		this.bg(color)
	}
}
function lib_writeIt(text,startHTML,endHTML){  
  if(bw.ns4){
    if(!startHTML){startHTML=""; endHTML=""}
      this.ref.write(startHTML+text+endHTML); this.ref.close()
    }else this.evnt.innerHTML=text
}
function lib_clipTo(t,r,b,l,setwidth){ 


	this.ct=t; this.cr=r; this.cb=b; this.cl=l
	if(bw.ns4){
		this.css.clip.top=t;this.css.clip.right=r
		this.css.clip.bottom=b;this.css.clip.left=l
	}else{
		if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
		this.css.clip="rect("+t+","+r+","+b+","+l+")";
		if(setwidth){
			if(bw.opera5){this.css.pixelWidth=r; this.css.pixelHeight=b}
			else{this.css.width=r; this.css.height=b}
			this.w=r; this.h=b
		}
	}
}
function lib_clipBy(t,r,b,l,setwidth){ //Clip by a spesified number of pixels
	this.clipTo(this.ct+t,this.cr+r,this.cb+b,this.cl+l,setwidth)
}
	
	//Clip start
	function lib_clipIt(tstop,rstop,bstop,lstop,step,fn,wh,www){

	if(!fn) fn=null; if(!wh) wh=null; var clipval=new Array()
	if(bw.dom || bw.ie4) {clipval=this.css.clip; clipval=clipval.slice(5,clipval.length-1);
	clipval=clipval.split(' '); for(var i=0;i<4;i++){clipval[i]=parseInt(clipval[i])}
	}else{clipval[0]=this.css.clip.top; clipval[1]=this.css.clip.right
	clipval[2]=this.css.clip.bottom; clipval[3]=this.css.clip.left}
	totantstep=Math.max(Math.max(Math.abs((tstop-clipval[0])/step),Math.abs((rstop-clipval[1])/step)),
	Math.max(Math.abs((bstop-clipval[2])/step),Math.abs((lstop-clipval[3])/step)))
	if(!this.clipactive)this.clip(clipval[0],clipval[1],clipval[2],clipval[3],(tstop-clipval[0])/totantstep,
	(rstop-clipval[1])/totantstep,(bstop-clipval[2])/totantstep,
	(lstop-clipval[3])/totantstep,totantstep,0, fn,wh,www)}
	function lib_clip(tcurr,rcurr,bcurr,lcurr,tperstep,rperstep,bperstep,lperstep,totantstep,antstep,fn,wh,www){
	tcurr=tcurr+tperstep; rcurr=rcurr+rperstep; bcurr=bcurr+bperstep; lcurr=lcurr+lperstep
	if(www)this.clipTo(tcurr,rcurr,bcurr,lcurr,1);
	else this.clipTo(tcurr,rcurr,bcurr,lcurr);
	eval(wh); if(antstep<totantstep){this.clipactive=true;	antstep++
	setTimeout(this.obj+".clip("+tcurr+","+rcurr+","+bcurr+","+lcurr+","+tperstep+","
	+rperstep+","+bperstep+","+lperstep+","+totantstep+","+antstep+",'"+fn+"','"+wh+"','"+www+"')",50)	
	}else{this.clipactive=false; eval(fn)}}



	function lib_slideIt(endx,endy,inc,speed,fn,wh) {

	if (!this.slideactive) {var distx = endx - this.x;var disty = endy - this.y
	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
	var dx = distx/num;var dy = disty/num
	this.slideactive = 1; this.slide(dx,dy,endx,endy,speed,fn,wh)}}
	function lib_slide(dx,dy,endx,endy,speed,fn,wh) {
	if (!fn) fn = null; if(!wh) wh=null
	if (this.slideactive && (Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x)) || Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))) {
	this.moveBy(dx,dy); eval(wh)
	slidTim=setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",'"+fn+"','"+wh+"')",speed)
	}else{this.slideactive = 0;this.moveIt(endx,endy);eval(fn)}}


function lib_obj_b(obj,nest,dnest,ddnest,num){
	this.num=num	
	if(!bw.bw) return lib_message('Old browser')

	if(!bw.ns4) this.evnt=bw.dom && document.getElementById(obj)||bw.ie4 && document.all[obj]
	else{
		if(ddnest){
	this.evnt=document[nest].document[dnest].document[ddnest].document[obj]?document[nest].document[dnest].document[ddnest].document[obj]:0;
		}else if(dnest){
			this.evnt=document[nest].document[dnest].document[obj]?document[nest].document[dnest].document[obj]:0;
		}else if(nest){
			this.evnt=document[nest].document[obj]?document[nest].document[obj]:0;
		}else{
			this.evnt=document.layers[obj]?document.layers[obj]:0;
		}	
	}
	if(!this.evnt) return lib_message('The layer does not exist ('+obj+') - Exiting script\n\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=this.css.left||this.css.pixelLeft||this.evnt.offsetLeft||0
	this.y=this.css.top||this.css.pixelTop||this.evnt.offsetTop||0
	this.w=this.ref.width||this.evnt.offsetWidth||this.css.pixelWidth||0
	this.h=this.ref.height||this.evnt.offsetHeight||this.css.pixelHeight||0
	this.moveIt=lib_moveIt; this.moveBy=lib_moveBy;
	this.showIt=lib_showIt; this.hideIt=lib_hideIt; 
	this.writeIt=lib_writeIt; this.bg=lib_bg; this.bg2=lib_bg2;

	this.c=new Array(4)
	if((bw.dom || bw.ie4) && this.css.clip) {
		this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1); 
		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.clipTo=lib_clipTo;	this.clipBy=lib_clipBy; this.clip=lib_clip; this.clipIt=lib_clipIt;
	this.slideIt=lib_slideIt; this.slide=lib_slide;
	this.obj = obj + "Object"; 	eval(this.obj + "=this")
	return this
}

var px = bw.ns4||window.opera?"":"px";


function lib_obj(obj,nest){ 

  nest=(!nest) ? "":'document.'+nest+'.'
  this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;	
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
  this.ref=this.css
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0; 
  return this
}

lib_obj.prototype.moveIt = function(x,y){

  this.x=x; this.y=y; this.css.left=x+px; this.css.top=y+px;
}

lib_obj.prototype.clipTo = function(t,r,b,l,setwidth){ 
  this.ct=t; this.cr=r; this.cb=b; this.cl=l
  if(bw.ns4){
    this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
  }else{
    if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
    this.css.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
    if (setwidth){
		this.css.pixelWidth = r;
		this.css.pixelHeight = b;
		this.css.width = r+px; 
		this.css.height = b+px;
	}
  }
}