
//Slide start
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);
		this.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_moveBy(x,y){ //Move by a specified number of pixels
	x=this.x+x
	y=y==0?-1:this.y+y
	this.moveIt(x,y)
}
function lib_moveIt(x,y){ //Move to a specified position
	this.x=x; this.css.left=x; 
	if(y!=-1){this.y=y; this.css.top=y}
}

//Default lib functions
function lib_obj(obj,num){
	this.num=num;	
	if(!is.is) return alert('Old browser');
	if(!is.ns4) this.evnt=is.dom && document.getElementById(obj)||is.ie4 && document.all[obj]
	else this.evnt=document.layers[obj]?document.layers[obj]:0;
	if(!this.evnt) return alert('The layer does not exist ('+obj+') - Exiting script\n\nIf your using Netscape please check the nesting of your tags!')
	this.css=is.dom||is.ie4?this.evnt.style:this.evnt;      
	this.ref=is.dom||is.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;
	*/
	//Clip values
	this.c=new Array(4)
	if((is.dom || is.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.slidTim=lib_slide.slidTim;
	this.obj = obj + "Object"; 	
	eval(this.obj + "=this");
	return this;
}
//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.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	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.ns=this.ns4||this.ns6;
	this.is=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
	return this;
}
function lib_clipTo(t,r,b,l,setwidth){ 
	this.ct=t; this.cr=r; this.cb=b; this.cl=l
	if(is.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(is.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 specified number of pixels
	//alert('bratta cr: '+this.cr);
	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(is.dom || is.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)
	}
}


