// FrmkLayer.js


//------------------------------------------------------- Constructor
/**  Constructor */
function FrmkLayer(layerName) 
{
	this.name = layerName || "";
	if (this.name=="") this.name = this.getName();
	this.htmlCode = this.getCode();	
	this.obj = this.putLayer();
}

//------------------------------------------------------- Metodos de clase
/** Calcula el nombre del objeto */
FrmkLayer.prototype.getName = function()
{
	var c = "";
	if (is.NS4) {
		c = document.layers.length + 1;
	} else if (is.IE4 || is.IE5) {
		c = document.all("div").length + 1;
	} else if (is.IE6||is.NS6) {	
		c = document.getElementsByTagName("div").length + 1;
	}
	return "&frmkLayer" + c;
}


/** Devuelve el codigo html de este objeto */
FrmkLayer.prototype.getCode = function()
{
	var tmpCode = "";
	if (is!=null && is!=undefined) {
		tmpCode  = '<' + ((is.NS4)?'layer':'div');
		tmpCode += ' id="'+this.name+'" name="'+this.name+'" style="visibility:hidden;position:absolute;width:0;height:0">';	
		tmpCode += ((is.NS4)?'</layer>':'</div>');
	}
	return tmpCode;	
}


/** Crea la clase y devuelve el objeto layer asociado a la propiedad name */
FrmkLayer.prototype.putLayer = function()
{	
	var obj;
	if (is.NS4 || is.IE4 || is.IE5) {
		document.open();
		document.write( this.htmlCode );
		document.close();			
	} else {
		obj=document.createElement("div");
		obj.name= this.name;
		obj.visibility="hidden";
		obj.position="absolute";
		obj.width=0;
		obj.height=0;
		document.body.appendChild(obj);
	}	
	return obj;
}


/** Aņade un objeto html a la capa */
FrmkLayer.prototype.appendHtml = function(htmlCode)
{
	if (is.NS4) {
		this.obj.document.open();
		this.obj.document.write(htmlCode);
		this.obj.document.close();
	} else {
		this.obj.innerHTML = htmlCode;		
	}	
}

/** Devuelve un objeto incluido en el layer */
FrmkLayer.prototype.getChild = function(childName)
{
	var cObj = null;
	if (is.NS4){
		cObj = eval(this.obj+".document."+childName);
	} else {
		cObj = eval("document."+childName);
	} 
	return cObj;
}
