I am very new to JQuery (beginning of this week actually!

) and have been struggling with an image rollover function I came across in a Google Search:
$(function() {
$(".hover").hover(function () {
var filePath = $(this).attr("src");
var dotPos = filePath.lastIndexOf(".") ;
var extension = filePath.substr(dotPos,filePath.length);
var newPath = filePath.replace(extension,"_on"+extension);
$(this).attr("src",newPath);
},function () {
$(this).stop(true,false);
$(this).attr("src", $(this).attr("src").split("_on.").join("."));
});
});
The code works fine for swapping/replacing the image and I understand some of it, however each page of my site will have an "on state" for the image to show people they are on that particular page. This is where the code falls down, as if the image already has the extension of "_on" it still tries to swap the image and adds another "_on" extension to it.
Can anyone help, I've tried adding in an if statement to say if image is "_on" don't swap but am really struggling to get a solution.
