// Coloca la selección "msn_ent" al valor que tenga "msn_rtr"
function ColocaMes() {

	document.formulario.msn_ent.options.selectedIndex =
	document.formulario.msn_rtr.options.selectedIndex;
	borraPrecio();
	
}


// Vacia el contenido de "document.getElementById("Presupuesto").innerHTML=tablahtml;"
function borraPrecio() {
	form = document.formulario;
	
	document.location = 'quote.php?vhc=' + form.vhc.value +
						'&day_rtr=' + form.day_rtr.options[form.day_rtr.selectedIndex].value +
						'&msn_rtr=' + form.msn_rtr.options[form.msn_rtr.selectedIndex].value +
						'&hrm_rtr=' + form.hrm_rtr.options[form.hrm_rtr.selectedIndex].value +
						'&day_ent=' + form.day_ent.options[form.day_ent.selectedIndex].value +
						'&msn_ent=' + form.msn_ent.options[form.msn_ent.selectedIndex].value +
						'&hrm_ent=' + form.hrm_ent.options[form.hrm_ent.selectedIndex].value;

}

//
// FunciÃ³n que comprueba que estÃ¡n todos los campos rellenos

function Send_form() {

	form = document.formulario;
	if (form.lgr.options[form.lgr.selectedIndex].value == 0) {
		alert("Please select a location.");
	} else if (	(form.name.value == "" )  || (form.flight.value == "" ) || 
				(form.email.value == "" ) || (form.mobile.value == "" ) || 
				(form.repeatemail.value == "" )		) {
		alert("Please fill all fields.");
	} else if (form.email.value != form.repeatemail.value) {
		alert("Email and Repeat email fields doesn´t match.");
	} else if (!esUnCorreo(form.email.value)) {
		alert("Please enter a valid email address.");
	} else {
		form.submit();
	} // if

} // Send_form

// Función que valida una dirección de correo electrónico
function esUnCorreo(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
//	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
//	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
//	    alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
//	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
//	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
//	    alert("Invalid E-mail ID")
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
//	    alert("Invalid E-mail ID")
	    return false
	 }

	 return true					
}

