 // JavaScript Document

function initRollovers() {
   var all_links;
   var link;
   var idx;

   if (!document.getElementsByTagName) {
      return;   
   }
   
   all_links = document.getElementsByTagName("a");
   
   for (idx = 0; idx < all_links.length; idx++) {
      link = all_links[idx];
	  
	  if (link.className && (' ' + link.className + ' ').indexOf(' rollover ') != -1) {
	     if (link.childNodes && link.childNodes.length == 1 && link.childNodes[0].nodeName.toLowerCase() == 'img') {
	        link.onmouseover = mouseover;
			link.onmouseout = mouseout;
			link.onfocus = mouseover;
			link.onblur = mouseout;
		 }
	  }
   }
}

function findTarget(e) {
   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);
   var img_tag;
   
   if (!target) return;
   
   img_tag = target.childNodes[0];
   
   if (img_tag.src.indexOf("_f2.") < 0) img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, "_f2$1"); 
}

function mouseout(e) {
   var target = findTarget(e);
   var img_tag;
   
   if (!target) return;
   
   img_tag = target.childNodes[0];
   img_tag.src = img_tag.src.replace(/_f2(\.[^.]+)$/, "$1");   
}

function confirmDelete(message, action_url) {
	var usr_choice;
	
	usr_choice = confirm(message + "\nDo you wish to continue?");

	if (usr_choice) {
		window.location = action_url;
	}
}


window.onload = initRollovers;

