$(document).ready(function(){
	//Rollover animations
	 //Preload any hover images
	$('img.wh-roll').each(function(){
		this.ExtraImage= new Image();
		this.ExtraImage.src = addSuffix(this.src,'_on');
	 });
	 //Create roll over images on any image with wh-roll as its class
	 $('img.wh-roll').hover(
	 function(){
		 //Over function
		 this.src = addSuffix(this.src,'_on');
	 },
	 function(){
		 //Out function
		 this.src = remSuffix(this.src,'_on');
	 }); 

	function remSuffix(a,b){
		//removes suffix b from filename a without removing the file extension
		var lastdot = a.lastIndexOf(b + '.');
		if (lastdot==-1){
			return a;
		} else {
			 var ext = a.slice(lastdot+b.length,a.length);
			 return a.slice(0,lastdot) + ext;
		}
	}
	function addSuffix(a,b){
		//adds suffix b to filename a without removing the file extension
		var lastdot = a.lastIndexOf(".");
		if (lastdot==-1){
			return a;
		} else {
			var ext = a.slice(lastdot,a.length);
			return a.slice(0,lastdot) + b + ext;
		}
	}			
})
