var currentMenuItem

function toggleSubMenu(menuItemID)
{
	var menuItem = document.getElementById(menuItemID);
	var isTopLevelNav;
		
	menuItem.className = switchClassName(menuItem.className);	
	if(currentMenuItem!=null)
	{	
		if(currentMenuItem!=menuItem)
		{
			ensureMenuItemClosed(currentMenuItem);
		}
	}
	
	currentMenuItem = menuItem;	
}

function switchClassName(className)
{
	className = className.indexOf('Show')>-1?className.replace('Show','Hide'):className.replace('Hide','Show');
	return className;
}

function ensureMenuItemClosed(menuItem)
{
	if(menuItem.className.indexOf('Show')>-1)
	{
		menuItem.className = switchClassName(menuItem.className);
	}
}

// Javascript to get the parameters used for salesforce and hitbox from the querystring of an article as 
// these are stripped out and so need to be pulled from the cookies
function GetSFHBXValues()
{

var query = ReadCookie('HitboxCP');
var fullquery = "";
	if (query != "")
	{	
	fullquery = "?cp=" + query;
	}

var sfquery = ReadCookie('sfid');
var sffullquery = "";
	if (sfquery != "")
	{	
	sffullquery = "&sfid=" + sfquery;
	}

var fullurl = fullquery + sffullquery;
return fullurl;
}

//Function to to get the parameters used for salesforce and hitbox from the querystring of an article as 
// these are stripped out and so need to be pulled from the cookies and adds this to the URL passed in
//and returns the full url
function GetSFHBXValuesWithURL(url)
{

var query = ReadCookie('HitboxCP');
var fullquery = url;
	if (query != "")
	{	
	fullquery += "?cp=" + query;
	}

var sfquery = ReadCookie('sfid');
var sffullquery = "";
	if (sfquery != "")
	{	
	sffullquery = "&sfid=" + sfquery;
	}

var fullurl = fullquery + sffullquery;
return fullurl;
}



function ReadCookie(cookieName) 
{
var theCookie = "" + document.cookie;
var ind = theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=="")
	{
		return ""; 
	}
var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1)
	{
		ind1=theCookie.length;
	} 
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
