var YA = false;
function _isNaN(controlvalue) 
{
	if (isNaN(controlvalue)) {
		return true;
	}
	else if ((controlvalue.indexOf("+")>-1) || (controlvalue.indexOf("-")>-1) || (controlvalue.indexOf(".")>-1)) {
		return true;
	}
	return false;
}

function _isTelefono(telefono) 
{
	if ( _isNaN(telefono))
	{
		return false;
	}
	
	var ch = telefono.charAt(0);
	if (telefono.length!=9) 
	{
		return false;					
	}

	if  ((ch != "9") && (ch != "8")) 
	{
		return false;
	}

	return true;
}

function verifica()
{
	if (document.frm_cob.tel.value == '')
	{
		alert("Debes introducir el teléfono donde deseas instalar el ADSL de YA.COM. (Si no dispones de línea telefónica fija -NO DE CABLE- no es posible que instales ningún tipo de ADSL). ----> EN LA SIGUIENTE PANTALLA TE MOSTRAREMOS LAS OFERTAS DISPONIBLES PARA TU TELÉFONO");
		document.frm_cob.tel.focus();
		return false;
	}
	else if (! _isTelefono(document.frm_cob.tel.value)) 
	{
		alert("El formato del número de teléfono que has introducido es incorrecto.");
		document.frm_cob.tel.focus();
		return false;			
	}
	if ( document.frm_cob.politica.checked == false)
	{
		alert("Es necesario que leas y aceptes expresamente nuestra politica de privacidad para poder continuar con la cobertura de tu linea ADSL y para que te podamos ofertar los mejores productos.");
		document.frm_cob.politica.focus();
		return false;
	}
	if ( YA == true )
	{
		alert("Un momento por favor, ya estamos procesando tu peticion.");
		return false;
	}
	YA = true;
	document.frm_cob.submit();
}
function compruebaEnter(e)
 {
  tecla = (document.all) ? e.keyCode : e.which;
  if (tecla==13) 
  {
  	if ( verifica() == false )
	{
	   if(e.preventDefault){
            e.preventDefault();
        }else{
            e.returnValue = false;
        }
	}
  }
}

function iniciaIndex(err)
{
//	if ( $err == 1 ) alert('¡El numero de telefono no es valido!');
	document.frm_cob.tel.focus();
}
