$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  /*$('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#E4F5FA"});
  });*/
  
/* duminda edited*/
  

/* end edite */
  
  
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
	$('.error').hide();
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
	
		
	  var fname = $("input#fname").val();
		if (fname == "") {
      $("label#fname_error").show();
      $("input#fname").focus();
	  $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
	var lname = $("input#lname").val();
		if (lname == "") {
      $("label#lname_error").show();
      $("input#lname").focus();
	  $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
	
	var company = $("input#company").val();
		
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
	   $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
		var add1 = $("input#add1").val();
		var add2 = $("input#add2").val();
		var city = $("input#city").val();
		var state = $("input#state").val();
		var zip = $("input#zip").val();
		var inquiry = $("input#inquiry").val();
		
/*		var msg = $("textarea#msg").val();
		if (msg == "") {
      $("label#msg_error").show();
      $("textarea#msg").focus();
	   $('input.text-input').css({backgroundColor:"#FFB0B0"});
	 
	   
      return false;
    }*/
		
		var dataString = 'fname='+ fname + '&lname=' + lname + '&company=' + company + '&add1=' + add1 + '&add2=' + add2 + '&city=' + city + '&email=' + email + '&state=' + state + '&zip=' + zip + '&inquiry=' + inquiry;
		/*alert (dataString);return false;*/
		
		$.ajax({
      type: "POST",
      url: "process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h4>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#fname").select().focus();
});

