var layerVistaAct ="";

function layerOcultarUltimo(){
	if (layerVistaAct != "") {
		var layer = eval(layerVistaAct);
		layer.style.visibility = 'hidden';
	}
	layerVistaAct ="";
}
 
function layerVer(cual){
	layerOcultarUltimo();
	var layer = eval(cual);
	layer.style.visibility = 'visible';
	layerVistaAct = cual;
}

function layerMovContHor(layer, des) {
	layer.style.clip.left += des;
	layer.style.clip.right += des;
	layer.style.left += des;
}

function Layer_fnGenerarCapaTransparente(){
	var html = '<div id="LayerTransparente" '+
			'class="capa_transparente" '+
			'style="position: absolute; top: 0px;left: 0px;width: 100%;height: 100%;">'+
		'</div>'
	document.write(html);
}

function Layer_fnDesaparecerCapas(){
	var parametros=Layer_fnDesaparecerCapas.arguments; 
	for(i=0; i<parametros.length; i++){
		var capa = document.getElementById(parametros[i]);
		if (capa) {
			capa.style.display='none';
			capa.style.visibility='hidden';
		}
	}
}

function Layer_fnAparecerCapas(){
	var parametros=Layer_fnAparecerCapas.arguments; 
	for(i=0; i<parametros.length; i++){
		var capa = document.getElementById(parametros[i]);
		if (capa) {
			capa.style.display='';
			capa.style.visibility='visible';
		}
	}
}

function Layer_fnCentrarCapa(nombreCapa){
	var capa = document.getElementById(nombreCapa);
	if (capa) {
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		capa.style.display='';
	}
}

function WindowRaiz(){
	var win = window;
	for (x=0; x<15; x++){
		if (win.self.parent && (win != win.self.parent)){
			win = win.self.parent
			break;
		}
	}
	return win;
}

function Layer_fnCloseIframe(frameNombre){
	var win = WindowRaiz();
	var doc = win.document;
	var objBody=doc.getElementsByTagName('body');
	var objCapa1=doc.getElementById(frameNombre + '_divtr');
	var objCapa2=doc.getElementById(frameNombre + '_divif');
	if (objCapa1) objBody[0].removeChild(objCapa1); 
	if (objCapa2) objBody[0].removeChild(objCapa2);
}

function Layer_fnOpenIframe(frameNombre, url, width, height, conBorde){
	var win = WindowRaiz();
	Layer_fnOpenIframe_2(win, frameNombre, url, width, height, conBorde);
}

function Layer_fnOpenIframeSelf(frameNombre, url, width, height, conBorde){
	var win = window;
	Layer_fnOpenIframe_2(win, frameNombre, url, width, height, conBorde);
}

function Layer_fnOpenIframe_2(win, frameNombre, url, width, height, conBorde){
	if (conBorde==null) conBorde=true;
	var doc = win.document;
	var objBody=doc.getElementsByTagName('body');
	var ob=doc.createElement('div');
	ob.className = 'capa_transparente';
	ob.style.left='0px';
	ob.style.top='0px';
	ob.style.width='100%';
	ob.style.height='100%';
	ob.style.position='absolute';
	ob.id = frameNombre + '_divtr';
	objBody[0].appendChild(ob);
	
	var divif=doc.createElement('div');
	divif.style.left='0px';
	divif.style.top='0px';
	divif.style.width='100%';
	divif.style.height='100%';
	divif.style.position='absolute';
	divif.id = frameNombre + '_divif';
	objBody[0].appendChild(divif);
	
	var tabla=doc.createElement('table');
	tabla.style.width='100%';
	tabla.style.height='100%';
	tabla.border='0';
	var tbody = doc.createElement( "tbody" );
	tabla.appendChild(tbody);
	var row = doc.createElement( "tr" );
	tbody.appendChild(row);
	var cell = doc.createElement( "td" );
	cell.align='center';
	row.appendChild(cell);
	
	divif.appendChild(tabla);
	
	/*divif.onclick=function(){
		Layer_fnCloseIframe(frameNombre);
	}*/
	
	var objIframe=doc.createElement('iframe');
	objIframe.style.width=width+'px';
	objIframe.style.height=height+'px';
	objIframe.style.backgroundColor='#FFFFFF';
	if (conBorde) {
		objIframe.style.border =  '1px #006600 solid';
		objIframe.style.border =  '2px outset';
	}
	objIframe.style.padding =  '0px';
	objIframe.frameBorder = "no";
	objIframe.scrolling = "no";
	//objIframe.allowTransparency="true";
	objIframe.src = url;
	objIframe.name = frameNombre;
	objIframe.id = frameNombre;
	cell.appendChild(objIframe);
}

function Layer_fnOpenIframe_Home(frameNombre, url, top, width, height, conBorde){
	if (conBorde==null) conBorde=true;
	var win = window;//WindowRaiz();
	var doc = win.document;
	var objBody=doc.getElementsByTagName('body');
	var ob=doc.createElement('div');
	ob.className = 'capa_transparente';
	ob.style.left='0px';
	ob.style.top='0px';
	ob.style.width='100%';
	ob.style.height='1700px';
	ob.style.position='absolute';
	ob.id = frameNombre + '_divtr';
	objBody[0].appendChild(ob);
	
	var divif=doc.createElement('div');
	divif.style.left='0px';
	divif.style.top=top+'px';
	divif.style.width='100%';
	divif.style.height='100%';
	divif.style.position='absolute';
	divif.id = frameNombre + '_divif';
	objBody[0].appendChild(divif);
	
	var tabla=doc.createElement('table');
	tabla.style.width='100%';
	tabla.style.height='100%';
	tabla.style.top='0px';
	tabla.border='0';
	var tbody = doc.createElement( "tbody" );
	tabla.appendChild(tbody);
	var row = doc.createElement( "tr" );
	tbody.appendChild(row);
	var cell = doc.createElement( "td" );
	cell.align='center';
	row.appendChild(cell);
	
	divif.appendChild(tabla);
	
	/*divif.onclick=function(){
		Layer_fnCloseIframe(frameNombre);
	}*/
	
	var objIframe=doc.createElement('iframe');
	objIframe.style.top=top+'px';
	objIframe.style.width=width+'px';
	objIframe.style.height=height+'px';
	objIframe.style.backgroundColor='#FFFFFF';
	if (conBorde) {
		objIframe.style.border =  '1px #006600 solid';
		objIframe.style.border =  '2px outset';
	}
	objIframe.style.padding =  '0px';
	objIframe.frameBorder = "no";
	objIframe.scrolling = "no";
	//objIframe.allowTransparency="true";
	objIframe.src = url;
	objIframe.name = frameNombre;
	objIframe.id = frameNombre;
	cell.appendChild(objIframe);
}