var subscriber = {
    manageUsers: {
        events: function(){
            $("tr td img[name=delete]").click(function(e){
                popup({
                    title: "Delete User?",
                    html: "This will permanently remove this user. Are you sure you want to do this?",
                    button1: "Delete",
                    height: "60px",
                    callback: function(){

                    }
                });
            });
        }
    },
    manageCampaigns: {
        events: function(purchaseCredits){
            //plug this into the action /subscriber/campaign/renew with no parameters
            $("[name=renew]").click(function(e){
                e.preventDefault();
                popup({
                    title: "Renew Campaign?",
                    html: "You campaign will be extended "+$(this).attr("renewdays")+" days from today.  Go ahead and renew?",
                    button1: "Renew",
                    height: "70px",
                    callback: function(){
                        document.location= base.context + "/a/subscriber/campaign/renew";
                    }
                });
            });
            $("[name=delete]").click(function(e){
                e.preventDefault();
                var cc = $(this).attr("campaign");
                popup({
                    title: "Delete Campaign?",
                    html: "This will permanently remove this campaign. Are you sure you want to do this?",
                    button1: "Delete",
                    height: "60px",
                    callback: function(){
                        document.location= base.context + "/a/subscriber/campaign/delete?campaignId="+cc;
                    }
                });
            });
            $("[name=contact_delete]").click(function(e){
                e.preventDefault();                
                var cc = ($(this).siblings('input')).get(0).value.split(",");
                popup({
                    title: "Delete Contact?",
                    html: "This will permanently remove this contact. Are you sure you want to do this?",
                    button1: "Delete",
                    height: "60px",
                    callback: function(){
                        $('#contactIdInput').val(cc[1]);
                        $('#campaignIdInput').val(cc[2]);
                        $('#deleteContactForm').submit();
                    }
                });
            });
            $("#purchase").click(function(e){
                e.preventDefault(); var that = this;
                popup({
                    title: "Purchase Campaign?",
                    html: "If you continue, your message will be sent to the talent you have selected and you will use <b>"+purchaseCredits+"</b> credit(s) from your SMARTT account. Do you wish to purchase this campaign?",
                    button1: "Purchase",
                    height: "80px",
                    callback: function(){
                        document.location = that.href;
                    }
                });
            });
        }
    },
    purchaseAd: {
        events: function(){
            $("div.continue a[name=purchase]").click(function(e){
                var el = this;
                e.preventDefault();
                popup({
                    title: "Purchase Ad?",
                    html: "This will purchase this ad and charge your account 2 contacts.  Do you want to do this?",
                    button1: "Purchase",
                    height: "60px",
                    callback: function(){
                        popup({
                            title: "Purchase Successful",
                            html: "Your advertisement has been submitted for the next newsletter.",
                            height: "50px",
                            close: function(){
                                document.location = el.href;
                            }
                        });
                    }
                });
            });

            $("div.continue button[name=purchase]").click(function(e){
                e.preventDefault();
                popup({
                    title: "Purchase Ad?",
                    html: "You are about to publish your ad for the next upcoming newsletter. Once published, your ad will be editable until the administrator publishes the full newsletter, at which point you will no longer be able to make changes to the ad. Newsletters are published monthly, but not on a specific date, so please make sure you have previewed the ad before submitting it. If you’d like to go back and preview your ad, click 'cancel'. If you are ready to publish your ad, click 'continue'.",
                    button1: "Continue",
                    height: "180px",
                    callback: function(){
                        $('#purchaseAdForm').trigger("submit");
                    }
                });
            });
        }
    }
};
