/**
* Main javascript class
*
* @author Mike Pritchard (mikep76@gmail.com)
* @since 18th, May 2009
*/
var wineTastingFrance = {

	validator : '',
	
	init : function(){
		wineTastinginFrance.validator = new Validation('form1', {onSubmit:false});
	},


	/**
	* Respond to a request to sumbit the 'request information'
	* form
	*/    
	onSubmitInfo : function(){
		
		if (!wineTastinginFrance.validator.validate()) return false;
		
		var ajax = new Ajax.Request("php/sendEmail.php",{
			onSuccess: wineTastinginFrance.onGotSubmitInfo,		
			on404: function(t) {alert('Ajax Error 404: Location "' + t.statusText + '" was not found. \nURL = ' + url); },
			onFailure: function(t) {alert('Ajax Error (probably a fatal php error). Status = ' + t.status + ' Message = ' + t.statusText + '\n' + url + '?' + params.toQueryString());},			
			parameters: $('form1').serialize(true),
			method: 'post'
		});
		
		return false; 
	},
	
	/**
	* Got the response from the server
	*/
	onGotSubmitInfo : function(response){
		$('send_form_response').innerHTML = response.responseText;
		setTimeout("wineTastinginFrance.clearInfoForm()", 5000);
		Effect.Appear('send_form_response');
	},
	
	/**
	* Clear the information request form status message 
	* (the message posted in the onGotSubmitInfo function)
	*/
	clearInfoForm : function(){
		Effect.Fade('send_form_response');
	}
 
}


