$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#E8F2B6"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var firstname = $("input#firstname").val();
		if (firstname == "") {
      $("label#firstname_error").show();
      $("input#firstname").focus();
      return false;
    }
	
	var surname = $("input#surname").val();
		if (surname == "") {
      $("label#surname_error").show();
      $("input#surname").focus();
      return false;
    }
	var company = $("input#company").val();
		if (company == "") {
      $("label#company_error").show();
      $("input#company").focus();
      return false;
    }
		var telephone = $("input#telephone").val();
		if (telephone == "") {
      $("label#telephone_error").show();
      $("input#telephone").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	var email = $("input#business").val();
		if (email == "") {
      $("label#business_error").show();
      $("input#business").focus();
      return false;
    }
		var captcha = $("input#captcha").val();
		if (captcha == "") {
      $("label#captcha_error").show();
      $("input#captcha").focus();
      return false;
    }	
		$.ajax({
      type: "POST",
      url: "http://www.webengine.co.nz/signup_webengine.php",
      data: dataString,
      success: function() {
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#firstname").select().focus();
});
