	var parent;
$(document).ready(function(){



	
	
	

	$(".contact-us").submit(function(){
		
		var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		$(".contact-us input, .contact-us select").each(function(){
			if($(this).val() == ''){
				$(this).val('required field').css({'color':'red'});
				errors=true;
			}
			if(!regex.test($("[name=email]").val())){
				$("[name=email]").val('please enter a valid email address').css({'color':'red'});
				errors=true;
			}
		});
		
		if(errors == false){
			$(".submit").hide();
			$(".submit").parent().append("<img id='loader' src='/wp-content/themes/fire/images/ajax-loader.gif' />")
			$.post('/wp-content/themes/fire/mailer.php', {
				name: $(".contact-us [name='name']").val(),
				email: $(".contact-us [name='email']").val(),
				msg: $(".contact-us [name='message-box']").val(), 
				mailTo: $(".contact-us .drop").val()
			}, function(){
				$(".contact-us .submit").attr('disabled', 'disabled');
				$("#loader").delay(500).fadeOut("slow", function(){
					$('.submit').unbind('click');
					$('.mailing-list').fadeOut('fast');
					$(".submit").parent().append("<p id='thanks'>Thank you! We have received your message and appreciate your time. We will be in contact shortly if you've asked us to follow up.</p>");
					
				});
			})
		}
		return false;
	});
});

isMenu = function(){
	if($(parent).attr('id')=='menu-ul'){
		return true;
	}
	
	else{
		return false;
	}
}
