// File: vt_menus.js
// Depends on: Utils.js
/**************************************************************************************************/
// Pages Definitions
var jsg_DailyMessagePage = 'Daily Message';
var jsg_VesselSchedulePage = 'Vessel Schedule';
var jsg_ImportsPage = 'Imports';
var jsg_ExportsPage = 'Exports';
var jsg_PremountsPage = 'Pre-mount';
var jsg_GatePage = 'Gate';
var jsg_ApptPage = 'Appointments';
var jsg_ReviewNotificationsPage = 'Review Notifications';
var jsg_MyAccountPage = 'MyAccount';
var jsg_QuickTrackPage = 'QuickTrack';
var jsg_AdminPage = 'Admin';
var jsg_LogonPage = 'Logon';
var jsg_LogoffPage = 'Logoff';
var jsg_TerminalInfoPage = 'Terminal Information';
var jsg_TruckerInstPage = 'Trucker Instructions';
var jsg_SignUpPage = 'Sign Up';
var jsg_ContactUsPage = 'Contact Us';
var jsg_QuickGatePage = 'Gate Moves';
var jsg_EmptyInPageStandAlone = 'Empty In'; //CR 25463 -- Christian -- 06/24/2009
/**************************************************************************************************/
// Menu defintions
var jsg_LoginMenu = 'Logon';
// VoyagerTrack Main Menu
var jsg_TerminalMenu = 'Terminal';
var jsg_VesselScheduleMenu = '&nbsp;&nbsp;Vessel&nbsp;Schedule&nbsp;&nbsp;';
var jsg_ImportsMenu = '&nbsp;&nbsp;&nbsp;Import&nbsp;&nbsp;&nbsp;';
var jsg_ExportsMenu = '&nbsp;&nbsp;&nbsp;Export&nbsp;&nbsp;&nbsp;';
var jsg_PremountsMenu = 'Pre-mount';
var jsg_GateActivityMenu = 'Gate&nbsp;Activity&nbsp;&nbsp;&nbsp;';
var jsg_GateMenu = '&nbsp;&nbsp;&nbsp;Gate&nbsp;&nbsp;&nbsp;';
var jsg_ReviewNotificationsMenu = '&nbsp;&nbsp;Review&nbsp;Notifications&nbsp;';
var jsg_MyAccountMenu = 'My&nbsp;Account';
var jsg_AdminMenu = 'Admin';
var jsg_ApptMenu = '&nbsp;&nbsp;Appointments&nbsp;&nbsp;';
var jsg_DailyMessageMenu = '&nbsp;&nbsp;&nbsp;Daily&nbsp;Message&nbsp;&nbsp;&nbsp;';
// 2nd Level Menus
var jsg_None = 'None'; 
// Imports
var jsg_ImportReportsMenu = '&nbsp;&nbsp;Import&nbsp;Report&nbsp;&nbsp;';
var jsg_ImportInquiryMenu = '&nbsp;&nbsp;Import&nbsp;Inquiry&nbsp;&nbsp;';
// Exports
var jsg_ExportReportsMenu = '&nbsp;&nbsp;Export&nbsp;Report&nbsp;&nbsp;';
var jsg_ExportInquiryMenu = '&nbsp;&nbsp;Export&nbsp;Inquiry&nbsp;&nbsp;';
// Pre-Mount
var jsg_PremountMakeRequestsMenu = '&nbsp;&nbsp;Make&nbsp;Requests&nbsp;&nbsp;'; 
var jsg_PremountReviewRequestsMenu = '&nbsp;&nbsp;Preview&nbsp;Requests&nbsp;&nbsp;' ; 
// Gate
var jsg_GateActivtyMenu			= '&nbsp;&nbsp;Gate&nbsp;Activity&nbsp;&nbsp;'; 
var jsg_GateNotificationsMenu   = '&nbsp;&nbsp;Gate&nbsp;Notifications&nbsp;&nbsp;';
// Appt
var jsg_ApptConfigMenu = '&nbsp;&nbsp;Configuration&nbsp;&nbsp;'; 
var jsg_ApptLimitsMenu = '&nbsp;&nbsp;Set&nbsp;Limits&nbsp;&nbsp;'; 
var jsg_ApptMakeMenu = '&nbsp;&nbsp;Import&nbsp;&nbsp;&nbsp;'; 
var jsg_ApptMakeBookingsMenu = '&nbsp;&nbsp;Booking&nbsp;&nbsp;&nbsp;'; 
var jsg_ApptMakeEmptyInMenu = '&nbsp;&nbsp;Empty&nbsp;In&nbsp;Checker&nbsp;&nbsp;'; 
var jsg_ApptTruckerReportMenu = '&nbsp;&nbsp;Report&nbsp;&nbsp;'; 
var jsg_ApptTerminalReportMenu = '&nbsp;&nbsp;Limits&nbsp;Report&nbsp;&nbsp;'; 
var jsg_ApptTestMenu = '&nbsp;&nbsp;Test&nbsp;&nbsp;&nbsp;'; 
var jsg_ApptTest2Menu = '&nbsp;&nbsp;Test2&nbsp;&nbsp;'; 
// My Account
var jsg_MyAccountProfileMenu = '&nbsp;Profile&nbsp;'; 
var jsg_MyAccountPermissionsMenu = '&nbsp;Permissions&nbsp;'; 
var jsg_MyAccountPreferencesMenu = '&nbsp;Preferences&nbsp;'; 
// Admin 2nd level menus
var jsg_SM_DailyMessageMenu = '&nbsp;&nbsp;&nbsp;Daily&nbsp;Message&nbsp;&nbsp;';
var jsg_SM_UserAdminMenu = '&nbsp;&nbsp;User&nbsp;Admin&nbsp;&nbsp;';
var jsg_SM_BroadcastEmailMenu = '&nbsp;&nbsp;&nbsp;Broadcast&nbsp;Email&nbsp;&nbsp;&nbsp;';
var jsg_SM_SiteConfigMenu = '&nbsp;&nbsp;&nbsp;Site&nbsp;Configuration&nbsp;&nbsp;&nbsp;';
var jsg_SM_SSCOConfigMenu = '&nbsp;&nbsp;&nbsp;SSCO&nbsp;Configuration&nbsp;&nbsp;&nbsp;';
var jsg_SM_TerminalAdminMenu = '&nbsp;&nbsp;&nbsp;&nbsp;Terminal&nbsp;&nbsp;&nbsp;';
var jsg_arrAdmin2nLevelMenus = new Array();
jsg_arrAdmin2nLevelMenus[0] =  jsg_SM_DailyMessageMenu ;
jsg_arrAdmin2nLevelMenus[1] =  jsg_SM_UserAdminMenu ;
jsg_arrAdmin2nLevelMenus[2] =  jsg_SM_BroadcastEmailMenu ;
jsg_arrAdmin2nLevelMenus[3] =  jsg_SM_SiteConfigMenu ;
jsg_arrAdmin2nLevelMenus[4] =  jsg_SM_SSCOConfigMenu ;
jsg_arrAdmin2nLevelMenus[5] =  jsg_SM_TerminalAdminMenu ;
// Admin 3rd Level menus
// Daily Message
var jsg_SM_DM_ViewMenu = 'View';
var jsg_SM_DM_EditMenu = 'Edit';
var jsg_SM_DM_UploadMenu = 'Upload';
// User Admin
var jsg_SM_UA_NewUserMenu = 'New User';
var jsg_SM_UA_BasicSearchMenu = 'Basic Search'; 
var jsg_SM_UA_AdvancedSearchMenu = 'Advanced Search'; 
var jsg_SM_UA_ViewAllUsersMenu = 'Edit All Users'; 
var jsg_SM_UA_ViewUnconfirmedMenu = 'Edit Unconfirmed Users'; 
var jsg_SM_UA_ViewAdminUsersMenu = 'Edit Administrators'; 
// Boradcast E-mail
var jsg_SM_BE_AllUsersMenu = 'To All Users'; 
// Site Configuration
var jsg_SM_SC_EditMenu = 'Edit Site Configuration'; 
var jsg_SM_SC_EditNDDMenu = 'Edit Non-Demurrage Days'; 
var jsg_SM_SC_EditNPDMenu = 'Edit Non-Pre-mount Days'; 
var jsg_SM_SC_CreateSiteMenu = 'Create New Site'; 
// SSCO Configuration
var jsg_SM_SSC_NewMenu = 'New SSCO'; 
var jsg_SM_SSC_EditMenu = 'Edit SSCO Configuration'; 

// Terminal Admin Menus
var jsg_SM_TA_ArchivesMenu = 'Equipment History'; 
var jsg_SM_TA_ReleaseTMFMenu = 'Release TMF'; 
var jsg_SM_TA_TerminalConfigMenu = 'Configuration'; 

/**************************************************************************************************/
// Below are the main URLs defintions
// Framework
var jsg_MainURL = "/default.asp?";
var jsg_HeaderURL = "/Framework/VT_HeaderFrame.asp";
var jsg_MenuURL = "/Framework/VT_MenuFrame.asp";
var jsg_ContentURL = "/Framework/VT_ContentFrame.asp";
// Login and Daily Message
var jsg_LoginURL = "/Framework/VT_Login.asp?";
var jsg_LogoffURL = "/Framework/VT_Logoff.asp?";
var jsg_DailyMessageURL = "/asp/en/daily_message.asp?" ;
//
var jsg_ContactUsURL = "/asp/en/email_us_page.asp?";
var jsg_SignUpURL = "/asp/en/sign_up_page.asp?";
// Main Input Pages
var jsg_VesselScheduleURL = "/asp/en/vessel_sched_page.asp?";
var jsg_ImportsURL = "/asp/en/imports_page.asp?";
var jsg_ExportsURL = "/asp/en/exports_page.asp?";
var jsg_PremountsURL = "/asp/en/premounts_page.asp?";
var jsg_PremountsRequestURL = "/asp/en/pre_mount_appointment_page.asp?";
var jsg_PremountsReviewURL = "/asp/en/premount_requests_preview_sort.asp?";
var jsg_ReviewNotificationsURL = "/asp/en/review_notifications_page.asp?";
var jsg_GateActivityURL = "/asp/en/gate_activity_page.asp?";
var jsg_QuickGateURL = "/Tracking/GateMoves.aspx?";
//
// Appt URLS
var jsg_ApptURL = "/Appt/Appt.aspx?";   // Depends on the user
var jsg_ApptMakeURL = "/asp/en/Appointment/Make_Appointment.asp?";
var jsg_ApptMakeBookingsURL = "/asp/en/Appointment/MakeBookingsAppointment.asp?";  // To be verifed.
var jsg_ApptMakeEmptyInURL = "/Appt/EmptyInApptPage.aspx?";  
var jsg_ApptConfigURL = "/asp/en/Appointment/Configuration.asp?";
var jsg_ApptLimitsURL = "/asp/en/Appointment/Set_Limits.asp?";
var jsg_ApptSetLimitsURL = "/asp/en/Appointment/Set_Limits.asp?";
var jsg_ApptTerminalReportURL = "/ApptAdmin/TerminalReportPage.aspx?";
var jsg_ApptTruckerReportURL = "/Appt/TruckerReportPage.aspx?";
var jsg_ApptTestURL = "/Prototypes/TestSessionChecker.aspx?";
var jsg_ApptTest2URL = "/SiteAdmin/SiteAdmin.aspx?";
// My Account URLs
var jsg_MyAccountURL = "/asp/en/myPermissions.asp?";
var jsg_MyInfoURL = "/asp/en/myinfo.asp?";
var jsg_MyPreferencesURL = "/asp/en/myPreferences.asp?";
// Terminal  (Site Specifc)
var jsg_TerminalInfoURL = "/file/en/terminal_info_page.html?";
var jsg_TruckerInstructionsURL = "/file/en/trucker_instructions.html?";
// Admin URLs
var jsg_SM_HomeURL = "/SiteManager/VTSM_Home.asp?";
var jsg_SM_DailyMessageViewURL = "/SiteManager/VTSM_DailyMessage.asp?";
var jsg_SM_DailyMessageEditURL = "/SiteManager/VTSM_DailyMessageEditor.asp?";
var jsg_SM_DailyMessageUploadURL = "/SiteManager/VTSM_DailyMessageUpload.asp?";
// Site Manager - Site Config
var jsg_SM_SiteConfigURL = "/SiteManager/VTSM_SiteConfig.asp?";
var jsg_SM_SiteConfigNonDemurrageDaysURL = "/SiteManager/VTSM_SiteConfigNonDemurrageDays.asp?DATETYPE=DEMURRAGE&"
var jsg_SM_SiteConfigNonPremountDaysURL = "/SiteManager/VTSM_SiteConfigNonDemurrageDays.asp?DATETYPE=PREMOUNT&"
var jsg_SM_CreateSiteURL = "/SiteManager/CreateSite.aspx?"
// Site Manager - SSCO Config
var jsg_SM_SSCOConfigURL = "/SiteManager/VTSM_SSCOConfig.asp?";
var jsg_SM_SSCOConfigNewURL = "/SiteManager/VTSM_SSCOEditor.asp?MODE=NEW&";
// Site Manager - User Manager
var jsg_SM_NewUserURL = "/SiteManager/VTSM_UserEditor.asp?MODE=NEW&";
var jsg_SM_SearchUserURL = "/SiteManager/VTSM_Search.asp?";
var jsg_SM_AdvancedSearchUserURL = "/SiteManager/VTSM_Filter.asp?";
var jsg_SM_ViewAllUsersURL = "/SiteManager/VTSM_UserInformation.asp?GROUP=ALL&";
var jsg_SM_ViewUnconfirmedUsersURL = "/SiteManager/VTSM_UserInformation.asp?GROUP=UNCONFIRMED&";
var jsg_SM_ViewAdminUsersURL = "/SiteManager/VTSM_UserInformation.asp?GROUP=ADMIN&";
// Site Manager - Broadcast email
var jsg_SM_BroadcastEmailURL = "/SiteManager/VTSM_BroadcastEmail.asp?"
// Admin - General Data Inquiry Tool
var jsg_SM_ArchivesURL = "/TerminalAdmin/Archives.aspx?"
var jsg_SM_ReleaseTMFURL = "/TerminalAdmin/ReleaseTMF.aspx?"
var jsg_SM_TerminalConfigURL = "/TerminalAdmin/TerminalConfig.aspx?"

/* -----------------------------------------------------------------------------------------
// MN - Menus (inherited from VinTel)
// Netscape issues:
//	 -- Using document.all
//	 -- cusror is not hand
//   -- Using window.event.srcElement
//	 -- (3rd Level menu)
-------------------------------------------------------------------------------------------*/
var jsg_colorBackgrond="#00216C";  // Dark Blue
var jsg_colorBackgrond2nd ="#00216C";  
var jsg_colorBackgrond3rd ="#00216C";  
var jsg_colorSelectedMenu= "#5f87BB"; // Medium Blue
var jsg_colorSelectedSubMenu = "#5f87BB"; 
var jsg_colorSelected3rdMenu = "#5f87BB"; 
var jsg_colorMouseOver = "#9AB1D1"; // Light Steel Blue /Sky Blue
///
var g_strOpenMenuID = "";
var g_iTimerID ;
var g_nChunk;
var iCurrent2ndLevelSelection; 
var _MenuHeight = '12';
var _idMout3Timer;
var _bSelected3rdMenuIsShown = false;

var _MenuContent = ""; 
//************************************************************************************
// Purpose: 
function CreateMenu()
{
	
	if (jsg_DebugFlag)
		debugMsg("<b style='color:red'>CreateMenu()</b>" + "1st: " + jsg_SelectedMenu + "- 2nd:" + jsg_SelectedSubMenu + "- 3rd: " + jsg_Selected3rdMenu);
	MenuInitConfig();
	SetupOffsets();
	SetupStyle(); 
	BuildMenu(); 
}
function MenuWrite(content)
{
	_MenuContent = _MenuContent + "\n" + content;
} 

function MenuRenderOn(htmlElement)
{
	_MenuContent = "";
	CreateMenu(); 
	htmlElement.innerHTML = _MenuContent; 	
}

//************************************************************************************
function SetupStyle()
{
}
//************************************************************************************
function BuildMenu()
{
	debugMsg("<b >Building System Menu ()</b>");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' >");
	MenuWrite("<TR>");
	createLevel1Button(jsg_DailyMessageMenu, 'OnMenu', '','idMenuTitle1','Go_Daily_Message');
	createLevel1Spacing('', 1);
	createLevel1Button(jsg_VesselScheduleMenu, 'OnMenu', '','idMenuTitle2','Go_Vessel_Schedule');
	createLevel1Spacing('', 1);
	createLevel1Button(jsg_ImportsMenu, 'OnMenu', '','idMenuTitle3','Go_Imports');
	createLevel1Spacing('', 1);
	createLevel1Button(jsg_ExportsMenu, 'OnMenu', '','idMenuTitle4','Go_Exports');
	if (jsg_IsPremountUser && jsg_CurrentSitePremountEnabled) 
	{
		createLevel1Spacing('', 1);
		createLevel1Button(jsg_PremountsMenu, 'OnMenu', '','idMenuTitle5','Go_Premounts');
	}
	createLevel1Spacing('', 1);
	createLevel1Button(jsg_GateMenu, 'OnMenu', '','idMenuTitle6','Go_Gate');
	createLevel1Spacing('', 1);
	// Check App Supported or beta tester 
	if (jsg_CurrentSiteApptSupported || jsg_IsBetaTestUser )
	{
		if (jsg_IsTruckingCompanyUser || jsg_IsApptAdminUser )
		{
			createLevel1Button(jsg_ApptMenu, 'OnApptMenu', '','idMenuTitle1','Go_ApptMain');
			createLevel1Spacing('', 1);
		}
	}
	createLevel1Button(jsg_ReviewNotificationsMenu, 'OnMenu', '','idMenuTitle7','Go_Review_Notifications');
	createLevel1Spacing('', 1);

	//----------------- BEGIN CR 25463 -- Christian -- 06/24/2009
	if ((!jsg_CurrentSiteApptSupported) && jsg_CurrentSiteEmptyInApptPageEnable)
	{
		if (jsg_IsTruckingCompanyUser)
		{
        createLevel1Button(jsg_ApptMakeEmptyInMenu, 'OnMenu', '','Go_ApptMakeEmptyIn','Go_ApptMakeEmptyIn'); 
	    createLevel1Spacing('', 1);
        }
    }
    //----------------- END CR 25463 -- Christian -- 06/24/2009
    
	createLevel1Button(jsg_MyAccountMenu, 'OnMenu', '','idMenuTitle8','Go_My_Account');
	if (jsg_IsAdminUser ) 
	{
		createLevel1Spacing('', 1);
		createLevel1Button(jsg_AdminMenu, 'OnMenu', '','idMenuTitle9','Go_Admin');
	}
	
    createLevel1Spacing('', 1);
	createLevel1SpacingRight('',2000);
	
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='8' height='1px' bgcolor='White'></TD></TR>");
	/* Code to select the menu to use */
	if (jsg_SelectedMenu==jsg_ImportsMenu && jsg_IsHighVolumeUser)	
	{
		BuildMenuImports();
	}
	else if (jsg_SelectedMenu==jsg_ExportsMenu && jsg_IsHighVolumeUser)	
	{
		BuildMenuExports();
	}
	else if (jsg_SelectedMenu==jsg_GateMenu && jsg_IsGateActivityUser)	
	{
		BuildMenuGate();
	}
	else if (jsg_SelectedMenu==jsg_ApptMenu )	
	{
		BuildMenuAppt();
	}
	else if (jsg_SelectedMenu==jsg_PremountsMenu && jsg_IsAdminUser && jsg_IsPremountUser && jsg_CurrentSitePremountEnabled)	
	{
		BuildMenuPremount();
	}
	else if(jsg_SelectedMenu== jsg_AdminMenu)	
	{
		BuildMenuAdmin();
	}
	else if(jsg_SelectedMenu== jsg_MyAccountMenu && jsg_IsLoggedIn)	
	{
		BuildMenuMyAccount();
	}
	else
	{
		debugMsg("No SubMenu.");
	}
	
    
	MenuWrite("</TABLE>");
	debugMsg("End Main Menu building <hr width=100%>");
} 
//************************************************************************************
// Purpose: Builds the Imports Menu
function BuildMenuImports()
{
	debugMsg("Building Import Menu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentImport!= 0)
		createLevel2Spacing('',jsg_AdjustmentImport);
	createLevel2Button(jsg_ImportReportsMenu, 'OnMenu', '','Go_ImportReport','Go_ImportReport');
	createLevel2Button(jsg_ImportInquiryMenu, 'OnMenu', '','Go_MultiTrackImport','Go_MultiTrackImport');
	createLevel2Spacing('',2500);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD width=100% height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: Builds the Exports menu
function BuildMenuExports()
{
	debugMsg("Building Export Menu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentExport!= 0)
		createLevel2Spacing('',jsg_AdjustmentExport);
	createLevel2Button(jsg_ExportReportsMenu, 'OnMenu', '','Go_Exports','Go_Exports');
	createLevel2Button(jsg_ExportInquiryMenu, 'OnMenu', '','Go_MultiTrackExport','Go_MultiTrackExport');
	createLevel2Spacing('',1500);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: Build the Pre-Mount Menu
function BuildMenuPremount()
{
	debugMsg("Building PremountMenu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentPremount!= 0)
		createLevel2Spacing('',jsg_AdjustmentPremount);
	createLevel2Button(jsg_PremountMakeRequestsMenu, 'OnMenu', '','Go_MakePremountRequests','Go_MakePremountRequests');
	createLevel2Button(jsg_PremountReviewRequestsMenu, 'OnMenu', '','Go_ReviewPremountRequests','Go_ReviewPremountRequests');
	createLevel2Spacing('',2000);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: Builds the Gate Menu
function BuildMenuGate()
{
	debugMsg("Building Gate Menu()");
	MenuWrite("<TABLE BORDER=0 CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentGate!= 0)
		createLevel2Spacing('',jsg_AdjustmentGate); 
	createLevel2Button(jsg_GateActivtyMenu, 'OnMenu', '','Go_GateActivity','Go_GateActivity');
	createLevel2Button(jsg_GateNotificationsMenu, 'OnMenu', '','Go_MultiTrackEnter','Go_MultiTrackEnter');
	createLevel2Spacing('',2000);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: Build the Appointment Menu
function BuildMenuAppt()
{
   // Need to add the check for the permissions
	debugMsg("Building Appt Menu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentAppt!= 0)
		createLevel2Spacing('',jsg_AdjustmentAppt );
	if (jsg_IsApptAdminUser )
	{
		createLevel2Button(jsg_ApptLimitsMenu, 'OnApptMenu', '','Go_ApptLimits','Go_ApptLimits');
		createLevel2Button(jsg_ApptTerminalReportMenu, 'OnApptMenu', '','Go_ApptTerminalReport','Go_ApptTerminalReport');
		createLevel2Button(jsg_ApptConfigMenu, 'OnApptMenu', '','Go_ApptConfig','Go_ApptConfig');
		createLevel2Button(jsg_ApptTruckerReportMenu, 'OnApptMenu', '','Go_ApptTruckerReport','Go_ApptTruckerReport');
		if (jsg_IsTruckingCompanyUser )
		{
			createLevel2Button(jsg_ApptMakeMenu, 'OnApptMenu', '','Go_ApptMake','Go_ApptMake');
			createLevel2Button(jsg_ApptMakeBookingsMenu, 'OnApptMenu', '','Go_ApptMakeBookings','Go_ApptMakeBookings');
			if(jsg_CurrentSiteEmptyInApptSupported)
			{
				createLevel2Button(jsg_ApptMakeEmptyInMenu, 'OnApptMenu', '','Go_ApptMakeEmptyIn','Go_ApptMakeEmptyIn');
			}
		}
		// Comment out the next 2 lines before release to QA
//		createLevel2Button(jsg_ApptTestMenu, 'OnApptMenu', '','Go_ApptTest','Go_ApptTest');
//		createLevel2Button(jsg_ApptTest2Menu, 'OnApptMenu', '','Go_ApptTest2','Go_ApptTest2');
	}
	else
	{
		if (jsg_IsTruckingCompanyUser )
		{
			createLevel2Button(jsg_ApptTruckerReportMenu, 'OnApptMenu', '','Go_ApptTruckerReport','Go_ApptTruckerReport');
			createLevel2Button(jsg_ApptMakeMenu, 'OnApptMenu', '','Go_ApptMake','Go_ApptMake');
			createLevel2Button(jsg_ApptMakeBookingsMenu, 'OnApptMenu', '','Go_ApptMakeBookings','Go_ApptMakeBookings');
			if (jsg_CurrentSiteEmptyInApptSupported )
			{
				createLevel2Button(jsg_ApptMakeEmptyInMenu, 'OnApptMenu', '','Go_ApptMakeEmptyIn','Go_ApptMakeEmptyIn');
			}
		}
	}
	createLevel2Spacing('',2000);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: creates the Admin menu
function BuildMenuMyAccount()
{
	debugMsg("Building MyAccount Menu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	if (jsg_AdjustmentMyAccount!= 0)
		createLevel2Spacing('',jsg_AdjustmentMyAccount );
	createLevel2Button(jsg_MyAccountProfileMenu, 'OnMenu', '','Go_My_AccountProfile','Go_My_AccountProfile');
	createLevel2Button(jsg_MyAccountPermissionsMenu, 'OnMenu', '','Go_My_AccountPermissions','Go_My_AccountPermissions');
	createLevel2Button(jsg_MyAccountPreferencesMenu, 'OnMenu', '','Go_My_AccountPreferences','Go_My_AccountPreferences');
	createLevel2Spacing('',1000);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************************
// Purpose: Builds the Admin menu
function BuildMenuAdmin()
{
	debugMsg("Building Admin Menu()");
	MenuWrite("<TABLE BORDER='0' CELLPADDING='0'  CELLSPACING='0' >");
	MenuWrite("<TR>");
	createAdminLevel2Button(jsg_SM_DailyMessageMenu, 'OnMenu', '','idMenuTitle0','clsMenuAdmin');
	createAdminLevel2Button(jsg_SM_UserAdminMenu, 'OnMenu', '','idMenuTitle1','clsMenuAdmin');
	createAdminLevel2Button(jsg_SM_BroadcastEmailMenu, 'OnMenu', '','idMenuTitle2','clsMenuAdmin');
	createAdminLevel2Button(jsg_SM_SiteConfigMenu, 'OnMenu', '','idMenuTitle3','clsMenuAdmin');
	createAdminLevel2Button(jsg_SM_SSCOConfigMenu, 'OnMenu', '','idMenuTitle4','clsMenuAdmin');
	if (jsg_IsSysAdminUser )
	{
	    createAdminLevel2Button(jsg_SM_TerminalAdminMenu, 'OnMenu', '','idMenuTitle5','clsMenuAdmin');
    }
	createLevel2Spacing('',1750);
	MenuWrite("</TR>");
	MenuWrite("<TR><TD colspan='7' height='1px' bgcolor='White'></TD></TR>");
	MenuWrite("<TR>");
	OpenDropDown('idMenu0','clsMenu',_MenuHeight,'10', jsg_SM_DailyMessageMenu);
	CreateDropDownMenu(jsg_SM_DailyMessageViewURL,jsg_SM_DM_ViewMenu,0);
	CreateDropDownMenu(jsg_SM_DailyMessageEditURL,jsg_SM_DM_EditMenu,0);//
	CreateDropDownMenu(jsg_SM_DailyMessageUploadURL,jsg_SM_DM_UploadMenu,0);//
	CloseDropDown();

	OpenDropDown('idMenu1','clsMenu',_MenuHeight,'10', jsg_SM_UserAdminMenu);
	CreateDropDownMenu(jsg_SM_NewUserURL, jsg_SM_UA_NewUserMenu, 1);
	CreateDropDownMenu(jsg_SM_SearchUserURL, jsg_SM_UA_BasicSearchMenu, 1);
	CreateDropDownMenu(jsg_SM_AdvancedSearchUserURL, jsg_SM_UA_AdvancedSearchMenu, 1);
	CreateDropDownMenu(jsg_SM_ViewAllUsersURL, jsg_SM_UA_ViewAllUsersMenu, 1);
	CreateDropDownMenu(jsg_SM_ViewUnconfirmedUsersURL,jsg_SM_UA_ViewUnconfirmedMenu, 1);
	CloseDropDown();

	OpenDropDown('idMenu2','clsMenu',_MenuHeight,'10', jsg_SM_BroadcastEmailMenu);
	CreateDropDownMenu(jsg_SM_BroadcastEmailURL, jsg_SM_BE_AllUsersMenu, 2);
	CloseDropDown();

	OpenDropDown('idMenu3','clsMenu',_MenuHeight,'10', jsg_SM_SiteConfigMenu);
	CreateDropDownMenu(jsg_SM_SiteConfigURL, jsg_SM_SC_EditMenu, 3);
	CreateDropDownMenu(jsg_SM_SiteConfigNonDemurrageDaysURL, jsg_SM_SC_EditNDDMenu, 3);
	CreateDropDownMenu(jsg_SM_SiteConfigNonPremountDaysURL, jsg_SM_SC_EditNPDMenu, 3);
	CloseDropDown();

	OpenDropDown('idMenu4','clsMenu',_MenuHeight,'10', 4);
	CreateDropDownMenu(jsg_SM_SSCOConfigNewURL,jsg_SM_SSC_NewMenu,4);
	CreateDropDownMenu(jsg_SM_SSCOConfigURL, jsg_SM_SSC_EditMenu, 4); 
	CloseDropDown();

	if (jsg_IsSysAdminUser )
	{
    	OpenDropDown('idMenu5','clsMenu',_MenuHeight,'10', jsg_SM_TerminalAdminMenu);
	    CreateDropDownMenu(jsg_SM_ArchivesURL, jsg_SM_TA_ArchivesMenu, 5); 
	// No included in VT 5.4
	//    CreateDropDownMenu(jsg_SM_TerminalConfigURL,jsg_SM_TA_TerminalConfigMenu,5);
		CreateDropDownMenu(jsg_SM_ReleaseTMFURL,jsg_SM_TA_ReleaseTMFMenu,5);
	}
	CloseDropDown();
	MenuWrite("</TR>");
	MenuWrite("</TABLE>");
}
//************************************************************************
// Used to create the main cells in the main menu
function createLevel1Button(name, f, status,sID,sCLS){
//************************************************************************
//	debugMsg("createLevel1Button - name: " + name + "; ID: " + sID + "; class: " + sCLS); 
	var col;
	if(jsg_SelectedMenu == name) status = "func";
	if(status=="func")
		col=jsg_colorSelectedMenu;
	else
		col=jsg_colorBackgrond;
	MenuWrite("<TD width=80pt CLASS='"+sCLS+"' nowrap align=center onmouseover=\"mOvr(this,'"+status+"'); \" ");
	MenuWrite(" onmouseout=\"return mOut(this,'"+status+"')\" onclick='return "+f+"(this);' bgcolor="+col+" style='width:81px;cursor:pointer;height:20px'  >");
	MenuWrite(name);
	MenuWrite("</TD>");
}
// width='85px' height='20px' 
//************************************************************************
// Used to create the main cells in the sub menu (2nd level) 
function createLevel2Button(name, f, status, sID , sCLS){
//************************************************************************
//	debugMsg("createLevel2Button - name: " + name + "; ID: " + sID + "; class: " + sCLS); 
	var col;
	if(jsg_SelectedSubMenu == name) 
		status = "func";

	if (jsg_SelectedSubMenu == name )
	{
		col = jsg_colorSelectedSubMenu;
	}
	else
		col= jsg_colorBackgrond2nd;    //steel blue

	MenuWrite("<TD width=80pt ID='"+sID+"' CLASS='"+sCLS+"' nowrap align=center "); 
	MenuWrite("  onmouseover=\"mOvr2(this,'" + status + "'); show3rdLevelMenu(this);\" ");
	MenuWrite("    onmouseout=\"mOut2(this,'" + status +"')\"; ") ; 
	MenuWrite("    onclick='return "+f+"(this);' bgcolor=" + col+ " style='width:81px;cursor:pointer;height:20px' >");
    MenuWrite(name);
	MenuWrite("</TD>");
}

//************************************************************************
//Used to create the main cells in the sub menu (2nd level)
//************************************************************************
function createAdminLevel2Button(name, f, status, sID, sCLS){
	debugMsg("createAdminLevel2Button - name: " + name + "; ID: " + sID + "; class: " + sCLS); 
	var col;
	if(jsg_SelectedSubMenu == name) 
		status = "func";

	if(jsg_SelectedSubMenu == name) 
	{
		col = jsg_colorSelectedSubMenu;   
		iCurrent2ndLevelSelection = sID.substring(sID.length - 1,sID.length);;
	} 
	else
		col = jsg_colorBackgrond2nd; 
	
	var strCell; 
	strCell = "<TD ID='"+sID+"' CLASS='"+sCLS+"' nowrap title='' align=center "; 
	strCell += "  onmouseover=\"mOvr2(this,'"+ status +"'); return show3rdLevelMenu(this);\" ";	
	strCell += " onmouseout=\"mOut2(this,'"+ status +"'); \" "; 
	strCell += " onclick='return " + f + "(this);' ";
	strCell += " bgcolor= " + col + " style='width:81px;cursor:pointer;height:20px'>";
    strCell += name;
	strCell += "</TD>";
	debugMsg("Admin 2nd level cell: <!-- createAdminLevel2Button " + strCell + "-->"); 
	MenuWrite(strCell);
}
//************************************************************************
function show3rdLevelMenu(src)
{
 	debugMsg("show3rdLevelMenu");
	var eSrc; 
	if (jsg_IsIE )
	{
		eSrc = window.event.srcElement; 
		window.event.cancelBubble = true;
	}
	else
		eSrc = src;
    OffMenu();
	debugMsg("show3rdLevelMenu() Menu ClassName: " + eSrc.className + " ID: " + eSrc.id);
    if (eSrc.className=="clsMenuAdmin") 
	{
		var nMenuNum = eSrc.id.substring(eSrc.id.length - 1,eSrc.id.length);
		debugMsg("show3rdLevelMenu() MenuTitle Case. Menu Number: " + nMenuNum);
		g_strOpenMenuID = "idMenu" + nMenuNum;
        var eMenu = document.getElementById(g_strOpenMenuID);
		if (eMenu)
		{
			debugMsg("show3rdLevelMenu() Menu Id: " + eMenu.id);
			eMenu.style.clip = "rect(0 0 0 0)";
			eMenu.style.display = "block";
			g_nChunk = 25;
			g_iTimerID = window.setTimeout("showMenu(" + eMenu.id + "),3");
		}
		else
			debugMsg("show3rdLevelMenu() No Menu with g_strOpenMenuID: " + g_strOpenMenuID);
	}
}
//************************************************************************
function showCurrentSelection3rdLevelMenu()
{
	if (jsg_DebugFlag )
		debugMsg("showCurrentSelection3rdLevelMenu");
	if (_bSelected3rdMenuIsShown)
		return; 
	window.clearTimeout(_idMout3Timer);
	OffMenu();
	g_strOpenMenuID = "idMenu" + iCurrent2ndLevelSelection;
 	if (jsg_DebugFlag )
		debugMsg("showCurrentSelection3rdLevelMenu - Open Menu ID: " + g_strOpenMenuID);
    var eMenu = document.getElementById(g_strOpenMenuID); 

	_bSelected3rdMenuIsShown = true;
	if (eMenu)
	{
		if (jsg_DebugFlag )
			debugMsg("showCurrentSelection3rdLevelMenu Menu Id: " + eMenu.id);
		// start displaying the pop-up menu ;
		eMenu.style.clip = "rect(0 0 0 0)";
		eMenu.style.display = "block";
		g_nChunk = 25;
		g_iTimerID = window.setTimeout("showMenu(" + eMenu.id + "),3");
	}
	else
		if (jsg_DebugFlag )
			debugMsg("showCurrentSelection3rdLevelMenu() No Menu with currentMenuID: " + g_strOpenMenuID);
}
//************************************************************************
// 1st Level menu cell pixel border
function createLevel1Spacing(name, size){
//************************************************************************
	MenuWrite("<TD nowrap style='background-color:white' title='' align=middle width='"+size+"'px >");
	MenuWrite(name);
	MenuWrite("</TD>");
}
//************************************************************************************
// Purpose: Adds extent to the right side
function createLevel1SpacingRight(name, size){
	var col;
	col=jsg_colorBackgrond;
	MenuWrite("<TD nowrap style='background-color:#00216c' title='' align=middle width='" + size + "' >");	
	MenuWrite(name);
	MenuWrite("</TD>");
}
//************************************************************************************
// Purpose: 
function createLevel2Spacing(name, size){
	var col;
	col = jsg_colorBackgrond2nd; 

	MenuWrite("<TD nowrap style='background-color:#00216c' title='' align=center width='"+size+"px'"
		+ "onmouseover='showCurrentSelection3rdLevelMenu(); '>");
	MenuWrite(name);
	MenuWrite("</TD>");
}
//************************************************************************
function OpenDropDown(sID, sCls,sH,sW, name)
{
	debugMsg("OpenDropDown() id: " + sID);
	var col;
	if(jsg_SelectedSubMenu == name) 
		col=jsg_colorSelectedSubMenu;
	else
		col=jsg_colorBackgrond2nd;

	MenuWrite("<td nowrap >"); 
	MenuWrite("<div ID='" +sID+ "' CLASS='" + sCls+ "' onmouseout='mOut3(); '>");	
}
//************************************************************************************
// Purpose: 
function CloseDropDown()
{
	MenuWrite("</div></td>");	
}
//************************************************************************************
// Purpose: 
function CreateDropDownMenu(sHref, name, parentMenu){
	debugMsg("CreateDropDownMenu() name: " + name);
	var col, status;
	if(jsg_Selected3rdMenu == name) 
		status = "func";

	if(status=="func")
		col=jsg_colorSelected3rdMenu;
	else
		col=jsg_colorBackgrond3rd;

	var strHref; 
	strHref = "<A id='XYZ' style='Height:20px;valign:bottom;border:none;padding-top:2px;background-color: " + col + " ' " ;
	strHref += "  HREF='javascript:OnMenuLink(\"" + sHref + "\"," + parentMenu + ", \""+ name + "\" ); ' " ; 
	strHref += "   onmouseover=\"A_BG('IN',this,'" + status + "')\" onmouseout=\"A_BG('OUT',this, '" + status + "' )\" >" ; 
	strHref += "<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ name +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></A>";
	if (jsg_DebugFlag )
		debugMsg("CreateDropDownMenu() HREF: <!--" + strHref + "-->");
	MenuWrite(strHref); 
}
//************************************************************************************
function OnMenuLink( url, parentMenu, thirdMenu )
{
	if (jsg_DebugFlag )
		debugMsg("OnMenuLink() parentMenu: " + parentMenu + " - " + thirdMenu);

	setAdminContentFrame(url, jsg_arrAdmin2nLevelMenus[parentMenu], thirdMenu);
}
//************************************************************************************
function OffMenu(){
    if (g_strOpenMenuID != "") 
	{
		if (jsg_DebugFlag )
			debugMsg("OffMenu():" + g_strOpenMenuID );
		_bSelected3rdMenuIsShown = false;
//		var eMenu = document.all[g_strOpenMenuID]; 
		var eMenu = document.getElementById(g_strOpenMenuID); 
		if (eMenu)
			eMenu.style.display = "none"
    }
}
//************************************************************************************
function showMenu(eMenu)
{
	// 
	if (jsg_DebugFlag )
		debugMsg("showMenu()" + eMenu.id + " - nChuck: " + g_nChunk);
	eMenu.style.clip = "rect(0 100% " + g_nChunk + "% 0)"
    g_nChunk +=25
    if (g_nChunk <= 100)
	{
		g_iTimerID = window.setTimeout("showMenu(" + eMenu.id + "),3")
    }
    else 
	{
		window.clearTimeout(g_iTimerID)
	}

}
//************************************************************************************
// Purpose: 
function A_BG(pDirect,pthis,status)
{
	// Used to change the color of the third level menu
	if (jsg_DebugFlag )
		debugMsg("A_BG() Direct:" + pDirect + " Status: " + status + ". This: " + pthis);

	if(pDirect == 'OUT')
	{
		if(status=="func")
			pthis.style.backgroundColor = jsg_colorSelected3rdMenu;
		else
			pthis.style.backgroundColor = jsg_colorBackgrond;

	}
	else
		if(status !="func")
			pthis.style.backgroundColor= jsg_colorMouseOver;

	pthis.style.color= 'white';
}
//************************************************************************************
// Purpose: Mouse move handlers
function mOvr(src,clrOver){  
	if (jsg_DebugFlag )
		debugMsg("mOvr() - " + clrOver); 
//	if (!src.contains(window.event.fromElement))
	{   
		src.style.cursor='hand';
		if(clrOver=="func") 
			src.bgColor= jsg_colorBackgrond;
		else
		{
			if(src.bgColor==jsg_colorSelectedMenu)
				return;
			else
				src.bgColor=jsg_colorMouseOver;
		}
	}
}
function mOvr2(src,clrOver){  
	if (jsg_DebugFlag )
		debugMsg("mOvr2() - " + clrOver); 
//	if (!src.contains(window.event.fromElement))
	{   
		src.style.cursor='hand';
		if(clrOver=="func") 
			src.bgColor= jsg_colorBackgrond2nd;
		else
		{
			if(src.bgColor==jsg_colorSelectedSubMenu)
				return;
			else
				src.bgColor=jsg_colorMouseOver;
		}
	}
}
function mOut(src,clrIn){
//	debugMsg("mOut() - " + clrIn); 
   
//	if (!src.contains(window.event.toElement))
	{  
	//	src.style.cursor='default';
        if(clrIn=="func" || src.title == "current" ) 
			src.bgColor=jsg_colorSelectedMenu;
		else
		{
			src.bgColor=jsg_colorBackgrond;
		}	
    }
}
function mOut2(src,clrIn){
	if (jsg_DebugFlag )
		debugMsg("mOut2() " + clrIn); 
//	if (!src.contains(window.event.toElement))
    {   
	//	src.style.cursor='default';
        if(clrIn=="func" || src.title == "current" ) 
			src.bgColor= jsg_colorSelectedSubMenu;
		else
		{
			if(src.bgColor==jsg_colorSelectedSubMenu)
				return;
			src.bgColor=jsg_colorBackgrond2nd;
		}
   }
}        
function mOut3()
{
	if (jsg_DebugFlag )
		debugMsg("mOut3() " ); 

	if (! _bSelected3rdMenuIsShown)
		_idMout3Timer = window.setTimeout("showCurrentSelection3rdLevelMenu()", 12000); 
}        
//*************************************************************************************
// Purpose: Main Menu Handler
function OnMenu(src)
{
	if (jsg_DebugFlag )
		debugMsg("OnMenu()");
		
	var eSrc; 
	if (jsg_IsIE )
	{
		eSrc = window.event.srcElement; 
		window.event.cancelBubble = true;
	}
	else
		eSrc = src;
	OffMenu();
	if (jsg_DebugFlag )
		debugMsg("OnMenu() Menu ClassName: " + eSrc.className + " ID: " + eSrc.id);

	if (eSrc.className=="Go_Daily_Message")
	{
		setContentFrame(jsg_DailyMessagePage, jsg_DailyMessageURL, jsg_DailyMessageMenu, jsg_None);
	}	
	else if (eSrc.className=="Go_Vessel_Schedule")
	{
		checkAccessAndSetContentFrame(jsg_VesselSchedulePage, jsg_VesselScheduleURL, jsg_VesselScheduleMenu, jsg_None);
	}	
	else if (eSrc.className=="Go_Imports" )
	{
		triggerMultiTrack(jsg_ImportsPage, jsg_ImportsURL, jsg_ImportsMenu, jsg_ImportReportsMenu);
	}	
	else if (eSrc.className=="Go_Exports")
	{
		triggerMultiTrack(jsg_ExportsPage, jsg_ExportsURL, jsg_ExportsMenu, jsg_ExportReportsMenu);
	}	
	else if (eSrc.className=="Go_Gate")
	{
		triggerMultiTrack(jsg_GatePage, jsg_GateActivityURL, jsg_GateMenu, jsg_GateActivtyMenu);
	}	
	else if (eSrc.className=="Go_MultiTrackImport" )  
	{
		OnMultiTrack(jsg_MT_ImportSubMenu);			//not to mix with main button MT, which will use OnMultiTrack("0") and keep user's selection.
	}	
	else if (eSrc.className=="Go_MultiTrackExport" )
	{
		OnMultiTrack("2");
	}	
	else if (eSrc.className=="Go_MultiTrackEnter" )
	{
		OnMultiTrack("3");
	}	
	else if (eSrc.className=="Go_ImportReport")
	{
		setContentFrame(jsg_ImportsPage, jsg_ImportsURL, jsg_ImportsMenu, jsg_ImportReportsMenu);
	}	
	else if (eSrc.className=="Go_Premounts")
	{
		setContentFrame(jsg_PremountsPage, jsg_PremountsRequestURL, jsg_PremountsMenu, jsg_PremountMakeRequestsMenu);
	}	
	else if (eSrc.className=="Go_MakePremountRequests")
	{
		setContentFrame(jsg_PremountsPage, jsg_PremountsRequestURL, jsg_PremountsMenu, jsg_PremountMakeRequestsMenu);
	}	
	else if (eSrc.className=="Go_ReviewPremountRequests") 
	{
		setContentFrame(jsg_PremountsPage, jsg_PremountsReviewURL, jsg_PremountsMenu, jsg_PremountReviewRequestsMenu);
	}	
	else if (eSrc.className=="Go_GateActivity")
	{
		setContentFrame(jsg_GatePage, jsg_GateActivityURL, jsg_GateMenu, jsg_GateActivtyMenu);
	}	
	else if (eSrc.className=="Go_Review_Notifications")
	{
		checkAccessAndSetContentFrame(jsg_ReviewNotificationsPage, jsg_ReviewNotificationsURL, jsg_ReviewNotificationsMenu, "None");
	}	
	//from Terminal Submenu
	else if (eSrc.className=="Go_Terminal_Information")
	{
		setContentFrame(jsg_TerminalInfoPage, jsg_TerminalInfoURL, jsg_TerminalMenu, "TermininalInfo", true);
	}	
	else if (eSrc.className=="Go_Trucker_Instructions")
	{
		setContentFrame(jsg_TruckerInstPage, jsg_TruckerInstructionsURL, jsg_TerminalMenu, "TruckerInstructions", true);
	}	
	else if (eSrc.className=="Go_My_Account")
	{
		setContentFrame(jsg_MyAccountPage, jsg_MyInfoURL, jsg_MyAccountMenu, jsg_MyAccountProfileMenu);
	}
	else if (eSrc.className=="Go_My_AccountPermissions") 
	{
		setContentFrame(jsg_MyAccountPage, jsg_MyAccountURL, jsg_MyAccountMenu, jsg_MyAccountPermissionsMenu);
	}
	else if (eSrc.className=="Go_My_AccountProfile") 
	{
		setContentFrame(jsg_MyAccountPage, jsg_MyInfoURL, jsg_MyAccountMenu, jsg_MyAccountProfileMenu);
	}
	else if (eSrc.className=="Go_My_AccountPreferences") 
	{
		setContentFrame(jsg_MyAccountPage, jsg_MyPreferencesURL, jsg_MyAccountMenu, jsg_MyAccountPreferencesMenu);
	}
	else if (eSrc.id == "idMenuTitle0" )
	{
		setAdminContentFrame(jsg_SM_DailyMessageViewURL,jsg_SM_DailyMessageMenu, jsg_SM_DM_ViewMenu);
	}
	else if (eSrc.id == "idMenuTitle1" )
	{
		setAdminContentFrame(jsg_SM_ViewUnconfirmedUsersURL,jsg_SM_UserAdminMenu, jsg_SM_UA_ViewUnconfirmedMenu);
	}
	else if (eSrc.id == "idMenuTitle2" )
	{
		setAdminContentFrame(jsg_SM_BroadcastEmailURL,jsg_SM_BroadcastEmailMenu, jsg_SM_BE_AllUsersMenu);
	}
	else if (eSrc.id == "idMenuTitle3" )
	{
		setAdminContentFrame(jsg_SM_SiteConfigURL,jsg_SM_SiteConfigMenu, jsg_SM_SC_EditMenu);
	}
	else if (eSrc.id == "idMenuTitle4" )
	{
		setAdminContentFrame(jsg_SM_SSCOConfigURL,jsg_SM_SSCOConfigMenu, jsg_SM_SSC_EditMenu);
	}
	else if (eSrc.id == "idMenuTitle5" )
	{
		setAdminContentFrame(jsg_SM_ArchivesURL,jsg_SM_TerminalAdminMenu, jsg_SM_TA_ArchivesMenu);
	}
	if (eSrc.className=="Go_Admin")
	{
		setAdminContentFrame(jsg_SM_DailyMessageViewURL,jsg_SM_DailyMessageMenu, jsg_SM_DM_ViewMenu);
	}
	if (eSrc.className=="Go_ApptMakeEmptyIn") // CR 25463 -- Christian -- 06/24/2009
	{
	    checkAccessAndSetContentFrame(jsg_EmptyInPageStandAlone, jsg_ApptMakeEmptyInURL, jsg_ApptMakeEmptyInMenu, jsg_None);
	}
	else 
		debugMsg("OnMenu(). Unhandled event - ID: " + eSrc.id + " - Class: " + eSrc.className);
}
//*************************************************************************************
// Purpose: Appointment Menus handler
function OnApptMenu(src)
{
	if (jsg_DebugFlag )
		debugMsg("OnApptMenu()");
	var eSrc; 
	if (jsg_IsIE )
	{
		eSrc = window.event.srcElement; 
		window.event.cancelBubble = true;
	}
	else
		eSrc = src;
	OffMenu();
	if (jsg_DebugFlag )
		debugMsg("OnApptMenu() Menu ClassName: " + eSrc.className + " ID: " + eSrc.id);

	if (eSrc.className=="Go_ApptMain")
	{   // add check for user type here (Appt Admin or terminal)
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptURL, jsg_ApptMenu, jsg_ApptMenu);
	}
	else if (eSrc.className=="Go_ApptConfig")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptConfigURL, jsg_ApptMenu, jsg_ApptConfigMenu);
	}
	else if (eSrc.className=="Go_ApptMake")
	{
		//trigger MultiTrack 
		OnMultiTrack("5");
	}
	else if (eSrc.className=="Go_ApptMakeBookings")
	{
		//trigger MultiTrack 
		OnMultiTrack("6");
	}
	else if (eSrc.className=="Go_ApptMakeEmptyIn")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptMakeEmptyInURL, jsg_ApptMenu, jsg_ApptMakeEmptyInMenu);
	}
	else if (eSrc.className=="Go_ApptLimits")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptLimitsURL, jsg_ApptMenu, jsg_ApptLimitsMenu);
	}	
	else if (eSrc.className=="Go_ApptTerminalReport")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptTerminalReportURL, jsg_ApptMenu, jsg_ApptTerminalReportMenu);
	}	
	else if (eSrc.className=="Go_ApptTruckerReport")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptTruckerReportURL, jsg_ApptMenu, jsg_ApptTruckerReportMenu);
	}	
	else if (eSrc.className=="Go_ApptTest")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptTestURL, jsg_ApptMenu, jsg_ApptTestMenu);
	}	
	else if (eSrc.className=="Go_ApptTest2")
	{
		checkAccessAndSetContentFrame(jsg_ApptPage, jsg_ApptTest2URL, jsg_ApptMenu, jsg_ApptTest2Menu);
	}	
	else 
		debugMsg("OnMenu(). Unhandled event - ID: " + eSrc.id + " - Class: " + eSrc.className);
}

// The variables below define the 2nd level menu right margin
// Premount menu width = 71
var jsg_AdjustmentImport = 204; 
var jsg_AdjustmentExport = 283; 
var jsg_AdjustmentPremount = 365;
var jsg_AdjustmentGate = 365 ;    // No premount
var jsg_AdjustmentAppt = 300 ;    // 381 before Empty In
var jsg_AdjustmentMyAccount = 405;  // no premount and no appt
var jsg_AdjustmentAdmin = 0; 
var jsg_MT_ImportSubMenu = "99";
function SetupOffsets()
{
	jsg_AdjustmentImport = 204; 
	jsg_AdjustmentExport = 283; 
	jsg_AdjustmentPremount = 365;
	jsg_AdjustmentGate = 365 ;    // No premount
	jsg_AdjustmentAppt = 300 ;    // 381 before Empty In
	jsg_AdjustmentMyAccount = 405;  // no premount and no appt
	jsg_AdjustmentAdmin = 0; 
	jsg_MT_ImportSubMenu = "99";

    // Setup With No Premount
	if (jsg_IsApptAdminUser && jsg_IsTruckingCompanyUser) 
		jsg_AdjustmentAppt = -40 ; // 41 before 41 - 81 = -40
	else if ( jsg_IsApptAdminUser ) 
		jsg_AdjustmentAppt = 203 ;	
	else
	{
		if(jsg_CurrentSiteEmptyInApptSupported)
			jsg_AdjustmentAppt = 190 ; // 296 before Empty In (trk only)
		else
			jsg_AdjustmentAppt = 296 ;
	}
	// Check Appt Premount Menu
	if (jsg_IsPremountUser && jsg_CurrentSitePremountEnabled) 
	{
		jsg_AdjustmentImport = 202; 
		jsg_AdjustmentExport = 284; 
		jsg_AdjustmentGate +=  81; 
		jsg_AdjustmentAppt +=  81;
		jsg_AdjustmentMyAccount += 81;
	}
	// If we add the Appt Menu
	if ( (jsg_IsApptAdminUser || jsg_IsTruckingCompanyUser) &&
		 (jsg_IsBetaTestUser || jsg_CurrentSiteApptSupported) ) 
	{
		jsg_AdjustmentMyAccount += 92;   // Appt Menu size
	}
	return ;
}


function focusOnChild()
{
	if (top != this)
		_MainFrame.focusOnChild(); 
}


// User Permission 
var jsg_IsLoggedIn = false;
var jsg_IsAdminUser = false;
var jsg_IsPremountUser = false;
var jsg_IsHighVolumeUser = false;
var jsg_IsGateActivityUser = false;
var jsg_IsTruckingCompanyUser = false;
var jsg_IsSuperAdminUser = false;
var jsg_IsApptAdminUser = false;
var jsg_IsBetaTestUser = false;
var jsg_IsSysAdminUser = false;
var jsg_IsApptResetUser = false;
var jsg_IsTerminalOperationUser = false;

// Site Config
var jsg_CurrentSitePremountEnabled = false;
var jsg_CurrentSiteApptSupported = false;
var jsg_CurrentSiteEmptyInApptSupported = false;
var jsg_CurrentSiteEmptyInApptPageEnable = false; //CR 25463 -- Christian -- 06/23/2009

// Current Menu selection
var jsg_SelectedMenu= "None"; // MN Key variable used to define the current page context
var jsg_SelectedSubMenu="None"; // MN Key variable used to define the current page in the second menu
var jsg_Selected3rdMenu= "None"; // MN Key variable used to define the current page in the second menu

function MenuOutputConfigInfo()
{
	debugMsg("jsg_IsLoggedIn: " + jsg_IsLoggedIn );
	debugMsg("jsg_IsAdminUser: " + jsg_IsAdminUser );
	debugMsg("jsg_IsPremountUser: " + jsg_IsPremountUser );
	debugMsg("jsg_IsHighVolumeUser: " + jsg_IsHighVolumeUser );
	debugMsg("jsg_IsGateActivityUser: " + jsg_IsGateActivityUser );
	debugMsg("jsg_IsTruckingCompanyUser: " + jsg_IsTruckingCompanyUser );
	debugMsg("jsg_IsSuperAdminUser: " + jsg_IsSuperAdminUser );
	debugMsg("jsg_IsSysAdminUser: " + jsg_IsSysAdminUser );
	debugMsg("jsg_IsApptAdminUser: " + jsg_IsApptAdminUser );
	debugMsg("jsg_IsBetaTestUser: " + jsg_IsBetaTestUser );
	debugMsg("jsg_DebugFlag: " + jsg_DebugFlag );
	debugMsg("jsg_SelectedMenu: " + jsg_SelectedMenu ); 
	debugMsg("jsg_SelectedSubMenu: " + jsg_SelectedSubMenu ); 
	debugMsg("jsg_Selected3rdMenu: " + jsg_Selected3rdMenu ); 
	debugMsg("jsg_CurrentSitePremountEnabled: " + jsg_CurrentSitePremountEnabled );
	debugMsg("jsg_CurrentSiteApptSupported: " + jsg_CurrentSiteApptSupported );
	debugMsg("jsg_CurrentSiteEmptyInApptSupported: " + jsg_CurrentSiteEmptyInApptSupported );
	debugMsg("jsg_IsApptResetUser: " + jsg_IsApptResetUser );
	debugMsg("jsg_IsTerminalOperationUser: " + jsg_IsTerminalOperationUser );
	debugMsg("jsg_CurrentSiteEmptyInApptPageEnable: " + jsg_CurrentSiteEmptyInApptPageEnable);//CR 25463 -- Christian -- 06/23/2009
}

function MenuInitConfig()
{
	if (top != this)
	{
		jsg_IsLoggedIn = _MainFrame.jsg_IsLoggedIn;
		jsg_IsAdminUser = _MainFrame.jsg_IsAdminUser;
		jsg_IsPremountUser = _MainFrame.jsg_IsPremountUser;
		jsg_IsHighVolumeUser = _MainFrame.jsg_IsHighVolumeUser;
		jsg_IsGateActivityUser = _MainFrame.jsg_IsGateActivityUser;
		jsg_IsTruckingCompanyUser = _MainFrame.jsg_IsTruckingCompanyUser;
		jsg_IsSuperAdminUser = _MainFrame.jsg_IsSuperAdminUser;
		jsg_IsSysAdminUser = _MainFrame.jsg_IsSysAdminUser;
		jsg_IsApptAdminUser = _MainFrame.jsg_IsApptAdminUser;
		jsg_IsBetaTestUser = _MainFrame.jsg_IsBetaTestUser;
		jsg_DebugFlag = _MainFrame.jsg_DebugFlag;
		jsg_SelectedMenu=  _MainFrame.jsg_SelectedMenu; 
		jsg_SelectedSubMenu= _MainFrame.jsg_SelectedSubMenu; 
		jsg_Selected3rdMenu = _MainFrame.jsg_Selected3rdMenu; 
		jsg_CurrentSitePremountEnabled = _MainFrame.jsg_CurrentSitePremountEnabled;
		jsg_CurrentSiteApptSupported = _MainFrame.jsg_CurrentSiteApptSupported;
		jsg_CurrentSiteEmptyInApptSupported =  _MainFrame.jsg_CurrentSiteEmptyInApptSupported;
		jsg_IsApptResetUser = _MainFrame.jsg_IsApptResetUser;
		jsg_IsTerminalOperationUser = _MainFrame.jsg_IsTerminalOperationUser;
		jsg_CurrentSiteEmptyInApptPageEnable = _MainFrame.jsg_CurrentSiteEmptyInApptPageEnable;//CR 25463 -- Christian -- 06/23/2009
		MenuOutputConfigInfo();
	} 
}
function checkAccessAndSetContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>checkAccessAndSetContentFrame() </b>"); 
		_MainFrame.checkAccessAndSetContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL);
	}
	else
		debugMsg("Testing checkAccessAndSetContentFrame() "); 
}
function checkPermissionsAndSetContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>checkPermissionsAndSetContentFrame() </b>"); 
		_MainFrame.checkPermissionsAndSetContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL);
	}
	else
		debugMsg("Testing checkPermissionsAndSetContentFrame() "); 
}
function setContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>setContentFrame() </b>"); 
		_MainFrame.setContentFrame(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL);
	}
	else
		debugMsg("Testing setContentFrame()"); 
		
}
function triggerMultiTrack(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>triggerMultiTrack() </b>"); 
		_MainFrame.triggerMultiTrack(pageName, pageFile, pageMenu, pageSubMenu, isSiteSpecifcURL);
	}
	else
		debugMsg("Testing triggerMultiTrack() "); 
}
function OnMultiTrack(selectEntity)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>OnMultiTrack() </b>"); 
		_MainFrame.OnMultiTrack(selectEntity);
	}
	else
		debugMsg("Testing On MultiTrack() "); 
}
function setAdminContentFrame(url,secondLevelMenu, thirdLevelMenu)
{
	if (top != this)
	{
		_MainFrame.debugMsg("<b style='background-color:lightblue'>setAdminContentFrame() </b>"); 
		_MainFrame.setAdminContentFrame(url,secondLevelMenu,thirdLevelMenu ); 
	}
	else
		debugMsg("Testing  setAdminContentFrame() "); 
}


