// proto block
//------------

// global vars
//------------
var normBgColor;
var overBgColor = "#CCCCCC";
var mdivs = new Array;
var myMenuswitch = new Object;

var Menuswitch = Class.create();

Menuswitch.prototype = {
	initialize: function() {
	  if (!document.getElementsByClassName){ return; }
	  mdivs = mdivs.concat(document.getElementsByClassName('m1p'));
	  mdivs = mdivs.concat(document.getElementsByClassName('m1a'));
	  mdivs = mdivs.concat(document.getElementsByClassName('m2p'));
	  mdivs = mdivs.concat(document.getElementsByClassName('m2a'));
	  for (var i=0; i<mdivs.length; i++){
	    var mdiv = mdivs[i];
	    //Event.observe(mdiv, 'mouseover', myMenuswitch.over.bindAsEventListener(this), false);
	    mdiv.onmouseover = function () {myMenuswitch.over(this); return false;}
	    mdiv.onmouseout = function () {myMenuswitch.out(this); return false;}	    	    
	    mdiv.onclick = function () {myMenuswitch.clicked(this); return false;}
	  }
  },
  clicked: function(objdiv){
    if(objdiv.firstChild.href) {window.location.href = objdiv.firstChild;}
  },
  over: function(objdiv){
    normBgColor = $(objdiv).getStyle('backgroundColor');
    $(objdiv).setStyle({backgroundColor: ''+overBgColor+''});
  },
  out: function(objdiv){
    $(objdiv).setStyle({backgroundColor: ''+normBgColor+''});
  }
}

// proto init
//-----------
function initMenuswitch() { myMenuswitch = new Menuswitch(); }
//Event.observe(window, 'load', initMenuswitch, false);

function exitMenuswitch() { Event.unloadCache(); }
Event.observe(window, 'unload', exitMenuswitch, false);

// proto end

addEvent(window, 'DOMContentLoaded', initMenuswitch);
