////////////////////////////////////////////////////////////////////////
//
// Filename: startup.js
// Purpose : Launch a JavaScript function once all files have been loaded
// Method  : Browser dependant
//
// Author  : J.van.der.Steen@gobase.org
// Date    : 2010-03-07
//
////////////////////////////////////////////////////////////////////////

/* for Mozilla */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", pageInit, false);
}

var scriptholder = null;
// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var scriptholder = document.getElementById("__ie_onload");
    if (scriptholder !== null) {
        scriptholder.onreadystatechange = function()
        {
            if (this.readyState == "complete") {
                pageInit();
            }
        };
    }
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval( function() {
                                  if (/loaded|complete/.test(document.readyState)) {
                                      pageInit();
                                  }
                              }
                            , 10
                            ) ;
}

/* for other browsers */
scriptholder = document.getElementById("__ie_onload");
if (scriptholder === null) {
    window.onload = pageInit;
}

/**
 * Initialize various page components.
 * This function is called once all page resources are loaded.
 */
function pageInit()
{
    if (true) {
        if (arguments.callee.done) {
            // quit if this function has already been called
            return;
        }
        arguments.callee.done = true;

        if (_timer) {
            // kill the timer
            clearInterval(_timer);
        }
    }

    //
    // Style panels
    //
    panelSetDimensions(hNavigator, wShare, hShare, wDetails);

    //
    // Add panel controls
    //
    panelAddControls();

    //
    // Install window resize event handler.
    //
    Event.observe(window, 'resize', panelDimensions);

    //
    // Create the lookup table
    //
    config.lookupTable = new LookupTable();

    //
    // Initialize the main menu
    //
    menuInit(menu, null);

    //
    // Create the main menu
    //
    menuLoad(menu, 'menumain');

    //
    // Select first menu item
    //
    contentLoad(menu[0].guid);

    //
    // Fill colofon
    //
    var html = '';
    var data;
    html += "<div style='text-align:center;'>\n";

    data = config.board.design;
    html += "<span style='float:left;margin: 0px 8px;'>\n";
    html += "design: <a target='external' href='" + data.url + "''>" + data.name.toLowerCase() + "</a>\n";
    html += "</span>\n";

    data = config.board.technique;
    html += "<span style='float:right;margin: 0px 8px;'>\n";
    html += "techniek: <a target='external' href='" + data.url + "''>" + data.name.toLowerCase() + "</a>\n";
    html += "</span>\n";

    html += "<span onclick='emitFormLogin();'>\n";
    html += "copyright: &copy; 2010-" + startupParam.thisyear + " " + config.copyright + "\n";
    html += "</span>\n";
    html += "</div>\n";

    Element.update('colofon', html);

    //
    // Is content by name requested?
    //
    if (startupParam.byname !== '/') {
     // alert("All loaded, fire: byname = '" + startupParam.byname + "'");
        contentLoadByName(menu, startupParam.byname);
    }
}


