
var objRowHref = "";
function MenuStartUp(checkURL, notLink)
{
	
	var mLTable = document.getElementById("MenuL");
	var lblNav = document.getElementById("lblNav");
	var checkL1Found;
	
	if (notLink == 'NotLink')
	{
		lblNav.innerHTML += " <b>" + mLTable.getAttribute("Grp") + "</b>";
	}
	
	for (i=0; i<mLTable.childNodes[0].childNodes.length; i++)
	{
		var objRow = mLTable.firstChild.childNodes[i];
		if (objRow.firstChild.firstChild.tagName == "A" && objRow.firstChild.firstChild.getAttribute("HREF").toUpperCase().indexOf(checkURL.toUpperCase()) > -1)
		{	
			lblNav.innerHTML += " <a href='" + mLTable.getAttribute("GrpLk") + "' class='k11a'>" + mLTable.getAttribute("Grp") + "</a> > ";
			if (objRow.getAttribute("Level") == '1')
			{	
				//FormatSelectedRow(objRow);
				lblNav.innerHTML += " <a href='" + objRow.firstChild.firstChild.getAttribute("href") + "' class='k11a'><b>" + objRow.firstChild.firstChild.innerHTML + "</b></a>";
				checkL1Found = true;
				j = 1;
				childRow = objRow.parentNode.childNodes[i + j];
				while (childRow && childRow.Level == 2)
				{
					j++
					childRow.style.display = "";
					childRow = objRow.parentNode.childNodes[i + j];
				}
			}
			else if (objRow.getAttribute("Level") == 2)
			{	
				if (checkL1Found)
				{				
					lblNav.innerHTML = lblNav.innerHTML.substring(0, lblNav.innerHTML.indexOf(mLTable.Grp) + mLTable.getAttribute("Grp").length + 8); // hehe
				}
				//FormatSelectedRow(objRow);
				var j = 1;
				var objParentRow = objRow.parentNode.childNodes[i - j];
				while (objParentRow)
				{
					if (objParentRow.getAttribute("Level") == 1)
					{
						break;
					}
					else
					{
						j++;
						objParentRow = objRow.parentNode.childNodes[i - j];
					}
				}
				k = i - j; // k: parent row's first level2 child row index
				if (checkL1Found)
					lblNav.innerHTML += " <a href='" + objRowHref + "' class='k11a'>" + objParentRow.firstChild.firstChild.innerHTML + "</a>";
				else
					lblNav.innerHTML += " <a href='" + objParentRow.firstChild.firstChild.getAttribute("href") + "' class='k11a'>" + objParentRow.firstChild.firstChild.innerHTML + "</a>";
				
				lblNav.innerHTML += " > <a href='" + objRow.firstChild.firstChild.getAttribute("href") + "' class='k11a'><b>" + objRow.firstChild.firstChild.innerHTML.substring(25, objRow.firstChild.firstChild.innerHTML.length) + "</b></a>";
				
				
				FormatSelectedRow(objParentRow);
				k++;
				var objRowToDisplay = objParentRow.parentNode.childNodes[k];
				while (objRowToDisplay && objRowToDisplay.getAttribute("Level") != 1)
				{
					
					objRowToDisplay.style.display = "";
					k++;
					objRowToDisplay = objParentRow.parentNode.childNodes[k];
				}
			}
			FormatSelectedRow(objRow);
		}
		
	}
}
function FormatSelectedRow(objRow)
{
	objRow.firstChild.firstChild.style.color = "ba0222";
	objRowHref = objRow.firstChild.firstChild.getAttribute("href");
	//objRow.firstChild.firstChild.getAttribute("href") = "#";
	//objRow.firstChild.firstChild.removeAttribute("href");
	objRow.firstChild.style.backgroundColor = "d4eced";
}
String.prototype.trim = function() {
		var x=this;
		x=x.replace(/^\s*(.*)/, "$1");
		x=x.replace(/(.*?)\s*$/, "$1");
		return x;
		}
function SearchClick()
{
	if (document.getElementById("Search1_TextBox1").value.trim() == "")
	{
		alert(SearchEmptyMsg);
		return false;
	}
	else
		return true;
}
function getKeyCode(e)
{
 if (window.event)
    return window.event.keyCode;
 else if (e)
    return e.which;
 else
    return null;
}
function keySearch(e)
{
key = getKeyCode(e);
 if (key == 13)
 {
document.getElementById("Search1_ImageButton1").click();
return false;
}
}
function TestSessionStart()
{
	if (document.getElementById("SessionStart")){
		GetScreenAX.GetScreen_AX(screen.width, screen.height);}
}
function PopupWindow(url,name,width,height)
{
			var centerX = (screen.width-width)/2;
			var centerY = (screen.height-height)/2;
			popWin = window.open(url,name,"toolbar=no,  resizable=no, status=yes, scrollbars=no, menubar=no, width=" + width + ",height="+height+ ',top='+centerY+',screenY='+centerY+',left='+centerX+',screenX='+centerX);
			popWin.focus();
}
function PopupWindow(url,name,width,height,scrollbars)
{
			var centerX = (screen.width-width)/2;
			var centerY = (screen.height-height)/2;
			popWin = window.open(url,name,"toolbar=no,  resizable=no, status=yes, scrollbars="+scrollbars+", menubar=no, width=" + width + ",height="+height+ ',top='+centerY+',screenY='+centerY+',left='+centerX+',screenX='+centerX);
			popWin.focus();
}
function ddlCountryChange(ddl)
{
	if (ddl.value != "")
		window.location.href = ddl.value;
}