$(document).ready(function() {

	// Animate the portfolio images on hover
	$(".projectimage").hover(function() {
		if($(this).parent().hasClass("right")) {
			$(this).stop().animate({ left:'-5px' }, 150);
		} else {
			$(this).stop().animate({ left:'5px' }, 150);
		}
	}, function() {
		if($(this).parent().hasClass("right")) {
			$(this).stop().animate({ left:'0' }, 150);
		} else {
			$(this).stop().animate({ left:'0' }, 150);
		}
	});

	// Animate the bclogo image on hover
	$("#bclogo").css( 'opacity', '0.5').hover(function() {
		$(this).stop().animate({ opacity: 1 }, 200);
	}, function() {
		$(this).stop().animate({ opacity: 0.5 }, 200);
	});

	// CONTACT FORM VALIDATION ------------------------------------------------------------------
	$("#contactform").validate({ 
        messages: {		sender: { required: "Please enter your name." }, 
						email: { required: "Please enter your email address." }, 
						message: { required: "Please enter your message." }
        },
        submitHandler: function(form) {
	        var sender = $("#sender").val();
			var email = $("#email").val();
			var message = $("#message").val();
			var dataString = 'sender='+ sender + '&email=' + email + '&message=' + message;
		
			$.ajax({
				type: "POST", url: "wp-content/themes/st/sendmail.php", data: dataString,
				success: function(){
					$(form).animate({ opacity: "hide", height: "hide" }, 700);
					$("#contact").append('<div id="response" class="serif"><h2>Message Sent</h2><p>Thanks! Your message has been sent. I\'ll get back to you as soon as I can.</p>');
					$("#response").delay(700).animate({ opacity: "show", height: "show"}, 700);
				}
			});
			return false;
        }
	});

});