var expand = false;
function doThis() {
	if(!expand) {
		$('#readthebook').stop().animate({'margin-top':0},200);
		$('#tellus').unbind('click').bind('click',function(){testimonial_formCheck();});
		expand=true;
	}
}

$(function() {
  $('.fielderror').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"});
  });

  $(".testimonial_submit").click(function() {
		// validate and process form
		// first hide any error messages
		testimonial_formCheck();
	});
});
function testimonial_formCheck()
{
	$('.fielderror').hide();
    
	  var testimonial_businessdescrip = $("input#testimonial_businessdescrip").val();
		
	  var testimonial_name = $("input#testimonial_first_name").val();
		if (testimonial_name == "") {
      $("label#testimonial_name_error").show();
      $("input#testimonial_first_name").focus();
      return false;
    }
		var testimonial_email = $("input#testimonial_email").val();
		if (!testimonial_email.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)) {
      $("label#testimonial_email_error").show();
      $("input#testimonial_email").focus();
      return false;
    }
		var testimonial = $("textarea#testimonial_message").val();
		if (testimonial == "") {
      $("label#testimonial_message_error").show();
      $("input#testimonial_message").focus();
      return false;
    }
    
    var lead = $("input#lead_source").val();
    var leadDetail = $("input#00N60000001TDZr").val();
		
		var dataString = '00N60000001SF54=' + testimonial_businessdescrip + '&first_name='+ testimonial_name + '&email=' + testimonial_email + '&description=' + testimonial + '&lead_source=' + lead+ '&00N60000001TDZr=' + leadDetail;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.yodledummiesbook.com/salesforce.php",
      data: dataString,
      success: function() {
        $('#readthebook').html("<div class='returnmessage' id='returnmessage2'></div>");
        $('#returnmessage2').html("<h3>Thanks!</h3>")
        .hide()
        .fadeIn(1500)
      }
     });
    return false;
}
