
            // "load" handler for the window

            YAHOO.example.onWindowLoad = function(p_oEvent) {
    

                // Hides submenus of the root Menu instance
                
                function hideSubmenus() {

                    if(oMenu.activeItem) {
                    
                        var oSubmenu = oMenu.activeItem.cfg.getProperty("submenu");

                        if(oSubmenu) {
                        
                            oSubmenu.hide();
                        
                        }
                    
                    }

                }


                // Cancels the call to "hideSubmenus"

                function cancelTimer() {

                    if(nTimeoutId) {
    
                        window.clearTimeout(nTimeoutId);
    
                    }
                
                }

    
                // "mouseout" event handler for each submenu
                
                function onSubmenuMouseOut(p_sType, p_aArguments, p_oMenu) {
    
                    cancelTimer();
    
                    nTimeoutId = window.setTimeout(hideSubmenus, 750);
                
                }


                // "beforeshow" handler for each submenu

                function onMenuBeforeShow(p_sType, p_sArgs) {

                    // Check if the menu has any items. If not, add them
                    
                    if(this.getItemGroups().length == 0) {

                        var aItemsData = this.itemsData,
                            nItems = aItemsData.length,
                            oItemData,
                            oItemConfig,
                            oSubmenu;


                        for(var i=0; i<nItems; i++) {

                            oItemData = aItemsData[i];

                            if(oItemData) {

                                oItemConfig = {};
    
                                if(oItemData.url) {
                                
                                    oItemConfig.url = oItemData.url;
                                
                                }
                                
    
                                if(oItemData.submenuItems) {
    
                                    oSubmenu = new YAHOO.widget.Menu(oItemData.submenuId);

                                    oSubmenu.itemsData = oItemData.submenuItems;

                                    oSubmenu.beforeShowEvent.subscribe(onMenuBeforeShow, oSubmenu, true);
                                    oSubmenu.mouseOverEvent.subscribe(cancelTimer);
                                    oSubmenu.mouseOutEvent.subscribe(onSubmenuMouseOut, oSubmenu, true);
    
                                    oItemConfig.submenu = oSubmenu;
                                
                                }
    
                                // Add the new YAHOO.widget.MenuItem instance to the Menu
    
                                this.addItem(new YAHOO.widget.MenuItem(oItemData.text, oItemConfig));

                            }

                        }


                        // Render the submenu into its parent MenuItem instance's element

                        this.render(this.parent.element);
                        
                    }
                
                }


                var nTimeoutId;


                /*
                     Use a JSON-formatted data structure to define the data for 
                     the submenus of the root menu
                */

var oMenuData = {
			"communication": [ 
			],

                    "shopping": [

                        { text: "välkkymätön projektori", url: "patentit_suo.html" },
                        { text: "saksalainen", url: "patentit_sak.html" },
                        { text: "japanilainen", url: "patentit_jap.html" }
                                            ],

                    "entertainment": [
                    
                        { text: "perusnäyttelyt", url: "perusnayttelyt.html" ,submenuId: "perus", submenuItems: [
					{ text: "mitä kaikkea puusta", url:"puusta.html" },
					{ text: "malmista metalliksi", url:"malmista.html" },
					{ text: "metallista tuotteiksi", url:"metallista.html" },
					{ text: "viestintä", url:"viestinta.html" },
					{ text: "rakennustekniikka", url:"rakennustekniikka.html" },
					{ text: "kemia", url:"kemia.html" },
					{ text: "hissitekniikka", url:"hissitekniikka.html" },
					{ text: "maanmittaus", url:"maanmittaus.html" },
					{ text: "voimakoneet", url:"voimakoneet.html" },
					{ text: "kirjapainotekniikka", url:"kirjapaino.html" },
					{ text: "sähkötekniikka", url:"sahkotekniikka.html" },
					{ text: "kotitalous", url:"kotitalous.html" },
					{ text: "tietotekniikka", url:"tietotekniikka.html" },
					{ text: "vedensuodatushalli", url:"suodatinhalli.html" }
					] 
			},
                        { text: "erikoisnäyttelyt", url: "erikoisnayttelyt.html",submenuId: "erikois", submenuItems: [
					{ text: "mikättimet", url:"mikattimet.html" },
					{ text: "C.W.Cyldenin kaupunkikartat", url:"kaupunkikartat.html" }
					]}, 

                        { text: "verkkonäyttelyt", url: "verkkonayttelyt.html" ,submenuId: "verkko", submenuItems: [
					{ text: "E.M.C.Tigerstedt", url:"tigerstedt.html" }
					]}, 

                        { text: "tapahtumat", url: "tapahtumat.html" }
                    ],

                    "information": [
                    
                        { text: "esineet", url: "esineet.html",submenuId: "esine", submenuItems: [
					{ text: "lahjoitukset", url:"lahjoitukset.html" },
					]}, 

                        { text: "kirjasto", url: "kirjasto.html" },
                        { text: "kuva-arkisto", url: "kuvaarkisto.html" }                    
                    ],

			  "hipu": [
                    
                        { text: "museon historia", url: "historia.html" },
                        { text: "museon hallinto", url: "hallinto.html" },
                        { text: "helsingin syntysijoilla", url: "syntysijat.html" },
                        { text: "hankkeet", url: "hankkeet.html" },
                        { text: "yhteistyökumppanit", url: "kumppanit.html" }                    
                    ],

			"koulut": [
                    
                        { text: "näyttelyt", url: "kuolunayttelyt.html" },
                        { text: "koululaisopastukset", url: "kouluopastukset.html" },
                        { text: "tehtävämateriaali", url: "koulumateriaali.html",submenuId: "materiaali", submenuItems: [
					{ text: "metallit", url:"metallit.html" },
					{ text: "9 kysymystä", url:"kysymykset.html" },
					{ text: "mitoista kartoiksi", url:"mitoistakartoiksi.html" },
					{ text: "riinan oma", url:"riinan.html" }
					
					]}, 

                        { text: "ohjeita", url: "ohjeita.html" },
                        { text: "innoapaja", url: "innoapaja.html" }                    
                    ],

			"press": [
                    
                       { text: "lehdistötiedotteet", url: "lehdistotiedote.html" },
                        { text: "kuvapankki", url: "kuvapankki.html" }                    
                        
                    ]




                };


                // Initialize the root menu

                var oMenu = new YAHOO.widget.Menu("productsandservices", { position: "static" });





                // Initialize the submenus of the items in the root menu

            //    var oCommunication = new YAHOO.widget.Menu("communication"),
                    oShopping = new YAHOO.widget.Menu("shopping"),
                    oEntertainment = new YAHOO.widget.Menu("entertainment"),
                    oInformation = new YAHOO.widget.Menu("information");
			  oHipu = new YAHOO.widget.Menu("hipu");
			oKoulut = new YAHOO.widget.Menu("hipu");
			oPress = new YAHOO.widget.Menu("hipu");



                /*
                     Add a property ("itemsData") to each submenu that 
                     is reference to the data for its items.
                     This data will be used in the "beforeshow" handler to add
                     the items to each submenu before it is displayed.
                */

             //   oCommunication.itemsData = oMenuData["communication"];
                oShopping.itemsData = oMenuData["shopping"];
                oEntertainment.itemsData = oMenuData["entertainment"];
                oInformation.itemsData = oMenuData["information"];
		    oHipu.itemsData = oMenuData["hipu"];
			oKoulut.itemsData = oMenuData["koulut"];
			oPress.itemsData = oMenuData["press"];



                // Assign event handlers

                // Add a "mouseover" event handler to the root menu

                oMenu.mouseOverEvent.subscribe(cancelTimer);


                // Add a "beforeshow" event handler to each submenu
                
              //  oCommunication.beforeShowEvent.subscribe(onMenuBeforeShow, oCommunication, true);
                oShopping.beforeShowEvent.subscribe(onMenuBeforeShow, oShopping, true);
                oEntertainment.beforeShowEvent.subscribe(onMenuBeforeShow, oEntertainment, true);
                oInformation.beforeShowEvent.subscribe(onMenuBeforeShow, oInformation, true);
		    oHipu.beforeShowEvent.subscribe(onMenuBeforeShow, oHipu, true);
			oKoulut.beforeShowEvent.subscribe(onMenuBeforeShow, oKoulut, true);
			oPress.beforeShowEvent.subscribe(onMenuBeforeShow, oPress, true);



                // Add a "mouseover" event handler to each submenu
                
         //       oCommunication.mouseOverEvent.subscribe(cancelTimer);
                oShopping.mouseOverEvent.subscribe(cancelTimer);
                oEntertainment.mouseOverEvent.subscribe(cancelTimer);
                oInformation.mouseOverEvent.subscribe(cancelTimer);
                oHipu.mouseOverEvent.subscribe(cancelTimer);
			oKoulut.mouseOverEvent.subscribe(cancelTimer);
			oPress.mouseOverEvent.subscribe(cancelTimer);
                

                // Add a "mouseout" event handler to each submenu

           //     oCommunication.mouseOutEvent.subscribe(onSubmenuMouseOut, oCommunication, true);
                oShopping.mouseOutEvent.subscribe(onSubmenuMouseOut, oShopping, true);
                oEntertainment.mouseOutEvent.subscribe(onSubmenuMouseOut, oEntertainment, true);
                oInformation.mouseOutEvent.subscribe(onSubmenuMouseOut, oInformation, true);
                oHipu.mouseOutEvent.subscribe(onSubmenuMouseOut, oHipu, true);
			oKoulut.mouseOutEvent.subscribe(onSubmenuMouseOut, oKoulut, true);
			oPress.mouseOutEvent.subscribe(onSubmenuMouseOut, oPress, true);



                // Add a "click" handler to the document

                YAHOO.util.Event.addListener(document, "click", hideSubmenus);


                // Add the submenus to the items in the root menu 

            //    oMenu.getItem(1).cfg.setProperty("submenu", oCommunication);
            //    oMenu.getItem(2).cfg.setProperty("submenu", oShopping);
             //   oMenu.getItem(3).cfg.setProperty("submenu", oEntertainment);
            //    oMenu.getItem(4).cfg.setProperty("submenu", oInformation);
            //    oMenu.getItem(5).cfg.setProperty("submenu", oHipu);
		//	oMenu.getItem(6).cfg.setProperty("submenu", oKoulut);
		//	oMenu.getItem(7).cfg.setProperty("submenu", oPress);



                // Render the root menu

                oMenu.render();

            }


            // Add a "load" handler for the window

            YAHOO.util.Event.addListener(window, "load", YAHOO.example.onWindowLoad);
