Event.observe(window,'load', function() {
  var a = document.getElementsByTagName("a");
  path_array = window.location.pathname.split('/');
  for(var i=0; i<a.length; i++) {
    link_array = a[i].pathname.split('/');
    if(path_array.length == 3 && path_array[2].length > 0) {
      if(link_array[2] == path_array[2]) {
        Element.addClassName(a[i],'current');        
      }
    } else if(link_array.length == 2 && link_array[1] == path_array[1]) {
      Element.addClassName(a[i],'current');
    }
  }
});

function isIE() {
  if(navigator.userAgent.match(/MSIE \d\.\d+/))
    return true;
  return false;
}

document.observe("dom:loaded", function() {
  tables = $$('#map ul.tables li.selected');
  tables.each(function(table) {
    
    Event.observe(table, "mouseover", function() {
      table.down('.information').addClassName("visible");      
      if(isIE()){
        $$('#map ul.tables li').each(function(t) {
          if(t != table) { Element.hide(t); }
        });
      }
    });
    Event.observe(table, "mouseout", function() {
      table.down('.information').removeClassName("visible");
      if(isIE()){
        $$('#map ul.tables li').each(function(t) {
          Element.show(t);
        });
      }
    });
  })
});

document.observe("dom:loaded", function() {
  $$('div.sponsors ul').each(Element.hide);
  
  var randomOrder = new Element('ul');
  randomOrder.setAttribute('class','sponsors');
  
  sponsors = $$('div.sponsors ul li').sort(function() {return 0.5 - Math.random()});
  sponsors.each(function(s) {
      randomOrder.insert(s);
  });
  $$('div.sponsors').each(function(e) {
      e.insert(randomOrder);
  });
});
