
/*#####################################################

          Libreria de funciones para manejo de capas

		  (C) Grupo5.com By Eduardo Fernandez Martínez
          http://www.grupo5.com




#####################################################*/


/*#####################################################
###  Funcion que OCULTA UNA CAPA
#####################################################*/
function oculta_div(id) {
		/*safe function to hide an element with a specified id*/
		if (document.getElementById) { /* DOM3 = IE5, NS6*/
		   if (typeof(document.getElementById(id))!='undefined' ){
			   document.getElementById(id).style.display = 'none';
		   }else{
			   document.write("Elemento ["+id+"] No encontrado");
		   }
		}else {
			if (document.layers) { /* Netscape 4*/
				document.id.display = 'none';
			}else { /* IE 4 */
				document.all.id.style.display = 'none';
			}
		}
}

/*#####################################################
###  Funcion que MUESTRA una capa
#####################################################*/

//Funcion que muestra un elemento div - con un id determinado
function muestra_div(id) {

	   if (typeof(id)=='undefined' ){ alert (id+" undefined"); }

		if (document.getElementById) { /* DOM3 = IE5, NS6 */
		   if (document.getElementById(id)){ document.getElementById(id).style.display = 'block'; }
		}else {
			if (document.layers) { /* Netscape 4*/
				document.id.display = 'block';
			}else { /* IE 4 */
				document.all.id.style.display = 'block';
			}
		}
}

/*####################################################################
###  Funcion que MUESTRA / OCULTA una capa en funciona del estado
####################################################################*/
function muestra_oculta_div(id) {

	if (document.getElementById) { /* DOM3 = IE5, NS6*/
		if (document.getElementById(id).style.display != 'none'){
			document.getElementById(id).style.display = 'none';
		}else{
			document.getElementById(id).style.display = 'block';
		}
	}else {
		if (document.layers) { /* Netscape 4 */
			if ( document.id.display != 'none' ){
				document.id.display = 'none';
			}else{
				document.id.display = 'block';
			}
		}else { /* IE 4*/
		    if (document.all.id.style.display != 'none'){
			   document.all.id.style.display = 'none';
			}else{
				document.all.id.style.display = 'block';
			}
		}
	}
}





/*#####################################################
###  Funcion que CARGA CONTENIDO EN UNA CAPA
#####################################################*/
function carga_div(capa,contenido){	
	if (document.getElementById) { /*  DOM3 = IE5, NS6*/
	    document.getElementById(capa).innerHTML = contenido;
	}else{
	    if (document.layers) { // Netscape 4
			document.capa.innerHTML = contenido;
	    }else{
			document.all.capa.innerHTML = contenido;
		}
	}
}

/*#####################################################
###  IMPRIMIR EL CONTENIDO DE UNA CAPA
#####################################################*/
function imprimir_capa(capa) {
   var ventana = window.open("", "", "");
   var contenido = "<style>.impresion {text-decoration: none;font-family: Tahoma;font-size: 6pt;color: black;}</style>";
   contenido += "<html><body onload='window.print();window.close();'>" + document.getElementById(capa).innerHTML + "</body></html>";
   ventana.document.open();
   ventana.document.write(contenido);
   ventana.document.close();
}



/*#####################################################
###  CREAR UNA CAPA DINAMICAMENTE
#####################################################*/
function crear_capa(id, html, width, height, left, top,center) {
   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);
   newdiv.style.background = "#FFFF99";
   newdiv.style.border = "1px solid #C0C0C0";

   if (html) {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }
   
   if (width) {newdiv.style.width = width;}
   if (height) { newdiv.style.height = height; }

   if (center && center=='center' ){
	   newdiv.style.position = "absolute";
	   newdiv.style.left = (screen.width/2)-(width/2);
	   newdiv.style.top = (screen.height/2)-(height/2)-100;// Restamos 200px para contrarestar las barras del explorador
   }else{
	   if ((left || top) || (left && top)) {
		   newdiv.style.position = "absolute";
		   if (left) {newdiv.style.left = left;}
		   if (top) {newdiv.style.top = top;}
	   }
   }
   
   document.body.appendChild(newdiv);
}



/*#####################################################
###  CREAR IFRAME DINAMICAMENTE
#####################################################*/
function crear_iframe(id, iframe, width, height, left, top,center) {
	//crear_capa(id,'aqui el iframe de '+width+'x'+height, width, height, left, top,center);
	crear_capa(id,'<iframe src="'+iframe+'&capa='+id+'"  width="'+width+'" height="'+height+'" frameborder="0" scrolling="no">Su explorador no soporta marcos, actualize su explorador.</iframe>', width, height, left, top,center);
}


/*#####################################################
###  Funcion que elimina UNA CAPA en caliente
#####################################################*/
function eliminar_div(id) {

		/*safe function to hide an element with a specified id*/
		if (document.getElementById) { /* DOM3 = IE5, NS6*/
		   if (typeof(document.getElementById(id))!='undefined' ){
			   oculta_div(id);
			   eliminar_div=document.getElementById(id);
	   		   document.body.removeChild(eliminar_div);
		   }else{
   			   alert("ELIMINANDO ["+id+"]["+eliminar_div+"] ");
		   }
		}else {
			if (document.layers) { /* Netscape 4*/
			     alert("Explorer no compatible no se puede eliminar la capa ["+id+"] ");
			}else { /* IE 4 */
				 alert("Explorer no compatible no se puede eliminar la capa ["+id+"] ");
			}
		}
}



