/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



Ext.onReady(function(){
    Ext.QuickTips.init();

    // Menus can be prebuilt and passed by reference
    var menu = new Ext.menu.Menu({
        id: 'mainMenu',
        items: [{text: 'Bathroom + Kitchen Today',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=bathroom";}}},
            {text: 'Concrete Technology Today',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=concrete";}}},
            {text: 'Security Solutions Today',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=firesecurity";}}},
            {text: 'Landscape Today',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=landscape";}}},
            {text: 'Lighting Today',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=lighting";}}},
            {text: 'SEA Building',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=seab";}}},
            {text: 'SEA Construction',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=seac";}}}
                            
        ]
    });
    var aboutMenu = new Ext.menu.Menu({
        id: 'aboutMenu',
        items: [{text: 'About Us',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=static&page=aboutus";}}},
            {text: 'Contact Us',iconCls: 'bulleticon',listeners:{click:function(){loadContactusForm()}}}
                            
        ]
    });

    var subscribeMenu = new Ext.menu.Menu({
        id: 'subscribeMenu',
        items: [{text: 'Free Digital Format',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="ControllerServlet?action=memberscheckuser";}}},
            {text: 'Print Format',iconCls: 'bulleticon',listeners:{click:function(){window.location.href="files/subscription_form.pdf";}}}
                            
        ]
    });

    var tb = new Ext.Toolbar();
    tb.render('toolbar');
                
    tb.add({
        text:'Home',
        iconCls: 'homeicon',
        listeners:{click:function(){window.location.href="ControllerServlet?action=index";}}
    });
    tb.addSeparator();
    tb.add({
        text:'Our Publications',
        iconCls: 'pubsicon',  // <-- icon
        menu: menu  // assign menu by instance
    });
    tb.addSeparator();
    tb.add({
        text:'Download PDFs',
        iconCls: 'pubsicon',  // <-- icon
        listeners:{click:function(){window.location.href="ControllerServlet?action=gallery";}}
    });
    tb.addSeparator();
    tb.add({
        text:'Subscribe',
        iconCls: 'subscribeicon',
        menu:subscribeMenu
    });
    tb.addSeparator();
    var supplierLabel = new Ext.menu.TextItem({
        text:'Supplier Search&nbsp;',
        iconCls: 'suppliericon'
    });
    var supplierField = new Ext.form.TextField({
        name:'supplierTF',
        width:80,
        inputType :'text',
        emptyText :'Keywords',
        enableKeyEvents :true,
        listeners:{
            keyup:function(k,e){
                if(e.getKey() == e.ENTER){
                  window.location.href="ControllerServlet?action=supplierssearchpost&country=0&company=&description="+supplierField.getValue();
                }
            }           
        }
    });
    tb.add(supplierLabel);
    tb.addField(supplierField);
    tb.addSeparator();
    /*  tb.add({
                    text:'Supplier Search',
                    iconCls: 'suppliericon',
                    listeners:{click:function(){window.location.href="ControllerServlet?action=suppliers";}}
                });
                tb.addSeparator();/**/
    tb.add({
        text:'More...',
        iconCls: 'moreicon',  // <-- icon
        menu: aboutMenu  // assign menu by instance
    });
                
});
