var menuItemWidth = 73;

var menuItemHeight = 19;

if (document.images) { // Browser supports image swaps (most do)

    // This section preloads the images to be used for the
    // button at the base of each menu (not the menu items
    // themselves; they're done using pure DHTML).

    //  -> The menuOutButtons array contains the images for
    //     the menu buttons' default appearance.
    var menuOutButtons = new Array();
    menuOutButtons[0] = new Image();
    menuOutButtons[0].src = "gambar/blackjan/menujan/menu_00_1.gif";
    menuOutButtons[1] = new Image();
    menuOutButtons[1].src = "gambar/blackjan/menujan/menu_01_1.gif";
    menuOutButtons[2] = new Image();
    menuOutButtons[2].src = "gambar/blackjan/menujan/menu_02_1.gif";
    menuOutButtons[3] = new Image();
    menuOutButtons[3].src = "gambar/blackjan/menujan/menu_03_1.gif";
    menuOutButtons[4] = new Image();
    menuOutButtons[4].src = "gambar/blackjan/menujan/menu_04_1.gif";

    //  -> The menuOverButtons array contains the images for
    //     the menu buttons' active appearance.
    var menuOverButtons = new Array();
	menuOverButtons[0] = new Image();
    menuOverButtons[0].src = "gambar/blackjan/menujan/menu_00_2.gif";
    menuOverButtons[1] = new Image();
    menuOverButtons[1].src = "gambar/blackjan/menujan/menu_01_2.gif";
    menuOverButtons[2] = new Image();
    menuOverButtons[2].src = "gambar/blackjan/menujan/menu_02_2.gif";
    menuOverButtons[3] = new Image();
    menuOverButtons[3].src = "gambar/blackjan/menujan/menu_03_2.gif";
    menuOverButtons[4] = new Image();
    menuOverButtons[4].src = "gambar/blackjan/menujan/menu_04_2.gif";

}

var menuLengths = new Array(0,0,3,2,2);

var menuURLs = new Array(menuLengths.length);
for (i=0;i<menuLengths.length;i++) 
    menuURLs[i] = new Array(menuLengths[i]);

	
	
//menuURLs[0][0] = "warta.php?op=viewbio";         // URL for "menu1item1"
//menuURLs[1][0] = "";         // URL for "menu2item1"
menuURLs[2][0] = "warta.php?op=viewcat&id=1";         // URL for "menu2item1"
menuURLs[2][1] = "warta.php?op=viewcat&id=2";        // URL for "menu2item4"
menuURLs[2][2] = "warta.php?op=viewcat&id=3";       // URL for "menu2item7"
menuURLs[3][0] = "warta.php?op=viewcat&id=4";     // URL for "menu3item1"
menuURLs[3][1] = "warta.php?op=foto";    // URL for "menu3item2"
menuURLs[4][0] = "warta.php?op=bukutamu&ix=0";    // URL for "menu4item1"
menuURLs[4][1] = "warta.php?op=linker";       // URL for "menu4item2"

var menuTimers = new Array(menuLengths.length);

function getStyleObj(id) {
    if (document.getElementById || // DOM-compliant browsers (MSIE5, NSN6, O5)
        document.all) {            // or MSIE 4
        return getObj(id).style;
	} else return getObj(id); // NSN4
}

function getObj(id) {
    if (document.getElementById) { // DOM-compliant browsers (MSIE5, NSN6, O5)
        return document.getElementById(id);
    } else if (document.all) { // MSIE4
        return document.all[id];
    } else if (document.layers) { // NSN4
        return document.layers[id];
    } else { // Trap DHTML-impaired browsers 
        //alert("Your browser does not support DHTML!");
        return false;
    }
}

function showMenu(index) {
    // Make sure this menu is not marked to be closed. This
    // cancels any previous request to close this menu.
    if (menuTimers[index-1]) clearTimeout(menuTimers[index-1]);

    // Immediately close any other menus so as to avoid
    // having more than one menu open at once (which is
    // quite ugly).
    for (i=1;i<=menuLengths.length;i++)
        if (i!=index) closeMenu(i);

    // Get a reference to the style of the menu to be displayed.
    if (navigator.appName=="Microsoft Internet Explorer") {
	var menu = getStyleObj("iemenu"+index); } 
	else { var menu = getStyleObj("menu"+index); }

    // Make sure we got a valid reference, and make the menu visible.
	if (index != 1) {
    if (menu) menu.visibility = "visible";
	}
	
    // Display the 'active' version of the menu button.
    if (document.images) document.images["menubutton"+index].src =
                            menuOverButtons[index-1].src;
}

function hideMenu(index) {
    // Cancel any previous closing timer for this menu
    if (menuTimers[index-1]) clearTimeout(menuTimers[index-1]);

    // Close the menu after a delay of 500ms (1/2 second).
    menuTimers[index-1] = setTimeout("closeMenu('"+index+"');",500);
}

function closeMenu(index) {
    // Get a reference to the style of the menu to be closed.
    if (navigator.appName=="Microsoft Internet Explorer") {
	var menu = getStyleObj("iemenu"+index); } 
	else { var menu = getStyleObj("menu"+index); }

    // Make sure we got a valid reference, and hide the menu.
    if (menu) menu.visibility = "hidden";

    // Display the 'inactive' version of the menu button.
    if (document.images) document.images["menubutton"+index].src =
                            menuOutButtons[index-1].src;
}

function overMenuItem() {
    // Each menu item has a 'hilightitem' variable that
    // contains a reference to the <div> that contains
    // the hilighted version of the menu item. We use that
    // reference here to make that hilighted menu item
    // visibile.
    this.hilightitem.visibility='visible';

    // Each menu item has a 'menuid' variable that contains
    // the integer ID of the menu that it belongs to
    // (e.g. 2 if it belongs to "menu2"). By calling the
    // showMenu() function for that menu, we ensure that that
    // menu stays open.
    showMenu(this.menuid);
}

function outMenuItem() {
    // Each menu item has a 'hilightitem' variable that
    // contains a reference to the <div> that contains
    // the hilighted version of the menu item. We use that
    // reference here to hide that hilighted menu item.
    this.hilightitem.visibility='hidden';

    // Each menu item has a 'menuid' variable that contains
    // the integer ID of the menu that it belongs to
    // (e.g. 8 if it belongs to "menu8"). By calling the
    // hideMenu() function for that menu, we indicate that
    // the menu closes after a delay if the mouse doesn't
    // move to another menu item that will keep it open.
    hideMenu(this.menuid);
}

function clickMenuItem() {
    if (this.url) { // There is a URL associated with this item
        window.location = this.url;
    }
}

window.onload=setupMenus; // Assign to onLoad event handler
function setupMenus() {
    if (document.layers) { // This section is for Netscape 4 only
        for (menuid=1;menuid<=menuLengths.length;menuid++) { // For each menu
            // Get the menu object
            var menu = getObj("menu"+menuid);

            // Set its 'clip' width and height. This forces NSN4 to fill in
            // the background color behind the whole menu area.
            menu.clip.width = menuItemWidth + 2;
            menu.clip.height = (menuItemHeight+1) * menuLengths[menuid-1] + 1;

            // Set the background color of the menu to force NSN4 to fill it
            // using the new 'clip' dimensions we just specified.
            menu.document.bgColor="#000000";

            for (i=1;i<=menuLengths[menuid-1];i++) { // For each menu item

                // Each menu item is actually composed of two <DIV> tags:
                // one for the menu item's regular appearance, and one for
                // what the menu item should look like when the user's mouse
                // passes over it. We start by obtaining references to each
                // of these page elements. Since they are nested inside the
                // menu DIV, we can't use the getObj function, so we use
                // eval() to grab them directly:
                var item = eval("menu.document.menu"+menuid+"item"+i);
                var onitem = eval("menu.document.menu"+menuid+"item"+i+"on");

                // Dynamically set the vertical position of each menu item,
                // leaving a 1-pixel gap between each (NSN4 ignores any
                // attempt to do this using CSS).
                item.top = (menuItemHeight + 1) * (i-1) + 1;
                onitem.top = (menuItemHeight + 1) * (i-1) + 1;

                // Dynamically set the 'clip' dimensions and background colors
                // of each of the menu items. Again, we're forcing NSN4 to
                // fill the full width and height of each menu item.
                item.clip.width = menuItemWidth;
                item.clip.height = menuItemHeight;
                item.document.bgColor="#FFFF99";
                onitem.clip.width = menuItemWidth;
                onitem.clip.height = menuItemHeight;
                onitem.document.bgColor="#0099FF";

                // When the user's mouse is over a menu item, we want to display
                // the highlighted version of the menu item (which is hidden by
                // default). The functions overMenuItem() and outMenuItem() are
                // responsible for showing and hiding the highlighted versions of
                // the menu items. Since these 'mouseover' and 'mouseout' events
                // can come from both the normal and hilighted menu item
                // under different conditions, we need a way for these functions
                // to access the hilighted menu item no matter which of the two
                // versions of the menu item ('item' and 'onitem') triggers them.
                // What we do is attach a variable called 'hilightitem' to both
                // of them containing a reference to the highlighted menu item
                // ('onitem'). The functions can then use this reference to show
                // and hide the hilighted item as appropriate.
                item.hilightitem = onitem;
                onitem.hilightitem = onitem;

                // The onverMenuItem() and outMenuItem() functions also need to
                // know what menu the menu item that triggered them belongs to,
                // so that they can close or keep open that menu as appropriate.
                // So we store the menu ID in a variable called 'menid'
                // attached to each menu item (and its highlighted version).
                item.menuid = menuid;
                onitem.menuid = menuid;

                // We also record the URL associated with each menu item, which
                // will be used by the clickMenuItem() function to load the URL
                // when the menu item is clicked on. The URL is fetched from the
                // menuURLs array created above.
                var url = menuURLs[menuid-1][i-1];
                item.url = url;
                onitem.url = url;

                // Finally, we set the onMouseOver/onMouseOut/onClick event
                // handlers for each menu item (and its highlighted version) so
                // that they call the overMenuItem(), outMenuItem(), and 
                // clickMenuItem() functions. We also set the types of events
                // that the menu items should react to. This is the only way to
                // get NSN4 to attach onMouseOver/onMouseOut/onClick event
                // handlers to anything but links.
                var eTypes = Event.MOUSEOVER | Event.MOUSEOUT | Event.CLICK;
                item.captureEvents(eTypes);
                onitem.captureEvents(eTypes);
                item.onmouseover = overMenuItem;
                onitem.onmouseover = overMenuItem;
                item.onmouseout = outMenuItem;
                onitem.onmouseout = outMenuItem;
                item.onclick = clickMenuItem;
                onitem.onclick = clickMenuItem;
            }
        }
    } else { // This section is for all other browsers
        for (menuid=1;menuid<=menuLengths.length;menuid++) { // For each menu

            // The menus' sizes and background colors are already set using CSS,
            // since Opera doesn't like dynamically setting page element sizes
            // with JavaScript.

                for (i=1;i<=menuLengths[menuid-1];i++) { // For each menu item

                // Each menu item is actually composed of two <DIV> tags:
                // one for the menu item's regular appearance, and one for
                // what the menu item should look like when the user's mouse
                // passes over it. We start by obtaining references to each
                // of these page elements and their styles.
                var item = getObj("menu"+menuid+"item"+i);
                var onitem = getObj("menu"+menuid+"item"+i+"on");
                var itemstyle = getStyleObj("menu"+menuid+"item"+i);
                var onitemstyle = getStyleObj("menu"+menuid+"item"+i+"on");

                // Dynamically set the vertical position of each menu item,
                // leaving a 1-pixel gap between each. All other style attributes
                // are set using CSS for compatibility with Opera.
                itemstyle.top = ((menuItemHeight + 1) * (i-1) + 1) + "px";
                onitemstyle.top = ((menuItemHeight + 1) * (i-1) + 1) + "px";
                
                // Set the mouse cursor for the menu items to look like a
                // hand. This is for MSIE only. DOM-compliant browsers like
                // NSN6 will use the cursor:pointer setting in the CSS.
                if (navigator.appName=="Microsoft Internet Explorer") {
                    itemstyle.cursor = "hand";
                    onitemstyle.cursor = "hand";
				}

                // When the user's mouse is over a menu item, we want to display
                // the highlighted version of the menu item (which is hidden by
                // default). The functions overMenuItem() and outMenuItem() are
                // responsible for showing and hiding the highlighted versions of
                // the menu items. Since these 'mouseover' and 'mouseout' events
                // can come from both the normal and hilighted menu item
                // under different conditions, we need a way for these functions
                // to access the hilighted menu item no matter which of the two
                // versions of the menu item ('item' and 'onitem') triggers them.
                // What we do is attach a variable called 'hilightitem' to both
                // of them containing a reference to the highlighted menu item
                // ('onitem'). The functions can then use this reference to show
                // and hide the hilighted item as appropriate.
                item.hilightitem = onitemstyle;
                onitem.hilightitem = onitemstyle;

                // The onverMenuItem() and outMenuItem() functions also need to
                // know what menu the menu item that triggered them belongs to,
                // so that they can close or keep open that menu as appropriate.
                // So we store the menu ID in a variable called 'menid'
                // attached to each menu item (and its highlighted version).
                item.menuid = menuid;
                onitem.menuid = menuid;

                // We also record the URL associated with each menu item, which
                // will be used by the clickMenuItem() function to load the URL
                // when the menu item is clicked on. The URL is fetched from the
                // menuURLs array created above.
                var url = menuURLs[menuid-1][i-1];
                item.url = url;
                onitem.url = url;

                // Finally, we set the onMouseOver/onMouseOut event handlers for
                // each menu item (and its highlighted version) so that they
                // call the overMenuItem() and outMenuItem() functions. We could
                // have just set these as attributes in the <DIV> tags, but since
                // NSN4 doesn't support that we'll keep things tidy and do it the
                // same way as we did above for that browser.
                item.onmouseover = overMenuItem;
                onitem.onmouseover = overMenuItem;
                item.onmouseout = outMenuItem;
                onitem.onmouseout = outMenuItem;
                item.onclick = clickMenuItem;
                onitem.onclick = clickMenuItem;
            }
        }
    }
}

/**
 * Compensate for the NSN4 resize bug by reloading the page
 * whenever the window is resized.
 */
function handleResize() {
  location.reload();
  return false;
}
if (document.layers) {
  window.onresize = handleResize;
}

navHover = function() {
  if(document.getElementById("navmenu-h")) {	
	var lis = document.getElementById("navmenu-h").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
}
if (window.attachEvent) window.attachEvent("onload", navHover);
