/*glabal Ext, AUTH, PAGE, TPAGE */

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

    var tb = new Ext.Toolbar();
    tb.render('main-menu');

    tb.add({text:'Home',   iconCls: (PAGE == 'index') ? 'icoMnuSel' : '', handler: function(){ location.href = 'index.php';} });
    tb.addSeparator();
    tb.add({text:'About Us', iconCls: (PAGE == 'about') ? 'icoMnuSel' : '',  handler: function(){ location.href = 'about.php';} });
    tb.addSeparator();

    var mnuSiteServices = new Ext.menu.Menu({ items: [
        {text: 'Drilling Services',  iconCls: (PAGE == 'drilling') ? 'icoMnuSel' : '', handler: function(){ location.href='drilling.php';}},
        {text: 'Landfill Site Testing', iconCls: (PAGE == 'landfill-site-testing') ? 'icoMnuSel' : '', handler: function(){ location.href='landfill-site-testing.php';}},
        {text: 'Coring Services',iconCls: (PAGE == 'concrete-coring') ? 'icoMnuSel' : '', handler: function(){ location.href='concrete-coring.php';}},
        {text: 'Concrete Sampling',iconCls: (PAGE == 'concrete-sampling') ? 'icoMnuSel' : '', handler: function(){ location.href='concrete-sampling.php';}},
        {text: 'Plate Bearing Test',iconCls: (PAGE == 'plate-bearing-test') ? 'icoMnuSel' : '', handler: function(){ location.href='plate-bearing-test.php';}},
        {text: 'California Bearing Ratio',iconCls: (PAGE == 'california-bearing-ratio') ? 'icoMnuSel' : '', handler: function(){ location.href='california-bearing-ratio.php';}},
        {text: 'Sample Collection',iconCls: (PAGE == 'sample-collection') ? 'icoMnuSel' : '',  handler: function(){ location.href='sample-collection.php';}}
    ]});
    tb.add({text:'Site Services', iconCls: (TPAGE == 'site-services') ? 'icoMnuSel' : '', menu: mnuSiteServices });
    tb.addSeparator();

    var mnuFacilities = new Ext.menu.Menu({ items: [
        {text: 'Labs', iconCls: (PAGE == 'facilities') ? 'icoMnuSel' : '', handler: function(){ location.href='facilities.php';}},
        {text: 'Rock Testing', iconCls: (PAGE == 'rock-testing') ? 'icoMnuSel' : '', handler: function(){ location.href='rock-testing.php';}},
        {text: 'Soil Testing', iconCls: (PAGE == 'soil-testing') ? 'icoMnuSel' : '', handler: function(){ location.href='soil-testing.php';}},
        {text: 'Large Scale Shear Box', iconCls: (PAGE == 'large-scale-shear-box') ? 'icoMnuSel' : '', handler: function(){ location.href='large-scale-shear-box.php';}},
        {text: 'Contamination Testing', iconCls: (PAGE == 'contamination-testing') ? 'icoMnuSel' : '', handler: function(){ location.href='contamination-testing.php';}},
        {text: 'Aggregate Testing', iconCls: (PAGE == 'aggregate-testing') ? 'icoMnuSel' : '', handler: function(){ location.href='aggregate-testing.php';}}
    ]});
    tb.add({text:'Facilities', iconCls: (TPAGE == 'facilities') ? 'icoMnuSel' : '',menu: mnuFacilities });
    tb.addSeparator();

    tb.add({text:'Rates',  iconCls: (PAGE == 'rates') ? 'icoMnuSel' : '', handler: function(){ location.href = 'rates.php';} });
    tb.addSeparator();
    //tb.add({text:'Standards',  iconCls: (PAGE == 'standards') ? 'icoMnuSel' : '', handler: function(){ location.href = 'standards.php';} });
   // tb.addSeparator();
    tb.add({text:'Contact',  iconCls: (PAGE == 'contact') ? 'icoMnuSel' : '', handler: function(){ location.href = 'contact.php';} });
    tb.addSeparator();
    tb.add({text:'Sample Collection',  iconCls: (PAGE == 'sample-collection') ? 'icoMnuSel' : '' ,handler: function(){ location.href = 'sample-collection.php';} });
    tb.addSeparator();
   // tb.add({text:'Sign Up',  iconCls: (PAGE == 'sign-up') ? 'icoMnuSel' : '' ,handler: function(){ location.href = 'sign-up.php';} });
    //tb.addSeparator();
    if(AUTH){
        tb.add({text:'Client Web',   iconCls: (PAGE == 'account') ? 'icoMnuSel' : '', handler: function(){ location.href = 'account.php';} });
    }else{
        tb.add({text:'Client Login',   iconCls: (PAGE == 'login') ? 'icoMnuSel' : '', handler: function(){ location.href = 'login.php';} });    
    }
    tb.addSeparator();
    tb.add({text:'Site Map',   iconCls: (PAGE == 'sitemap') ? 'icoMnuSel' : '', handler: function(){ location.href = 'sitemap.php';} });

    if(AUTH == 1){
        tb.addSeparator();
        tb.add({text:'Logout',   
            handler: function(){
                        Ext.Msg.show({
                            title:'Logout',
                            msg: 'Are you sure you want to logout',
                            buttons: Ext.Msg.YESNO,
                            fn: function(btn){
                                if(btn == 'yes'){
                                    location.href = 'logout.php';
                                }
                            },
                            animEl: 'elId',
                            icon: Ext.MessageBox.QUESTION
                        });

                    } 
        });
    }

});