var initialized = false;
var isNav = false, isIE = false;
var activeMenu = 0;
var basepath = "../";

function tbPreloadImages(basepath)
{
   // Main-Menu buttons
   mbtn1_on    = new Image(85,22);   mbtn1_on.src     = basepath + "global_graphics/mbutton1_on.gif";
   mbtn1_off   = new Image(85,22);   mbtn1_off.src    = basepath + "global_graphics/mbutton1_off.gif";
   mbtn2_on    = new Image(85,22);   mbtn2_on.src     = basepath + "global_graphics/mbutton2_on.gif";
   mbtn2_off   = new Image(85,22);   mbtn2_off.src    = basepath + "global_graphics/mbutton2_off.gif";
   mbtn3_on    = new Image(85,22);   mbtn3_on.src     = basepath + "global_graphics/mbutton3_on.gif";
   mbtn3_off   = new Image(85,22);   mbtn3_off.src    = basepath + "global_graphics/mbutton3_off.gif";

   synapse_on = new Image( 9,32);   synapse_on.src    = basepath + "global_graphics/synapse.gif";
   synapse_off = new Image( 9,32);   synapse_off.src  = basepath + "global_graphics/medge_u.gif";

   subbtn_on   = new Image(27,20);   subbtn_on.src    = basepath + "global_graphics/lbarm_highlighted.gif";
   subbtn_off  = new Image(27,20);   subbtn_off.src   = basepath + "global_graphics/lbarm_unselected.gif";
}


function tbInitialize(start)
{
   if (navigator.appName.indexOf("Microsoft") != -1) {
      isIE = true;
	} else {
      if (parseInt(navigator.appVersion) >= 5) {
			isIE = true;
		} else {
			isNav = true;
		}
	}

   if (!start)
	  tbPreloadImages("");
   else
      tbPreloadImages(basepath);
   initialized = true;
}


function tbSwitchOn( imageName, source )
{
   if ( document.images ) {
      if(isIE) {
         document[imageName].src = eval( source );
      } else {
         // document.layers[0].document.images[imageName].src = eval( source );
         document.images[imageName].src = eval( source );
      }
   }
}


function tbSwitchOff( imageName, source )
{
   if ( document.images ) {
      if(isIE) {
         document[imageName].src = eval( source );
      } else {
         // document.layers[0].document.images[imageName].src = eval( source );
         document.images[imageName].src = eval( source );
      }
   }
}


function tbMouseOvr( imageName ) {
   tbSwitchOn( imageName, imageName + "_on.src" );
}


function tbMouseOut( imageName ) {
   tbSwitchOff( imageName, imageName + "_off.src" );
}


function tbMouseOvrMenu( menu )
{
   if ( menu == activeMenu ) {
      return;
   }

   switch( menu )
   {
      case 1:
      {
         tbSwitchOn( "mbtn1", "mbtn1_on.src" );
         tbSwitchOn( "synapse1", "synapse_on.src" );
         break;
      }
      case 2:
      {
         tbSwitchOn( "mbtn2", "mbtn2_on.src" );
         tbSwitchOn( "synapse2", "synapse_on.src" );
         break;
      }
      case 3:
      {
         tbSwitchOn( "mbtn3", "mbtn3_on.src" );
         tbSwitchOn( "synapse3", "synapse_on.src" );
         break;
      }
      default:
      { }
   }
}


function tbMouseOutMenu( menu )
{
   if ( menu == activeMenu ) {
      return;
   }

   switch( menu )
   {
      case 1:
      {
         tbSwitchOn( "mbtn1", "mbtn1_off.src" );
         tbSwitchOn( "synapse1", "synapse_off.src" );
         break;
      }
      case 2:
      {
         tbSwitchOn( "mbtn2", "mbtn2_off.src" );
         tbSwitchOn( "synapse2", "synapse_off.src" );
         break;
      }
      case 3:
      {
         tbSwitchOn( "mbtn3", "mbtn3_off.src" );
         tbSwitchOn( "synapse3", "synapse_off.src" );
         break;
      }
      default:
      { }
   }
}


function tbWriteToDoc( text ) {
   if( !initialized ) {
      tbInitialize();
   }

   if ( isIE ) {
      document.write( text );
   } else {
      // document.layers[0].document.write( text );
      document.write( text );
   }
}


function subBeginTab()
{
   tbWriteToDoc( '<tr><td>' );
   tbWriteToDoc( '<img src="' + basepath + 'global_graphics/lbarm_tab_o.gif" width="46" height="16"><img src="' + basepath + 'global_graphics/sub_tab_o.gif" width="100" height="16">' );
   tbWriteToDoc( '</td></tr>' );
}

function subEndTab()
{
   tbWriteToDoc( '<tr><td><img src="' + basepath + 'global_graphics/lbarm_tab_u.gif" width="46" height="18"><img src="' + basepath + 'global_graphics/sub_tab_u.gif" width="100" height="18"></td></tr>' );
   tbWriteToDoc( '<tr><td><img src="' + basepath + 'global_graphics/lbar_alt.gif" width="46" height="20"></td></tr>' );
   tbWriteToDoc( '<tr><td><img src="' + basepath + 'global_graphics/lbar_unten.gif" width="46" height="18"></td></tr>' );
}

function open_win( myDoc ) {
   window.open( myDoc, "viewWin", "resizable=no, width=640, height=540, menubar=no, location=no, toolbar=no, status=no, scrollbars=yes" );
}

function open_sub( myDoc, name ) {
   if( !name ) {
      name = "viewSub";
   }
   window.open( myDoc, name, "resizable=no, width=640, height=540, menubar=no, location=no, toolbar=no, status=no, scrollbars=no" );
}

function open_newwin( myDoc ) {
   window.open( myDoc, "viewNew", "resizable=yes, menubar=yes, location=yes, toolbar=yes, status=yes, scrollbars=yes" );
}
