// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function highlighttab(id)  {
  var item = $('menu_' + id);
  item.src = 'images/' + id + 'buttonselected.gif';
}

function unhighlighttab(id)  {
  if(id != page_name)  {
    var item = $('menu_' + id);
    item.src = 'images/' + id + 'button.gif';
  }
}

function preloadImages() {
  var d=document;
  if(d.images){
    if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments;
    for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){
      d.MM_p[j]=new Image;
      d.MM_p[j++].src='/images/'+a[i];
    }
  }
}

startList = function() {
  if (document.all&&document.getElementById) {
    document.getElementById('menu').style.top = '44px';
    navRoot = document.getElementById("nav");
    preloadImages('homebutton.gif', 'homebuttonselected.gif', 'about_usbutton.gif', 'about_usbuttonselected.gif', 'productsbutton.gif', 'productsbuttonselected.gif', 'contact_usbutton.gif', 'contact_usbuttonselected.gif');
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
        node.onmouseover=function() {
          this.className+=" over";
        }
        node.onmouseout=function() {
          this.className=this.className.replace(" over", "");
        }
      }
    }
  }
}
window.onload=startList;
