//images script for menu
var loaded = 1;
var currentDown = null;

//preload the onmouseover images for quick response
if (document.images)
{
  var the_images = new Array(
	  'images/home-over.gif',
	  'images/aboutus-over.gif',
	  'images/employers-over.gif',
	  'images/candidates-over.gif',
	  'images/opportunities-over.gif',
	  'images/testimonials-over.gif',
	  'images/contactus-over.gif'
	  );
  preloadImages(the_images);
}

 function preloadImages(the_images_array)
 {
   if (document.preloadArray==null) {
 	document.preloadArray = new Array();
   }
 
   var i = document.preloadArray.length;
 
   for(var loop = 0; loop < the_images_array.length; loop++)
   {
       document.preloadArray[i] = new Image;
       document.preloadArray[i++].src = the_images_array[loop];
   }
 }

function imageOver (el)
{
  if (loaded)
  {
    if (!currentDown || el.name != currentDown.name)
    {
      var str_switch = "over";
      chr = el.src.lastIndexOf("-") + 1;
      period = el.src.lastIndexOf("."); 
      el.src = "" + el.src.substring(0, chr) + str_switch + el.src.substring(period, el.src.length);
      return true;
    }

  }
}

function imageOn (el)
{
  if (loaded)
  {
    if (!currentDown || el.name != currentDown.name)
    {
      var str_switch = "on";
      chr = el.src.lastIndexOf("-") + 1;
      period = el.src.lastIndexOf("."); 
      el.src = "" + el.src.substring(0, chr) + str_switch + el.src.substring(period, el.src.length);
      return true;
    }

  }
}

function imageOff (el, override)
{
  if (loaded)
  {
    if (!currentDown || override || el.name != currentDown.name)
    {
      var str_switch = "off";
      chr = el.src.lastIndexOf("-") + 1;
      period = el.src.lastIndexOf(".");

      el.src = "" + el.src.substring(0, chr) + str_switch + el.src.substring(period, el.src.length);
      return true;
    }
  }
}