// Funciones AJAX //
var estado = "10";

function Guardar_Distr(){
a = 1+Math.round(Math.random()*9999999999); 
conexion1=crearXMLHttpRequest();
conexion1.onreadystatechange = procesarEventosProv;
conexion1.open("GET", "guardar.php?distribuidor="+document.Distribuidores.distribuidor.value+"&a="+a, true);
conexion1.send(null);
}


function procesarEventosProv()
{
  var detalles_perfil = document.getElementById("capa_buscando");
  if(conexion1.readyState == 4)
  {
    detalles_perfil.innerHTML = conexion1.responseText;
  } 
  else 
  {
    document.getElementById("capa_buscando").style.visibility="visible";
}
}

function addEvent(elemento,nomevento,funcion,captura)
{
  if (elemento.attachEvent)
  {
    elemento.attachEvent('on'+nomevento,funcion);
    return true;
  }
  else  
    if (elemento.addEventListener)
    {
      elemento.addEventListener(nomevento,funcion,captura);
      return true;
    }
    else
      return false;
}

function crearXMLHttpRequest() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}


// FIN FUNCIONES AJAX //




function refreshimg(){
	var aleatorio = Math.random();
	document.getElementById('imagen_cod').src = 'https://online.jazztel.com/images/securimage_show.php?sid='+aleatorio;
	document.F_Alta_ADSL_JAZZTEL.sid.value = aleatorio;
	
}

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 check_data(){
var telf_number = document.F_Alta_ADSL_JAZZTEL.telf_number.value;
if ((telf_number.length < 9)||(telf_number.charAt(0) != '9')){
	alert("NUMERO DE TELEFONO INCORRECTO");
	document.F_Alta_ADSL_JAZZTEL.telf_number.focus();
	return false;
}// fin de if
return true;
}

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');
}

function abrir_producto(){ 
if (document.F_Alta_ADSL_JAZZTEL.NumberProduct.value == '0'){
	alert ("No ha elegido producto para visualizar");
}
else{
	window.location = "http://www.jazztel.com/hogar/detalle.php?id_producto=" + document.F_Alta_ADSL_JAZZTEL.NumberProduct.value;
}
} 

function abrir_tarifas(id_tar){ 
    switch (id_tar) { 
	    case "1": 
		    window.open("tarifas_20.html","","width=560,height=320,scrollbars=NO"); 
		   break;
		case "2": 
		   window.open("tarifas_3.html","","width=560,height=320,scrollbars=NO");
		   break;
		case "3": 
		   window.open("tarifas_1.html","","width=560,height=320,scrollbars=NO");
		   break;
		case "4": 
		    window.open("tarifas_tv.html","","width=560,height=390,scrollbars=NO");
		   break;
		case "5": 
		    window.open("tarifas_6.html","","width=560,height=390,scrollbars=NO");
		   break;
	} 
	
} 


function chequea_si(tatus){
	if ((tatus == "SI")&&(estado == "01")){
			document.SIdispongo.src = "img_par/si_dispongo_check.gif";
			document.NOdispongo.src = "img_par/no_dispongo_uncheck.gif";
			estado = "10";
			if(document.layers)document.layers['Con_Telefono'].visibility='show' // Si utilizamos NS
			if(document.all)document.all('Con_Telefono').style.visibility='visible' // Si utilizamos IE
			if(document.layers)document.layers['Sin_Telefono'].visibility='hide' // Si utilizamos NS
			if(document.all)document.all('Sin_Telefono').style.visibility='hidden' // Si utilizamos IE

	}
	if ((tatus == "NO")&&(estado == "10")){
			document.SIdispongo.src = "img_par/si_dispongo_uncheck.gif";
			document.NOdispongo.src = "img_par/no_dispongo_check.gif";
			estado = "01";
			if(document.layers)document.layers['Con_Telefono'].visibility='hide' // Si utilizamos NS
			if(document.all)document.all('Con_Telefono').style.visibility='hidden' // Si utilizamos IE
			if(document.layers)document.layers['Sin_Telefono'].visibility='show' // Si utilizamos NS
			if(document.all)document.all('Sin_Telefono').style.visibility='visible' // Si utilizamos IE
		
	}
}