// .arena v2.0 (01.04.01)
// (C) Copyright 2001 por Emiliano Benítez, Israel Pastrana
// 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";
arena.spd = (navigator.userAgent.indexOf("Mac")!=-1)? 5 : (navigator.userAgent.indexOf("NT")!=-1)? 1 : 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";
		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;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.delChild = function(ch){ (arena.nav=="sup")? (this.nostyle.hasChildNodes()) ? this.child(ch).del() : null : (arena.nav=="ns4")? this.ref.layers[ch-1].arenaId.del() : this.nostyle.children[ch-1].arenaId.del(); }
arena.arenaIns.prototype.child = function(ch){ 
	if (arena.nav=="sup") {
		if (this.nostyle.hasChildNodes()) {
			var nodo = this.nostyle.firstChild;
			var num = 1;
			if (ch) for (var i=0; i<(ch-1); i++) nodo = nodo.nextSibiling; 
			else while(nodo!=this.nostyle.lastChild) { num++; nodo = nodo.nextSibiling; }
			return (ch || ch==0) ? nodo.arenaId : num;
		} else return (ch || ch==0) ? false : 0;
	} else {
		if (ch || ch==0) return (arena.nav=="ns4")? this.ref.layers[ch-1].arenaId : this.nostyle.children[ch-1].arenaId;
		else {
			var num = 0;
			var aux = (arena.nav=="ns4")? "this.ref.layers" : "this.nostyle.children";
			for (var i=0; i<eval(aux+".length"); i++) if (eval(aux+"["+i+"].arenaId.exist")) num++;
			return num; 
		}		
	}
}
arena.arenaIns.prototype.del = function(ch){
	if (arena.nav=="sup") {
		if (this.nostyle.hasChildNodes()) {
			var nodo = this.nostyle.firstChild;
			do {
				nodo.arenaId.exist=false
				this.nostyle.removeChild(nodo);
				if (nodo!=this.nostyle.lastChild) nodo = nodo.nextSibling;			
			} while (nodo!=this.nostyle.lastChild)
		}
		var nodo = this.nostyle.parentNode.firstChild;
		while (nodo != this.nostyle) nodo = nodo.nextSibling;
		nodo.arenaId.exist=false;
		this.nostyle.parentNode.removeChild(nodo);		
	} else {
		if (!ch) for (i=1;i<=this.child();i++) this.child(i).exist=false;
		this.hide();
		this.fill("");
		this.exist=false;	
	}
}
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.ref.left = this.x = x;
	this.ref.top = this.y = y;
}
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.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)
}
arena.arenaIns.prototype.releaseEv = function(evento, fun){ (arena.nav=="sup")? (this.nostyle.removeEventListener)? eval(this.id+".nostyle.removeEventListener('"+evento+"',"+'function(event){ '+fun+' }'+",false)") : eval(this.id+".nostyle.detachEvent('on"+evento+"',"+fun+")") : eval(this.strRef+".on"+evento+" = null"); }
