﻿// JScript File

function checkCookie(divElement)
{         
    document.getElementById(divElement).innerHTML = '';    
    
    SetCookie('varCook','True','','/','','');
    if (GetCookie() != "True")            
    {            
        window.location = "enableCookie.aspx?js=false&id=" + document.Form1.userid.value + "&type=" + document.Form1.usertype.value;
    }           
}

function GetCookie()
{
    var strName = "varCook";
    if (document.cookie.indexOf(strName) == -1)
    {
        alert("Cookies are NOT currently enabled!\nPlease read below on this page for information on how to enable cookies.");                
        return false;
    }
    else
    {
    cookieStart = document.cookie.indexOf(strName);
    cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
    cookieValEnd = document.cookie.indexOf(";", cookieStart);
    if (cookieValEnd == -1)
        {
        cookieValEnd = document.cookie.length;
        }
    cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
    }
    if (cookieValue = "True")
    {
        return ("True");
    }
}

function SetCookie(name,value,expires,path,domain,secure)
{
    var strDNS = GetDNS();
        document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        ( (path) ? ";path=" + path : "") +            
        ( (domain) ? ";domain=" + strDNS : "") +
        ( (secure) ? ";secure" : "");
        return true
}

function GetDNS()
{
    cookieDomain = document.location.hostname;
}
