function solodigitos(f){
var Numero="abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
texto=f.value;
for (i=0;i<texto.length;i++){
	letra=texto.charAt(i);
	if (Numero.indexOf(letra)==-1) {
		alert('El campo seleccionado sólo acepta números, letras o el signo "-".\n'+
		'Caracter ilegal "'+texto.charAt(i)+'"');
		f.focus();
		f.select();
		return false;
	}
}
return true
}

function valTexto(f,validos){
texto=f.value;
for (i=0;i<texto.length;i++){
 if (validos.indexOf(texto.charAt(i))==-1) {
  alert('El campo seleccionado sólo acepta números, letras o el signo "-".\n'+
  'Caracter ilegal "'+texto.charAt(i)+'"');
  f.focus();
  f.select();
  return false;
  }
 }
}

function validosOtros(f){
var Numero="¿?¡!@_*+#&$%.()";
texto=f.value;
for (i=0;i<texto.length;i++){
 if (Numero.indexOf(texto.charAt(i))!=-1) {
	alert('Caracter ilegal "'+texto.charAt(i)+'"');
	f.focus();
	f.select();
	return false;
	}
  }
}

function validaEmail(t){
Val=t.value;
arroba=Val.indexOf("@");
punto=Val.lastIndexOf(".");
if (arroba!=-1 && punto>arroba){ return true;}
else{
 alert('El email que ha escrito no es válido.');
 t.focus();
 t.select();
 return false;
 }
}

function numero(f){
var Numero="1234567890";
texto=f.value;
for (i=0;i<texto.length;i++){
 if (Numero.indexOf(texto.charAt(i))==-1) {
  alert('El campo seleccionado sólo acepta números.');
  f.focus();
  f.select();
  return false;
  }
 }
}

function valor(f,min,max,num){
var s="";
  if (f.value==""){
    if (min>0||max>0){
    s='Rellene el campo seleccionado con un ';
	if (min>0) s+='mínimo de '+min;
	if (min>0 && max>0)s+=' y un ';
	if (max>0) s+='máximo de '+max;
	s+=' caracteres.';
	}
	else{s="Escriba un valor para el campo seleccionado.";}
    alert(s);
    f.focus();
    return (false);
  }
  if (min>0){
  if (f.value.length<min){
    alert("Escriba como mínimo "+min+" caracteres en el campo seleccionado.");
    f.focus();
    return (false);
  }
}
  if (max>0){
   if (f.value.length>max){
    alert("Escriba como máximo "+max+" caracteres en el campo seleccionado.");
    f.focus();
    return (false);
  }
}
return true;
}

function CreaLista(FIN){
for (i=1;i<FIN+1;i++){
 texto=i+'';
 if (texto.length==1) texto='0'+texto;
 document.write('<option value='+texto+'>'+texto+"</option>")
}
}

function estaEnArray(valor,arr){
 for (i=0;i<arr.length;i++) if (arr[i]==valor) return 1;
 return 0;
}

function cambiaExt(cmpExtension,cmpAnio){
 estaExt=OptVal(cmpExtension);
 if (estaEnArray(estaExt,ext_es)==1){
  cmpAnio.selectedIndex=0;
  alert("El registro de los dominios:\n"+ext_es.join(", ")+"\n es por un año")
 }
 if (estaExt==".tv"){
  mensaje="En breve nos pondremos en contacto con ud.\n"+
   "para confirmarle la disponibilidad y tarifas\n"+"del dominio solicitado."
  alert(mensaje);
 } 
}

function soloNums(tx){
	nums="0123456789";
	for (N=0;N<tx.length;N++){
		if (nums.indexOf(tx.charAt(N))==-1) return false;
	}
	return true;
}

function valTelPrefijo(f){
	mensajeError="El valor que ha escrito en el campo seleccionado no es correcto.\nFormato: +123.123456789"
	nums="0123456789"
	Val=f.value;
	posDot=Val.indexOf(".");
	posMas=Val.indexOf("+");
	if (posMas!=0||posDot<2){alert(mensajeError);f.select();return false;}
	prefijo=Val.substr(posMas+1,posDot-1);
	tel=Val.substr(posDot+1);
	if (tel.length<7){alert(mensajeError);f.select();return false;}
	if (!soloNums(prefijo)||!soloNums(tel)){alert(mensajeError);f.select();return false;}
	return true;
}



function ValidarContrato(f){
	if (f.Aceptado.checked==false){
		alert('Es obligatoria la aceptación de las normas de contratacion');
		f.Aceptado.focus();
		return false;
	}
	return true;
}
