$(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 yur_name = $("input#yur_name").val();
		if (yur_name == "") {
      $("label#yur_name_error").show();
      $("input#yur_name").focus();
      return false;
    }
		var yur_email = $("input#yur_email").val();
		if (yur_email == "") {
      $("label#yur_email_error").show();
      $("input#yur_email").focus();
      return false;
    }
		var yur_friends = $("input#yur_friends").val();
		if (yur_friends == "") {
      $("label#yur_friends_error").show();
      $("input#yur_friends").focus();
      return false;
    }
				
		
		var dataString = 'name='+ yur_name + '&yemail=' + yur_email + '&femail=' + yur_friends;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "_classes/share_process.php",
      data: dataString,
      success: function() {
        $('#share_form').html("<div id='message2'></div>");
        $('#message2').html("<h2 class='fancy white'>Email Sent!</h2>")
        .append("<p class='footer_link white'>Feel free to click below to share our site on your various social networking sites!</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message2').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#yur_name").select().focus();
});

