$(document).ready(function(){
  $("#email,#name,#cell").click(function(){
    if($(this).val() == "enter your email address" || $(this).val() == "enter your name" || $(this).val() == "enter your contact number"){
      $(this).css("color","#000000");
      $(this).val("");
    }
    else{
      $(this).css("color","#000000");
    }
  });
  
  $("#email,#name,#cell").blur(function(){
    if($(this).val() == ""){
      $(this).css("color","#999999");
      var value = "";
      value = ($(this).attr("id") == "email") ? "enter your email address" : value;
      value = ($(this).attr("id") == "name") ? "enter your name" : value;
      value = ($(this).attr("id") == "cell") ? "enter your contact number" : value;
      $(this).val(value);
    }
    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;
  });
});