
	// -------------------------------------------------------------
	// Client-side global variables
	// -------------------------------------------------------------
	var menuID = "imgMenuTitle"
	var divID = "divMenu"

	var sOpenMenuID = "";

	var iChunk = 0;
	var iChunkStep = 15;
	var iChunkDelay = 10;

	var currEvent = "";
	var prevEvent = "";
	var leftOffset = 0;
	var topOffset = 0;

	var openMenuTime = 1000;
		
	/*-------------------------------------------------------
	funtion that changes the menu font from bold to normal
	-------------------------------------------------------*/
	function MenuChangeFont() {
		//the element that was clicked
		var eSrc = window.event.srcElement;
		
		if( "Tpl_LinksBold" == eSrc.className )
			eSrc.className = "Tpl_Links";
	}

	/* ----------------------------------------------------------------
	main function, doMenu, that hides any open pop-up menus, determines 
	which menu DIV to access, and starts its display 
	---------------------------------------------------------------- */
	function DoMenu() {
		window.event.cancelBubble = true;
		
		//the element that was clicked
		var eSrc = window.event.srcElement;

		var ret = CloseOpenMenu();
		if( 1 == ret )
			return false;
				
		if( "Tpl_Links" == eSrc.className ) {
			eSrc.className = "Tpl_LinksBold";
		}
				
		// ----------------------------------------------------------
		// If a menu title (other than that of an open menu) was clicked
		// ----------------------------------------------------------
		if( "clsMenuTitle" == eSrc.className ) {
			// ----------------------------------------------------------
			// Cancel default link behavior
			// ----------------------------------------------------------
			window.event.returnValue = false;

			// ----------------------------------------------------------
			// Get Menu associated with the Menu Title and make sure it exists
			// If it does, show the Menu
			// ----------------------------------------------------------
			
			sOpenMenuID = eSrc.id.replace(menuID,divID);
			if( "object" == typeof( document.all[sOpenMenuID] ) ) {
				var eMenu = document.all[sOpenMenuID];
				iChunk = iChunkStep;

				// ----------------------------------------------------------
				// Get the offset of the parent TR and TABLE for positioning the Menu
				// ----------------------------------------------------------
				leftOffset = GetOffsetLeft(eSrc);
				eMenu.style.left = leftOffset;
				topOffset = GetOffsetTop(eSrc);
				eMenu.style.top = topOffset;
				
				// ----------------------------------------------------------
				// Zero out the Menu size and start the ShowMenu process
				// ----------------------------------------------------------
				eMenu.style.clip = "rect(0 0 0 0)";
				eMenu.style.visibility = "visible";
				return window.setTimeout("ShowMenu(" + eMenu.id + ")", iChunkDelay);
			}
		}
	}

	// -----------------------------------------------------------------
	// Function which closes any open menu
	// -----------------------------------------------------------------
	function CloseOpenMenu() {
		var ret = 0;
		
		var e = window.event;
		var divHeight = 0;
		var divWidth = 0;
		
		if( "object" == typeof( document.all[currEvent] ) && divID == currEvent.match(divID) && document.all[currEvent].style.visibility == "visible" ) {

			divHeight = document.all[currEvent].clientHeight;
			divWidth = document.all[currEvent].clientWidth;
			
			if( e.clientX > divWidth + leftOffset || e.clientY > divHeight + topOffset
			  || e.clientX < leftOffset || e.clientY + 20 < topOffset ) {
			  
				if( "object" == typeof( document.all[currEvent] ) )
					HideCurrMenu( eSrc, currEvent );
			}
		}

		var eSrc = window.event.srcElement;
				
		if( "" != eSrc && ( menuID == eSrc.id.match(menuID) || divID == eSrc.id.match(divID) ) ) {
			currEvent = eSrc.id.replace(menuID, divID);
			if( "" == prevEvent ) prevEvent = currEvent;
			if( currEvent != prevEvent ) {
				if( "object" == typeof( document.all[prevEvent] ) && document.all[prevEvent].style.visibility == "visible" )
					HideCurrMenu( eSrc, prevEvent );
				prevEvent = currEvent;
			}
		}

		if ("object" == typeof(document.all[sOpenMenuID])) {
			// ----------------------------------------------------------
			// If the menu open is the one whose title we click then bail
			// ----------------------------------------------------------
			if (sOpenMenuID == eSrc.id.replace(menuID,divID)) {
				sOpenMenuID = "";
				ret = 1;
			} else {
				sOpenMenuID = "";
			}
		}
		
		return ret;
	}
	
	// -----------------------------------------------------------------
	// Function which calculates total offset of menu item from the top
	// -----------------------------------------------------------------
	function GetOffsetTop(eSrc) {
		var totalOffset = 0;
		var temp = eSrc;
		while ("FORM" != temp.tagName) {
			//alert("Tag Name = " + temp.tagName + ", OffsetTop = " + temp.offsetTop);
			//consider only A and TD
			if( "TABLE" == temp.tagName || "TD" == temp.tagName || "A" == temp.tagName ) { 
				totalOffset += temp.offsetTop;
				if( temp.tagName == "A" ) {
					totalOffset = totalOffset + temp.offsetHeight;
					//alert("Tag Name = " + temp.tagName + ", OffsetTop = " + temp.offsetHeight);
				}
			}
			temp = temp.parentElement;
		}
		return totalOffset;
	}
	
	// -----------------------------------------------------------------
	// Function which calculates total offset of menu item from the left
	// -----------------------------------------------------------------
	function GetOffsetLeft(eSrc) {
		var totalOffset = 0;
		var temp = eSrc;
		while ("FORM" != temp.tagName) {
			//alert("TagName = " + temp.tagName + ", OffSet = " + temp.offsetLeft);
			if( temp.tagName == "TABLE" || temp.tagName == "TD" || temp.tagName == "A" ) 
				totalOffset = totalOffset + temp.offsetLeft;

			temp = temp.parentElement;
		}
		return totalOffset;
	}
	
	// ----------------------------------------------------------
	// Function which returns the appropriate menu diplay animation
	// ----------------------------------------------------------
	function GetShowStyle() {
		return "rect(0 100% " + iChunk + "% 0)";
	}

	// ----------------------------------------------------------
	// Function which incrementally displays Menu in appropriate style
	// ----------------------------------------------------------
	function ShowMenu(eMenu) {
		eMenu.style.clip = GetShowStyle();
		if (100 >= iChunk) {
			window.setTimeout("ShowMenu(" + eMenu.id + ")", iChunkDelay);
		}
		iChunk += iChunkStep;
	}

	function HideCurrMenu(elem, evnt) {
		if( typeof( elem ) == "object" && menuID == elem.id.match(menuID) && typeof( document.all[elem.id.replace(menuID, divID)] ) == "object" )
			document.all[evnt].style.visibility = "hidden";
		else
			window.setTimeout("HideMenu('" + evnt + "')", openMenuTime);
	}

	function HideMenu(evnt) {
		var elem = document.all(evnt);
		if( "object" == typeof(elem) )
			elem.style.visibility = "hidden";
	}

