ContactUs = Class.create();
ContactUs.prototype = {
	initialize: function() {
		this.contact = $('contactFormContainer');
		this.contactForm = $('contactUsForm');
		this.contactFormError = $('contactUsError');
		this.contactFormSuccess = $('contactFormSuccess');
		this.isError = false;
	},
	
	submitForm: function(){
		this.isError = false;
		
		var elements = this.contactForm.getElements();
		
		if(elements[0].value == ""){
			this.contactFormError.style.display = '';
			this.isError = true;
		}
		
		if(elements[2].value == "" && elements[3].value == ""){
			this.contactFormError.style.display = '';
			this.isError = true;
		}
		
		if(!this.isError)
			this.sendForm();
	},
	
	sendForm: function(){
		var options = {
			method: 'get', 
			parameters: this.contactForm.serialize(), 
			onComplete: function(response, json){this.submitCallBack(response, json);}.bind(this)
		}
		
		var myAjax = new Ajax.Request('/submit.php', options);
	},
	
	submitCallBack: function(response, json){
		this.contact.style.display = 'none';
		this.contactFormSuccess.style.display = '';
	}
}