// Funciones AJAX //

function Guardar_Distr(){
a = 1+Math.round(Math.random()*9999999999); 
conexion1=crearXMLHttpRequest();
conexion1.onreadystatechange = procesarEventosProv;
conexion1.open("GET", "guardar.php?distribuidor="+document.Distribuidor.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 refresca_imagen(){
	var aleatorio = Math.random();
	document.getElementById('ima').src = 'https://online.jazztel.com/images/securimage_show.php?sid='+aleatorio;
	document.Formulario.sid.value = aleatorio;
	
}

function soloNumeros(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 chequea_alta(){
var telefono = document.Formulario.telefono.value;
if ((telefono.length < 8)||(telefono.charAt(0) != '9')){
	alert("Número de teléfono incorrecto");
	return false;
}// fin de if
else{
	if (document.Formulario.code.value == ""){
		alert("Introduzca el código de seguridad");
		return false;
	}// fin de if
	else{
		Guardar_Distr()
		document.Formulario.NumSegmento.value = "3";
		document.Formulario.ConsultaNumero.value = document.Formulario.telefono.value;
		document.Formulario.Sentido.value = "3";
		//document.Formulario.submit();
		return true;
	}//fin else
}// fin de else
}

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

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


