
function verificaCobertura(){
		var x = window.document.getElementById('numero').value;
//		document.getElementById('cntResultado').style.background='none';

		
		if(x != ""){       
          callAHAH('/cobertura.php?telefono='+x, 'cntResultado', '<br /><img src="/imagenes/ajax-loader.gif" width="16" height="16" alt="Verificando cobertura" /><p>Obteniendo informaci&oacute;n.<br />Por favor espere ...</p>', 'Error');
		  location.href= "#ofertas";
        } else {
          callAHAH('/cobertura.php?telefono='+x, 'cntResultado', '', '<p>Hemos detectado un error, verifica nuevamente tu número de teléfono</p>');
        }
}


function verificaCoberturav2010(){
		var x = window.document.getElementById('numero').value;
//		document.getElementById('cntResultado').style.background='none';

		
		if(x != ""){       
          callAHAH('/coberturav2010.php?telefono='+x, 'cntResultado', '<br /><img src="/imagenes/ajax-loader.gif" width="16" height="16" alt="Verificando cobertura" /><p>Obteniendo informaci&oacute;n.<br />Por favor espere ...</p>', 'Error');
		  location.href= "#ofertas";
        } else {
          callAHAH('/coberturav2010.php?telefono='+x, 'cntResultado', '', '<p>Hemos detectado un error, verifica nuevamente tu número de teléfono</p>');
        }
}


function ofertas(producto,accion){
	var x = window.document.getElementById('idConsulta').value;
	
	if(x != 'error' && x != '-1'){
		if(accion == 'info'){
			y = '/Producto/'+producto+'.html';
		} else if(accion == 'contratar'){
			y = '/Producto/'+producto+'-contratar.html';			
		}
		location.href= y;
	} else {
		if(x == 'error'){
			alert('De momento no contamos con cobertura para número.');
		} else {
			alert('Verifica por favor antes la cobertura de tu número de teléfono.');			
		}
	}
}


function checkcontactform(formulario,campos,formatos,nombres) {
         var form=document.getElementById(formulario);
	 var emailaddress=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	 var errormsg = "";
         var arCampos = campos.split("|");
         var arFormatos = formatos.split("|");
         var arNombres = nombres.split("|");
         var i = 0;

        while (i<arCampos.length)
         {
           if(arFormatos[i] == "email"){
          	if (! emailaddress.test(form[arCampos[i]].value)) {
          		errormsg += "- Campo "+arNombres[i]+" incompleto o erroneo\n";
          	}
           }
           if(arFormatos[i] == "texto"){
          	if (form[arCampos[i]].value == "") {
          		errormsg += "- Campo "+arNombres[i]+" incompleto o erroneo\n";
          	}
           }

           if(arFormatos[i] == "select"){
                 if ( form[arCampos[i]].selectedIndex == 0 ) {
          		errormsg += "- Campo "+arNombres[i]+" no seleccionado o definido\n";
                 }
           }

           if(arFormatos[i] == "checkbox"){
                 if ( form[arCampos[i]].checked == false ) {
          		errormsg += "- Campo "+arNombres[i]+" no seleccionado o definido\n";
                 }
           }

           if(arFormatos[i] == "radiobutton"){
                var arOpciones = arCampos[i].split(",");
                var n = 0;
                var largo = arOpciones[0];
                var estado = 1;

                while (n<largo)
                {
                   if ( form[arOpciones[1]][n].checked == false ) {
                     estado = 1;
                   } else {
                     estado = 0;
                     break;
                   }
                   n+=1;
                }
                if(estado == 1){
          		errormsg += "- Campo "+arNombres[i]+" no seleccionado o definido\n";
                }
           }

          i+=1;
          }

	if (errormsg != "") {
		alert("Se han detectado los siguientes errores:\n\n"+errormsg+"\n Por favor, corríjalos e intente nuevamente.");
		return false;
	} else {
		return true;
	}
}

