/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * written by Alen Grakalic (http://cssglobe.com)
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 */
 
this.imagePreview = function(){	
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		//var c = (this.t != "") ? this.t + "<br />" : "";
		var c = (this.t != "") ? "<span>" + this.t + "</span>" : "";
		$("#container").append("<p id='preview'>"+ c + "<img src='"+ this.href +"' alt='Image preview' /></p>");
		var preview = $("#preview");
		preview
			.css("top",(document.body.scrollTop + document.documentElement.scrollTop + 50) + "px")
			//.css("right","20px")
			.css("left","300px")
			.fadeIn("fast");						
		// recherche le champ caché suivant le lien courant, qui contient la largeur de l'image
		var largeur = $(this).next(":hidden");
		if (largeur) {
			// fixe la largeur du viewer pour éviter qu'elle ne s'adapte automatiquement à la largeur du libellé
			preview.css("width", largeur.val() + "px")
		} // if
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    })	
	// désactive le click sur le lien (sinon l'image est chargée)
	.click(function(){
		return false;
    });	
};

