// .arena v2.0 (01.04.01)
// (C) Copyright 2001 por Emiliano Benítez[emi.arena@terra.es], Israel Pastrana[isra.arena@terra.es]
// Prohibido su uso o distribucion en su totalidad o en parte del codigo sin autorizacion del autor.

function arena(id,parent,left,top,width,height,state,stack,color,cont){
	arena.create(arguments);	
	eval(id+" = new arena.arenaIns('ly"+id+"','"+ ((parent != null)? parent : '') +"')");
	id = eval(id);
	id.move(left,top);
	if (height) id.resize(width,height);
	if (stack) id.z(stack);
	if (color) id.color(color);
	if (cont) id.fill(cont,((height)? null : true));
	(state=="hide")? id.hide() : id.show();
	if (typeof(stPlace)!="undefined") stPlace.add(id); 
	return id;
}

arena.nav = (document.getElementById) ? "sup" : (document.all) ? "ie4" : "ns4";
if(arena.nav=="sup")(document.all)?arena.ie5=true:arena.ns6=true;
arena.isMac=(navigator.appVersion.indexOf("Mac")==-1)?false:true;

arena.spd = (navigator.userAgent.indexOf("Mac")!=-1)? 1/5 : (navigator.userAgent.indexOf("NT")!=-1)? 3 : 1/5;

arena.speed = function(time){ return Math.round(time*arena.spd); }

arena.create = function(args,nav){
	var idm = "ly"+args[0];
	if (arena.nav=="sup"){ 
		var aux = document.createElement("DIV");
		aux.style.position = "absolute";
		aux.id = idm;
		aux.style.width = args[4]+"px";
		aux.style.left = args[2]+"px";
		aux.style.top = args[3]+"px";
		eval(((args[1])? eval(args[1]+".strRef") : "document.body")+".appendChild(aux)");
	} 
	
	//else (arena.nav=="ns4") ? (args[1])? eval(eval(args[1]+".strRef")+'.document.layers["'+idm+'"] = new Layer('+args[4]+','+eval(args[1]+".strRef")+')') : document.layers[idm] = new Layer(args[4]) : eval(((args[1])? eval(args[1]+".strRef") : "document.body")+".insertAdjacentHTML('BeforeEnd','<DIV id="+idm+" style=position:absolute; left:0px; top:0px; width:"+args[4]+"></DIV>')");
}

arena.arenaIns = function(id,parent){
	var aux = (arena.nav=="sup")? "document.getElementById('"+id+"')" : (((arena.nav == "ns4")? "document.layers['" : "document.all['")+id+"']");
	this.strRef = (parent && arena.nav!="sup")? eval(parent+".strRef")+"."+aux : aux;
	this.ref = (arena.nav=="ns4")? eval(this.strRef) : eval(this.strRef+".style");
	(arena.nav=="ns4")? this.refDoc = eval(this.strRef+".document") : this.nostyle = eval(this.strRef);
	this.id = id.substr(2);
	this.exist=true;	
	(arena.nav=="ns4")? this.ref.arenaId=this : this.nostyle.arenaId=this;
	this.parent = (arena.nav=="ns4")? this.ref.parentLayer.arenaId : (arena.nav=="ie4")? this.nostyle.parentElement.arenaId : this.nostyle.parentNode.arenaId;
	this.w = (arena.nav=="ns4")? this.ref.clip.width : this.nostyle.offsetWidth;
}

arena.arenaIns.prototype.show = function(){ this.ref.visibility = "inherit"; }

arena.arenaIns.prototype.hide = function(){	this.ref.visibility = (arena.nav=="ns4")? "hide" : "hidden"; }

arena.arenaIns.prototype.z = function(zI){
	if (zI) this.ref.zIndex = this.setz = zI;
	else return this.setz;
}

arena.arenaIns.prototype.color = function(colH){
	if (colH) this.setcolor = (arena.nav=="ns4")? this.refDoc.bgColor = colH : this.ref.backgroundColor = colH;
	else return this.setcolor;
}

arena.arenaIns.prototype.image = function(ima){
	if (ima) {
		this.ima = ima;
		(arena.nav=="ns4")? this.ref.background.src = ima : this.ref.backgroundImage = "url("+ima+")";
	} else return this.ima;
}

arena.arenaIns.prototype.move = function(x,y){
	this.x = x;
	this.ref.left = x + "px";
	this.y = y;
	this.ref.top = y + "px";
}

arena.arenaIns.prototype.push = function(x,y){ this.move(this.x+x,this.y+y); }

arena.arenaIns.prototype.fill = function(cont,rf){
	if (arena.nav=="ns4") {
		this.refDoc.open();
		this.refDoc.write(cont);
		this.refDoc.close();
	} else this.nostyle.innerHTML = cont;
	if (rf) this.refresh();
}

arena.arenaIns.prototype.refresh = function(){
	this.h = (arena.nav=="ns4")? this.refDoc.height : (arena.nav=="ie4") ? parseInt(this.nostyle.scrollHeight) : parseInt(this.nostyle.offsetHeight);
	this.w = (arena.nav=="ns4")? this.refDoc.width : (arena.nav=="ie4") ? parseInt(this.nostyle.scrollWidth) : parseInt(this.nostyle.offsetWidth);
	this.clip(this.w,this.h,0,0);
}

arena.arenaIns.prototype.resize = function(w,h){
	this.w = (w||this.w);
	this.h = (h||this.h);
	if (arena.nav=="ns4") {
		this.ref.resizeTo(w,h);
		this.clip(w,h);	
	} else {
		this.ref.width = (arena.nav=="sup") ? w+"px" : w;
		this.ref.height = (arena.nav=="sup") ? h+"px" : h;
		this.ref.clip = "rect(0px "+w+"px "+h+"px 0px)";
	}
}

arena.arenaIns.prototype.clip = function(r,b,t,l){
	if (arena.nav=="ns4") {
		if (t) this.ref.clip.top = t;
		this.ref.clip.right = r;
		this.ref.clip.bottom = b;
		if (l) this.ref.clip.left = l;
	} else {
		if (!t) t=0;
		if (!l) l=0;
		this.ref.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)";
		if (arena.nav=="sup" && this.visibility!="hidden") { this.hide();this.show(); }
	}
}

arena.arenaIns.prototype.clipInv = function(t,l){
	this.clip(800,64,t,l);
}

arena.arenaIns.prototype.mOver = function(fun){ this.eventCapture("mouseover","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mOut = function(fun){ this.eventCapture("mouseout","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mMove = function(fun){ this.eventCapture("mousemove","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mClick = function(fun){ this.eventCapture("click","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mDClick = function(fun){ this.eventCapture("dblclick","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mUp = function(fun){ this.eventCapture("mouseup","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.mDown = function(fun){ this.eventCapture("mousedown","function(event){ "+fun+" }"); }

arena.arenaIns.prototype.eventCapture = function(evento,fun){
	if (arena.nav=="ns4") eval(this.strRef+".captureEvents(Event."+evento.toUpperCase()+")");
	eval(this.strRef+".on"+evento+" = "+fun)
}
