$(window).load(function(){
	$("#slider_top, #menu").css('display','block');
	$(".articles_in").each(function(){
		$(this).css("min-height", $(".content_article .img img",this).height()+15)	;
		//alert($(".content_article .img img",this).height())
	});
	//$(".articles_in").css("min-height",($("#zooom .img img").height()+15));
	if(($("#zooom .img img").height()+15) < 100){
		$("#zooom a.suite").css("margin-top","-10px");	
	}
	$("#eve_home .articles_in").each(function(){
		$(this).css("min-height",($(".evene img", this).height()+5));
	});
	$(document).ready(function(){
		$('#slider').nivoSlider({});
		$("#content_header, #content_menu, #content_in, #content_footer, img").pngfix({sizingMethod: "scale"});
		var IE7 = false;
		var IE6 = false;
		var strChUserAgent = navigator.userAgent;
		var intSplitStart = strChUserAgent.indexOf("(",0);
		var intSplitEnd = strChUserAgent.indexOf(")",0);
		var strChStart = strChUserAgent.substring(0,intSplitStart);
		var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
		var strChEnd = strChUserAgent.substring(strChEnd);
		if(strChMid.indexOf("MSIE 7") != -1){
			$('#header_background').css('float','left');
		}else if(strChMid.indexOf("MSIE 6") != -1){
		}else{
		}
		/*if(strChMid.indexOf("MSIE 7") != -1 || strChMid.indexOf("MSIE 6") != -1 ){
			$("#pos_background").css("width",$(window).width());
			$("#img_header").css("width",$(window).width());
			$("#img_background").css("width",$(window).width());
		}*/
		menuWidth = 0;
		$("#menu_in ul li.nav1").each(function(){
			menuWidth += $(this).width();								   
		});
		newNav =($(window).width()-$(".nivo-controlNav a").size()*25)/2+27;
		$(".nivo-controlNav").css('margin-left',newNav);
		$(".nivo-prevNav").css('margin-left',newNav-46);
		$(".nivo-nextNav").css('margin-right',newNav-46);
		menuLeft = ($(window).width()-menuWidth)/2;
		$('#menu_in').css('margin-left',menuLeft);
		$(window).resize( function(){
			/* Position et taille des différents éléments au redimansionnement de la page */
			newNav =($(window).width()-$(".nivo-controlNav a").size()*25)/2+27;
			$(".nivo-controlNav").css('margin-left',newNav);
			$(".nivo-prevNav").css('margin-left',newNav-46);
			$(".nivo-nextNav").css('margin-right',newNav-46);
			menuLeft = ($(window).width()-menuWidth)/2;
			$('#menu_in').css('margin-left',menuLeft);
		});
		//
		$(".centrale_top a").each( function(){
			$(this).click( function(){
				$(".centrale_top a").each( function(){
					$(this).removeClass("click");
				});
				$(".centrale_in .form").each( function(){
					$(this).fadeOut(1000);
				});
				$(this).addClass("click");
				id = $(this).attr('id').substr(2,1);
				$(this).parent().next().children('#form'+id).fadeIn(1000);
				return false;
			});
		});
		
		/**/
		$('li.toggleSubMenu.nav1').each(function () {
			var time = 500;
			var hideDelay = 400;
			var hideDelayTimer = null;
			var beingShown = false;
			var shown = false;
			var trigger = $(this);
			$(trigger.get(0)).mouseover(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
					// reset position of info box
					beingShown = true;
					$('ul.subMenu',trigger).slideDown("normal", function(){
						$(this).parent().addClass('open');
						beingShown = false;
						shown = true;										   
					}); 
				return false;
			}).mouseout(function () {
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				hideDelayTimer = setTimeout(function () {
					hideDelayTimer = null;
					$(trigger).children("ul.subMenu").slideUp("normal", function(){
						$(this).parent().removeClass('open');
						shown = false;	
					});
				}, hideDelay);
				return false;
			});
		});
		/**/
		$("#print").click(function(){
			window.print();			  
		});
		$("a.renseignement").each(function(){
			$(this).click( function(){
				if($(this).next().css('display') == 'block'){
					$(this).next().css('display','none');
				}else{
					$(this).next().css('display','block');
				}
				return false;
			});
		});
		/* SLIDER IMAGES PASSEPORT */
		wSlider = 285*($('#slider_mov .slide1').length);
		$('#slider_mov').css('width', wSlider);
		$('.slider a.mov_right').click(function(){
			l=$('#slider_mov').css('margin-left').length;
			w = $('#slider_mov').css('margin-left').substr(0,l-2);
			if(w>-wSlider+290){
				$('#slider_mov').animate({
						marginLeft: "-=285px"
					},500 
				);
			}
			return false;
		});
		$('.slider a.mov_left').click(function(){
			l=$('#slider_mov').css('margin-left').length;
			w = $('#slider_mov').css('margin-left').substr(0,l-2);
			if(w<-280){
				$('#slider_mov').animate({
						marginLeft: "+=285px"
					},500 
				);
			}
			return false;
		});
		
		$('#menu li ul li').each(function () {
			$(this).mouseover(function(){
				$(this).children(".menu_ul").css("display","block");
				$(this).children(".menu_ul").css("margin-left",$(this).width());
			});
			$(this).mouseout(function(){
				$(this).children(".menu_ul").css("display","none");
			});
		});
		$(".bt0").click(function(){
			$("#info0").css('display','block');
			$("#info1").css('display','none');
			$("#info2").css('display','none');
			return false;
		});
		$(".bt1").click(function(){
			$("#info1").css('display','block');
			$("#info0").css('display','none');
			$("#info2").css('display','none');
			return false;
		});
		$(".bt2").click(function(){
			$("#info2").css('display','block');
			$("#info1").css('display','none');
			$("#info0").css('display','none');
			return false;
		});
	});
});

