
// <script language="javascript">

 	var totalLayersInLoop=4;
	var layerNumShowing=1;

	function init(){
       	  if (navigator.appName == "Netscape") {
		    layerStyleRef="layer.";
 			layerRef="document.layers";
			styleSwitch="";

			}else{
 			layerStyleRef="layer.style.";
			layerRef="document.all";
 			styleSwitch=".style";
			} 	}

	function showLayerNumber(number){
 		var layerNumToShow=number;
		hideLayer(eval('"layer' + layerNumShowing+'"'));
 		showLayer(eval('"layer' + layerNumToShow+'"'));
 		layerNumShowing=layerNumToShow;	 	}

	function showPreviousLayer(){
		var layerNumToShow=layerNumShowing-1;
		if (layerNumToShow < 1){layerNumToShow=totalLayersInLoop;}
		hideLayer(eval('"layer' + layerNumShowing+'"'));
		showLayer(eval('"layer' + layerNumToShow+'"'));
		layerNumShowing=layerNumToShow; 	}

	function showNextLayer(){
		var layerNumToShow=layerNumShowing+1;
		if (layerNumToShow > totalLayersInLoop){layerNumToShow=1;}
		hideLayer(eval('"layer' + layerNumShowing+'"'));
		showLayer(eval('"layer' + layerNumToShow+'"'));
		layerNumShowing=layerNumToShow; 	}

	function showLayer(layerName){
 		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"'); 	} 	

	function hideLayer(layerName){
 		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"'); 	} 

/*-----------------------------------------------------------------------------------------------*/		
	function popUp1(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=800,left = 490,top = 325');");
		}

/*-----------------------------------------------------------------------------------------------*/		

	function popUp2(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=600,left = 490,top = 325');");
		}

/*-----------------------------------------------------------------------------------------------*/		

	function popUp3(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=800,height=500,left = 50,top = 75');");
		}

/*-----------------------------------------------------------------------------------------------*/		


	
// Esta función cargará las paginas
function llamarasincrono(url, id_contenedor){
var pagina_requerida = false
if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
pagina_requerida = new XMLHttpRequest()
} else if (window.ActiveXObject){ // pero si es IE
try {
pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){ // en caso que sea una versión antigua
try{
pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
pagina_requerida.onreadystatechange=function(){ // función de respuesta
cargarpagina(pagina_requerida, id_contenedor)
}
pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
pagina_requerida.send(null)
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor){
if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText
}		

/*-----------------------------------------------------------------------------------------------*/	

function validarEmail(cadena) {
var a = cadena.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;

if (a.length == 0 )
return true;

if (filter.test(a))
return true;
else
alert("Por favor, debe ingresar una dirección de correo válida");

cadena.focus();
return false;
}

/*-----------------------------------------------------------------------------------------------*/	

function ValidarFormulario(contacto) { 


if (contacto.nombre.value == ""){ 
    alert("Por favor ingrese su nombre"); contacto.nombre.focus(); return; 
} 

if (contacto.telefono.value == "") { 
    alert("Por favor ingrese su número de teléfono"); contacto.telefono.focus(); return; 
} 


if (isNaN(contacto.telefono.value) == true) { 

    alert("Teléfono inválido.\nIngrese su teléfono solo con caracteres numéricos");  
    contacto.telefono.focus(); contacto.telefono.select(); return; 
} 

if (contacto.email.value == "") { 
    alert("Por favor ingrese su dirección de e-mail"); contacto.email.focus(); return; 
} 


if (contacto.email.value.indexOf('@', 1) == -1 || contacto.email.value.indexOf('.',  
    contacto.email.value.indexOf('@', 0)) == -1) { 
    alert("Dirección de e-mail inválida"); contacto.email.focus(); return; 
} 

if (contacto.mensaje.value == "") { 
    alert("Por favor escriba su mensaje");  
    contacto.mensaje.focus(); return; 
} 

/* Se envía el formulario */ 
contacto.submit(); 

} 


