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 expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if (expires!=null) 
	{
		var expire = expires.split("-");
		var d = new Date(expire[0], expire[1], expire[2]);
		expdate.setTime(d.getTime());
	}
		

	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expdate.toGMTString()))
	+ ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain))
	+ ((secure == true) ? "; secure" : "");
}

function DelCookie(name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

function GetCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function QueryString(qs)
{
    s = location.href;
    s = s.replace("?","?&").split("&");
    re = "";
    for(i=1;i<s.length;i++)
    {
         if(s[i].indexOf(qs+"=")==0)
         {
             re = s[i].replace(qs+"=","");
         }
    }
	re = replace_all(re,"%20"," ");
    return re;
}

function replace_all (S_str, R_str, D_str)
{
    while (S_str.indexOf(R_str)!=-1) {
         S_str=S_str.replace(R_str,D_str);
    }
    return S_str;
}

var mover = "this.className='curArea';" 
var mout  = "this.className='';" 

function showoff() { 
	var mlay = document.getElementById("mlay");
	if (!mlay)
	   return;
	mlay.style.display = "none"; 
} 

function fresh() 
{
	var ph = 18, mwidth = 88;
	
	for (var i=0;i< mname.length; i++)
	{
		if(mname[i].length < 4)
		{
            mwidth = 70; 
		}
	}
	
    var bgc = "#CCCCCC",txc = "#FFFFFF";
	try {
		if (typeof(mname) == "undefined") {
			return;
		}

		mlay.style.backgourndColor = "#FFFFFF";
		mlay.style.width = mwidth; 
		mlay.style.height= mname ? (mname.length * ph) : 1; 

		var h = "<table width='100%' height='" + mname.length * ph + "px' cellpadding='0' cellspacing='0' border='0'>"; 
		var i = 0; 
		for (i = 0; i < mname.length; i++) { 
			h += "<tr align='left' height=" + ph + " onclick=\""+murl[i]+"\" onMouseover=\""+mover+"\" onMouseout=\""+mout+"\">"
			+ "<td style='font-size:9pt;' id='menuitem'>"+mname[i]+"</td></tr>";
		} 
		h += "</table>"; 

		mlay.innerHTML = h; 
	} catch (e) {
		showError("fresh: " + e.message);
	}
}

