Ext.onReady(function(){
  Ext.BLANK_IMAGE_URL = 'ext-2.2/resources/images/default/s.gif';
  buildMenu();
});

function buildMenu(){
  var tb = new Ext.Toolbar();
  tb.render('toolbar');
  tb.add(
  {
    text:'Bands',
    menu: {
      items:[
        {
          text: '5th Grade',
          menu: {items: [
            {
              text: 'Handbook',
			  link: 'files/elem handbook.doc',
			  handler: openLink  
            },
            {
              text: 'Standards & Benchmarks',
			  link: 'files/Benchmark Objectives elem.doc',
			  handler: openLink 
            }
          ]}
        },
        {
          text: '6th Grade',
          menu: {items: [
            {
              text: 'Handbook',
			  link: 'files/elem handbook.doc',
			  handler: openLink  
            },
            {
              text: 'Standards & Benchmarks',
			  link: 'files/Benchmark Objectives elem.doc',
			  handler: openLink 
            }
          ]}
        },
        {
          text: 'Junior High',
          menu: {items: [
            {
              text: 'Handbook',
			  link: 'files/jh handbook.doc',
			  handler: openLink  
            },
            {
              text: 'Standards & Benchmarks',
			  link: 'files/Benchmark Objectives jh.doc',
			  handler: openLink 
            }
          ]}
        },
        {
          text: 'High School',
          menu: {items: [
            {
              text: 'Handbook',
			  link: 'files/handbook.doc',
			  handler: openLink  
            },
            {
              text: 'Standards & Benchmarks',
			  link: 'files/Benchmark Objectives hs.doc',
			  handler: openLink 
            }
          ]}
        }
      ]
    }
  },
  {
    text: 'Schedule',
    link: 'schedule.htm',
    handler: openInPage    
  },
  {
    text: 'Band News',
    link: 'news.htm',
    handler: openInPage 
  },
  {
    text: 'Band Alumni',
    link: 'alumni.htm',
    handler: openInPage 
  },
  {
    text: 'Pictures',
    menu: {items:[
	  {
	    text: 'Adventureland 2005',
	    link: 'adventureland2005.htm',
	    handler: openInPage
	  },
	  {
	    text: 'Kansas City 2007 -- Coming Soon',
	    link: 'kansasCity2007.htm',
	    handler: openInPage
	  }
	]}
  },
  {
    text: 'Instruments For Sale',
    link: 'instruments.htm',
    handler: openInPage 
  },
  {
    text: 'Links',
	menu: {items:[
	  {
	    text: 'Online Metronome',
	    link: 'http://www.metronomeonline.com',
	    handler: openLink
	  },
	  {
	    text: 'Scales -- Coming Soon',
	    link: '',
	    handler: openLink
	  },
	  {
	    text: 'Rays Midbell',
	    link: 'http://www.midbellmusic.com/',
	    handler: openLink
	  }
	]}
  },
  {
    text: 'Contact',
    link: 'contact.htm',
    handler: openInPage 
  }
  );
  
  function openLink(btn){
    document.location = btn.link;
  }
  
  openInPage({link: 'news.htm'});
}

function openInPage(btn){
  clientSideInclude('body', btn.link);
}
  

function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  }
}
