/***************************************************************************
Copyright (C) 1999 Thomas Brattli
All scripts here are made by and copyrighted to Thomas Brattli from
www.bratta.com and can under no circumstances be used anywhere else, if
you want to use this or something, please take contact with me at
dhtml@bratta.com.
****************************************************************************/
//Default browsercheck, added to all scripts!
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()

function makePageCoords(){
	this.x=0;this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth;
	this.y=0;this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight;
	this.x50=this.x2/2;	this.y50=this.y2/2;
	this.x10=(this.x2*10)/100-5;this.y10=(this.y2*10)/100-5
	this.x15=(this.x2*15)/100-5;this.y15=(this.y2*15)/100-5; 
	return this;
}
function makeObj(obj,nest,x,y){
	//Added some stuff for NS5. Must be fixed when full version is realeasd
	nest=(!nest) ? '':'document.'+nest+'.'		
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;		
	this.evnt=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?this.css:0;			
	this.ref=bw.dom || bw.ie4?document:bw.ns4?this.css.document:0;
	if(x && y){this.pagex=x; this.pagey=y; this.place=b_place;}
	this.writeIt=b_writeIt;
	this.scrollHeight=bw.ns4?this.ref.height:this.evnt.offsetHeight;
	this.scrollWidth=bw.ns4?this.ref.width:bw.ns5?this.css.width:this.evnt.offsetWidth;
	this.x=(bw.ns4 || bw.ns5)? parseInt(this.css.left):this.css.pixelLeft;
	this.y=(bw.ns4 || bw.ns5)? parseInt(this.css.top):this.css.pixelTop;							
	this.hideIt=b_hideIt;	this.showIt=b_showIt; this.vis=b_vis								
	this.moveIt=b_moveIt; this.moveBy=b_moveBy;										
	this.slide=b_slide; this.slideIt=b_slideIt;	
	this.bgChange=b_bgChange;					
	this.clipIt=b_clipIt; this.clip=b_clip; this.clipactive=false;this.clipTo=b_clipTo;				
	this.obj = obj + "Object"; 	eval(this.obj + "=this")
	return this
}
	
function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}
function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}

function b_bgChange(color){
	if(bw.dom || bw.ie4) this.css.backgroundColor=color
	else if(bw.ns4) this.css.bgColor=color	
}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}
function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x;this.css.top=this.y}
function b_place(){this.moveIt(this.pagex,this.pagey); this.showIt()}

function b_writeIt(text){
	if(bw.ns4){this.ref.write(text);this.ref.close()}
	else if(bw.ie4 || bw.ie5) this.evnt.innerHTML=text
	else if(bw.ns5) null; //ADD NS5 HERE.
}

function b_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 b_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.moveIt(this.x+dx,this.y+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 b_clipTo(t,r,b,l,w){
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(r<0) r=0; if(b<0) b=0
this.css.clip="rect("+t+","+r+","+b+","+l+")"; if(w){this.css.width=r; this.css.height=b}}}
function b_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 b_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)}
}