Event.observe(window,"load",init);
function init(){
	if (navigator.appName == "Microsoft Internet Explorer"){
		if ($("modeles")) {
			$("modeles").style.width="10";
			$("modeles").style.width=$("blck").offsetWidth - 50;
		}
	}
	
	Event.observe($("cnt"),"mouseover",hiddenSmenu);
	
	Event.observe(window,"dblclick",hiddenSmenu);
	$$(".model").each(function(elt){
		Event.observe(elt,"mouseover",function(e){
			$("cntetiquette").update(elt.alt)
			$("etiquette").style.left=(Event.pointerX(e) + 15) + "px";
			$("etiquette").style.top=(Event.pointerY(e) + 5) + "px";
			$("etiquette").show();
		})
		Event.observe(elt,"mousemove",function(e){
			$("etiquette").style.left=(Event.pointerX(e) + 15) + "px";
			$("etiquette").style.top=(Event.pointerY(e) + 5) + "px";
			$("etiquette").show();
		})
		Event.observe(elt,"mouseout",function(e){
			$("etiquette").hide();
		})
	})
	
	var menu=$$(".menu")
	menu.each(function(elt){
		Event.observe(elt,"mouseover",function(e){
			hiddenSmenu()
			var idsm="s" + Event.findElement(e,"td").id
			var elt=Event.findElement(e,"td")
			tp=elt.offsetTop;
			tw=elt.offsetLeft;
			$(idsm).style.top="179px";
			$(idsm).style.left=(tw +28) + "px";
			$(idsm).style.width=elt.offsetWidth + "px";
			$(idsm).style.display="block";
		})
	})
	
	Event.observe($("cnt"),"mouseover",function(e){
		hiddenSmenu();
	});
	
	$$(".miniimg").each(function(elt){
		Event.observe(elt,"click",zoomph)
	})
	
	
	
}

function hiddenSmenu(){
	for(i=1;i<10;i++){
		if($("smenu" + i)){
			$("smenu" + i).style.display="none";
		}
	}
}

var scrol=0;
function droite()
{
	if (scrol<$("modeles").scrollWidth-$("modeles").offsetWidth){
		scrol=scrol+300;
	dr();
	}
}

function dr(){
	var timer1;
	$("modeles").scrollLeft=$("modeles").scrollLeft+10;
	
	//alert($("modeles").scrollLeft + "--" + scrol);
	
	if ($("modeles").scrollLeft<scrol){
		timer1 = setTimeout("dr()",1);
	}
	else
	{
		$("modeles").scrollLeft=scrol
		clearTimeout(timer1);
	}
}

function gauche()
{
	if (scrol > 0) {
		scrol = scrol - 300;
		ga();
	}
}

function ga(){
	var timer1;
	$("modeles").scrollLeft=$("modeles").scrollLeft-10;
	
	
	if ($("modeles").scrollLeft>scrol){
		timer1 = setTimeout("ga()",1);
	}
	else
	{
		$("modeles").scrollLeft=scrol
		clearTimeout(timer1);
	}
}

function zoomph(e){
	$("photo").update("<img style=\"cursor:pointer;border:10px solid #ffffff\" id='imgz' src='" + Event.findElement(e,"img").src.replace("min","max") + "'><br/><span style='cursor:pointer;font-weight:bold;font-family:arial;font-size:11px;color:#ffffff' id='close'>X Fermer</span>");
	if (!typeof document.body.style.maxHeight != "undefined") {
	  $("cachephoto").style.height=screen.height;
	  $("cachephoto").style.width=screen.width - 25;
	}
	//img = new Image();
	//img.src = Event.findElement(e,"img").src.replace("min","max");

	
	new Effect.Opacity($("cachephoto"),{duration:0.0, from:1.0, to:0,afterFinish:function(){
		$("cachephoto").style.display="block";
		$("photo").style.width=screen.width - 25;
		

		/*Event.observe(img, "load", function(e){
			if (img.width != 0 && img.width != "") {
				$("fermer").style.width = img.width + 12 + "px";
			}
			else 
				if (img2.width != 0) {
					$("fermer").style.width = img2.width + 12 + "px";
				}
				else {
					$("fermer").style.width = 150 + "px";
				}
		})*/


		
		new Effect.Opacity($("photo"),{duration:0.0, from:1.0, to:0,afterFinish:function(){
			$("photo").style.display="block";
			new Effect.Opacity($("photo"),{duration:0.4, from:0.0, to:1})
			new Effect.Opacity($("cachephoto"),{duration:0.4, from:0.0, to:0.7})
		}})

		Event.observe($("imgz"),"click",function(e){
			new Effect.Opacity($("photo"),{duration:0.4, from:1.0, to:0.0,afterFinish: function(){
				$("photo").style.display="none";
			}})
			new Effect.Opacity($("cachephoto"),{duration:0.4, from:1.0, to:0.0,afterFinish: function(){
				$("cachephoto").style.display="none";
			}})
		})
		
		Event.observe($("close"),"click",function(e){
			new Effect.Opacity($("photo"),{duration:0.4, from:1.0, to:0.0,afterFinish: function(){
				$("photo").style.display="none";
			}})
			new Effect.Opacity($("cachephoto"),{duration:0.4, from:1.0, to:0.0,afterFinish: function(){
				$("cachephoto").style.display="none";
			}})
		})
		
		/*img = new Image();
		img.src = Event.findElement(e,"img").src.replace("min","max");
		Event.observe(img,"load",function(e){
			if (img.width != 0 && img.width != "") {
				$("fermer").style.width = img.width + 12 + "px";
			}
			else 
				if (img2.width != 0) {
					$("fermer").style.width = img2.width + 12 + "px";
				}
				else {
					$("fermer").style.width = 150 + "px";
				}
		})
		if(img.width==0 || img.width==""){
			$("fermer").style.width = 200+ "px";
		}*/
		
	}})

}
