//rollovers
function findimg(){
	var ia,imgs;
	// loop through all images of the document
	imgs=document.getElementsByTagName('img');
	for(ia=0;ia<imgs.length;ia++){
		// test if the class 'roll' exists
		if(/roll/.test(imgs[ia].className)){
			// add the function roll to the image onmouseover and onmouseout and send
			// the image itself as an object
			preloader(imgs[ia]);
			imgs[ia].onmouseover=function(){roll(this);};
			imgs[ia].onmouseout=function(){roll(this);};
		}
	}
}
function roll(o){
	// get the src of the image, and find out the file extension
	var src = o.src;
	var ftype = src.substring(src.lastIndexOf('.'), src.length);
	// check if the src already has an _over and delete it, if that is the case
	if(/_over/.test(src)){
		var newsrc = src.replace('_over','');
	}else{
		// else, add the _over to the src
		var newsrc = src.replace(ftype, '_over'+ftype);
	}
	o.src=newsrc;
}
function preloader(k){
	var imgsrc = k.src;
	var imgName = imgsrc.substring(0, imgsrc.lastIndexOf('.'));
	var imgType = imgsrc.substring(imgsrc.lastIndexOf('.'), imgsrc.length);
	imageObj = new Image();
	imageObj.src=imgName+'_over'+imgType;
} 
$(document).ready(function(){
	findimg();
});

