

this.contact_init = function(){
	
	this.validate = function(name, email, message){
		$("#errorname").hide()
		$("#erroremail").hide()
		$("#errormessage").hide()
		var valid = true;
		//name
		if(name == "") {
			$("#errorname").hide().show('fast');
			valid = false;
		};	
		//email
		if(!checkEmail(email)) {
			$("#erroremail").hide().show('fast');
			valid = false;
		};			
		//messgae
		if(message == "") {
			$("#errormessage").hide().show('fast');
			valid = false;
		};					
		return valid;
	};
	
	this.checkEmail = function(str){
	  var regEx = /^[^@]+@[^@]+.[a-z]{2,}$/;
	  return (str.search(regEx) != -1);
	};

	$("#contactForm button").click(function(){
		var name = $("#name").val();
		var email = $("#email").val();	 		
		var message = $("#message").val();	 				
		if(validate(name, email, message)) return true;
		return false;
	});	
};


$(document).ready(function(){	
	contact_init();
});