//document.onbeforeunload="unParkCookie();";
//document.onload="unParkCookie();";
//document.onload="checkAuth();";

function unParkCookie() {
//alert("Setting Cookie.  Current Value:" + getCookie("pageNavigationState"));
SetCookie("pageNavigationState", "MIGRATE", 10);
//alert("Cookie Set.  New Value:" + getCookie("pageNavigationState"));
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 //expire.setTime(today.getTime() + 3,600,000*24*nDays);
 expire.setTime(today.getTime() + 2000);
 document.cookie = cookieName + "=" + escape(cookieValue) + ";expires="+expire.toGMTString() + ";domain=aims.maxit.biz;path=/";
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

// DISABLE RIGHT CLICKING
    function right(e)
    {
        if (document.layers && e.which == 3)
        {
            alert("Use the application tabs to navigate the application.");
            return false;
        }
        else if (document.all && event.button == 2)
        {
            alert("Use the application tabs to navigate the application.");
            return false;
        }
        return true;
    }

    document.onmousedown=right;

    if (document.layers)
    {
        window.captureEvents(Event.MOUSEDOWN);
    }
    
// CHECK TO SEE IF THE USER HAS LEFT THE SITE    
    function checkAuth() {
     if (getCookie("pageNavigationState") != "PARKED") {
       location.href="/admin/logOff.aspx";
     }
     //alert("you're Authorized.." + getCookie("pageNavigationState"));
    } 

