jQuery.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages(
	"images/fr/menu/1-ok.png",
	"images/fr/menu/2-ok.png",
	"images/fr/menu/3-ok.png",
	"images/fr/menu/4-ok.png",
	"images/fr/menu/5-ok.png",
	"images/fr/menu/6-ok.png",
	"images/fr/interface/valider-ok.png",
	"images/interface/fond-item-ok.png",
	"images/interface/fond-item-ok.png",
	"images/interface/fond-menu-cat-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"
	}
	var nb_items_menu = 7;
	var nb_items_menu2 = 10;
	
	$("#tree >li[class^='tree-cat']").mouseover(function () {
		$(this).children('span').css('background-color', '#0196C8');
		$(this).css('background-image', '../images/interface/derouler-ok.png');
		$(this).children('span').css('color', 'white');
	});
	
	$("#tree >li[class^='tree-cat']").mouseout(function () {
		$(this).children('span').css('background-color', '');
		$(this).children('span').css('background-image', 'images/interface/derouler.png');
		$(this).children('span').css('color', '');
	});
	
	$("#sample-menu-5 >li[id^='roll'] >a").mouseover(function () {
        imgsrc = $(this).children("img").attr(attribut);
        pos = ((imgsrc.indexOf('.'))-1);
        position = imgsrc.charAt(pos);
        prec = position-1;
        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);
        pos = ((imgsrc.indexOf('.'))-4);
        position = imgsrc.charAt(pos);
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/-ok.png/, ".png");
            $(this).children("img").attr(attribut, imgsrcON);
            $("img[id^='chmenu"+position+"']").attr(attribut, 'images/fr/menu/'+position+'a.png');
        }
	});
	
	$("#anim-flash >ul >li[id^='menu'] >a").mouseover(function () {
        imgsrc = $(this).children("img").attr(attribut);
        pos = ((imgsrc.indexOf('.'))-1);
        position = imgsrc.charAt(pos);
        prec = position-1;
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/.png/, "-ok.png");
            $(this).children("img").attr(attribut, imgsrcON);
        }
	});
	
	$("#anim-flash >ul >li[id^='menu'] >a").mouseout(function () {
        imgsrc = $(this).children("img").attr(attribut);
        pos = ((imgsrc.indexOf('.'))-4);
        position = imgsrc.charAt(pos);
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/-ok.png/, ".png");
            $(this).children("img").attr(attribut, imgsrcON);
        }
	});
	
	// images de fond menu de gauche
	/*
	$("ul.treeview li ul li").mouseover(function () {
        imgsrc = $(this).attr('style');
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/.png/, "-ok.png");
            $(this).attr('style', imgsrcON);
        }
	});
	
	$("ul.treeview li ul li").mouseout(function () {
        imgsrc = $(this).attr('style');
        matches = imgsrc.match(/.png/);
        if (matches) {
            imgsrcON = imgsrc.replace(/-ok.png/, ".png");
            $(this).attr('style', 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);
        }
	});
	
	
});


