/**********************************************
acDiv.js -x/01/01
Autor: jaime.crespillo.vilchez
Comentarios: azulcore@mixmail.com
************************************************/
function acDiv(capa,x,y,z,w,h,visibility,bgcolor,contenido){
	acCreator(capa,x,y,z,w,h,visibility,bgcolor,contenido);
	this.w=w;
	this.h=h;
	this.ie4=(document.all)? true:false;
	this.name = (this.ie4) ? document.all[capa] : document.layers[capa];	
	this.nST = (this.ie4) ? this.name.style : document.layers[capa];
	this.strName = (this.ie4) ? 'document.all["'+capa+'"]' : 'document.layers["'+capa+'"]';
	this.nom = capa;
}
acDiv.prototype.refresh=function (x,y,z,w,h,color,str){
	if(x!=null) this.setLeft(x);
	if(y!=null) this.setTop(y);
	if(z!=null) this.setZindex(z);
	if(w!=null)	this.setClipWidth(0,w);
	if(h!=null)	this.setClipHeight(0,h);
	if(color!=null)	this.setColor(color);
	if(str!=null) this.writeString(str);
}
acDiv.prototype.writeString=function wDivTD(contenido){
	if(this.ie4){
		this.name.innerHTML = contenido;
	} else {
		this.name.document.open();
		this.name.document.write(contenido);
		this.name.document.close();	
	}
}
acDiv.prototype.show=function (){this.nST.visibility = 'visible';}
acDiv.prototype.hide=function (){this.nST.visibility = 'hidden';}
acDiv.prototype.setLeft=function (l){ this.nST.left=l;}
acDiv.prototype.setTop=function (t){this.nST.top=t;}
acDiv.prototype.getTop=function (){return parseInt(this.nST.top);}
acDiv.prototype.getLeft=function (){return parseInt(this.nST.left);}
acDiv.prototype.setXY=function (x,y){this.setLeft(x);this.setTop(y);}
acDiv.prototype.setZindex=function (z){this.nST.zIndex=z;}
acDiv.prototype.getZindex=function (){return this.nST.zIndex;}
acDiv.prototype.getHeight=function getHeight(){
	if(this.ie4) return this.name.offsetHeight;
	else return this.name.document.height;
}
acDiv.prototype.getWidth=function getWidth(){
	if(this.ie4) return this.name.offsetWidth;
	else return this.name.document.width;
}
acDiv.prototype.setColor=function(color){(this.ie4) ? this.nST.backgroundColor=color : this.nST.bgColor=color;}
acDiv.prototype.setClipWidth=function(left,width){
	this.w=width;
	if(this.ie4){
		this.nST.clip="rect(0px,"+this.w+"px,"+this.h+"px,"+left+"px)";
	}else{
		this.nST.clip.width=width;
		this.nST.clip.left=left;}
}
acDiv.prototype.setClipHeight=function(top,height){	
	this.h=height;
	if(this.ie4){
		this.nST.clip="rect("+top+"px,"+this.w+"px,"+this.h+"px,0px)";
	}else{
		this.nST.clip.height=height;
		this.nST.clip.top=top;}
}
acDiv.prototype.setClip=function(left,top,width,height){
	this.h=height;
	this.w=width;
	if(this.ie4){
		this.nST.clip="rect("+top+"px,"+this.w+"px,"+this.h+"px,"+left+"px)";
	}else{
		this.nST.clip.right=this.w;
		this.nST.clip.left=left;
		this.nST.clip.height=this.h;
		this.nST.clip.bottom=height;}
}
acDiv.prototype.mOver=function(e){
	eval(this.strName+".onmouseover = function(event){"+e+"}");
	if(!this.ie4) eval(this.strName+".captureEvents(Event.MOUSEOVER)");
}
acDiv.prototype.mOut=function(e){
	eval(this.strName+".onmouseout = function(event){"+e+"}");
	if(!this.ie4) eval(this.strName+".captureEvents(Event.MOUSEOUT)");
}
acDiv.prototype.mOnClick=function(e){
	eval(this.strName+".onclick = function(event){"+e+"}");
	if(!this.ie4) eval(this.strName+".captureEvents(Event.CLICK)");
}
acDiv.prototype.mOnDown=function(e){
	eval(this.strName+".onmousedown = function(event){"+e+"}");
	if(!this.ie4) eval(this.strName+".captureEvents(Event.MOUSEDOWN)");
}
acDiv.prototype.mOnUp=function(e){
	eval(this.strName+".onmouseup = function(event){"+e+"}");
	if(!this.ie4) eval(this.strName+".captureEvents(Event.MOUSEUP)");
}
acDiv.prototype.drageando=false;
acDiv.prototype.drag=function (e){
	this.xC = (!this.ie4)? e.pageX : event.x+document.body.scrollLeft;
	this.yC = (!this.ie4)? e.pageY : event.y+document.body.scrollTop;
	if(this.drageando){
		this.setLeft(this.xC);
		this.setTop(this.yC);
	}return true;
}
// acCreator based on teknoCreator 1.0 (Emi)
function acCreator(id,left,top,stack,width,height,visibility,vcolor,contenido) {
	var nav = (document.all)? true : false;
	if (!nav) {
		document.layers[id] = new Layer(width);
		var aux = document.layers[id];
		aux.name = id;
		aux.left = left;
		aux.top = top;
		if(height!=null){ aux.clip.height = height }
		if (vcolor != null) { aux.bgColor = vcolor }
		aux.visibility = visibility;
		aux.zIndex = stack 
		if (contenido != null) {
			aux.document.open();
			aux.document.write(contenido);
			aux.document.close();
		}
	} else {
		var aux = '<DIV id=' + id + ' style="position:absolute;left:' + left + ';top:' + top + ';width:' + width;
		if(height!=null){
			aux += '; height:' + height;
			aux += '; clip:rect(0,'+width+','+height+',0)';
		}
		if (vcolor != null) { aux += '; background-color:' + vcolor }	
		(visibility == "hide")? aux += '; visibility:hidden' : aux += '; visibility:'+visibility;
		//aux +=';visibility:'+visibility;
		aux += '; z-index:' + stack
		aux += '">';
		if (contenido != null) { aux += contenido }
		aux += '</DIV>';
		document.body.insertAdjacentHTML("BeforeEnd",aux);
	}
}
