function mail(texto){ 

    var mailres = "ok";             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = "no"; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = "ok"; 
    else 
     mailres = "no"; 
                 
    return mailres; 
} 




function check_form(){
if (document.Datos.nombre.value == ""){
	alert ("ERROR: NO HA INTRODUCIDO EL NOMBRE");
	document.Datos.nombre.focus();
	return false;
}
if (document.Datos.apellidos.value == ""){
	alert ("ERROR: NO HA INTRODUCIDO LOS APELLIDOS");
	document.Datos.apellidos.focus();
	return false;
}
if (document.Datos.movil.value == ""){
	alert ("ERROR: NO HA INTRODUCIDO EL TELEFONO MOVIL");
	document.Datos.movil.focus();
	return false;
}

//if  (document.getElementById("txtlegal2").checked == false){ 
	//alert("Por favor, acepte la politica de privacidad"); 
	//return false; 
//}

var mov = document.Datos.movil.value;
if ((mov.charAt(0) != '6' && mov.charAt(0) != '7')||(mov.length != 9)){
	alert ("ERROR: EL NUMERO MOVIL INTRODUCIDO ES ERRONEO");
	document.Datos.movil.focus();
	document.Datos.movil.select();
	return false;
}
if ((mov == '666666666') || (mov == '611111111') || (mov == '622222222') || (mov == '633333333') || (mov == '644444444') || (mov == '655555555') || (mov == '677777777') || (mov == '688888888') || (mov == '699999999') || (mov == '600000000') || (mov == '612345678')){
	alert ("ERROR: EL NUMERO MOVIL INTRODUCIDO ES ERRONEO");
	document.Datos.movil.focus();
	document.Datos.movil.select();
	return false;
}

var valido_email = mail(document.Datos.email.value);
/*if (valido_email == "no"){
	alert ("ERROR: EL EMAIL INTRODUCIDO NO ES CORRECTO");
	document.Datos.email.focus();
	document.Datos.email.select();
	return false;
}*/
		if ((document.Datos.telefono.value == "") && (document.Datos.opciones[0].checked)){
			alert ("ERROR: NO HA INTRODUCIDO EL NUMERO DE TELEFONO DONDE DESEA EL ADSL");
			document.Datos.telefono.focus();
			document.Datos.telefono.select();
			return false;
		}
		
		if ((document.getElementById("txtlegal2").checked == false) && (document.Datos.opciones[0].checked)){
			alert("Por favor, acepte la politica de privacidad");
			return false;
		}
		
		
		//if  (document.getElementById("txtlegal2").checked == false){ 
	//alert("Por favor, acepte la politica de privacidad"); 
	//return false; 
//}

		
		else{
			if ((document.Datos.opciones[1].checked) || (document.Datos.opciones[2].checked)){
			 if (document.Datos.direccion.value == "")
			 {
			  alert ("ERROR: NO HA INTRODUCIDO LA DIRECCION DONDE DESEA EL ADSL");
			  document.Datos.direccion.focus();
			  document.Datos.direccion.select();
			  return false;
			 }
			 if (document.Datos.numero.value == "")
			 {
			  alert ("ERROR: NO HA INTRODUCIDO EL NUMERO DE LA DIRECCION DONDE DESEA EL ADSL");
			  document.Datos.numero.focus();
			  document.Datos.numero.select();
			  return false;
			 }
			 if (document.Datos.poblacion.value == "")
			 {
			  alert ("ERROR: NO HA INTRODUCIDO LA POBLACION DONDE DESEA EL ADSL");
			  document.Datos.poblacion.focus();
			  document.Datos.poblacion.select();
			  return false;
			 }
			 if (document.Datos.provincia.value == "")
			 {
			  alert ("ERROR: NO HA INTRODUCIDO LA PROVINCIA DONDE DESEA EL ADSL");
			  return false;
			 }
			 if (document.getElementById("txtlegal3").checked == false)
			 {
			  alert("Por favor, acepte la politica de privacidad"); 
			  return false;
			 }

		    }
			
			//	var telf = document.Datos.telefono.value;
			//	if ((telf.charAt(0) != '9' && telf.charAt(0) != '8')||(telf.length != 9) && (document.Datos.opciones[0].checked)){
			//		alert ("ERROR: EL NUMERO DE TELEFONO DE ADSL ES INCORRECTO");
			//		document.Datos.telefono.focus();
				//	document.Datos.telefono.select();
				//	return false;
			//	}
			//	else{
				//	if(document.layers){
				//		document.layers['carga'].style.visibility='show'; 
				//	}
				//	if(document.all){
				//		document.all('carga').style.visibility='visible';
				//	}
			//	document.forms['Datos'].submit();
				//enviando = new Image();enviando.src = "img/load.gif";document['enviando'].src = enviando.src;return false;
			//	}
			}
         //document.forms['Datos'].submit();//enviando = new Image();enviando.src = "img/load.gif";document['enviando'].src = enviando.src;return false;
}
function numbers(evt) { 
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && (charCode < 48 || charCode > 57)) { 
        return false; 
    } 
    return true; 
 } 

function visualizar(opcion){
if (opcion == '1'){
	if(document.layers){
		document.layers['direccion'].style.visibility='hide';
		document.layers['telefono'].style.visibility='show'; 
	}
	if(document.all){
		document.all('direccion').style.visibility='hidden';
		document.all('telefono').style.visibility='visible';
	}
}

if (opcion ==  '2'){
	if(document.layers){
		document.layers['direccion'].style.visibility='show';
		document.layers['telefono'].style.visibility='hide'; 
	}
	if(document.all){
		document.all('direccion').style.visibility='visible';
		document.all('telefono').style.visibility='hidden';
	}	
}
}


// incializamos que no se vea ningún despegable

var mostrar_adsl_tv_j = '0';
var mostrar_adsl_j = '0';
var mostrar_adsl_tv = '0';
var mostrar_adsl = '0';
var mostrar_voz = '0';


function Mostrar(caso) {
  if (!document.getElementById) return false;
  fila_tel = document.getElementById('telefonica');
  fila_otro = document.getElementById('otro');
  fila_no = document.getElementById('no_tel');  
  
  if (caso == '1'){
	  	fila_tel.style.display = ""; //mostrar fila 
		fila_otro.style.display = "none"; //ocultar fila
		fila_no.style.display = "none"; //ocultar fila
		document.images["img_tel"].src = "img/activo.jpg";
		document.images["img_otro"].src = "img/no_activo.jpg";
		document.images["img_no"].src = "img/no_activo.jpg";
  }//Fin caso 1
  if (caso == '2'){
	  	fila_tel.style.display = "none"; //mostrar fila 
		fila_otro.style.display = ""; //ocultar fila
		fila_no.style.display = "none"; //ocultar fila
		document.images["img_tel"].src = "img/no_activo.jpg";
		document.images["img_otro"].src = "img/activo.jpg";
		document.images["img_no"].src = "img/no_activo.jpg";
  }//Fin caso 1
  if (caso == '3'){
	  	fila_tel.style.display = "none"; //mostrar fila 
		fila_otro.style.display = "none"; //ocultar fila
		fila_no.style.display = ""; //ocultar fila
		document.images["img_tel"].src = "img/no_activo.jpg";
		document.images["img_otro"].src = "img/no_activo.jpg";
		document.images["img_no"].src = "img/activo.jpg";
  }//Fin caso 1
}



function Mostrar_producto(caso) {
  if (!document.getElementById) return false;
 
  pro_adsl_tv_j = document.getElementById('adsl_tv_jazztel');
  pro_adsl_j = document.getElementById('adsl_jazztel');
   pro_adsl_tv = document.getElementById('adsl_tv');
   pro_adsl = document.getElementById('adsl');
   pro_voz = document.getElementById('voz');
  
  
  if (caso == '1'){//si dan a despliegue de tc + adsl con Jazztel
  		if (mostrar_adsl_tv_j == "0"){ // si no está visible el despegable
			pro_adsl_tv_j.style.display = ""; // le hacemos visible
			document.images["des_tv_adsl_jazz"].src = "productos/recoger.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_tv_j = '1';
		}
		else{ // si está visible el despegable
			pro_adsl_tv_j.style.display = "none"; // le hacemos visible
			document.images["des_tv_adsl_jazz"].src = "productos/desplegar.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_tv_j = '0';
			
		}
	  	
  }//Fin caso 1
  
  if (caso == '2'){//si dan a despliegue de adsl con Jazztel
  		if (mostrar_adsl_j == "0"){ // si no está visible el despegable
			pro_adsl_j.style.display = ""; // le hacemos visible
			document.images["des_adsl_jazz"].src = "productos/recoger.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_j = '1';
		}
		else{ // si está visible el despegable
			pro_adsl_j.style.display = "none"; // le hacemos visible
			document.images["des_adsl_jazz"].src = "productos/desplegar.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_j = '0';
			
		}
	  	
  }//Fin caso 2	 
  
  
  if (caso == '3'){//si dan a despliegue de adsl con Jazztel
  		if (mostrar_adsl_tv == "0"){ // si no está visible el despegable
			pro_adsl_tv.style.display = ""; // le hacemos visible
			document.images["des_adsl_tv"].src = "productos/recoger.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_tv = '1';
		}
		else{ // si está visible el despegable
			pro_adsl_tv.style.display = "none"; // le hacemos visible
			document.images["des_adsl_tv"].src = "productos/desplegar.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl_tv = '0';
			
		}
	  	
  }//Fin caso 3	   
  
  if (caso == '4'){//si dan a despliegue de adsl con Jazztel
  		if (mostrar_adsl == "0"){ // si no está visible el despegable
			pro_adsl.style.display = ""; // le hacemos visible
			document.images["des_adsl"].src = "productos/recoger.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl = '1';
		}
		else{ // si está visible el despegable
			pro_adsl.style.display = "none"; // le hacemos visible
			document.images["des_adsl"].src = "productos/desplegar.gif"; // cambiamos la imagen para recoger producto
			mostrar_adsl = '0';
			
		}
	  	
  }//Fin caso 4	  
  
  if (caso == '5'){//si dan a despliegue de adsl con Jazztel
  		if (mostrar_voz == "0"){ // si no está visible el despegable
			pro_voz.style.display = ""; // le hacemos visible
			document.images["des_voz"].src = "productos/recoger.gif"; // cambiamos la imagen para recoger producto
			mostrar_voz = '1';
		}
		else{ // si está visible el despegable
			pro_voz.style.display = "none"; // le hacemos visible
			document.images["des_voz"].src = "productos/desplegar.gif"; // cambiamos la imagen para recoger producto
			mostrar_voz = '0';
			
		}
	  	
  }//Fin caso 5	  

 
}

function ProteccionDatos(){
	window.open('https://online.jazztel.com/avisoLegal.htm','LEGAL','scrollbars=yes,width=536,height=490');
}

function Seguridad(){
	window.open('https://online.jazztel.com/avisoSeguridad.htm','SEGURIDAD','scrollbars=yes,width=560,height=400');
}

