﻿var jQueryScriptOutputted = false;

function initJQuery() {

    //if the jQuery object isn't available
    if (typeof (jQuery) == 'undefined') {


        if (!jQueryScriptOutputted) {
            //only output the script once..
            jQueryScriptOutputted = true;

            //output the script (load it from google api)
            var head = document.getElementsByTagName('head')[0];
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
            head.appendChild(script);
        }
        setTimeout("initJQuery()", 50);
    } else {

        $(function() {
            //do anything that needs to be done on document.ready
            ResetSessionTimer();
        });
    }

}
initJQuery();

var session_timer;
var sessionTimeout = 900000; //15min
function ResetSessionTimer() {
    //for live
    session_timer = setTimeout("RefreshSession()", sessionTimeout);
}

function RefreshSession() {
    //reload page
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: document.location.protocol + "//" + document.location.host + "/WebServices/WSApplicationUsers.asmx/KeepAlive",
        data: '{}',
        dataType: "json",
        success: function(data) {
            ResetSessionTimer();
        }
    });
}

