$(document).ready(function(){
  $("#email").click(function(){
    if($(this).val() == "enter your email address"){
      $(this).css("color","#000000");
      $(this).val("");
    }
    else{
      $(this).css("color","#000000");
    }
  });
  
  $("#email").blur(function(){
    if($(this).val() == ""){
      $(this).css("color","#999999");
      $(this).val("enter your email address");
    }
    else{
      $(this).css("color","#000000");
    }
  });
  
  $("#subscribe").click(function(){
    $("#subscribe_loader").html("<img src='/images/ajax_loader.gif' alt='' />");
    var form = $(this).parents("form");
    $.ajax({
      type:"post",
      url:form.attr("action"),
      data:form.serialize(),
      success:function(returnText){
        if(returnText.indexOf("error") > -1){
          $("#subscribe_loader").html("");
          $.fn.colorbox({html:returnText});
        }
        else{
          $("#special_offers").html("<h3>Special Offers by email:</h3><p>" + returnText + "</p>");
        }
      },
      error:function(){
        $("#subscribe_loader").html("");
        $.fn.colorbox({html:"There was an error while adding your email address to the subscriber list, please try again."});
      }
    });
    return false;
  });
});
