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

  $(".news-button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var newsName = $("input#news-name").val();
		if (newsName == "") {
      $("label#news-name_error").show();
      $("input#news-name").focus();
      return false;
    }
		var newsEmail = $("input#news-email").val();
		if (newsEmail == "") {
      $("label#news-email_error").show();
      $("input#news-email").focus();
      return false;
    }
		var newsCountry = $("input#news-country").val();
		if (newsCountry == "") {
      $("label#news-country_error").show();
      $("input#news-country").focus();
      return false;
    }
		
		var dataString = 'newsName='+ newsName + '&newsEmail=' + newsEmail + '&newsCountry=' + newsCountry;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "form/bin/newsletter.php",
      data: dataString,
      success: function() {
        $('#news-form').html("<div id='news-message'></div>");
        $('#news-message').html("<h4>Signup Successful! We will be in touch soon.</h4>")
        .append("")
        .hide()
        .fadeIn(1500, function() {
          $('#news-message').append("");
        });
      }
     });
    return false;
	});
});
//runOnLoad(function(){
//  $("input#news-name").select().focus();
//});
