jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages(
	"images/menu/1-ok.png",
	"images/menu/2-ok.png",
	"images/menu/3-ok.png",
	"images/menu/4-ok.png",
	"images/menu/5-ok.png",
	"images/menu/6-ok.png",
	"images/menu/7-ok.png",
	"images/menu/8-ok.png",
	"images/interface/valider-ok.png"
);

$(document).ready(function(){
	
	if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
		attribut = "style"
	}
	else {
		attribut = "src"
	}
	
	$("#sample-menu-5 >li[id^='roll'] >a").mouseover(function () {
        imgsrc = $(this).children("img").attr(attribut);
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/.png/, "-ok.png");
            $(this).children("img").attr(attribut, imgsrcON);
        }
	});
	
	$("#sample-menu-5 >li[id^='roll'] >a").mouseout(function () {
        imgsrc = $(this).children("img").attr(attribut);
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/-ok.png/, ".png");
            $(this).children("img").attr(attribut, imgsrcON);
        }
	});
	
	// bouton valider formulaire de contact
	$("div >input[id^='valider']").mouseover(function () {
        imgsrc = $(this).attr('src');
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/.png/, "-ok.png");
            $(this).attr('src', imgsrcON);
        }
	});
	
	$("div >input[id^='valider']").mouseout(function () {
        imgsrc = $(this).attr('src');
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/-ok.png/, ".png");
            $(this).attr('src', imgsrcON);
        }
	});
	
	
});

