function array_contains(needle, haystack) {
  var i = haystack.length;
  while (i--) {
    if (haystack[i] === needle) {
      return true;
    }
  }
  return false; 
} // end function array_contains


function rotate(id, zone) {
  // menu image rotation script 
  // James Barros 2010-04-28
  
  // requires that images are named id_on.png and id_off.png 
  // zone is for if you wish to keep an image on despite it not being moused over.
  // to turn everything (except zone) off, call with a blank id. 
  // eg: if its also what identifies what part of the website you're on. 
  
  // we can't trust mouseout to catch, so on mouseover, reset everything. 
  // don't judge me, I've not done this type of thing in a long time ;-p 

  
  // turn off every other image. 
  for (x in images) { 
    if (images[x] == id || images[x] == zone) {
      document.getElementById(images[x]).src = "nav_images/"+images[x]+"_on.png";
    } else { 
      document.getElementById(images[x]).src = "nav_images/"+images[x]+"_off.png";
    } // end if this is our id
  } // end for images
  
  // hide the projects layer, if appropriate. 
  /* 
  if(!array_contains(id, projects) && !array_contains(display_zone, project_zones)) {
    document.getElementById("projectslayer").style.display = "none"; 
  } else {
    document.getElementById("projectslayer").style.display = "block"; 
  } // end if display projects layer.             
  */ 
  if(!array_contains(id, projects)) {
    document.getElementById("projectslayer").style.display = "none"; 
  } else {
    document.getElementById("projectslayer").style.display = "block"; 
  } // end if display projects layer.        
  
  
} // end rotate function

function preload() {
   // preload images. 
   // only preload the on images. the off images are loaded by default on page load. 
   
  if (document.images)
  {
    preload_image_object = new Image();
    
    for(x in images) 
      preload_image_object.src = "nav_images/"+images[x]+"_on.png";
  } // end for images
  
} // end preload function. 

function hide_projects() {
   if (!array_contains(display_zone, project_zones)) {
     document.getElementById("projectslayer").style.display = "none";       
   }
} // end hide projects.


function removeFocusOnAllLinks(){
  for(var i=0 ; i < document.links.length ; i++) 
    document.links[i].onfocus=blurLink; 
}

function blurLink() {
  if (this.blur) this.blur(); 
}



// run the preload function after the rest of the page has completed running, 
window.onload = "preload";removeFocusOnAllLinks; 



