window.onload=function(){
	Validation.add('validate-name', 'The name is wrong.', {
     pattern : new RegExp("^([A-Za-zñÑ ])+$")
	});
	new Validation('reservationForm', {immediate : true, useTitles : true, onFormValidate : SubmitForm});
	var reservation=$('reservationForm');
	reservation.onreset=function(){
		this.subjectTxt.value="";
		this.firstnameTxt.value="";
		this.lastnameTxt.value="";
		this.countryTxt.value="";
		this.cityTxt.value="";
		this.phoneTxt.value="";
		this.faxTxt.value="";
		this.emailTxt.value="";
		this.travelersTxt.value="";
		//this.arrivaldateTxt.value=formatDate(new Date(),'d/M/y');
		this.tourLst.selectedIndex=0;
		this.commentTxt.value="";
		return false;
	}
	reservation.onreset();
}
function SubmitForm(status, form){
	if(status){
		$('reservationformPanel').style.visibility="hidden";
		var panel=$('reservationresponsePanel');
		panel.innerHTML='<img src="imgs/loader.gif" /><br />Making your reservation. Please wait a moment ...';
		panel.style.display="block";
		var cad=
			"subject="+form.subjectTxt.value+
			"&firstname="+form.firstnameTxt.value+
			"&lastname="+form.lastnameTxt.value+
			"&country="+form.countryTxt.value+
			"&city="+form.cityTxt.value+
			'&phone='+form.phoneTxt.value+
			'&fax='+form.faxTxt.value+
			"&email="+form.emailTxt.value+
			"&travelers="+form.travelersTxt.value+
			//"&arrivaldate="+form.arrivaldateTxt.value+
			"&tour="+form.tourLst.options[form.tourLst.selectedIndex].value+
			'&comment='+form.commentTxt.value;
		var ajax=new Ajax.Request("php/submitreservation.php?lang=en", 
															{parameters:cad,
															 method:"post",
															 onSuccess: SubmitedForm,//Success
															 onFailure: ReportError
															});
	}else{
	}
}
function SubmitedForm(response){
	$('reservationformPanel').style.visibility='visible';
	var panel=$('reservationresponsePanel');
	panel.innerHTML='';
	panel.style.display='none';
	$('reservationForm').reset();
	alert(response.responseText);
}
function ReportError(){
	alert("Unable to make the reservation. \nPlease try later.");
	$('reservationformPanel').style.visibility='visible';
	var panel=$('reservationresponsePanel');
	panel.innerHTML='';
	panel.style.display='none';
}