$(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"});
  });

  $(".sbutton").click(function() {
		// validate and process form
		// first hide any error messages
    $('.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 telephone = $("input#telephone").val();
		if (telephone == "") {
      $("label#telephone_error").show();
      $("input#telephone").focus();
      return false;
    }
	var ch1='';
	if(document.getElementById('ch1').checked)
	{
	ch1 = $("input#ch1").val();
	}
	var ch2='';
	if(document.getElementById('ch2').checked)
	{
	ch2 = $("input#ch2").val();
	}
	var ch3='';
	if(document.getElementById('ch3').checked)
	{
	ch3 = $("input#ch3").val();
	}
	var ch4='';
	if(document.getElementById('ch4').checked)
	{
	ch4 = $("input#ch4").val();
	}
		var dataString = 'name='+ name + '&email=' + email + '&telephone=' + telephone + '&ch1=' + ch1 + '&ch2=' + ch2 + '&ch3=' + ch3 + '&ch4=' + ch4;
		//alert (dataString);return false;

		$.ajax({
      type: "POST",
      url: "process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2><br /><br /><br />Call back Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});
