      function isCookieValue(name,value)
{
    var allCookies = "";
    if(document.cookie!=null)
    {
        allCookies = document.cookie;
        allCookieArr = allCookies.split(';');
        if(allCookieArr!=null)
        {
            var i = 0;
            for(i=0;i < allCookieArr.length;i++)
            {
                var cook = allCookieArr[i].split('=');
                if(cook!=null && cook[0] == name && cook[1] == value)
                {
                    return true;
                    break;
                }
            }
        }
    }
    return false;
}

function addCookie(name,value)
{
    document.cookie=name + "=" + value;
}

function getCookie(name)
{
    var allCookies = "";
    if(document.cookie!=null)
    {
        allCookies = document.cookie;
        allCookieArr = allCookies.split(';');
        if(allCookieArr!=null)
        {
            var i = 0;
            for(i=0;i < allCookieArr.length;i++)
            {
                var cook = allCookieArr[i].split('=');
                if(cook!=null && name!='login.jsp' && cook[0] == name)
                {
                    return cook[1];
                    break;
                }
            }
        }
    }
    return null;
}

function navigateValidPage()
{
    var loc = new String(window.location);
    if(loc!=null)
    {
        //alert("loc : "+loc);
        var slashIndex = loc.lastIndexOf("/");
        var fileName = loc.substring(slashIndex+1,loc.length);
        var fileName1 = fileName;
        if(fileName.indexOf('?')!=-1)
        {
       
           fileName1 = fileName.substring(0,fileName.indexOf('?'));
            

        }
        var cook = getCookie('fileName');
        var fileName2 = cook;
        if(cook.indexOf('?')!=-1)
        {
            
            fileName2 = cook.substring(0,cook.indexOf('?'));

        }
      
        if(cook!=null && cook!='null' && cook!='' && fileName1!=fileName2)
        {
            //window.navigate(cook);
           window.navigate("invalid.jsp")
        }
    }
}
