//this this will assign the proper profiles to the top level navigation and also set up the mouseover and mouseout's for all of the images.  The if statement around the img.src = img.img[on/off]].src is to make sure it's only doing the replacement when you're hovered over that single images sourounding li.
function enableSectionImageRollovers(id)
{
	var container = document.getElementById(id);
	if (!container)
	{
	    return;
    }
	var lis = container.getElementsByTagName('a');
	for(x=0; x< lis.length; x++)
	{
		var li=lis[x];

		li.onmouseover=function() 
		{
			var imgs = this.getElementsByTagName('img');
			for(i=0; i < imgs.length; i++)
			{
				var img=imgs[i];
		
				img.src=img.src.replace("_off","_on");
				
			}
		}

		li.onmouseout=function() 
		{
			var imgs = this.getElementsByTagName('img');
			for(i=0; i < imgs.length; i++)
			{
				var img=imgs[i];
					img.src = img.src.replace("_on","_off");

			}
		}

	}

}


document.getElementsByTagAndClassName=function(tagName, className, parentElement)
{
	var items = new Array();
	var elems = (document.getElementById(parentElement) || document.body).getElementsByTagName(tagName);
	for(var i = 0; i < elems.length; i++)
	{
		var elem = elems[i];
		var classNames = elem.className.split(" ");
		for (var j = 0; j < classNames.length; j++)
		{
			if(classNames[j] == className)
			{
				items.push(elem);
			}
		}
	}
	return items;
};





function bindBehaviors()
{
  // quit if this function has already been called
  if (arguments.callee.done) return;

  // flag this function so we don't do the same thing twice
  arguments.callee.done = true;

//  setInterval("console.log(document.readyState)",500);


  enableSectionImageRollovers('HeaderLinkButtons');
  enableSectionImageRollovers('SidebarLinkButtons');
}


if (window.addEventListener)
{
  window.addEventListener('load', bindBehaviors, false);

}
else if (window.attachEvent)
{
  window.attachEvent('onload',bindBehaviors);

}
