
            // "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": [ 
                    
                        { text: "liput ja aukioloajat", url: "liputjaaukiolo.html" },
                        { text: "sijainti ja yhteydet", url: "sijaintijayhteydet.html", submenuId: "sijainti", submenuItems: [

                                { text: "Kuninkaankartanonsaari", url:"kuninkaankartano.html" },
                                
                            ]

				},
                        { text: "henkilökunta", url: "henkilokunta.html" }
                        
                        
                        
                    
                    ],

                    "shopping": [
			 { text: "museokauppa", url: "museokauppa.html" },
                        { text: "ohjelmapalvelut", url: "ohjelmapalvelut.html" },
			
                        { text: "kokouspalvelut", url: "kokouspalvelut.html",submenuId: "kokous", submenuItems: [
 						{ text: "auditorio", url:"auditorio.html" },
						{ text: "ryhmätyötila", url:"ryhmatyotila.html" }						           
                      ]
			},		
                        
                     ],   

                    "entertainment": [
                    
                        { text: "perusnäyttelyt", url: "perusnayttelyt.html" ,submenuId: "perus", submenuItems: [

					{ text: "kemiaa koko elämä", url:"http://www.tekniikanmuseo.fi/kemiaa/index.php" },					
					
					{ text: "malmista metalliksi", url:"malmista.html" },
					{ text: "metallista tuotteiksi", url:"metallista.html" },
					{ text: "mitä kaikkea puusta", url:"puusta.html" },
					{ text: "viestintä", url:"viestinta.html" },
					
					{ text: "hissitekniikka", url:"hissitekniikka.html" },
					{ text: "maanmittaus", url:"maanmittaus.html" },
					{ text: "voimakoneet", url:"voimakoneet.html" },
					
					
					
					{ text: "vedensuodatushalli", url:"suodatinhalli.html" }
					] 
			},
                        { text: "erikoisnäyttelyt", url: "erikoisnayttelyt.html",submenuId: "erikois", submenuItems: [
					
					{ text: "Säteilyn lumo", url:"sateilynlumo.html" },
					{ text: "Vodaa Stadiin", url:"vodaastadiin.html" },
					
					
					]}, 

                        { text: "verkkonäyttelyt", url: "verkkonayttelyt.html" ,submenuId: "verkko", submenuItems: [
					{ text: "E.M.C.Tigerstedt", url:"tigerstedt/etusivu.html" }
					]}, 

                        { text: "tapahtumat", url: "tapahtumat.html" }
                    ],

                    "information": [
                    
                        { text: "esineet", url: "esineet.html" },
                        { text: "kirjasto", url: "kirjasto.html" },
                        { text: "kuva-arkisto", url: "kuvaarkisto.html"}, 
			{ text: "tietopalvelu", url: "tietopalvelu.html" }, 
		        { text: "lahjoitukset", url: "lahjoitukset.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: "julkaisut", url: "julkaisut.html" },  
                        { text: "yhteistyökumppanit", url: "kumppanit.html" }                    
                    ],
	"koulut": [
			{ text: "ajankohtaista", url: "ajankohtaistakouluille.html" },
			{ text: "vierailuohjeet", url: "ohjeita.html" },

			{ text: "palvelut alakouluille", url: "alakoulupalvelut.html",submenuId: "alakoulupalvelut", submenuItems: [
					
						{ text: "opastukset", url:"kouluopastukset_alakoulu.html" },
						{ text: "tehtävämateriaalit", url:"koulumateriaali_alakoulu.html" },
						{ text: "oppimispolut", url:"innoapajatoiminta_alakoulu.html" },
					]}, 

			{ text: "palvelut yläkouluille", url: "ylakoulupalvelut.html", submenuId: "ylakoulupalvelut", submenuItems: [
						
						{ text: "opastukset", url:"kouluopastukset_ylakoulu.html" },
						{ text: "tehtävämateriaalit", url:"koulumateriaali_ylakoulu.html" },
						{ text: "oppimispolut", url:"innoapajatoiminta_ylakoulu.html" },
						
						]},
                                     				
									
                        
			
                       
		],
			"press": [
                    
                       { text: "lehdistötiedotteet", url: "lehdistotiedote.html", submenuId: "tiedote", submenuItems: [
					{ text: "ESKOn päivät", url:"tiedote22.html" },
					{ text: "Säteilyn lumo", url:"tiedote21.html" },
					{ text: "Vodaa Stadiin", url:"tiedote20.html" },
					
					
										
					
					]},
                        { text: "kuvat", 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);