/*================================
Ajax handler functions
================================*/

//var root = "http://development.neilmills.com/secantor";
var root = "http://optimasemper.meridian.titaninternet.co.uk/preview";
sendRequest = function(url,params,hf,ef){
	
new Ajax.Request(
	url,
	{
		method: 'post',
		parameters: params,
		onSuccess: hf,
		onFailure: ef
		});
}

sendUpdateRequest = function(container,url,params,hf,ef){
new Ajax.Updater(
			container,url,
			{
				method: 'post',
				parameters: params,
				onSuccess: hf,
				onFailure: ef
			});
}


/*================================
Contact functions
================================*/
sendBooking = function(){
	//submit form
	

	//	$("form-loader").show();
		var params = Form.serialize($("booking"));
		//console.log(params);
		var url = '/ajax/ajax.booking.php';
	//	$("booking").disable();
		newAjax = sendRequest(url,params,bookingHandler,bookingError);
	}
	
bookingHandler = function(t){
		//$("form-loader").hide();
	if(t.responseText=="0"){
		contactError();
	} else{
		//$("booking").enable();
		$("booking").reset();
		$("form_wrap").hide();
		$("thanks").show();
		//$("status").innerHTML="Thankyou...we'll be in touch shortly.";
	
	}
}

bookingError = function(){
	$("booking").enable();
	$("status").innerHTML = 'Server Error. Please try again.';
}


