/*--------------------------------------------------------------------------
 *  YOJA-WEB.COM : module zoom
 *  Copyright (c) Jamal Chaqouri, Yohann Fontaine, of yoja team (http://www.yoja-web.com)
 *  module zomm is a yoja-web.com work.
 *  For details, see the yoja web site: http://www.yoja-web.com
 *--------------------------------------------------------------------------*/

YOJA.module.zoom = {
	
	init : function(){
		  $j("img.product_thumbnail_medium, .product_thumbnail_medium img").each(function(i, val){
		   		var image = $j(this);
				var url = image.attr("src");
				if(url){
					var urlLarge = url.replace("/medium/","/large/");
					var zoom = "zoom"+i;
					$j("body").append("<div id=\""+zoom+"\" class=\"imgZoom\"><img/></div>");	
		
					   image.mousemove(
							  function (e) {	
									$j("#"+zoom).css({top:e.pageY+8, left:e.pageX+8});
								}
						);
		
					   image.hover(
							   function(){
									var divZoom = $j("#"+zoom);
									$j("img", divZoom).attr("src",urlLarge);
									divZoom.show();   
							   },
							   function(){
									$j("#"+zoom).hide();
							   }
						  );
				}
			});//fin each img
		}
}

/*******************************************************************************
 * Charger dynamiquement les dépendances puis exécution du module
 ******************************************************************************/

YUI(
		{
			loadOptional :(typeof jQuery == 'undefined'),
			modules : {
				jquery : {
					name :"jquery",
					type :"js",
					fullpath :"http://yoja-web.com/javascript/build/plugins/jquery/jquery.js"
				},
				yoja : {
					name :"yoja",
					type :"js",
					fullpath :"http://yoja-web.com/javascript/build/plugins/yoja/yoja.core.js",
					optional :[ "jquery" ]
				},				
				zoomCSS : {
					name :"zoomCSS",
					type :"css",
					fullpath :"http://yoja-web.com/javascript/assets/modules/zoom/v4.0/zoom.css"
				}
			}
		}).use('yoja', 'zoomCSS', function(Y) {
			window.setTimeout(YOJA.module.zoom.init,10000);
});


