$(document).ready(function(){
		
	$("#submit").click(function() {
		
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var frm_name = $("#frm_name").val();
		var frm_email = $("#frm_email").val();
		var frm_phone = $("#frm_phone").val();
		var frm_enquiry = $("#frm_enquiry").val();
		var frm_submit = $("#submit").val();
		
		
		if(frm_name == '') {
			$("#frm_name_req").after('<small class="error">Required</small>');
			hasError = true;
		}
		
		if(frm_email == '') {
			$("#frm_email_req").after('<small class="error">Required</small>');
			hasError = true;
		} else if(!emailReg.test(frm_email)) {
			$("#frm_email_req").after('<small class="error">Email address is not valid</small>');
			hasError = true;
		}
		
		if(frm_enquiry == '') {
			$("#frm_enquiry_req").after('<small class="error">You forgot to enter your message</small>');
			hasError = true;
		}
	
		
	if(hasError == false) {
		$(this).hide();
		$("#submit_block").append('<img src="/static/images/loading.gif" alt="Loading" id="loading" />');
		
			$.post("/inc/_form_logic.php",
		   	{ frm_email: frm_email, frm_name: frm_name, frm_phone: frm_phone, frm_enquiry: frm_enquiry, submit: frm_submit },
		   		function(data){
				$("#frmContact").slideUp("slow", function() {				   
					$("#frmContact").before('<h2>Success</h2><p>Your enquiry was sent to us. We\'ll be in contact shortly.</p>');										
				});
		   		});
	}else{
						$("#frmContact").before('<p class=\"error\"><strong>The form was not sent. Please make sure that you have filled in all the required fields.</strong></p>');			
					}
					
		return false;
	});
	
	$.scrollTo( 0 );//reset the screen to (0,0)
				
	$('#navAbout').click(function(){
		$.scrollTo( '#sectionAbout h2', 500 );
		return false;
	});
	
	$('#navPricing').click(function(){
		$.scrollTo( '#sectionPricing h2', 500 );
		return false;
	});
	
	$('#navPackages').click(function(){
		$.scrollTo( '#sectionPackages h2', 500 );
		return false;
	});
	
	$('#navContact').click(function(){
		$.scrollTo( '#sectionContact h2', 500 );
		return false;
	});
	
	$('#bodyContact').click(function(){
		$.scrollTo( '#sectionContact h2', 500 );
		return false;
	});
	
	$('.topLink a').click(function(){
		$.scrollTo( 0, 500 );//reset the screen to (0,0)
		return false;
	});
	
	
	$('#header h1').pngfix();
	$('#headInfoPane').pngfix();
});
