$(function() {
    $('#contact-form').submit(function() {
	
        var name    = $('input#name').val(),
            company = $('input#company').val(),
            email   = $('input#email').val(),
            msg     = $('textarea#message').val();
        
        if (name == '') {
            alert('Please enter your name');
            $('input#name').focus();
            return false;
        }
        
        if (email == '') {
            alert('Please enter your e-mail address');
            $('input#email').focus();
            return false;
        }
	
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        if(!emailReg.test(email)) {
            alert('The e-mail address you have entered appears to be invalid');
            $('input#email').focus();
            return false;
        }
	
        if (msg == '') {
            alert('Please enter a message');
            $('textarea#message').focus();
            return false;
        }
		
        var dataString = 'name='+ name + '&company=' + company + '&email=' + email + '&msg=' + msg;
        //alert (dataString);return false;
		
        $.ajax({
            type: 'POST',
            url: 'process.php',
            data: dataString,
            success: function() {
                $('#contact').html('<div id="contact-message"></div>');
                $('#contact-message').html('<h5>Contact Form Submitted!</h5>')
                .append('<p>We will be in touch soon.</p>')
                .hide()
                .fadeIn(1500, function() {
                    $('#message');
                });
            }
        });
        return false;
    });
});


