$(document).ready(function(){
	
	/* Function for adding loading gif for contact window send button */
	$("#send").click(function () { 
      $('#loading').fadeIn("slow"); 
    });

	/* Functions for ajax sending data of contact form */
	$('#myForm').ajaxForm(function(data) {
		if (data==1){
			$('#loading').fadeOut("fast");
			alert("Thank you for your inquiry - we will get back to you as soon as possible!");
			$('#myForm').resetForm();
		}
		else if (data==2){
			$('#loading').fadeOut("fast");
			alert("Oops! There was an error in sending your message, please try again");
		}
		else if (data==3)
		{
			$('#loading').fadeOut("fast");
			alert("Oops! It seems you entered an invalid email address, please try again");
		}
	});
});

function requireEmail()
{
	if(document.mailfrm.layout.value=="none"){
		alert("You must select a template to use before sending your email!");
		return false;
	}
	else if(document.mailfrm.to.value==""){
		alert("You must select a recipient before sending your email!");
		return false;
	}
	else if(document.mailfrm.email.value=="none"){
		alert("You must select a sender address before sending your email!");
		return false;
	}
	else if(document.mailfrm.subject.value==""){
		alert("You must enter a subject before sending your email!");
		return false;
	}
	else if(document.mailfrm.message.value==""){
		alert("You must enter your message before sending your email!");
		return false;
	}
	else{
		return true;	
	}
}