var old_active_link_id;
			
function GetCookie(sName)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	// a name/value pair (a crumb) is separated by an equal sign
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
}

function SetCookie(NameOfCookie, value, expiredays) 
{
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function SaveURL(anchor)
{
	var href = document.getElementById(anchor).href;
	var re = /(http:\/\/[^/]+)(.+)/;
	var arr = re.exec(href);
	var url = arr[2];
	if (url == '/qterm')
		{  SetCookie('CurrPage',"HomePage.aspx",1); }
	else
		{	SetCookie('CurrPage',url,1);}
	//SetCookie('CurrPage',url,1);
}

function OnLinkClick()
{
	if (document.activeElement.id == '')
	{
		// we're in the div inside the <a> element
		document.activeElement.parentElement.className = "prod_level2_selected";
		if ((old_active_link_id != null) && (old_active_link_id != document.activeElement.parentElement.id))
		{
			document.getElementById(old_active_link_id).className = "prod_level2";
		}
		old_active_link_id = document.activeElement.parentElement.id;
		
		SaveURL(document.activeElement.parentElement.id);
		SetCookie('ActiveLink',document.activeElement.parentElement.id,1);
	}
	else if (document.activeElement.id != null)
	{
		// we're in the <a> element
		document.activeElement.className = "prod_level2_selected";
		if ((old_active_link_id != null) && (old_active_link_id != document.activeElement.id))
		{
			document.getElementById(old_active_link_id).className = "prod_level2";
		}
		old_active_link_id = document.activeElement.id;
		
		SaveURL(document.activeElement.id);
		SetCookie('ActiveLink',document.activeElement.id,1);
	}
}

function ShowMainSubMenu(menuID)
{
	document.getElementById(menuID).style.display="block";
}
function HideMainSubMenu(menuID)
{
	//debugger;
	document.getElementById(menuID).style.display="none";
}
