// JavaScript Document

contact = {
	sendForm: function () {
		var formError = false;
		var query = $('contactForm').toQueryString();
		if(!formError){
			//console.log("Ready to send");
			//$('form_cont').fade('out');;
			var fx = new Fx.Tween('contactForm')
			fx.start('opacity', 1, 0);
			
			var req = new Request({method: 'post', url:"/sendEmail.php", onSuccess:this.completeHandler, onFailure:this.showFailure}).send(query);
		}else {
			alert("Please fill in all required fields");
		}
	},
	completeHandler: function () {
		$('thanks').setStyle('opacity', 0);
		$('thanks').setStyle('display', 'block');
		$('thanks').morph({'opacity': 1});
	},
	showFailure: function () {
		alert("There was a problem with the request");
	}
}