////////////////////////
// Работа с куками
////////////////////////
function getCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1) endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
        }
        return null;
}
function SetCookie (name, value) {
	var argv;
	var argc;
	if (Set_Cookie)
	{
    	argv = Set_Cookie.arguments;
    	argc = Set_Cookie.arguments.length;
	}
	else
	{
		argv = SetCookie.arguments;
		argc = SetCookie.arguments.length;
	}
    document.cookie = name + "=" + escape (value) +
		( (argc > 2) ? '; expires=' + argv[2].toGMTString() : '' ) +
		( (argc > 3) ? '; path=' + argv[3] : '' )
		;
}

function SetSessionCookie(name, value, path) {
    document.cookie = name + "=" + escape (value) + '; path=' + path;
}

Set_Cookie=SetCookie;

function DelCookie(name){
	document.cookie = name + "=" + GetCookie(name) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

