		function popFaqWin(url)
			{
			w = window.open(url,'FAQ','width=600,height=400,resizable,scrollbars');
			w.focus();
			}

		function openDesignSidebar()
			{
			var elem = document.getElementById ("designSidebar");
			if (elem && elem.style.display == "none" && gParentDBID != "")
				{
				var spacer = document.getElementById ("dsbSpacer");
				
				elem.style.display = "";
				spacer.style.display = "";
				spacer.style.width = elem.offsetWidth - 1;
				document.cookie = "dbar=" + gParentDBID;

				if (typeof DesignSideBarHook == 'function')
					DesignSideBarHook(true, elem.offsetWidth);
				}
			
			}


		function closeDesignSidebar()
			{
			var elem = document.getElementById ("designSidebar");
			if (elem && elem.style.display == "" && gParentDBID != "")
				{
				var spacer = document.getElementById ("dsbSpacer");
				var wid    = elem.offsetWidth;

				elem.style.display = "none";
				spacer.style.display = "none";
				document.cookie = "dbar=0";

				if (typeof DesignSideBarHook == 'function')
					DesignSideBarHook(false, wid);
				}
			
			}


		function ShowNavMenu(clicked)
			{
			ShowMenu ("NavMenu", "NavButton", clicked, 1);
			}

		function ShowShareMenu(clicked)
			{
			ShowMenu ("ShareMenu", "ShareButton", clicked, 1);
			}

		function ShowCustomizeMenu(clicked)
			{
			ShowMenu ("CustomizeMenu", "CustomizeButton", clicked, 1);
			}

		function ShowViewsMenu(clicked)
			{
			ShowMenu ("ViewsMenu", "ViewsButton", clicked, 1);
			}

		function ShowIWantToMenu(clicked)
			{
			if (clicked)
				ShowMenu ("IWantToMenu", "IWantToButton", clicked, 3);
			}

		function ShowHelpMenu(clicked)
			{
			if (clicked)
				ShowMenu ("HelpMenu", "HelpButton", clicked, 3);
			}

		function ShowFind(clicked)
			{
			ShowMenu ("FindLayer", "FindButton", clicked, 1);
			
			var srchtxt = document.getElementById ("srchtxt");
			if (srchtxt)
				srchtxt.select();
			}

		function ShowTableMenu (which, clicked)
			{
			var menuID   = "table" + which + "Menu";
			var buttonID = "table" + which + "Button";
			
			ShowMenu (menuID, buttonID, clicked, 1);
			}

		function ShowFieldsMenu (dbid)
			{
			// if focus allowed then the window jumps forward - bug #8736

			ShowMenu ("FieldsMenu_" + dbid, "fieldsButton_" + dbid, true, 2, "auto", "noFocus");
			}

	/************************************************/

	var gPageLoadComplete	= false;
	var gMenuInvokingElem	= null;
	var gTrialFooter		= null;
	var gCustomUIFooter		= null;
	var gBottomSpacer		= null;
	var gBottomFooter		= null;
	var	gHasFooter			= false;

	/***********************************************
			PositionFooters
	*/
	function PositionFooters()
		{
		if (gHasFooter)
			{		
			var bsBox = GetBox(gBottomSpacer);

			PositionBottomButNot (gBottomFooter, 0, bsBox.bottom);
			}
		}

	/***********************************************
			StdIdleProc
	*/
	function StdIdleProc()
		{
		PositionFooters();

		if (typeof IdleProc == 'function')
			IdleProc();

		if (gMsgBoxSubMsg != "")		// done here for cases where StdClickProc would erase - this happens when the invoking event
			{							// fires BEFORE the browser calls the onClick method of the body
			OpenMsgBox (gMsgBoxSubMsg);
			gMsgBoxSubMsg = "";
			}

		setTimeout("StdIdleProc()", 200);
		}

	/***********************************************
			StdLoadProc
	*/
		function StdLoadProc()
			{
			var elem = document.getElementById ("designSidebar");
			if (elem.style.display != "none")
				{
				var spacer = document.getElementById ("dsbSpacer");
				spacer.style.display = "";
				spacer.style.width = elem.offsetWidth - 1;
				}

			var defItem = document.getElementById ("defFocus");
			if (defItem)
				defItem.focus();

			// issue #8855 - show "QuickBase Expert Service" popup, if necessary			
			if ( hasCookie("DoQESPopup") && 
				 getCookieValue("DoQESPopup") == "1")
				{
				window.open ("/pgm/d/QESPopup.html","QESPopup",
							 "width=550, height=80, scrollbar");
				}


			gBottomFooter	= document.getElementById ("bottomFooter");
			gBottomSpacer	= document.getElementById ("bottomSpacer");

			PositionFooters();

			var trialFooter	= document.getElementById ("trialFooter");
			var uiFooter	= document.getElementById ("customUIfooter");

			if (trialFooter || uiFooter)
				{
				gHasFooter = true;
				SetStyleVisibility (gBottomFooter, "visible");
				SetStyleDisplay (gBottomFooter, "");
				}

			if (gMsgBoxMsg != "")
				OpenMsgBox("", gMsgBoxMsg);

			if (autoFAQ != "")
				popFaqWin ('main?a=faq&faqid=' + autoFAQ);

			if (typeof InitializeDatePicker == 'function')
				InitializeDatePicker ();

			var cursorIcon = document.getElementById ("cursorIcon");
			if (cursorIcon && !IsOnScreen(cursorIcon))
				{
				ScrollPageToShow (cursorIcon);
				}

			if (typeof LoadProc == 'function')
				LoadProc();

			gPageLoadComplete = true;
			
			StdIdleProc();
			}

		function StdUnloadProc()
			{
			if (typeof UnloadProc == 'function')
				UnloadProc();
			}

		
	/***********************************************
			StdClickProc
	*/
		function StdClickProc(event)
			{
			if (!gPageLoadComplete)
				return;

			var isDatePickerOpen = false;			

			if (typeof g_Calendar != "undefined" && g_Calendar.containerLayer)
				isDatePickerOpen = (g_Calendar.containerLayer.style.visibility == 'visible');

			var isInMenu			= IsClickInOpenMenu(event)
			var isInInvokingElem	= IsClickInElem (gMenuInvokingElem, event);

			CaptureEventInfo(event);

			if (!isInInvokingElem && !isDatePickerOpen && ( !isInMenu || GetTargetTag(event) == "A" ))
				{
				HideMenus();
				gMenuInvokingElem = null;
				}

			if (typeof DatePickerClick == 'function')
				DatePickerClick (event);

			CaptureSelectState();

			if (typeof ClickProc == 'function')
				ClickProc(event);

			}

	/***********************************************
			StdKeyDownProc
	*/
		function StdKeyDownProc(event)
			{
			if (typeof KeyDownProc == 'function')
				KeyDownProc();
			}

	/***********************************************
			StdKeyPressProc
	*/
		function StdKeyPressProc(event)
			{
			if (typeof KeyPressProc == 'function')
				return KeyPressProc();
			}

	/***********************************************
			StdResizeProc
	*/
		function StdResizeProc(event)
			{
			//smoother to do it here than to wait for idle to catch up
			PositionFooters();

			if (typeof ResizeProc == 'function')
				ResizeProc();
			}

	/***********************************************
			StdScrollProc
	*/
		function StdScrollProc(event)
			{
			//smoother to do it here than to wait for idle to catch up
			PositionFooters();

			if (typeof ScrollProc == 'function')
				ScrollProc();
			}

	/***********************************************
			CloseBox
	*/
		function CloseBox(which)
			{
			var popup = document.getElementById (which);
			if (popup)
				{
				popup.style.visibility = "hidden";
				popup.style.display = "none";
				}
			ShowSelects();
			}

	//***********************************************
	//
	// Functions for the popup Table selector
	//

	var gAction;

	function popupTableSelector(action)
		{
		if (gSingleTableAppDBID != "")
			{
			location = gSingleTableAppDBID + "?a=" + action;
			return;
			}

		gAction = action;
		
		var popup = document.getElementById ("tableSelector");
		if (popup)
			{
			popup.style.display = "";
			Center (popup);
			popup.style.visibility = "visible";
			
			SetCurrentMenuElem (popup, 0);
			HideSelects(popup);
			}
		}

	/*********************************************************************/

		var	userWin;

		function popupUserWin (id)
			{
			userWin = window.open ("main?a=userwin&uid=" + id, "UserWin", "width=430,height=180,resizable");

			if (userWin)
				userWin.focus();
			}

	//***********************************************
	//
	// Functions for the Message Box
	//

	function OpenMsgBox(submsg, msg)
		{
		if (submsg && submsg != "")
			{
			var elem = getElementBy ("msgBoxSubMsg")
			if (elem)
				elem.innerHTML = submsg;
			}

		if (msg && msg != "")
			{
			var elem = getElementBy ("msgBoxMsg")
			if (elem)
				elem.innerHTML = msg;
			}

		ShowPopupDiv ("msgBox");	
		}

	function SetMsgBoxSubMsg (submsg)
		{
		gMsgBoxSubMsg = submsg;
		}

	//***********************************************
	//
	// Functions for the More Intro Box
	//

	function OpenMoreIntro()
		{
		ShowPopupDiv ("moreIntroBox");
		}

