// JavaScript Document
jQuery.fn.zoomableImages = function(){
	var o = $(this[0]);

	var magnificationW = 1.5;
	var magnificationH = 1.5;	
	
	o.find('.quadroImagem').each(function(){
		
		var isMOver = false;
		//Initial node that contains all the boxes (divs) with the images
		var img = $(this).find('img')[0];
		//Original image Width
		var imgWOri = img.offsetWidth;
		//Original image Height		
		var imgHOri = img.offsetHeight;
		//New image width for the zoomed images
		var imgW = imgWOri * magnificationW;
		//New image height for the zoomed images		
		var imgH = imgHOri * magnificationH;		

		$(this).prepend('<div style="width:'+ imgWOri +'px;height:'+imgHOri+'px" class="genericZoomableImageBox"><img src="' + img.src + '" class="genericZoomableImage" alt=""/></div>');

		
		
		$(this).find(".genericZoomableImageBox")[0].onmouseover = function(){
			$(this).css("display","inline");
		};
		$(this).find(".genericZoomableImageBox")[0].onmouseout = function(){

			isMOver = false;
			
			$(this).children("img").animate({
				width : imgWOri,
				height : imgHOri
			},'medium');
			$(this).animate({
				width : imgWOri,
				height : imgHOri
			}, 'fast',function(){
				$(this).css("display","none");
			});			
			

		};

		if(typeof(bindDetImageClickEvent) != "undefined" && bindDetImageClickEvent){
			$(this).find(".genericZoomableImageBox")[0].onclick = function(){
				showDetalhesImagem($(this).parent().find('.img > img').attr('idImagem'));
			};
		}


		$(this).click(function(){
			//showDetalhesImagem($(this).find('.img > img').attr('idImagem'));
		});


		img.onmouseover = function(){
			isMOver = true;
			var currentImg = $(this);
			setTimeout(function(){
				if(isMOver){
					
					$(currentImg).parent().parent().parent().find(".genericZoomableImageBox").css("display","inline");
					$(currentImg).parent().parent().parent().find(".genericZoomableImageBox").animate({
						width : imgW,
						height : imgH
					}, 'fast');					
					$(currentImg).parent().parent().parent().find(".genericZoomableImageBox").find("img").css({
						width : imgW,
						height : imgH
					});
				}
	
			},500);
			
		};

		
		img.onmouseout = function(imgW,imgH){
			$(this).parent().parent().parent().find(".genericZoomableImageBox").css("display","none");
			isMOver = false;
		};

	});
};
function zoomImage(imgW,imgH){
}

