$(function(){
    $("#privateoffers-name, #privateoffers-email").bind('focus',function(e){
		$(this).val($(this).val()==$(this).attr("default") ? "" : $(this).val());
	});

    $("#privateoffers-name, #privateoffers-email").bind('blur',function(e){
		$(this).val($(this).val()=="" ? $(this).attr("default") : $(this).val());
	});

    $("#privateoffers-name, #privateoffers-email").each(function(){
		$(this).val($(this).val()=="" ? $(this).attr("default") : $(this).val());
		$("#privateoffers-button").attr("href","/popUpPages/privateOffers.aspx");
	});

	$("#privateoffers-button").bind('click',function(){
		var list = $("#privateoffers-list").val();
		var name = $("#privateoffers-name").val();
		var email = $("#privateoffers-email").val();
		var name_defult = $("#privateoffers-name").attr("default");
		var email_defult = $("#privateoffers-name").attr("default");

		if(name!='' && email!='' && name!=name_defult && email!=email_defult)
		{
			var hostUrl = window.location.protocol+"//"+location.hostname;
			var refererURL = window.document.location.href;
			var successURL = hostUrl+"/popuppages/privateOffers.aspx?mail=1";
			var failureURL = hostUrl+"/popuppages/privateOffers.aspx?mail=0";
			var popUpURL = 'http://action.clickkingdom.com/mailman.aspx?name='+name+'&email='+email+'&list='+list+'&mode=add&referer='+escape(refererURL)+'&success='+escape(successURL)+'&failure='+escape(failureURL);

			$("#privateoffers-button").attr("href",popUpURL);
			$.cookie('privateoffers', (new Date()).toUTCString(), { expires: 178, path: '/', domain: 'zenmed.com' });
		}
		else
			$("#privateoffers-button").attr("href","/popUpPages/privateOffers.aspx");
	});

    $("#privateoffers-name, #privateoffers-email, #privateoffers-button").bind('keypress',function(e){
        if(e.which==13)
		{
			$("#privateoffers-button").click();
			return false;
		}
    });
});
