function terms()
{
        window.open('legales.html','TerminosyCondiciones','width=650,height=550,toolbar=no,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no,left');
}



function validate(){
	var input = document.getElementsByTagName("input");
	au_ERROR = false;
	for (var i=0; i<input.length;i++){
		
		if ((input.item(i).type == "text")){
			switch(input[i].name){
				case "mobile":
					if(input[i].value.length < 10){
						alert("Por favor introduzca su número de teléfono de 10 dígitos!");
						return false;
					}
					break;
					
				case "mobile1":
					if(isNaN(input[i].value)){
						  alert("Introduzca el código de Área válido.");
						  document.getElementById('mobile1').focus();
						  document.getElementById('mobile1').value = "";
						  return false;
						 }
						 
					if(input[i].value.length < 3){
						alert("Su codigo de Área debe contener 3 dígitos.");
						document.getElementById('mobile1').focus();
						return false;
					}
					 
					if(input[i].maxLength == 4){
						au_ERROR = true;
						if(input[i].value == ""){
							alert(" Introduzca el código de Área.");
							document.getElementById('mobile1').focus();
							return false;
						}
					}
				
					break;
					
				case "mobile2":
					if(isNaN(input[i].value)){
						  alert("Verifique los datos provistos.");
						  document.getElementById('mobile2').focus();
						  document.getElementById('mobile2').value = "";
						  return false;
						 }
						 
			
					
					if(input[i].value.length < 7){
						alert("Su número debe contener 7 digitos.");
						document.getElementById('mobile2').focus();
						return false;
					}
					
					break;
					
				case "mobile3":
					if(au_ERROR && input[i].value.length < 3){
						alert(" Su nÃºmero de telÃ©fono debe  contener 10 digitos, verifique los datos provistos.");
						return false;
					}
					else if(!au_ERROR && input[i].value.length < 4){
						alert("Su nÃºmero de telÃ©fono debe  contener 10 digitos, verifique los datos provistos.");
						return false;
					}
					break;
					
				case "pin":
					if(isNaN(input[i].value)){
						  alert("Su número PIN debe de tener solo números.");
						  document.getElementById('pin').focus();
						  document.getElementById('pin').value = "";
						  return false;
						 }
					
					if(input[i].value.length < 4 && input[i].value != NaN){
						alert("Su número de PIN debe de contener 4 dígitos!");
						return false;
					}
					break;
			}
			
		} else if ((input.item(i).type == "checkbox")){
			if(input.item(i).checked == false){
				alert("¡Debe estar de acuerdo con los términos y condiciones del servicio!");
				return false;
			}
		}
	}
}

function check_phone_number(phone_number)
  {
      	if (phone_number.substring(0, 1) == '0' || phone_number.substring(0, 1) == '1' || phone_number.length != 10 || isNaN(phone_number))
  		{
          	alert('Su nÃºmero de telÃ©fono debe  contener 10 digitos, verifique los datos provistos.');
              return false;
          }
      return true;
  }	
  
function MM_openBrWindow(theURL,winName,features)
{ //v2.0
	window.open(theURL,winName,features);
}  

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
  
function xx(o, x, obj)
{
	if (o.value.length == x)
		eval(obj).focus();
}


function whichButton() {
var PreguntaChecked 

	for (var i=0; i<document.form.Pregunta.length; i++) {
	
		if (document.form.Pregunta[i].checked) {
		PreguntaChecked = document.form.Pregunta[i].value
		}
		
	}
	
	
	if(!PreguntaChecked){ //if PreguntaChecked does not equal null
	alert("No hemos recibido su respuesta.")
	return false 
	}

}

function validate2(){
 if(document.getElementById('nombre').value == "") {
  alert("Por favor introduzca su nombre.");
  document.getElementById('nombre').focus();
 }else{
  
  window.location = "s2.html";
 }
}

//Funtions to limit characters and to clear the field if the first number entered is 0 
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.substr(0,1) == "0"){
		limitField.value = "";
	}
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		// limitCount.value = (limitNum - limitField.value.length) +6;
		limitCount.maxLength = (limitNum - limitField.value.length) +7;
	}
}

function noZero(noZeroField) {
	if (noZeroField.value.substr(0,1) == "0"){
		noZeroField.value = "";
	}
}

// Function to select where the focus should be on when the page loades
function setFocus(focusWho) {
	document.getElementById(focusWho).focus();
}

// Jump to the next input field when it equal to the maxlength
function checkLen(x,y){
	if (x.value.length == y) {
		document.getElementById("mobile2").focus();
	}
}
