function setCounter() {
    if (getQuery('close', window.parent.$('#session iframe').attr('src')) == '1') {
        window.parent.$('#session').fadeOut();
        window.parent.redirectUrl('', "iframeSession");
        window.parent.checkSessionTimeout();
    }
    else {
        window.parent.$('#session').fadeIn();
        setInterval(function () {
            var pad = "00";
            var strMin = $('#spTime').text().split(':')[0];
            var strSec = $('#spTime').text().split(':')[1];
            if (strSec == "00") {
                if (strMin == "00") {
                    exitWebApplication(true);
                }
                else {
                    strMin = pdLeft((parseInt(strMin) - 1).toString());
                    strSec = "59";
                }
            }
            else {
                strSec = pdLeft((parseInt(strSec) - 1).toString());
            }
            $('#spTime').text(strMin + ':' + strSec);

        }, 1000);
    }
}
function pdLeft(input) {
    var pad = "00";
    return pad.substring(0, pad.length - input.length) + input;
}
function getQuery(name, url) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(url);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}
function exitWebApplication(exit) {
    window.top.exitWebApplication(exit);
}
function sessionContinue() {
    window.parent.$('#session').fadeOut();
    ajax({
        loading: true,
        url: "GeneralApi/LiveSession",
        success: function (retValue) {
            window.top.redirectUrl("SessionTimeout?close=1", "iframeSession");
        }
    });
}