/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){
    Ext.QuickTips.init();

    // Menus can be prebuilt and passed by reference
    var menu = new Ext.menu.Menu({
        id: 'mainMenu',
        items: [
				{
					text: 'Company Introduction',
					group: 'theme',
					href:"../en/about/himaxdisplay.asp",
					hrefTarget:"_self"
				}, {
					text: 'Company Milestone',
					group: 'theme',
					href:"../en/about/milestone.asp",
					hrefTarget:"_self"
				}, {
					text: 'Core Technologies',
					group: 'theme',
					href:"../en/about/core.asp",
					hrefTarget:"_self"
				}
        ]
    });

    var menu2 = new Ext.menu.Menu({
        id: 'mainMenu2',
        items: [
				{
					text: 'ISO 9001 Certification',
					href:"../en/quality/iso.asp",
					hrefTarget:"_self"
				}, {
					text: 'ISO 14001 Certicifation',
					href:"../en/quality/iso14001.asp",
					hrefTarget:"_self"
				}, {
					text: 'Quality System Flow',
					href:"../en/quality/quality.asp",
					hrefTarget:"_self"
				}, {
					text: 'Reliability Assurance',
					href:"../en/quality/reliability.asp",
					hrefTarget:"_self"
				}, {
					text: 'Green Product Specification',
					href:"../en/quality/Green_product.asp",
					hrefTarget:"_self"
				}, {
					text: 'Environmental Strategy',
					href:"../en/quality/Environmental.asp",
					hrefTarget:"_self"
				}
        ]
    });

    var menu3 = new Ext.menu.Menu({
        id: 'mainMenu3',
        items: [
				{
					text: 'Press Release',
					href:"../en/news/news.asp?typeId=S0004",
					hrefTarget:"_self"
				}, {
					text: 'News Clipping',
					href:"../en/news/news.asp?typeId=S0005",
					hrefTarget:"_self"
				}, {
					text: 'Events',
					href:"../en/news/news.asp?typeId=S0006",
					hrefTarget:"_self"
				}
        ]
    });

    var menu5 = new Ext.menu.Menu({
        id: 'mainMenu5',
        items: [
				{
					text: 'Sales/Technical Support',
					href:"../en/customerservice/technical.asp",
					hrefTarget:"_self"
				},{
					text: 'Map',
					href:"../en/customerservice/contactus.asp",
					hrefTarget:"_self"
				}
        ]
    });

    var tb = new Ext.Toolbar(
		{id: 'mainMenuBar',
		 width:'90%'
		}
	);
    tb.render('toolbar');


    tb.add({
            text:'About Us',
            iconCls: 'bmenu',  // <-- icon
            menu: menu  // assign menu by instance
        });
	tb.addSpacer();
	tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'Quality Policy',
            iconCls: 'bmenu',  // <-- icon
            menu: menu2  // assign menu by instance
        });
	tb.addSpacer();
	/*tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'News',
            iconCls: 'bmenu',  // <-- icon
            menu: menu3  // assign menu by instance
        });*/
	tb.addSpacer();
	tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'Products',
            iconCls: 'bmenu',
			enableToggle: true,
			toggleHandler: onProductToggle
        });
	tb.addSpacer();
	tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'Contact Us',
            iconCls: 'bmenu',  // <-- icon
            menu: menu5  // assign menu by instance
        });
	tb.addSpacer();
	/*tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'Investor Relations',
            iconCls: 'bmenu',
			enableToggle: true,
			toggleHandler: onInvestorToggle
        });*/
	tb.addSpacer();
	tb.addSeparator();
	tb.addSpacer();
    tb.add({
            text:'Employment',
            iconCls: 'bmenu',
			enableToggle: true,
			toggleHandler: onEmploymentToggle
        });	
    
    // Menus have a rich api for
    // adding and removing elements dynamically
    //var item = menu.add({
        //text: 'Dynamically added Item'
    //});
    // items support full Observable API
    //item.on('click', onItemClick);



    // functions to display feedback

    function onInvestorToggle(){
		window.location.href="http://www.himax.com.tw/en/investor/ir-compintro.asp";
    }

    function onEmploymentToggle(){
		window.location.href="http://www.himax.com.tw/ch/employment/search.asp";
    }

    function onProductToggle(){
		window.location.href="../en/product/info.asp";
    }
});