var menuids = ["sbm1", "sbm2", "sbm3"];

function initsidebarmenu() {
    for (var i = 0; i < menuids.length; i++) {
        var menu = document.getElementById(menuids[i]);
        if (!menu) continue;
        
        var ultags = menu.getElementsByTagName("ul")
        for (var t = 0; t < ultags.length; t++) {
            ultags[t].parentNode.getElementsByTagName("a")[0].className += " subfolderstyle"
            if (ultags[t].parentNode.parentNode.id == menuids[i]) //if this is a first level submenu
                ultags[t].style.left = ultags[t].parentNode.offsetWidth + "px" //dynamically position first level submenus to be width of main menu item
            else //else if this is a sub level submenu (ul)
                ultags[t].style.left = ultags[t - 1].getElementsByTagName("a")[0].offsetWidth + "px" //position menu to the right of menu item that activated it
            ultags[t].parentNode.onmouseover = function() {
                this.getElementsByTagName("ul")[0].style.display = "block"
            }
            ultags[t].parentNode.onmouseout = function() {
                this.getElementsByTagName("ul")[0].style.display = "none"
            }
        }
        for (var t = ultags.length - 1; t > -1; t--) { //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
            ultags[t].style.visibility = "visible"
            ultags[t].style.display = "none"
        }
    }
}

if (window.addEventListener)
    window.addEventListener("load", initsidebarmenu, false)
else if (window.attachEvent)
    window.attachEvent("onload", initsidebarmenu)

function ShowVideo(inID) {
    var URL2 = "/videowindow.aspx?id=" + inID;

    LeftPosition = (screen.width) ? (screen.width - 480) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - 385) / 2 : 0;

    var dWin = window.open(URL2, '_drwin', 'left=' + LeftPosition + ',top=' + TopPosition + ',resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=480,height=385');
    dWin.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init == true) with (navigator) {
        if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
            document.MM_pgW = innerWidth; document.MM_pgH = innerHeight; onresize = MM_reloadPage;
        } 
    }
    else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function showpano(id) {
    settings = 'width=370,height=480,top=5,left=5,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
    var win = window.open('http://display.maxvr.com/windstar/viewer.asp?id=' + id, 'maxvrviewer', settings);
    win.focus();
}

function toggleDisplay(id) {
    var style = $get(id).style;
    style.display = style.display == "none" ? "block" : "none";
}

function CheckNumericValues(evt) {
    evt = (null == evt) ? event : evt;
    var code = evt.keyCode;
    if (code == 0)
        code = evt.charCode;
    if ((code >= '48' && code <= '57') || code == '8' || code == '46') //8-backspace, 46-delete
        return true;
    else
        return false;
}