$(function() {
  $('.error').hide();
  $('input.text-input').css({border:"1px solid #ccc"});
  $('input.text-input').focus(function(){
    $(this).css({border:"1px solid #8fea27"});
  });
  $('input.text-input').blur(function(){
    $(this).css({border:"1px solid #ccc"});
  });

  $(".submitInquiry").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	var name = $("input#name").val();
	if (name == "") {
      $("span#name_error").show();
      $("input#name").focus();
      return false;
    }
    
    var title = $("input#title").val();
    
    var company = $("input#company").val();
	
	var email = $("input#email").val();
	if (email == "") {
      $("span#email_error").show();
      $("input#email").focus();
      return false;
    }

	var phone = $("input#phone").val();
	if (phone == "") {
      $("span#phone_error").show();
      $("input#phone").focus();
      return false;
    }
    
    var msgsubject = $("input#msgsubject").val();
	if (msgsubject == "") {
      $("span#subject_error").show();
      $("input#msgsubject").focus();
      return false;
    }
    
    var message = $("textarea#message").val();
	if (message == "") {
      $("span#message_error").show();
      $("input#message").focus();
      return false;
    }
    
	var dataString = 'name='+ name + '&title=' + title + '&company=' + company + '&email=' + email + '&phone=' + phone + '&msgsubject=' + msgsubject + '&message=' + message;
		//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "/wp-content/themes/gpl/data/process.php",
      data: dataString,
      success: function() {
        $('#contactContainer').html("<div id='thanks'></div>");
        $('#thanks').html("<h2>INQUIRY SUBMITTED!</h2>")
        .append("<p>Thank you for your inquiry!<br />We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#thanks');
        });
      }
     });
    return false;
	});
});
//runOnLoad(function(){
//  $("input#name").select().focus();
//});

