$(function() {

	$('.error').hide();

	$(".submit").click(function() {	
      // validate and process form here

		$('.error').hide();
		var name = $("input#name").val();
		if (name == "") {
			$("label#name_error").show();
			$("input#name").focus();
			return false;
		}
		var email = $("input#email").val();
		if (email == "") {
			$("label#email_error").show();
			$("input#email").focus();
			return false;
		}
		var phone = $("input#phone").val();
		/*if (phone == "") {
			$("label#phone_error").show();
			$("input#phone").focus();
			return false;
		}*/
		
		var source = $("select#source").val();
		/*
		if (source == "Select One...") {
			$("label#source_error").show();
			$("select#source").focus();
			return false;
		}*/
		
		var message = $("textarea#message").val();
		if (message == "") {
			$("label#message_error").show();
			$("textarea#message").focus();
			return false;
		}

      
        var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone +'&message=' + message +'&source=' + source;
  //alert (dataString);return false;
		
		$.ajax({
			type: "POST",
			url: "bin/process.php",
			data: dataString,
			beforeSend: function(){
				$('#contact_form form#contactForm').append('<img src="images/ajax-loader.gif" class="loaderIcon" alt="Loading..." />');			
			},
			success: function() {
				$('#contact_form form#contactForm').fadeOut(1000);
				
				$('#contact_form').html("<div id='feedback'></div>");
				$('#feedback').html("<h3>Contact Form Submitted!</h3>")
					.append("<p>We will be in touch soon.</p>")
					.hide()
					.fadeIn(1500);
			}
		});
		return false;
	});
});
