// teknoDiv 3.0 - JS Object Development by Emi in Teknoland RTT, 2000
function teknoDiv(tip,obj,child) {
	this.nav = (document.layers)? true : false;
	if (this.nav) {
		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 (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+'"]';
		}
	}
	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.timeGoo;
	this.show = teknoDivShow;
	this.hide = teknoDivHide;
	this.stack = teknoDivStack;
	this.paint = teknoDivPaint;
	this.move = teknoDivMove;
	this.push = teknoDivPush;
	this.resize = teknoDivResize;
	this.clip = teknoDivClip;
	this.clip2 = teknoDivClip2;
	this.clip3 = teknoDivClip3;
	this.fill = teknoDivFill;
	this.cut = teknoDivCut;
	this.cut2 = teknoDivCut2;
	this.cut3 = teknoDivCut3;	
	this.slide = teknoDivSlide;
	this.beizer = teknoDivBeizer;
	this.whatToMove = teknoWhatToMoveGoo;
	this.runGoo = teknoWhatToMoveRun;
	this.mOver = teknoDivMOver;
	this.mOut = teknoDivMOut;
	this.mMove = teknoDivMMove;
	this.mClick = teknoDivMClick;
	this.mUp = teknoDivMUp;
	this.mDown = teknoDivMDown;
	this.load = teknoDivLoad;
	this.bufferLoad = bufferLoad;
}

function teknoDivShow() {
	this.name.visibility = (this.nav) ? 'show' : 'visible';
}

function teknoDivHide() {
	this.name.visibility = (this.nav) ? 'hide' : 'hidden';
}

function teknoDivStack(zI) {
	this.name.zIndex = zI;
}

function teknoDivPaint(colH) {
	 (this.nav)? this.name.bgColor = colH : this.name.backgroundColor = colH;
}

function teknoDivResize(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 teknoDivClip(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 teknoDivClip2(t,l) {
	if (this.nav) {
		this.name.clip.top=t;
		this.name.clip.right=486;
 		this.name.clip.bottom=68;
 		this.name.clip.left=l;
 	} else {
 		this.name.clip = "rect("+t+"px 486px 68px "+l+"px)";
 	}
}

function teknoDivClip3(l,r) {
	if (this.nav) {
		this.name.clip.top=0;
		this.name.clip.right=r;
 		this.name.clip.bottom=68;
 		this.name.clip.left=l;
 	} else {
 		this.name.clip = "rect(0px "+r+"px 68px "+l+"px)";
 	}
}

function teknoDivMove(x,y) {
	this.x = x;
	this.y = y;
	this.name.left = this.x;
	this.name.top = this.y;
}

function teknoDivPush(x,y) {	
	this.x += x;
	this.y += y;
	this.name.left = this.x;
	this.name.top = this.y;
}

function teknoDivFill(puppet) {
	if (this.nav) { 
		this.name.document.open();
		this.name.document.write(puppet);
		this.name.document.close();
	} else {
		this.nostyle.innerHTML = puppet;
	}	
}

function teknoDivCut(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 teknoDivCut2(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.clip2',nextEv);
}

function teknoDivCut3(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.clip3',nextEv);
}

function teknoDivSlide(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 teknoDivBeizer(xf,yf,resolution,speed,xbeizer,ybeizer,nextEv) {
	this.whatToMove(this.x,this.y,xf,yf,resolution,speed,xbeizer,ybeizer,'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];	
	}
	clearTimeout(this.timeGoo);
	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]++;
		this.timeGoo=setTimeout(this.nameTip+".runGoo()",this.datGoo[1]);		
	} else { 
		if (this.datGoo[6]) eval(this.datGoo[6]);
	}	
}

function teknoDivMOver(eve) {
	eval(this.strName+".onmouseover = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEOVER)');
}

function teknoDivMOut(eve) {
	eval(this.strName+".onmouseout = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEOUT)');
}

function teknoDivMMove(eve) {
	eval(this.strName+".onmousemove = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEMOVE)');
}

function teknoDivMClick(eve) {
	eval(this.strName+".onclick = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.CLICK)');
}

function teknoDivMUp(eve) {
	eval(this.strName+".onmouseup = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEUP)');
}

function teknoDivMDown(eve) {
	eval(this.strName+".onmousedown = function(event){"+eve+"}");
	if (this.nav) eval(this.strName+'.captureEvents(Event.MOUSEDOWN)');
}


function teknoDivLoad(puppet,nextEv) {
	this.loadNE = nextEv;
	if (!this.nav) { 
		this.fill("<IFRAME STYLE='width:0pt;height:0pt' NAME="+this.tip+"Frame></IFRAME>");
		this.iframe = document.frames[this.tip+"Frame"];
	 	this.iframe.location.href = puppet;        
		this.timeLoad=setTimeout(this.nameTip+".bufferLoad()",200);	
	} else {
		bufferNSLocal = nextEv;
		if (nextEv) this.name.onload = bufferNS;
		this.name.src = puppet;
	}
}

var bufferNSLocal = "";

function bufferNS(){
	eval(bufferNSLocal);
}

function bufferLoad(nextEv) {
	if (this.iframe.document.readyState=="complete") {
		this.fill(this.iframe.document.body.innerHTML);
		this.refresh();
		if (this.loadNE) eval(this.loadNE);
	} else this.timeLoad=setTimeout(this.nameTip+".bufferLoad()",200);
}