$(function() {
  $('#cb_form .error').hide();
  $('#cb_form input.text-input').css({backgroundColor:"#000000"});
  $('#cb_form input.text-input').focus(function(){
    $(this).css({backgroundColor:"#333333"});
  });
  $('#cb_form input.text-input').blur(function(){
    $(this).css({backgroundColor:"#000000"});
  });
    $('#cb_form textarea').css({backgroundColor:"#000000"});
  $('#cb_form textarea').focus(function(){
    $(this).css({backgroundColor:"#333333"});
  });
  $('#cb_form textarea').blur(function(){
    $(this).css({backgroundColor:"#000000"});
  });

  $(".cbbutton1").click(function() {
		// validate and process form
		// first hide any error messages
    $('#cb_form .error').hide();
		
	  var name = $("input#cbname").val();
		if (name == "") {
      $("label#cbname_error").show();
      $("input#cbname").focus();
      return false;
    }
		
		var phone = $("input#cbphone").val();
		if (phone == "") {
      $("label#cbphone_error").show();
      $("input#cbphone").focus();
      return false;
    }
		
		var dataString = 'cbname='+ name + '&cbphone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/processcb.php",
      data: dataString,
      success: function() { 
        $('#cb_form').html("<div id='cbmessage'></div>");
        $('#cb_form #cbmessage').html("<h2>Callback Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#cb_form #cbmessage').append("<img id='cbcheckmark' src='images/check.gif' />");
        });
		
      }
     });
    return false;
	});
});
runOnLoad(function(){
  
});
