$(document).ready(function() {
    $('form#contactForm').submit(function() {

        $('form#contactForm .error').remove();
	var hasError = false;

        $('.requiredField').each(function() {
            if(jQuery.trim($(this).val()) == '') {

                var labelText = $(this).prev('label').text();
		$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
		hasError = true;
                }
                 else if($(this).hasClass('email')) {
                    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
                    if(!emailReg.test(jQuery.trim($(this).val()))) {
                        var labelText = $(this).prev('label').text();
			$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
			hasError = true;
			}
                    }
		});

            if(!hasError) {
                $('form#contactForm li.buttons button').fadeOut('normal', function() {
                        $(this).parent().append('<img src="http://www.voothemes.com/wordpress/themes/demo/voosky/wp-content/themes/voosky/images/sending.gif" alt="Loading&hellip;" height="31" width="31" />');
                });
                var formInput = $(this).serialize();
                $.post($(this).attr('action'),formInput, function(data){
                        $('form#contactForm').slideUp("fast", function() {
                                $(this).before('<p class="thanks"><strong>Thank you.</strong> Your message was successfully sent.</p>');
                        });
                });
            }
		
		return false;
		
	});
});

$('document').ready(function(){
    $('input#contactName').focus(function(){
        $(this).after("<span style='margin-left: 10px'>Contact Name<span>");
    });
    $('input#contactName').blur(function(){
        $(this).next("span").fadeOut(1000);
    });

    $('input#conemail').focus(function(){
        $(this).after("<span style='margin-left: 10px'>Your Email Address<span>");
    });
    $('input#conemail').blur(function(){
        $(this).next("span").fadeOut(1000);
    });

    $('input#conwebsite').focus(function(){
        $(this).after("<span style='margin-left: 10px'>Your phone number (optional)<span>");
    });
    $('input#conwebsite').blur(function(){
        $(this).next("span").fadeOut(1000);
    });
})
