$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var vname = $("textarea#vtextname").val();
		if (vname == "") {
      $("label#name_error").show();
      $("input#vtextname").focus();
	$(".button").removeAttr("disabled");
     $(".button").val("Send");	
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
     
     $(".button").removeAttr("disabled");
     $(".button").val("Send");	
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
	$(".button").removeAttr("disabled");
     $(".button").val("Send");	
      return false;
    }
		
		var dataString = 'name='+ $("textarea#vtextname").val() + '&email=' + email + '&phone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "process.aspx",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div style='border: 3px coral solid;' id='message'><form name='contact' method='post' action=''><fieldset></fieldset></form></div>");
        $('#message').html("<h2>Query Form Submitted!</h2>")
        .append("<table cellpadding=1 cellspacing=1><tr><td ><h3>Thank you! Your query has reached us. We will revert soon.<Br><Br>We look forward to assist you in all your legal requirements.<br><br>Thinklegal Team.</h3></font></td></tr></table>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});



