﻿$(function(){
        var imagesBig=new Object();
        var imagesSmall=new Object();
		var vigPosX=new Object();
		var vigPosY=new Object();
        $(".lienVignette img").each(function(n) {
                var s;
                s=this.src.substr(0,this.src.length-4)+"-big."+this.src.substr(this.src.length-3);
                imagesSmall[this.id]=new Image;
                imagesSmall[this.id].src=this.src;
                imagesBig[this.id]=new Image;
                imagesBig[this.id].src=s;
				vigPosX[this.id]=parseInt($(this).css("left"),10);
				vigPosY[this.id]=parseInt($(this).css("top"),10);
        });
        
        $(".lienVignette img").bind("mouseenter",function(){
				var deltaWidth=imagesBig[this.id].width-imagesSmall[this.id].width;
				var deltaHeight=imagesBig[this.id].height-imagesSmall[this.id].height;
				this.src=imagesBig[this.id].src;
				this.width=imagesSmall[this.id].width;
				$(this).animate({ 
					left: vigPosX[this.id]-(deltaWidth/2),
					top: vigPosY[this.id]-(deltaHeight/2),
					width: imagesBig[this.id].width
				}, 300);
				//$("#texteInfo").html(getMessageFor($(this).attr("id")));
	}).bind("mouseleave",function(){
				var deltaWidth=imagesBig[this.id].width-imagesSmall[this.id].width;
				var deltaHeight=imagesBig[this.id].height-imagesSmall[this.id].height;
				$(this).animate({ 
					left: vigPosX[this.id],
					top: vigPosY[this.id],
					width: imagesSmall[this.id].width
				}, 300,"linear",function(){this.src=imagesSmall[this.id].src;}
				);
				//$("#texteInfo").html("");
	});
});
/* AJOUTER AUX FAVORIS */
/* les variables urlAddress et pageName doivent être définies dans la page d'où est appelé ce script */
function ajouterFavoris() {
    var urlAddress=window.location.href;
    var pageName=document.title;
	    if (document.all) {
	        window.external.AddFavorite(urlAddress,pageName);
	    } else if (window.sidebar) {
	        window.sidebar.addPanel(pageName, urlAddress, "");
	    } else {
	        alert("Désolé! Votre navigateur ne supporte pas cette fonction.");
	    }
}

// POUR FONCTION Rechercher  ON PRE-CHARGE LES IMAGES /
function precache() {
if (document.images) {
	imagesOff=new Object();
	imagesOver=new Object();
	imagesOff["btCherche"]=new Image;
	imagesOff["btCherche"].src="squelettes/images/rechercher/boutonGo_1.png";
	imagesOver["btCherche"]=new Image;
	imagesOver["btCherche"].src="squelettes/images/rechercher/boutonGo_2.png";
   }
 }
 /* ON APPELLE LA FONCTION POUR PRECHARGER LES IMAGES */
	precache();
 /*Swap des images*/
	function setImage(imgName,type) {
		if (document.images) {
			if (type=="over") {
				document.images[imgName].src=imagesOver[imgName].src;
				return true;
			} else if (type=="off") {
				document.images[imgName].src=imagesOff[imgName].src;
				return true;
			} else if (type=="on") {
				document.images[imgName].src=imagesOn[imgName].src;
				return true;
			}
		}
		return false;
	}

/* FONCTION QUI LANCE LA RECHERCHER QUAND ON CLIQUE SUR LA PETITE LOUPE */
function chercher() {
	document.searchForm.submit();
}

