//////////////////////////////////////////////////////////////////////
//  Page.js
//////////////////////////////////////////////////////////////////////

// Code for all site pages (main section)

//////////////////////////////////////////////////////////////////////
//  Global references
//////////////////////////////////////////////////////////////////////

// Site menus and current menu items
var navMenu;
var mainMenu;
var curNavMenuId;
var curMainMenuId;
var curTabsMenuId;
var curSubMenuId;

//////////////////////////////////////////////////////////////////////
//  All-pages functions 
//////////////////////////////////////////////////////////////////////

function setCurMenus(navMenuId, mainMenuId, tabsMenuId, subMenuId) {
    curNavMenuId = navMenuId;   // e.g. "nav.download"
    curMainMenuId = mainMenuId; // e.g. "menu.download.smslist"
    if (!(tabsMenuId==undefined))
        curTabsMenuId=tabsMenuId;
    if (!(subMenuId==undefined))
        curSubMenuId=subMenuId;
}

function onPageLoad() {

    // Set debug window
    setDebugWindow(document.getElementById("debug"), false);

    // Dump page information
    debug("Page URL: "+document.location);

    // Set menus
    debug("Menu: "+curMainMenuId);
    navMenu = document.getElementById("nav");
    mainMenu = document.getElementById("menu");
    selectNavMenu(curNavMenuId);
    selectMenu(curMainMenuId);
    if (!(curTabsMenuId==undefined))
        selectTabsMenu(curTabsMenuId);
    if (!(curSubMenuId==undefined))
        selectSubMenu(curSubMenuId);
	
    // Show error dialog
    //showErrorDialog(); // TODO
}

//////////////////////////////////////////////////////////////////////
//  All-pages code 
//////////////////////////////////////////////////////////////////////

window.onload = onPageLoad;

