var activa=null;

function mostrarcapa(nombrecapa)
{	
	obj=eval(document.getElementById(nombrecapa));
	
	if (activa!=null && activa==obj)
	 {
		ocultarcapa();
		activa=null;
	 }
	else
	 {
		obj.style.visibility="visible";
		activa=obj;
	 }
}

function ocultarcapa()
 {
	if (activa!=null) 
	{ 
	    activa.style.visibility="hidden";
	}
 }
  
 function precarga()
 { 
	if (!document.images) return;
	var imagen= new Array();
	var param=precarga.arguments;
	for(var i=0;i<param.length;i++)
	 {
		imagen[i]=new Image();
		imagen[i].src="./Imagenes/"+param[i];
	 }
 }

function CargaPopUp()
{
    var Url = "../PopUp.html";
     
    var Ventana = window.open(Url, '', 'width=410, height=410')
    Ventana.moveTo(350,150); 
}

function redimBorde()
{
    var alto = document.getElementById("VisorCentro").offsetHeight;

	if (alto <= 840)
      alto = 840;
    
	document.getElementById('BordeIzquierdo').style.height = alto+"px";
    document.getElementById('BordeDerecho').style.height = alto+"px";
}

function redimBordeCom()
{
    var alto2 = document.getElementById("VisorCentroCom").offsetHeight;

    if (alto2 <= 840)
      alto2 = 840;

    document.getElementById('BordeIzquierdoCom').style.height = alto2+"px";
    document.getElementById('BordeDerechoCom').style.height = alto2+"px";
}

function redimBordeAdm()
{
    var alto3 = document.getElementById("VisorCentroAdm").offsetHeight;

    document.getElementById('BordeIzquierdoAdm').style.height = alto3+"px";
    document.getElementById('BordeDerechoAdm').style.height = alto3+"px";
}

function cambiarcapa(nombrecapa,valor)
 {	
	if (document.layers) //Navigator 4.x
	 {
		obj=document.layers[nombrecapa]
		obj.document.Open();
		obj.document.write("<font face='Tahoma' size='1' color='#0077A5'>"+valor+"</font>");
		obj.document.Close();
	 }
	else if (document.all && !document.getElementById) //IExplorer 4
	 {
		obj=eval(document.all[nombrecapa]);
		obj.innerHTML="<font face='Tahoma' size='1' color='#0077A5'>"+valor+"</font>";
	 }
	else //Netscape 6.x y + IExplore 5.x y +
	 {	
		obj=eval(document.getElementById(nombrecapa));
		obj.innerHTML="<font face='Tahoma' size='1' color='#0077A5'>"+valor+"</font>";
	 }
 }

function actual()
 {
	 valor=document.forms[2].dom.options[document.forms[2].dom.selectedIndex].value;
	 cambiarcapa("denvio",dir[valor]);
	 cambiarcapa("cpenvio",cp[valor]);
	 cambiarcapa("localidadenvio",loc[valor]);
	 cambiarcapa("provinciaenvio",pro[valor]);
	 cambiarcapa("telefonoenvio",tel[valor]);
	 document.forms[2].elements[1].value=del[valor];
	 document.forms[2].elements[3].value=pro[valor];
	 document.forms[2].elements[4].value=loc[valor];
 }
 

function validaInputBuscador(obj,e) 
{ 
    tecla = (document.all) ? e.keyCode : e.which; 
    
    if ((tecla == 39) || (tecla == 42 ))
    { 
        alert('Simbolo No Permitido'); 
        return false; 
    }
    else
    {
        if ((tecla == 13) && (document.getElementById("CadenaBusqueda").value == ""))
        {
            alert('DEBE INDICAR UN TERMINO DE BUSQUEDA'); 

            return false; 
        }
    }
    
}

function validaClickBuscador(obj) 
{ 
    if (obj == "")
    { 
        alert('DEBE INDICAR UN TERMINO DE BUSQUEDA'); ; 
        return false; 
    } 
}

function validaInputLogin(obj,e) 
{ 
    tecla = (document.all) ? e.keyCode : e.which; 
    
    if (((tecla > 32) && (tecla < 48 )) || ((tecla > 57) && (tecla < 65 )))
    {
        alert('Simbolo No Permitido'); 
        return false; 
    } 
} 

function imprimir()
{
    var contenido = document.getElementById("VisorCentro").innerHTML;
    var ventana= window.open(' ', 'popimpr');

    ventana.document.write('<html><head><title>VISTALEGRE, Suministro Integral, Material Oficina, Mobiliario Oficina, Material Escolar, Papeleria, Informatica, Audiovisuales, consumibles</title><link rel="stylesheet" type="text/css" href="./EstilosImpresion.css" media="ALL" /></head><body>');
    ventana.document.write(contenido);
    ventana.document.write('</body></html>');
    ventana.document.close();
    ventana.print();
    ventana.close();

}

function ImprimirComercial()
{
    var contenido = document.getElementById("VisorCentroCom").innerHTML;
    var ventana= window.open(' ', 'popimpr');

    ventana.document.write('<html><head><title>VISTALEGRE, Suministro Integral, Material Oficina, Mobiliario Oficina, Material Escolar, Papeleria, Informatica, Audiovisuales, consumibles</title><link rel="stylesheet" type="text/css" href="./EstilosImpresion.css" media="ALL" /></head><body>');
    ventana.document.write(contenido);
    ventana.document.write('</body></html>');
    ventana.document.close();
    ventana.print();
    ventana.close();

}
