// motionDiv 2 - JS Object Development by Raquel,Pepe & Carlos in marchFIRST, 2001
// Añadidos:
//  - gestión de capas anidadas
//  - función para realizar el rollover
//	- compatibilidad con NS 6
function motionDiv(tip,obj,child) {
	this.ie=(document.all)? true:false;
	this.nn4=(document.layers)? true:false;
	this.nn6=(!document.all && document.getElementById)? true:false;
	if (this.nn4) {
		this.strName = 'document.layers["'+obj+'"]';
		if (child) {
			this.name = document.layers[obj].document.layers[child];
			this.strName += '.document.layers["'+child+'"]';
		} else {
			this.name = document.layers[obj];
		}
	}else if(this.ie){
		if (child) {
			this.name = document.all[child].style;
			this.nostyle = document.all[child];
			this.strName = 'document.all["'+child+'"]';
		} else {
			this.name = document.all[obj].style;
			this.nostyle = document.all[obj];
			this.strName = 'document.all["'+obj+'"]';
		}
	}else if(nn6){
		this.name = document.getElementById(arguments[1]).style;
		this.nostyle = document.getElementById(arguments[1]);
		this.strName = document.getElementById(arguments[1]);
	}
	this.nameTip = tip;
	this.x = (this.ie) ? this.name.pixelLeft : this.name.left;
	this.y = (this.ie) ? this.name.pixelTop : this.name.top;
	this.w = (this.nn4)? this.name.clip.width : this.nostyle.offsetWidth;
	this.h = (this.nn4)? this.name.clip.height : this.nostyle.offsetHeight;
	this.w2 = (this.nn4)? this.name.width : this.nostyle.scrollWidth;
	this.h2 = (this.nn4)? 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.ident;
	this.direccion;
	this.clasemout;
	this.clasemover;
	this.contenedor;
	this.cadena;
	this.gotoA;
	this.gotoB;
	this.show = motionDivShow;
	this.hide = motionDivHide;
	this.move = motionDivMove;
	this.slide = motionDivSlide;
	this.whatToMove = teknoWhatToMoveGoo;
	this.runGoo = teknoWhatToMoveRun;
}
function motionDivShow() {
	this.name.visibility = (this.nn4) ? 'show' : 'visible';
}
function motionDivHide() {
	this.name.visibility = (this.nn4) ? 'hide' : 'hidden';
}
function motionDivMove(x,y) {
	this.x = x;
	this.y = y;
	this.name.left = this.x;
	this.name.top = this.y;
}
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 motionDivSlide(xf,yf,resolution,speed,kine,nextEv){
	this.whatToMove(parseInt(this.x),parseInt(this.y),xf,yf,resolution,speed,Math.round(parseInt(this.x)+(xf-parseInt(this.x))/20*(10+kine)),Math.round(parseInt(this.y)+(yf-parseInt(this.y))/20*(10+kine)),'this.move',nextEv);
}
function teknoWhatToMoveGoo(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];	
	}
	this.runGoo();
}
function teknoWhatToMoveRun() {
	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]++;
		setTimeout(this.nameTip+".runGoo()",this.datGoo[1]);		
	} else { 
		if (this.datGoo[6]) eval(this.datGoo[6]);
	}	
}
