var mmA;
var mmI = new Array();
function activateMenus(){
	if ( document.getElementById("sub_menu") ){
		var LI = document.getElementById("sub_menu").getElementsByTagName("li");
		for (var i = 0; i < LI.length; i ++){
			LI[i].onmouseover = function(){ this.className += " doHover"; }
			LI[i].onmouseout  = function(){ this.className = ''; }
		}
	}
	if ( document.getElementById("main_menu") ){
		mmA = document.getElementById("main_menu").getElementsByTagName("a");
		for (var i = 0; i < mmA.length; i ++){
			// Preload the image
			mmI[i] = new Image();
			mmI[i].src = mmA[i].firstChild.src.split('_on.gif').join('_off.gif');
			// Do the mouseover
			mmA[i].onmouseover = function(){
				for (var j = 0; j < mmA.length; j ++){
					if ( mmA[j] != this ){
						mmA[j].firstChild.src = mmA[j].firstChild.src.split('_on.gif').join('_off.gif');
					}
				}
			}
			// Do the mouseout
			mmA[i].onmouseout = function(){
				for (var j = 0; j < mmA.length; j ++){
					if ( mmA[j] != this ){
						mmA[j].firstChild.src = mmA[j].firstChild.src.split('_off.gif').join('_on.gif');
					}
				}
			}
		}
	}
}

function initRollovers(){
  if ( document.images ){
    var preLoad = new Array();
    var tempSrc;
    for (var i = 0; i < document.images.length; i ++ ){

      // Only add rollover to images with the classname 'rollover'
      if ( document.images[i].className == 'rollover' ){
        var src = document.images[i].getAttribute('src'); // get the src
        var ext = src.substring( src.lastIndexOf('.'), src.length ); // get the file extension
        var hsrc = src.replace( ext, '_over' + ext ); // store the rollover src
        document.images[i].setAttribute('hsrc', hsrc); // set the new src attribute
        document.images[i].style.cursor = 'hand'; // Hand cursor where supported

        // Preload the image
        preLoad[i] = new Image();
        preLoad[i].src = hsrc;

        // Add the rollover functions
        document.images[i].onmouseover = function(){
          tempSrc = this.getAttribute('src');
          this.setAttribute('src', this.getAttribute('hsrc'));
        }
        document.images[i].onmouseout = function(){
          if (!tempSrc) tempSrc = this.getAttribute('src').replace('_r'+ftype, ftype);
          this.setAttribute('src', tempSrc);
        }
      }
    }
  }
	// Do rollover on go image
	if ( document.getElementById('go_button') ){
		var gb = document.getElementById('go_button');
		var gbi = new Image();
		gbi.src = gb.src.split('.gif').join('_over.gif');
		gb.onmouseover = function(){ this.src = this.src.split('.gif').join('_over.gif'); }
		gb.onmouseout  = function(){ this.src = this.src.split('_over.gif').join('.gif'); }
	}
}


window.onload = function(){
	activateMenus();
	initRollovers();
}

