var site = {
	init:function(){
	},
	
	showEmail:function(){
		$("#email-form").css({'display':'block'});
		$("p.success").text("");
	},
	
	emailFormSubmit:function(){
		if (this.isEmail(document.emailForm.email.value)){
			$.post("contact.php", { state: "process", email: document.emailForm.email.value, msg:document.emailForm.msg.value },function(){
				$("p.success").text("Your email has been sent. I'll get back to you soon.");
				$("#email-form").css({'display':'none'});
			} );
		} else {
			this.writeError('Please use a valid email address');
			return false;
		}
	},
	
	emailCheckFocus:function(){
		if (document.emailForm.email.value == "Your Email"){
			document.emailForm.email.value = "";
		}
	},

	msgCheckFocus:function (){
		if (document.emailForm.msg.value == "Your Message"){
			document.emailForm.msg.value = "";
		}
	},

	resetFields:function(){
		document.emailForm.email.value = "Your Email";
		document.emailForm.msg.value = "Your Message";
	},
	
	isEmail:function(strValue){
		var objRegExp  = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		return objRegExp.test(strValue);
	},

	writeError:function(msg){
		alert("msg:"+msg);
		$("p.error").text(msg);
	}
};

$(document).ready(function () {
	site.init();
});