	
	

	var iCurrentMenu = 0;
	var iSelectedMenu = -1;
	var iSelectedSubmenu = -1;
	var fContentChanged = false;
	
	function initPage(e){

		var strPageTitle = document.forms['DRT_PageData'].elements['oPageTitle'].value;
		
		var strURL = document.URL;
		if (document.forms['DRT_PageData'].elements['oLoginMode'].value != "1" && strURL.indexOf('showlogin=1') > 0)
				DRT_openLoginBox();
			
		formatWindow();
		showActiveMenus();
		window.focus();
	}
	
	function formatWindow()
	{
		var iW = document.body.clientWidth;
		if (iW < 600) window.resizeTo(600,600);
		
		var iH = document.body.clientHeight;
		var iX = document.body.scrollLeft;
		var iY = document.body.scrollTop;
		
		var iMenuHeight = 0;
		//For FireFox...children.length and childNodes.length does not seem to work:
		var iMenuTotal = oSideMenu_oMenuFrame.getElementsByTagName('div').length;
		if (iMenuTotal > 1)  //More than just an Empty Edit Div
		{	
			var colMenu = oSideMenu_oMenuFrame.getElementsByTagName('div');
			for(var i=0; i<iMenuTotal; i+=2)
			{
				if (colMenu.item(i).style.visibility == "visible") iMenuHeight = iMenuHeight + 16;
			}
		}
		oSideMenuEditTag.style.top = iMenuHeight;
		
		//var iColUnit = (iW-45)/5;
		//var iLeftWidth = iColUnit*3;
		//var iRightWidth= iColUnit*2;
		var iLeftWidth = 515;
		var iRightWidth= (iW-30)-520;
		if (iRightWidth < 270) iRightWidth = 270;
		
		divContentWell_1.style.width=iLeftWidth;
		divContentWell_2.style.width=iRightWidth;
		divContentWell_3.style.width=iRightWidth;
		
		divContentWell_4.style.width = iW-20;
		divContentWell_4.style.left = 10;

		divSideMenu.style.height = iMenuHeight+3;	
		divSideMenu.style.width = iRightWidth;	
		
	}
	
	
	var fContentChanged = false;
	function Make_refreshWindow()
	{
		if (fContentChanged == true)
		{
			fContentChanged = false;
			Make_PageData.submit();
		}
		return true;
	}
	function DRT_imgRollOver(strName, strPath, strType, fOver)
	{
		if (fOver)
		{
			window.document.images[strName].src = strPath + strName + "_on." + strType;
		} else {
			window.document.images[strName].src = strPath + strName + "_off." + strType;
		}
	}
	function imgRollOver(strName, fOver)
	{
		var strPath = "images/";
		if (fOver)
		{
			window.document.images[strName].src = strPath + strName + "_on.gif";
		} else {
			window.document.images[strName].src = strPath + strName + "_off.gif";
		}
	}
	
	function loadPage(iPage)
	{
		window.location = 'Make.aspx?page=' + iPage;
	}
	function showActiveMenus()
	{
		//FireFox doesn't pick up the divBreadCrumbs.innerText value written by js.
		var strBreadCrumbs = document.forms['DRT_PageData'].elements['oBreadCrumbs'].value;
		/*
		if (strBreadCrumbs.length > 0)
		{
			for (var mm=0; mm < aMenus.length; mm++)
			{
				var fFound = false;
				var strMenuName = 'oMenu' + mm;
				var oMenuParent = document.getElementById(strMenuName);
				var oMenuParentName = oMenuParent.innerHTML;
				
				if (strBreadCrumbs.indexOf(oMenuParentName) > 0)
				{
					iSelectedMenu = mm;
					loadMenu(mm);
					fFound = true;
				}
				for (var m=0; m < aMenus[mm].length; m++)
				{
					var oSubMenu = document.getElementById("oSubMenu" + m);
					var oSubMenuName = oSubMenu.innerHTML;
					if (strBreadCrumbs.indexOf(oSubMenuName) > 0)
					{
						iSelectedSubmenu = m;
						oSubMenu.style.color = "#ffffff";
						loadMenu(mm);
						fFound = true;
						break;		
					}
				}
				
	
				if (fFound) break;
			}
		}
		*/
	}
	function loadMenu(iMenu)
	{
	
		if (iCurrentMenu >= 0)
		{
			var oPrevMenuParent = document.getElementById("oMenu" + iCurrentMenu);
			oPrevMenuParent.style.color = '#999999';
			window.document.images['menuarrow'+iCurrentMenu].src = "images/clear.gif";
		}	
		
		if (iMenu >= 0)
		{

			var oMenuParent = document.getElementById("oMenu" + iMenu);
			oMenuParent.style.color = '#aacc00';
			
			var oSubMenuParent = document.getElementById("oSubMenuParent");
			oSubMenuParent.className = "submenu";
					
			window.document.images['menuarrow'+iMenu].src = "images/submenu_arrow.gif";
			iCurrentMenu = iMenu;
		
			for (var m=0; m < 6; m++) //Up to 6 submenus -- based in AutoMenu class
			{
			
				var oSubMenu = document.getElementById("oSubMenu" + m);
				var oSubMenuSpacer = document.getElementById("oSubMenuSpacer" + m);
				if (m == (aMenus[iCurrentMenu].length)-1)
				{
					oSubMenu.innerHTML = aMenus[iCurrentMenu][m];
					oSubMenuSpacer.innerHTML = "";
				}
				else if (m < aMenus[iCurrentMenu].length)
				{
					oSubMenu.innerHTML = aMenus[iCurrentMenu][m];
					oSubMenuSpacer.innerHTML = "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;";
				}
				else
				{
					oSubMenu.innerHTML = "";
					oSubMenuSpacer.innerHTML = "";
				}
				submenuRollover(m, false);
			}		
		}
		else
		{
			for (var m=0; m < 6; m++) //Up to 6 submenus -- based in AutoMenu class
			{
				var oSubMenu = document.getElementById("oSubMenu" + m);
				var oSubMenuSpacer = document.getElementById("oSubMenuSpacer" + m);
				oSubMenu.innerHTML = "";
				oSubMenuSpacer.innerHTML = "";
			}			
		}
	}
	var fLoginVisible = false;
	function DRT_toggleLogin()
	{
		var iH = document.body.clientHeight;
		var iW = document.body.clientWidth;
		var iY = document.body.scrollTop;
		
		//If already logged in, then logout.
		if (document.forms['DRT_PageData'].elements['oLoginMode'].value == "1")
		{
			var response = confirm('You are currently logged in.  Are you sure you want to log off?');
			if (response == true) 
			{
				document.forms['DRT_PageData'].elements['oLoginMode'].value = "0";
				__doPostBack('Login','');
			}	
		} else {
			DRT_openLoginBox();
		}
		return true;
	}
	function DRT_openLoginBox()
	{
		var iX = screen.width/2 - 130;
		var iY = screen.height/2 - 145;
		var iPageID = document.forms['DRT_PageData'].elements['oPageID'].value;
		var strURL = document.URL;
		var strPath = strURL.substring(4, strURL.toLowerCase().indexOf("maker.aspx"));
		
		window.open('LoginBox.aspx?page='+iPageID,'login','width=260,height=290,left='+iX+',top='+iY+',status=no,titlebar=no,toolbar=no,menubar=no,location=no,resizable=yes');
		
		return true;
	}
	function DRT_removeObject(ID)
	{
		//DRT_clearSearchBox();
		
		var response = confirm('Are you sure you want to remove this item from the page?');
		if (response == true) 
		{
			document.forms['DRT_PageData'].elements['oSelectedPart'].value = ID;
			__doPostBack('RemovePart',ID);
		}
		return true;
	}
	
	function DRT_rankAdjust(ID)
	{
		//DRT_clearSearchBox();
		
		document.forms['DRT_PageData'].elements['oSelectedPart'].value = ID;
		__doPostBack('RankAdjust',ID);
		return true;
	}
	function DRT_clearSearchBox()
	{
		document.forms['DRT_PageData'].elements['oSearch'].value = "";
		return true;
	}	
	
	function submitPageNum()
	{
		var iPageNum = document.forms['formFooterMenu'].elements['page'].value;
		loadPage(iPageNum);
	}
	function submenuRollover(iSubMenu, fOver)
	{
		var oSubMenu = document.getElementById("oSubMenu" + iSubMenu);
		if (iSubMenu != iSelectedSubmenu)
		{
			if (fOver)
				oSubMenu.style.color = "#efefef";
			else
				oSubMenu.style.color = "#dddddd";
		} 
		else if (iSelectedMenu == iCurrentMenu)
			oSubMenu.style.color = "#ffffff";
		else
			oSubMenu.style.color = "#dddddd";
		
	}
	function submenuClick(iSubMenu)
	{
		var iPage = aMenuLinks[iCurrentMenu][iSubMenu];
		loadPage(iPage);
	}
	function checkForPageSubmit()
	{
		var e = window.event;
		var charCode = e.keyCode;
		if (charCode == 13)
			submitPageNum();
		return true;
	}
	
	
	
	function Trim(strInput) 
	{
		while ((strInput.substring(0,1) == ' ') || (strInput.substring(0,1) == '\n') || (strInput.substring(0,1) == '\r'))
			strInput = strInput.substring(1,strInput.length); 

		while ((strInput.substring(strInput.length-1,strInput.length) == ' ') || (strInput.substring(strInput.length-1,strInput.length) == '\n') || (strInput.substring(strInput.length-1,strInput.length) == '\r'))
			strInput = strInput.substring(0,strInput.length-1); 

		return strInput;
	} 