var localhost = 'www.powrsurg.com';
function installTabByName(e) {
   e = e || fixEvent(window.event);
   var target = getTarget(e);
   if (!target) return;
   var title;
   var path;

   switch(target.id){
      case 'mpi':
         title = 'MPI Quick Reference';
         path = 'work/sidebar.html';
         break;
      default:
         break;
   }
   if (title) {
      e.preventDefault();
      installTab(title, path);
   }
}
function addTab(sbTitle,sbLoc){
   // hack: bc 2002-01-04 work around http://bugzilla.mozilla.org/show_bug.cgi?id=99808
   window.onerror = function()	{
      alert('An error has occured during the sidebar installation. Please make sure your sidebar panel is open and then retry.');
   };
   if ((typeof(window.sidebar) == 'object') && (typeof(window.sidebar.addPanel) == 'function'))
      window.sidebar.addPanel (sbTitle,sbLoc,'');
   else{
      var rv = window.confirm ('This page uses features supported by Netscape Gecko-based browsers such as Mozilla Firefox. \r' + 'Would you like to upgrade now?');
      if (rv)
         document.location.href = 'http://www.mozilla.org/products/firefox/';
   }
}

/*****************************************
/* wrapper to allow simple passage of URL
*****************************************/
function installTab(title,whichSidebar) {
   var url=whichSidebar;
   if (url.indexOf('http') != 0){
      url='http://'+localhost + '/' +url;
   }
   return addTab(title,url);
}

function sidebarInit() {
   if (!document.getElementById) return;
   var sidebarWork = document.getElementById('moz_sidebars');
	if (!sidebarWork) return;
   var sidebars = sidebarWork.getElementsByTagName('a');
   var i, sidebar;
	for (i = 0; sidebar = sidebars[i]; i++) {
		addEvent(sidebar, 'click', installTabByName);
	}
}

addEvent(window, 'load', sidebarInit);
