function validar_form()
{
	retiro=document.Form1.retiro.value;
	fecha_inicio=document.Form1.fecha_inicio.value;
	hora_inicio=document.Form1.hora_inicio.value;
	minuto_inicio=document.Form1.minuto_inicio.value;
	devolucion=document.Form1.devolucion.value;	
	fecha_termino=document.Form1.fecha_termino.value;
	hora_termino=document.Form1.hora_termino.value;
	minuto_termino=document.Form1.minuto_termino.value;
	nombre=document.Form1.nombre.value;
	apellidos=document.Form1.apellidos.value;
	email=document.Form1.email.value;
	pais=document.Form1.pais.value;
	ciudad=document.Form1.ciudad.value;
	auto=document.Form1.vehiculos;
	
	if(retiro=='Select')
	{
		alert("You must select the Pickup location");
		document.Form1.retiro.style.background="red";
		return(false);
	}
	else{
		document.Form1.retiro.style.background="white";
	}

	if(devolucion=='Select')
	{
		alert("You must select the Dropoff location");
		document.Form1.devolucion.style.background="red";
		return(false);
	}
	else{
		document.Form1.devolucion.style.background="white";
	}

	if(fecha_inicio=='')
	{
		alert("You must select the Pickup date");
		document.Form1.fecha_inicio.style.background="red";
		return(false);
	}
	else{
		document.Form1.fecha_inicio.style.background="white";
	}


	if(hora_inicio=='--')
	{
		alert("You must select the Pickup time");
		document.Form1.hora_inicio.style.background="red";
		return(false);
	}
	else{
		document.Form1.hora_inicio.style.background="white";
	}

	if(minuto_inicio=='--')
	{
		alert("You must select the Pickup time");
		document.Form1.minuto_inicio.style.background="red";
		return(false);
	}
	else{
		document.Form1.minuto_inicio.style.background="white";
	}

	if(fecha_termino=='')
	{
		alert("You must select the Dropoff date");
		document.Form1.fecha_termino.style.background="red";
		return(false);
	}
	else{
		document.Form1.fecha_termino.style.background="white";
	}

	if(hora_termino=='--')
	{
		alert("You must select the Dropoff time");
		document.Form1.hora_termino.style.background="red";
		return(false);
	}
	else{
		document.Form1.hora_termino.style.background="white";
	}
	
	if(minuto_termino=='--')
	{
		alert("You must select the Dropoff time");
		document.Form1.minuto_termino.style.background="red";
		return(false);
	}
	else{
		document.Form1.minuto_termino.style.background="white";
	}



	if(nombre=='')
	{
		alert("Your name!");
		document.Form1.nombre.style.background="red";
		return(false);
	}
	else{
		document.Form1.nombre.style.background="white";
	}

	if(apellidos=='')
	{
		alert("Your last name!");
		document.Form1.apellidos.style.background="red";
		return(false);
	}
	else{
		document.Form1.apellidos.style.background="white";
	}
	
	if(email=='' || !validaCorreo(email)){ 
		if(email==''){
			alert("Your email!");
		}
		else{
			alert("Email not valid!");
		}

		document.Form1.email.style.background="red";
		return(false);
	}
	else{
		document.Form1.email.style.background="white";
	}


	if(pais=='Select')
	{
		alert("You must select one country");
		document.Form1.pais.style.background="red";
		return(false);
	}
	else{
		document.Form1.pais.style.background="white";
	}

	if(ciudad=='')
	{
		alert("You must enter a city");
		document.Form1.ciudad.style.background="red";
		return(false);
	}
	else{
		document.Form1.ciudad.style.background="white";
	}

	if(getRadioButtonSelectedValue(auto)=='-1'){
		alert("You must select one car");
		return(false);
	}

    

	return(true);
}

function getRadioButtonSelectedValue(ctrl)
{

    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) 
			return ctrl[i].value;

	return(-1);
}


function validar_int(campo)
{
	var cont=0;
	for (t=0;t<campo.length;t++){  
		if (((campo.charAt(t))>='0') && ((campo.charAt(t))<='9')){   
			continue;
		}
		else{
			cont++;
			break;
		}
	}
	if(cont>0)
		return 1;
	else
		return 0;
}



function validaCorreo(valor)
{
	var reg=/(^[a-zA-Z0-9._-]{1,30})@([a-zA-Z0-9.-]{1,30}$)/;
	if(reg.test(valor)) return true;
	else return false;
}

function paises()
{
	var x = document.Form1.pais.value;
	alert('x'+x);
	if(x=='CHILE'){
		var url = 'ciudad_chile.html';
	}
	else{
		var url = 'otra_pais.html';
	}
	var parametro = 'info='+x;
	var myAjax = new Ajax.Updater('nada',url);
}
