/*
     Initialize and render the MenuBar when its elements are ready 
     to be scripted.
*/
YAHOO.util.Event.onContentReady("topMenu", function () {

    /*
         Instantiate a MenuBar:  The first argument passed to the 
         constructor is the id of the element in the page 
         representing the MenuBar; the second is an object literal 
         of configuration properties.
    */
    var oMenuBar = new YAHOO.widget.MenuBar("topMenu", { 
                                                autosubmenudisplay: true, 
                                                hidedelay: 750, 
                                                lazyload: true });

    /*
         Define an array of object literals, each containing 
         the data necessary to create a submenu.
    */

    var aSubmenuData = [

        {
            id: "VISA", 
            itemdata: [
                { text: "ビザ申請の流れ", url: "http://japan.attictours.ph/visaprocess.html" },
                { text: "ビザの種類", url: "http://japan.attictours.ph/typesofvisa.html" },
                { text: "申請に必要となる書類", url: "visachecker_j.html" },
                { text: "料金と宅配サービス", url: "http://japan.attictours.ph/feesandcourier.html" }
            ]    
        },
        {
            id: "SERVICE",
            itemdata: [
 
				{ text: "日本訪問エアチケットパック", url: "promo.html#ATTIC" },
				{ text: "フィリピンナショナルバンク", url: "promo.html#PNB" },
				{ text: "国際電話カード", url: "promo.html#ACP" },
				{ text: "ＴＦＣｋｏ", url: "promo.html#TFCKO" }
            ]
        },
        {
            id: "TV",
            itemdata: [
                { text: "ＡＢＳ－ＣＢＮ", url: "tfcko.html" },
                { text: "ＧＭＡ－７＆Ｌｉｆｅ", url: "accesstv.html" }
            ]
        },
        {
            id: "ABOUTUS",
            itemdata: [
                { text: "所在地", url: "http://japan.attictours.ph/locationmap.html" },
                { text: "会社概要", url: "http://japan.attictours.ph/aboutthecompany.html" }
            ]
        },
        {
            id: "LANGUAGE",
            itemdata: [
                { text: "Japanese", url: "http://japan.attictours.ph/index.html" },
                { text: "English", url: "http://www.attictours.ph/index.html" }
            ]
        }

    ];

    /*
         Subscribe to the "beforerender" event, adding a submenu 
         to each of the items in the MenuBar instance.
    */
    oMenuBar.subscribe("beforeRender", function () {
        if (this.getRoot() == this) {
            this.getItem(1).cfg.setProperty("submenu", aSubmenuData[0]);
            this.getItem(3).cfg.setProperty("submenu", aSubmenuData[1]);
            this.getItem(4).cfg.setProperty("submenu", aSubmenuData[2]);
            this.getItem(5).cfg.setProperty("submenu", aSubmenuData[3]);
            this.getItem(6).cfg.setProperty("submenu", aSubmenuData[4]);
        }
    });
    /*
         Call the "render" method with no arguments since the 
         markup for this MenuBar instance is already exists in 
         the page.
    */
    oMenuBar.render();         
});
