/* These functions provide interaction with cookie
 *
 *      setCookie()
 *      getCookie()
 *      locateCookieInStr()
 *      getCookieVal()
 *      resetCookie()
 *
*/


function setTempCookie(name,val,path,domain){
        document.cookie = name + "=" + val + ";path=" + path;
	return true;
}


function getCookie(cookieName){
        var loc = locateCookieInStr(cookieName);
        if (loc){
                return getCookieVal(loc);
        } else {
                return false;
        }
}



function locateCookieInStr(name){
        name = name + "=";
        var nameLen = name.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i<clen){
                var j = i + nameLen;
                if (document.cookie.substring(i,j) == name){
                        return j;
                }
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
        }
}


function getCookieVal(offset){
        var endstr = document.cookie.indexOf(";", offset);
        if (endstr == -1){
                endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
}


function resetCookie(){
        location.reload();
}


function getExpiryTime(delay_in_days){
        var exp = new Date();
        var expiryTime = exp.getTime() + (delay_in_days * 24 * 60 * 60 * 1000);
        exp.setTime(expiryTime);
        return exp.toGMTString();
}






/*-------------------------------------------------*/

