
/* "Highlight" a category by changing the image displayed (or
/  un-highlight it). Takes the category identifier and "on" to
/  highlight or "off" to switch back to normal.*/
function swapCatImage(cat, on_off) {

	if (on_off == "on") {
		eval("window.document." + cat + "_image").src = ("/images/" + cat + "_on.gif");
	}
	else if (on_off == "on_other") {
		eval("window.document." + cat + "_image").src = ("/images/category/" + cat + "_on.gif");
	}
	else if (on_off == "off") {
		eval("window.document." + cat + "_image").src = ("/images/" + cat + "_off.gif");
	}
	else if (on_off == "off_other") {
		eval("window.document." + cat + "_image").src = ("/images/category/" + cat + "_off.gif");
	}
}


function findimg() {

	var imgs,i;

	// loop through all images of the document
	imgs=document.getElementsByTagName('img');

	for(i=0;i<imgs.length;i++) {

		// test if the class 'roll' exists
		if(/roll/.test(imgs[i].className)) {

			// add the function roll to the image 
			// onmouseover and onmouseout and send
			// the image itself as an object
			imgs[i].onmouseover=function(){roll(this);};
			imgs[i].onmouseout=function(){roll(this);};
		}
	}
}


function roll(o) {

	var src,ftype,newsrc;

	// get the src of the image, and find out the file extension
	src = o.src;
	ftype = src.substring(src.lastIndexOf('.'), src.length);
	
	// check if the src already has an _on and delete it, if that is the case 
	if(/_on/.test(src)) {
		//alert('if');
		newsrc = src.replace('_on','');
	}else{
		//alert('else');
		// else, add the _on to the src 
		newsrc = src.replace(ftype, '_on'+ftype);	
	}
	//alert(newsrc);
	o.src=newsrc;
}

window.onload=function(){
	findimg();
}
