
var addedGreetingId = 0;
var gotoGreetingUrl = '/youmail/greeting/communityList.do?p_o1=subscriptions.subscribeTime&p_oa1=false';

YAHOO.namespace("example.container");

function useCommunityGreeting( id )
{
    useGreeting( id, '/youmail/greeting/communityList.do?p_o1=subscriptions.subscribeTime&p_oa1=false' );
}

function usePremiumGreeting( id )
{
    useGreeting( id, '/youmail/greeting/premiumList.do?p_o1=subscriptions.subscribeTime&p_oa1=false' );
}

function useGreeting( id, gotoUrl )
{
    var url = '/community/greetingMemberUse.do';
    var pars = 'id=' + id;
    addedGreetingId = id;
    gotoGreetingUrl = gotoUrl;
    
    var goAjax = new Ajax.Request( url + '?' + pars,
        {
            method: 'get',
            asynchronous: false,
            onSuccess: function(transport) {
                // do nothing
            }                                    
        } );        
    
    YAHOO.example.container.dialog1.show();
    return true;
}

function init() {
    // Define various event handlers for Dialog
    var handleSurfMore = function() {
        this.cancel();
    };
    var handleGoToGreetings = function() {
        window.location = gotoGreetingUrl + '&lastAddedGreetingId=' + addedGreetingId;
    };
    
    // Instantiate the Dialog
    YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1", 
                { width : "440px",
                    x : 420,
                    y: 390,
                  fixedcenter : true,
                  iframe: true,
                  visible : false, 
                  constraintoviewport : true,
                  buttons : [ { text:"Keep Surfing", handler:handleSurfMore },
                              { text:"Go To My Greetings Now", handler:handleGoToGreetings } ]
                 } );    

    // Render the Dialog
    YAHOO.example.container.dialog1.render();    

}

YAHOO.util.Event.onDOMReady(init);

