var imgs = new Array();
function imgObj(arr, url) {
	var o = new Image();
	o.src = url;
	arr.push(o);
}

function addEvent(obj, evType, fn, useCapture){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		//alert("Handler could not be attached");
	}
}
function setupRollovers() {
	var el;
  if (!document.getElementsByTagName) 
    return; 
  var all_links = document.getElementById('categories-content').getElementsByTagName('a'); 
  for (var i = 0; i < all_links.length; i++) {
    var link = all_links[i]; 
    if (link.className && 
        (' ' + link.className + ' ').indexOf(' category-top ') != -1) 
    { 
		if (link.childNodes) {
			el = link.childNodes[0];
			while (el.nodeName.toLowerCase() != "img") {
			el = el.nextSibling;
			}
			if (el.className == "rol") {
				imgObj(imgs, el.src.replace(/(\.[^.]+)$/, '_rol$1'));
				link.onmouseover = mouseover; 
				link.onmouseout = mouseout; 
			}
		} 
    } 
  } 
} 
function findTarget(e) 
{ 
  /* Begin the DOM events part, which you */ 
  /* can ignore for now if it's confusing */ 
  var target; 
  if (window.event && window.event.srcElement) 
    target = window.event.srcElement; 
  else if (e && e.target) 
    target = e.target; 
  if (!target) 
    return null; 
  while (target != document.body && 
      target.nodeName.toLowerCase() != 'a') 
    target = target.parentNode;
    if (target.nodeName.toLowerCase() != 'a') 
    return null; 
  return target; 
} 
function mouseover(e) {
  var target = findTarget(e); 
  if (!target) return; 
  // the only child node of the a-tag in target will be an img-tag 
  var img_tag = target.childNodes[0];
  while (img_tag.nodeName.toLowerCase() != "img") {
  	img_tag = img_tag.nextSibling;
  }
  // Take the "src", which names an image called "something.ext", 
  // Make it point to "something_rol.ext" 
  // This is done with a regular expression 
  img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_rol$1'); 
} 
function mouseout(e) { 
  var target = findTarget(e); 
  if (!target) return; 
  // the only child node of the a-tag in target will be an img-tag 
  var img_tag = target.childNodes[0];
  while (img_tag.nodeName.toLowerCase() != "img") {
  	img_tag = img_tag.nextSibling;
  }
  // Take the "src", which names an image as "something_rol.ext", 
  // Make it point to "something.ext" 
  // This is done with a regular expression 
  img_tag.src = img_tag.src.replace(/_rol(\.[^.]+)$/, '$1'); 
} 
// When the page loads, set up the rollovers 
addEvent(window, 'load', setupRollovers);