var isIE6 = ((navigator.userAgent.indexOf("MSIE 6.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
var isIE7 = ((navigator.userAgent.indexOf("MSIE 7.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
var isChrome = ((navigator.userAgent.indexOf("Chrome") != -1));
var isSafari = ((navigator.userAgent.indexOf("Safari") != -1));
 
 
 
    $(document).ready( function () {
        // On cache les sous-menus
        // sauf celui qui porte la classe "open_at_load" :
        $("ul.subMenu:not('.open_at_load')").hide();
        // On selectionne tous les items de liste portant la classe "toggleSubMenu"
    
        // et on remplace l'element span qu'ils contiennent par un lien :
        $("li.toggleSubMenu span").each( function () {
            // On stocke le contenu du span :
            var TexteSpan = $(this).text();
            $(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '</a>') ;
        } ) ;
    
        // On modifie l'evenement "click" sur les liens dans les items de liste
        // qui portent la classe "toggleSubMenu" :
        $("li.toggleSubMenu > a").click( function () {
            // Si le sous-menu etait deja ouvert, on le referme :
            if ($(this).next("ul.subMenu:visible").length != 0) {
                $(this).next("ul.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
            }
            // Si le sous-menu est cache, on ferme les autres et on l'affiche :
            else {
                $("ul.subMenu").slideUp("normal", function () { $(this).parent().removeClass("open") } );
                $(this).next("ul.subMenu").slideDown("normal", function () { $(this).parent().addClass("open") } );
            }
            // On empêche le navigateur de suivre le lien :
            return false;
        });
    
    } ) ;
	
	
	$(document).ready(function() { 
$(".carousel_js img").height("267px");
$(".carousel_js img").width("850px");
 
		$(".les_visites a").click( 
			function() { 
		var monId='#'+$(this).attr("id")+'go';
				var answer = $(".visite");
				
				answer.slideUp("fast",function(){


				}
				)

				
				$(monId).slideDown( "slow",function(){} ); 
					
	                   
			}
			
			
		);
	}

);


$(document).ready(function(){
	
	
	
	//background for input on hover anf focus
	$("input").hover(function(){
		$(this).addClass("write_hover");
	},function(){
		$(this).removeClass("write_hover");
	});
	
	$("input").click(function(){
		$(this).addClass("write");
	});
	
	$("input").blur(function(){
		$(this).removeClass("write");
	});
	
	$("input").focus(function(){
		$(this).addClass("write");
	});
	
	$("textarea").hover(function(){
		$(this).addClass("write_hover");
	},function(){
		$(this).removeClass("write_hover");
	});
	
	$("textarea").click(function(){
		$(this).addClass("write");
	});
	
	$("textarea").blur(function(){
		$(this).removeClass("write");
	});
	
	$("textarea").focus(function(){
		$(this).addClass("write");
	});
	
	$("#contact_form #name").addClass("write");
	$("#contact_form #name").focus();
	
	
});

$(function(){
	// custom scroll.
	if($("#scrollpane").jScrollPane != undefined){
		$("#scrollpane").jScrollPane({scrollbarWidth: 4});
	}
	
	//init carousel Banner
	if($(".carousel_js img").length>1) {
		if($(".carousel_js").infiniteCarousel != undefined){
			if(isChrome || isSafari){//temps de chargement suppl sinon marche pas!
				setTimeout("$('.carousel_js').infiniteCarousel({imagePath: '/img/carousel/',displayThumbnails : 1,displayProgressBar : 0,transitionSpeed: 1000,displayTime: 6000,inView:1,advance:1,easeLeft: 'easeInOutBack',easeRight:'easeInOutBack'});",700);
			}
			else{
				$(".carousel_js").infiniteCarousel({
					displayThumbnails : 1,
					displayProgressBar : 0,	
					transitionSpeed: 1200,
					displayTime: 7000,
					inView:1,
					advance:1,
					easeLeft: 'easeInOutBack',
					easeRight:'easeInOutBack'
				});
			}
		}
	}
	else {}
	//init carousel News
	if($(".news_js").carousel != undefined){
		$(".news_js").carousel({ 
			dispItems: 3,
			direction: "vertical",
			loop: true,
			autoSlide: true,
			nextBtn: "<span class='down'>down</span>",
			prevBtn: "<span class='up'>up</span>",
			effect : "slide",
			animSpeed: "slow",
			autoSlideInterval: 7000
		});
	}
	
		if($(".temoin_js").carousel != undefined){
		$(".temoin_js").carousel({ 
			dispItems: 1,
			direction: "vertical",
			loop: true,
			autoSlide: true,
			nextBtn: "<span class='down'>down</span>",
			prevBtn: "<span class='up'>up</span>",
			effect : "slide",
			animSpeed: "slow",
			autoSlideInterval: 7000
		});
	}

		
	//init carousel partenaires
	if($(".partenaires_js").carousel != undefined){
		$(".partenaires_js").carousel({ 
			direction: "horizontal",
			dispItems: 2,
			loop: true,
			autoSlide: true,
			nextBtn: "<span></span>",
			prevBtn: "<span></span>",
			effect : "slide",
			animSpeed: "slow",
			autoSlideInterval: 4000
		});
	}
});

$(
function() {
$('.navigation li.niv1').mouseover(function() {$('.navigation li.niv1').removeClass('hover');$(this).addClass('hover'); });
$('.navigation li.niv1').mouseleave(function() {$(this).removeClass('hover'); });
$('.media').media( 

	);
$('a.agenda').nyroModal({bgColor: '#000', width: 600,  height: 400,minWidth: 400,minHeight: 300});
}
)
