/**
 * zoom fiche produit Conforama.
 */


var monZoom={
	thumbToBigImg: new Array(),
	nbGros: 5,//nombre de fois que le visuel peut être grossis
	ratio: 100,//ratio d'agrandissement
	ratioScroll:"",
	ratioDeplace: 25,
	_SetStatus:function(){
		if($("#zoomImg").height()>600){
			
		}
	},
	
	_Init:function(element, hrefInitImage){
		$("#layerPopin").load($(element).attr("href"), function(){
			masqueShow();
			initPopin();//dans scripts/popin.js
			showPopin();//dans scripts/popin.js
			$("#contentPopinZoom .closePopin").click(function(){
				$("#contentPopinZoom").remove();
				return(false);
			});//fermeture du zoom
			
			monZoom._InternalInit(hrefInitImage);
			monZoom.ratioScroll=($("#zoomScrollBarre").height()-$("#zoomScrollBarre span").height())/5;
			$("#menuTumbs a").click(function(){
				$("#menuTumbs a").removeClass("thumbon");
				$("#menuTumbs a").removeClass("thumboff");
				$("#menuTumbs a").addClass("thumboff");
				$(this).attr("class", "thumbon");

				try{
					filename = $(this).children("img").attr("src");
					if(filename.indexOf("http://") == 0){
						filename = filename.substring(filename.indexOf("/",7));
						urlBigImage = monZoom.thumbToBigImg[filename];
					}else{
						urlBigImage = monZoom.thumbToBigImg[filename];
					}
				}catch(e){
					urlBigImage = '';
				}
				$("#zoomImg").attr("src", urlBigImage );
				
				$("#zoomImg").css({height: "600px", width: "800px", marginLeft: "0px", marginTop: "0px"});
				$("#zoomScrollBarre span").css({top: ($("#zoomScrollBarre").height()-$("#zoomScrollBarre span").height())+"px"})
				return(false);
			});
			
			
			$("#zoomPlus").click(function(){
				if($("#zoomImg").height()>599 && $("#zoomImg").height()<1099){
					$("#zoomImg").css({height: ($("#zoomImg").height()+monZoom.ratio)+"px", width: ($("#zoomImg").width()+monZoom.ratio)+"px"});
					$("#zoomImg").css({marginTop: -1*(parseInt($("#zoomImg").css("width"))-800)/2+"px", marginLeft: -1*(parseInt($("#zoomImg").css("height"))-600)/2+"px"});
					
					$("#zoomScrollBarre span").css({top: (parseInt($("#zoomScrollBarre span").css("top"))-monZoom.ratioScroll)+"px"});
				}
				return(false);
			});
			
			$("#zoomMoins").click(function(){
				if($("#zoomImg").height()>600){
					$("#zoomImg").css({height: ($("#zoomImg").height()-monZoom.ratio)+"px", width: ($("#zoomImg").width()-monZoom.ratio)+"px"});
					
					$("#zoomImg").css({marginTop: -1*(parseInt($("#zoomImg").css("width"))-800)/2+"px", marginLeft: -1*(parseInt($("#zoomImg").css("height"))-600)/2+"px"});
					
					$("#zoomScrollBarre span").css({top: (parseInt($("#zoomScrollBarre span").css("top"))+monZoom.ratioScroll)+"px"});
					
				}
				return(false);
			});
			
			$("#zoomToBottom").click(function(){
				if(($("#zoomZone").height() + (parseInt($("#zoomImg").css("marginTop"))*-1)) < $("#zoomImg").height()){
					$("#zoomImg").css({marginTop: (parseInt($("#zoomImg").css("marginTop"))-monZoom.ratioDeplace)+"px"});
				}
				return(false);
			});
			
			$("#zoomToTop").click(function(){
				if(parseInt($("#zoomImg").css("marginTop"))<0){
					$("#zoomImg").css({marginTop: (parseInt($("#zoomImg").css("marginTop"))+monZoom.ratioDeplace)+"px"});
				}
				return(false);
			});
			
			$("#zoomToRight").click(function(){
				if(($("#zoomZone").width() + (parseInt($("#zoomImg").css("marginLeft"))*-1)) < $("#zoomImg").width()){
					$("#zoomImg").css({marginLeft: (parseInt($("#zoomImg").css("marginLeft"))-monZoom.ratioDeplace)+"px"});
				}
				return(false);
			});
			
			$("#zoomToLeft").click(function(){
				if(parseInt($("#zoomImg").css("marginLeft"))<0){
					$("#zoomImg").css({marginLeft: (parseInt($("#zoomImg").css("marginLeft"))+monZoom.ratioDeplace)+"px"});
				}
				return(false);
			});
			
		});//on chargent le zoom
		
		
		
		
		
		
	},//initialisation de l'objet zoom.
	_InternalInit: function(urlImage){
		try{
			if(monZoom.thumbToBigImg.length == 0 && InitThumbToBigImgArray){
				InitThumbToBigImgArray();
			}
			try{
				if(monZoom.thumbToBigImg.length == 0 && InitThumbToBigImgArray2){
					InitThumbToBigImgArray2();
				}
			}catch(e){}
			urlBigImage = monZoom.thumbToBigImg[urlImage];
			if(!urlBigImage){
				filename=urlImage.substring(urlImage.lastIndexOf("/"));
				filename=filename.substring(filename.indexOf("_"));
				filename=filename.substring(filename.lastIndexOf("."));
				for(var thn in monZoom.thumbToBigImg){
					if(thn.indexOf(filename)!=-1){
						urlBigImage = monZoom.thumbToBigImg[thn];
					}
				}
			}
		}catch(e){
			urlBigImage = '';
		}	
		if(urlBigImage != '')
			$("#zoomImg").attr("src", urlBigImage);
		$("#zoomImg").css({height: "600px", width: "800px", marginLeft: "0px", marginTop: "0px"});
		$("#menuTumbs img[@src="+ urlImage +"]").parent().attr("class", "thumbon");
		
		$("#zoomScrollBarre span").css({top: ($("#zoomScrollBarre").height()-$("#zoomScrollBarre span").height())+"px"})

	}
	
	
}//objet zoom initialisé depuis slideShow.js





