var str_usr_Logged;

var opn_ItnUpd = {
    success: btn_Toggle,
    timeout: 3000
};

var opn_Vote = {
    success: confirmreg,
    timeout: 3000
};

// post-submit callback
function btn_Toggle(responseText, statusText) {

    if ($("#btn_Toggle").val() == "Add to My Night") {
        $("#btn_Toggle").attr("value", "Remove from My Night");
        $("#btn_Toggle").attr("name", "Remove from My Night");
        $('#div_frm_ItineraryUpdate')
                    .hide()
                    .fadeIn(1500);
        //$.jGrowl('Added to Your Night', $("#lb_ImgDetail").html() + 'is now scheduled for your night!');
    }
    else
        if ($("#btn_Toggle").val() == "Remove from My Night") {
        $("#btn_Toggle").attr("value", "Add to My Night")
        $("#btn_Toggle").attr("name", "Add to My Night")
        $('#div_frm_ItineraryUpdate')
                    .hide()
                    .fadeIn(1500);
        //$.jGrowl('Removed from Your Night', $("#lb_ImgDetail").html() + 'is not scheduled any more for your night!'); 
    }
}

function DisableVote() {
    $("#btn_Vote").attr('value', 'Vote Accepted');
    $("#btn_Vote").attr("disabled", "true");
}

function confirmreg() {
    DisableVote();
    if ($.cookie('vt_' + str_usr_Logged + '_registered') != null)
        return;

    var options;
    if (str_usr_Logged == "Anonymous")
        options = { path: '/', expires: 1 };
    else
        options = { path: '/', expires: 90 };

    $.cookie('vt_' + str_usr_Logged + '_registered', '1', options);

    $("#dia_RemItd").html('<p>Would you like to enter the contest?</p>' +
                                  '<p><b>Grand prize</b>: You could win an art-inspired weekend in Toronto.<br />' +
                                  '<b>Secondary prizes</b>: one of 5 AGO memberships or one of 5 ROM memberships.</p>');
    $("#dia_RemItd").dialog('option', 'title', '<b>Thank you for voting for Scotiabank People\'s Choice.</b>');
    $("#dia_RemItd").dialog('option', 'buttons', {
        "Yes": function() {
            $(this).dialog("close");
            if (b_IsMobile)
                window.location.replace('/peopleChoiceRegister_m.shtml');
            else
                showreg();
        },
        "No": function() {
            $(this).dialog("close");
        }
    });
    $("#dia_RemItd").dialog("open");
}

function showreg() {
    $("#dia_RemItd").html('<iframe id="ifrm_PeoplesChoice" src="https://www.scotiabankcontests.com/nuitblanche" width="900" height="495">' +
                                          '<p>Your browser does not support iframes.</p>' +
                                          '</iframe>');
    $("#dia_RemItd").dialog('option', 'height', 600);
    $("#dia_RemItd").dialog('option', 'width', 955);
    $("#dia_RemItd").dialog('option', 'title', '');
    $("#dia_RemItd").dialog('option', 'buttons', {
        "Close": function() {
            $(this).dialog("close");
        }
    });
    $("#dia_RemItd").dialog("open");
}
