$(document).ready(function() {
	/* PNG FIX */
	//	DD_belatedPNG.fix('#nav, a, img, #content, #titlebar, h4, .client_logo');
	/* DROPDOWN MENU */
	$(".dropdown").mouseover(function() {
		$(this).addClass("over");
	}).mouseout(function() {
		$(this).removeClass("over");
	});
	$('#content .team-list li:nth-child(4n)').css("margin-right","0");
});

// scroll back to top of the page
jQuery('.top').click(function(event){
	event.preventDefault();
	jQuery('html, body').animate({scrollTop:0}, 'slow');
});

/* CONTACT FORM */
/* thank you message */
$('#submit_btn').click(function(e) {
	var name = $("#contact_form").find("#name").val();
	var email = $("#contact_form").find("#email").val();
	var subject = $("#contact_form").find("#subject").val();
	var message = $("#contact_form").find("#message").val();
	//var recipient = "info@johnhenry.net"; the recipient is being determined in the blog settings

	var regularExpression = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if (!regularExpression.test(email)) {
		alert("Please enter a valid email address");
		return false;
	}
	if (message == "") {
		alert("Please enter your meesage");
	}

	$.ajax({
		type: "POST",
		url: path+'/functions/sendMail.php',
		data: "command=contact&name=" + name + "&email=" + escape(email) + "&subject=" + subject + "&message=" + escape(message) + "&phone=" + $("#contact_form").find("#phone").val(),
		success: function(response) {
			if(response == 'success'){
				var height = $('#contact_form').css('height');
				var newHeight = height.substring(0, height.lastIndexOf('p')) - 10; /*-10 because of 5px border*/
				$('#thanks_msg').css('height', newHeight + 'px');
				$('#thanks_msg').css('display', 'block');
				$('#thanks_msg').css('margin-top', '-' + $('#contact_form').css('height'));
			}
		}
	});
});
$('.close').click(function() {
	$('#thanks_msg').css('display', 'none');
	$('#name, #email, #message').css('color', '#989898');
	$('#name').val('Name');
	$('#email').val('Email');
	$('#message').val('Message');
});
$('#name, #email, #message').focus(function() {
	if ($(this).val() == 'Name' || $(this).val() == 'Email' || $(this).val() == 'Message') {
		$(this).val('');
		$(this).css('color', '#000000');
	}
});
$('#name,#email').blur(function() {
	if ($(this).val() == '') {
		$(this).css('color', '#989898');
		if ($(this).attr('id') == 'name') {
			$(this).val('Name');
		} else if ($(this).attr('id') == 'email') {
			$(this).val('Email');
		} else if ($(this).attr('id') == 'message') {
			$(this).val('Message');
		}
	}
});



