var tabsPanel = null;


Ext.onReady(function(){

   tabsPanel = new Ext.TabPanel({
        renderTo: 'tabsDiv',
        id: 'tabsPanel',
        activeTab: 0,
        width:800,
        height:900,
        plain:true,
        defaults:{autoScroll: true},
        items:[{
                title: 'Home',
                iconCls: 'tabs',
                autoLoad: {url: "home.html"}
            },{
                title: 'About',
                iconCls: 'tabs',
                autoLoad: {url: 'about_us_loader.html'}
            },{
                title: 'Contact',
                iconCls: 'tabs',
                autoLoad: {url: 'contact_us_loader.html'}
            },{
                title: 'Sample Code',
                iconCls: 'tabs',
                autoLoad: {url: 'sample_code_loader.html'}
            },{
                title: 'NHIbernate Sample Code',
                iconCls: 'tabs',
                autoLoad: {url: 'NSeminar_NHibernate_unit_tests_loader.html'}
            }
        ]
    });

    tabsPanel.doLayout();
    tabsPanel.activate(getActivePanel());

});


/* called to set an active panel */
function switchToTab(activeTab){
   tabsPanel.setActiveTab(activeTab);
}

/* returns a panel to set based on URL */
function getActivePanel() {

   var url = document.URL;
   var returnPanel = 0;
   if (
   (url.indexOf("about_us",0)) > -1
   ) {
      returnPanel = 1;
   }

   if (
   (url.indexOf("contact_us",0)) > -1
   ) {
      returnPanel = 2;
   }

   if (
   (url.indexOf("sample_code",0)) > -1
   ) {
      returnPanel = 3;
   }

   if (
   (url.indexOf("NSeminar_NHibernate_unit_tests",0)) > -1
   ) {
      returnPanel = 4;
   }

   return returnPanel;

}

