var current_mid = 0;
var massoc = { "m1" : "menu_home",
               "m2" : "menu_howitworks",
               "m3" : "menu_features",               
               "m4" : "menu_freetrial",
               "m5" : "menu_buynow",
               "m6" : "menu_signin" };
var mcache = { };

function setMID(mid)
{
   current_mid = mid;
}

function menuOver(e)
{
   var source;
   
   try 
   {
      if(window.event) e = window.event;
      if(!e) return;
      (typeof(e.srcElement) != 'undefined') ? source = e.srcElement : source = e.target;
   } 
   catch(err) { return; }
   
   if(source.id != current_mid)
      source.src = "http://www.addonlivesupport.com/images/livesupport/menu/selected/" + massoc[source.id] + ".jpg";
}

function menuOut(e)
{
   var source;
   
   try 
   {
      if(window.event) e = window.event;
      if(!e) return;
      (typeof(e.srcElement) != 'undefined') ? source = e.srcElement : source = e.target;
   } 
   catch(err) { return; }
   
   if(source.id != current_mid)
      source.src = "http://www.addonlivesupport.com/images/livesupport/menu/unselected/" + massoc[source.id] + ".jpg";
}

function menuInit(mid)
{
   var doce;
   
   setMID(mid);
   
   /* Set Current Location */
   try {
      document.getElementById(mid).src = "http://www.addonlivesupport.com/images/livesupport/menu/selected/" + massoc[mid] + ".jpg";
   } catch(err) { }
   
   /* Create Unload Event */
   window.onunload = function() { cleanUp(); }
   
   /* Set Event Listeners */
   for(prop in massoc)
   {      
      document.getElementById(prop).onmouseover = menuOver;
      document.getElementById(prop).onmouseout = menuOut;
   }
   
   /* Cache Images */
   for(prop in massoc)
   {
      if(prop != mid)
      {
         mcache[prop] = new Image();
         mcache[prop].src = "http://www.addonlivesupport.com/images/livesupport/menu/selected/" + massoc[prop] + ".jpg";
      }
   }
}

function cleanUp()
{
   try {
      document.getElementById(current_mid).src = "http://www.addonlivesupport.com/images/livesupport/menu/unselected/" + massoc[current_mid] + ".jpg";
   } catch(err) { }
}
