// .arena v3.0 (28.06.04)
// (C) Copyright 2001 por Emiliano Benítez[emi@latalatina.com], Israel Pastrana[isra@latalatina.com]
// 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();
	return id;
}

arena.create = function(args,nav){
	var aux = document.createElement("DIV");
	aux.style.position = "absolute";
	aux.id = "ly"+args[0];
	eval(((args[1])? eval(args[1]+".strRef") : "document.body")+".appendChild(aux)");		
}

arena.arenaIns = function(id,parent){
	this.strRef = "document.getElementById('"+id+"')";
	this.ref = eval(this.strRef+".style");
	this.nostyle = eval(this.strRef);
	this.id = id.substr(2);
	this.iniFx=[true,true];
}
arena.arenaIns.prototype.show = function(){ this.ref.visibility = "inherit"; }

arena.arenaIns.prototype.hide = function(){	this.ref.visibility = "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 = this.ref.backgroundColor = colH;
	else return this.setcolor;
}

arena.arenaIns.prototype.image = function(ima){
	if (ima) {
		this.ima = 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){
	this.nostyle.innerHTML = cont;
	if (rf) this.refresh();
}

arena.arenaIns.prototype.extract = function(ifr){
	if (ifr) this.fill(document.frames[ifr].document.all[ifr].innerHTML,true);
	return this.nostyle.innerHTML;
}

arena.arenaIns.prototype.refresh = function(){
	this.h = parseInt(this.nostyle.offsetHeight);
	this.w = 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);
	this.ref.width = w;
	this.ref.height = h;
	this.ref.clip = "rect(0 "+w+" "+h+" 0)";
}

arena.arenaIns.prototype.clip = function(r,b,l,t){
	if (!t) t = "auto";
	if (!l) l = "auto";
	this.ref.clip = "rect("+t+" "+r+" "+b+" "+l+")";
}

arena.arenaIns.prototype.clipInv = function(l,t){
	this.clip("auto","auto",l,t);
}

arena.arenaIns.prototype.cursor = function(t){
	this.ref.cursor = t;
}

arena.arenaIns.prototype.opacity = function(o){
	if(o!=null){
		var temp = this.ref.filter;
		if(!this.iniFx[0]){
			temp=temp.split("progid:");
			temp = (temp[1].indexOf("Alpha")==-1)? "progid:"+temp[1]+" " : "progid:"+temp[2]+" ";
		}
		this.ref.filter = temp + "progid:DXImageTransform.Microsoft.Alpha(opacity="+o+") ";
		this.iniFx[0]=false;
	} else{
		var aux=this.nostyle.filters.item("DXImageTransform.Microsoft.Alpha").opacity;
		return aux;
	}
}

arena.arenaIns.prototype.rotate = function(r){
    var rad=r*0.017453;
    var tmpC = Math.cos(rad);
    var tmcS = Math.sin(rad);

	var temp = this.ref.filter;
	if(!this.iniFx[1]){
		temp=temp.split("progid:");
		temp = (temp[1].indexOf("Matrix")==-1)? "progid:"+temp[1]+" " : "progid:"+temp[2]+" ";
	}
	this.ref.filter = temp + "progid:DXImageTransform.Microsoft.Matrix(M11="+tmpC+",M12="+-tmcS+",M21="+tmcS+",M22="+tmpC+",sizingMethod='auto expand',filterType = bilinear) ";
	this.iniFx[1]=false;

	this.ref.left=this.x+(this.w/2)-((this.nostyle.offsetWidth-1)/2);
	this.ref.top=this.y+(this.h/1)-((this.nostyle.offsetHeight-2)/2)
}

arena.arenaIns.prototype.scale = function(t){	if(this.iniFx[1]){
		this.ref.filter = this.ref.filter + "progid:DXImageTransform.Microsoft.Matrix(M11='1.0',sizingMethod='auto expand') ";
	}
	
	this.nostyle.filters.item("DXImageTransform.Microsoft.Matrix").M11 *= t;
	this.nostyle.filters.item("DXImageTransform.Microsoft.Matrix").M12 *= t;
	this.nostyle.filters.item("DXImageTransform.Microsoft.Matrix").M21 *= t;
	this.nostyle.filters.item("DXImageTransform.Microsoft.Matrix").M22 *= t;
	
	this.iniFx[1]=false;
}

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){ eval(this.strRef+".on"+evento+" = "+fun); }










