// motionDiv 1.0 - JS Object Development by Raquel,Pepe & Carlos in marchFIRST, 2001
function motionDiv(tip,obj){
	this.nav=(document.layers)?true:false;
	if(this.nav){
		this.strName='document.layers["'+obj+'"]';
		this.name=document.layers[obj];
	}else{
		this.name=document.all[obj].style;
		this.nostyle=document.all[obj];
		this.strName='document.all["'+obj+'"]';
	}
	this.nameTip=tip;
	this.x=(this.nav)?this.name.left:this.name.pixelLeft;
	this.y=(this.nav)?this.name.top:this.name.pixelTop;
	this.w=(this.nav)?this.name.clip.width:this.nostyle.offsetWidth;
	this.h=(this.nav)?this.name.clip.height:this.nostyle.offsetHeight;
	this.w2=(this.nav)?this.name.width:this.nostyle.scrollWidth;
	this.h2=(this.nav)?this.name.height:this.nostyle.scrollHeight;
	this.color=(this.nav)?this.name.bgColor:this.name.backgroundColor;
	this.ov=this.name.overflow;
	this.z=this.name.zIndex;
	this.activo=false;
	this.draging=false;
	this.xdrag=0;
	this.ydrag=0;
	this.haveFrame=false;
	this.show=motionDivShow;
	this.hide=motionDivHide;
	this.stack=motionDivStack;
	this.paint=motionDivPaint;
	this.fader=motionDivFader;
	this.faderGoo=motionDivFaderGoo;
	this.faderHex=motionDivFaderHex;
	this.move=motionDivMove;
	this.push=motionDivPush;
	this.resize=motionDivResize;
	this.clip=motionDivClip;
	this.fill=motionDivFill;
	this.mOver=motionDivMOver;
	this.mOut=motionDivMOut;
	this.mMove=motionDivMMove;
	this.mClick=motionDivMClick;
	this.mUp=motionDivMUp;
	this.mDown=motionDivMDown;
	this.cut=motionDivCut;
	this.slide=motionDivSlide;
	this.beizer=motionDivBeizer;
	this.timeWTM;
	this.whatToMove=motionWhatToMoveGoo;
	this.runGoo=motionWhatToMoveRun;
	this.faderText=motionDivFaderText;
}
function motionDivShow(){
	this.name.visibility=(this.nav)?'show':'visible';
}
function motionDivHide(){
	this.name.visibility=(this.nav)?'hide':'hidden';
}
function motionDivStack(zI){
	this.name.zIndex=zI;
}
function motionDivPaint(colH){
	 (this.nav)?this.name.bgColor=colH:this.name.backgroundColor=colH;
}
function motionDivFader(speed,res,i1,i2,i3,f1,f2,f3,text,clase,href,nextEv){
	this.datFad=new Array();
	this.datFad[0]=res;
	this.datFad[1]=0;
	this.datFad[2]=new Array();
	this.datFad[2][1]=i1;
	this.datFad[2][2]=i2;
	this.datFad[2][3]=i3;
	this.datFad[2][4]=f1;
	this.datFad[2][5]=f2;
	this.datFad[2][6]=f3;
	this.datFad[3]=speed;
	this.datFad[4]=nextEv;
	eval(this.nameTip+"hexa=new makearray(16)");
	for(var i=0;i<10;i++) eval(this.nameTip+"hexa["+i+"]="+i);
	eval(this.nameTip+"hexa[10]='a'");
	eval(this.nameTip+"hexa[11]='b'");
	eval(this.nameTip+"hexa[12]='c'");
	eval(this.nameTip+"hexa[13]='d'");
	eval(this.nameTip+"hexa[14]='e'");
	eval(this.nameTip+"hexa[15]='f'");
	this.isText=false;
	if(text){
		this.tfText=text;
		this.isText=true;
		this.tfHref=href;
	}
	if(clase) this.tfClass=clase;
	this.faderGoo();
}
function motionDivFaderHex(i){
	if(i<0) return "00";
	else if(i>255) return "ff";
	else return ""+eval(this.nameTip+"hexa[Math.floor("+i+"/16)]")+eval(this.nameTip+"hexa["+i+"%16]");
}
function motionDivFaderGoo(){
	if (this.datFad[1]<=this.datFad[0]){
		var aux1=this.datFad[1]/this.datFad[0];
		var aux2=(this.datFad[0]-this.datFad[1])/this.datFad[0];
		var hr=this.faderHex(Math.floor(this.datFad[2][1]*aux2+this.datFad[2][4]*aux1)); 
		var hg=this.faderHex(Math.floor(this.datFad[2][2]*aux2+this.datFad[2][5]*aux1)); 
		var hb=this.faderHex(Math.floor(this.datFad[2][3]*aux2+this.datFad[2][6]*aux1));
		(this.isText)?this.faderText("#"+hr+hg+hb):this.paint("#"+hr+hg+hb);
		this.datFad[1]++;
		setTimeout(this.nameTip+".faderGoo()",this.datFad[3]);
	}else{
		if(this.datFad[4]) eval(this.datFad[4]);
	}
}
function makearray(n){
	this.length=n;
	for(var i=1;i<=n;i++) this[i]=0;
	return this;
}
function motionDivFaderText(color){
	if(this.tfHref!=null){
		this.fill("<a href="+this.tfHref+" class="+this.tfClass+"><font color="+color+">"+this.tfText+"</font></a>");
	}else{
		this.fill("<span class="+this.tfClass+"><font color="+color+">"+this.tfText+"</font></span>");
	}
}
function motionDivResize(x,y){
	if(this.nav){
		eval(this.strName+'.resizeTo('+x+','+y+')');	
	}else{
		this.name.width=x;
		this.name.height=y;
		this.name.clip="rect(0px "+x+"px "+y+"px 0px)"
	}
}
function motionDivClip(r,b,t,l){
	if(this.nav){
		if(t) this.name.clip.top=t;
		this.name.clip.right=r;
 		this.name.clip.bottom=b;
 		if(l) this.name.clip.left=l;
 	}else{
		if(!t) t=0;
		if(!l) l=0;
 		this.name.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
 	}
}
function motionDivMove(x,y){
	this.x=x;
	this.y=y;
	this.name.left=this.x;
	this.name.top=this.y;
}
function motionDivPush(x,y){
	this.x+=x;
	this.y+=y;
	this.name.left=this.x;
	this.name.top=this.y;
}
function motionDivFill(puppet){
	if (this.nav){
		this.name.document.open();
		this.name.document.write(puppet);
		this.name.document.close();
	}else{
		this.nostyle.innerHTML=puppet;
	}	
}
function motionDivMOver(eve){
	eval(this.strName+".onmouseover=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEOVER)');
}
function motionDivMOut(eve){
	eval(this.strName+".onmouseout=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEOUT)');
}
function motionDivMMove(eve){
	eval(this.strName+".onmousemove=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEMOVE)');
}
function motionDivMClick(eve){
	eval(this.strName+".onclick=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.CLICK)');
}
function motionDivMUp(eve){
	eval(this.strName+".onmouseup=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEUP)');
}
function motionDivMDown(eve){
	eval(this.strName+".onmousedown=function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEDOWN)');
}
function motionDivCut(xi,yi,xf,yf,resolution,speed,kine,nextEv){
	this.whatToMove(xi,yi,xf,yf,resolution,speed,Math.round(xi+(xf-xi)/20*(10+kine)),Math.round(yi+(yf-yi)/20*(10+kine)),'this.clip',nextEv);
}
function motionDivSlide(xf,yf,resolution,speed,kine,nextEv){
	this.whatToMove(this.x,this.y,xf,yf,resolution,speed,Math.round(this.x+(xf-this.x)/20*(10+kine)),Math.round(this.y+(yf-this.y)/20*(10+kine)),'this.move',nextEv);
}
function motionDivBeizer(xf,yf,resolution,speed,xbeizer,ybeizer,nextEv){
	this.whatToMove(this.x,this.y,xf,yf,resolution,speed,xbeizer,ybeizer,'this.move',nextEv);
}
function motionWhatToMoveGoo(xi,yi,xf,yf,resolution,speed,xbeizer,ybeizer,func,nextEv){
	this.datGoo=new Array();
	this.datGoo[0]=resolution+1;
	this.datGoo[1]=speed;
	this.datGoo[2]=1;
	this.datGoo[3]=0;
	this.datGoo[4]=1/resolution;
	this.datGoo[5]=func;
	this.datGoo[6]=nextEv;
	this.datGoo[7]=new Array();
	this.datGoo[8]=new Array();
	for (i=1;i<=this.datGoo[0];i++){
		var auxS0=1-this.datGoo[3];
		var auxS1=auxS0*auxS0;
		var auxS2=this.datGoo[3]*this.datGoo[3];
		var auxS3=2*this.datGoo[3]*auxS0; 
		this.datGoo[7][i]=Math.round((auxS1*xi)+(auxS3*xbeizer)+(auxS2*xf));
		this.datGoo[8][i]=Math.round((auxS1*yi)+(auxS3*ybeizer)+(auxS2*yf));
		this.datGoo[3]=i*this.datGoo[4];	
	}
	clearTimeout(this.timeWTM);
	this.runGoo();
}
function motionWhatToMoveRun(){
	if(this.datGoo[2]<=this.datGoo[0]){
		eval(this.datGoo[5]+'('+this.datGoo[7][this.datGoo[2]]+','+this.datGoo[8][this.datGoo[2]]+')');
		this.datGoo[2]++;
		this.timeWTM=setTimeout(this.nameTip+".runGoo()",this.datGoo[1]);		
	}else{ 
		if(this.datGoo[6]) eval(this.datGoo[6]);
	}	
}