$(document).ready(function(){
	
	
	ddsmoothmenu.init({
		 mainmenuid: "smoothmenu", //menu DIV id
		 orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
		 classname: 'ddsmoothmenu', //class added to menu's outer DIV
		 //customtheme: ["#1c5a80", "#18374a"],
		 contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
	});
	
	

	
	
	$("select, input").uniform();

	$('.li_libelle').hover(function() {
		
		var parent = $(this).parent('li');
		parent.children('.rollover').addClass('hover');
	
	}, function() {	
		var parent = $(this).parent('li');
		parent.children('.rollover').removeClass('hover');
	});
	
	
	$(".coche_photo").click(function() {
	  
		var parent = $(this).parent('li');
		
		
		$(location).attr('href',parent.children('a:first').attr('href'));
	    return false;
	});
	

	
	$('.liste_bateau li').hover(function() {
		
		var enfant = $(this).children(".coche_photo");
		enfant.addClass("coche_photo_hover");
		enfant.removeClass("coche_photo_normal");
		
	
	}, function() {	
		var enfant = $(this).children(".coche_photo");
		enfant.addClass("coche_photo_normal");
		enfant.removeClass("coche_photo_hover");
	});
	
	
	// pretty photo
	if($("a[rel^='prettyPhoto']").size()>0) {
			
			$("a[rel^='prettyPhoto']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.40, /* Value betwee 0 and 1 */
				showTitle: false, /* true/false */
				allowresize: true, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
				hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
				modal: false, /* If set to true, only the close button will close the window */
				changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
				callback: function(){} /* Called when prettyPhoto is closed */
			});
		}
	
	
	//Menu dÃ©roulant
	/*
	$(function() {
    	$('#menu_niveau_un').droppy({speed: 100});
	});
	*/
	//Formulaire newsletter
	$('#bt_valid_newsletter').click(function(){
		
		var nom 	= $('#nom').val();
	    var prenom 	= $('#prenom').val();
	    var email 	= $('#email').val();	    
	    var choix 	= $('input[type=radio][name=choix_news]:checked').attr('value');
	    
	    $.post('/cgi/inscription-newsletter.php', {'email': email, 'choix': choix, 'nom': nom, 'prenom': prenom}, function(data){
	    	$('#message_validation').css('opacity', 1);
	    	$("#message_validation").css("display","block");
	    	$('#message_validation').empty();
	    	$('#message_validation').append(data);
	    	setTimeout(function(){
				$('#message_validation').animate({opacity: 0}, 500);
				$("#message_validation").css("display","none");
    		}, 5000);
	    });
    });
	
	//Calendrier
	$.datepicker.regional['fr'];
	$('.champ_date').datepicker({
		showOn: 'both', 
		buttonImage: '/image/interface/calendar.png', 
		buttonImageOnly: true
	});
	// Menu 
	
/* Menu image rollover*/
	
	$("ul#menu_niveau_un li").hover(function(){
		var fade = $('> a.rollover img.survol', this);
		if (!fade.hasClass('animated')) {
			fade.dequeue().stop().fadeIn(250);
		}
	}, function() {
		var fade = $('> a.rollover img.survol', this);
		fade.addClass('animated').fadeOut(250, function() {
				fade.removeClass('animated');
		});
			
		
	});
	
	
	$("#critere_recherche").focus(function() {
		//if ($("#critere_recherche").val()=="Rechercher") {
			$("#critere_recherche").val("");
		//}
		$("#critere_recherche").css("color","#238EA0");
	});
	
	$("#critere_recherche").blur(function() {
		//if ($("#critere_recherche").val()=="") {
			//$("#critere_recherche").val("Rechercher");
		//}
		//$("#critere_recherche").css("color","#d4d4d4");
	});
	
	// gérer l'image courante -> sert pour l'opcité des boutons suivant précédent
	$('.Nav').click(function(e){ 
		
		var nb_image = $('#diaporama .SlideTab').size();
	
		var current = $("#diaporama .current_page");
		
		var id = (current.attr("id")).substr(4,(current.attr("id")).length);
		
		var nav = ($(this).attr("id")).substr(4,($(this).attr("id")).length);
		
		var pos = parseInt(id)+parseInt(nav);
		
		if (pos==-1) {pos=nb_image-1;}
		if (pos==nb_image) {pos=0;}
		
		
		current.removeClass('current_page');
		
		$('#diaporama .SlideTab[id=img_'+pos+']').addClass('current_page');
		
		//$('#diaporama .SlideTab').tabSwitch('moveStep',{step: parseInt(nav)});
		$('#diaporama .SlideTab').tabSwitch('moveTo',{index: parseInt(pos)});
		
		e.preventDefault();
			
	});
	
	
	$('.tabSelect').click(function(e){
		
		var current = $("#pagination_actu a.current_page");
		current.removeClass('current_page');
		var current = $("#liste_actu div.current_page");
		current.removeClass('current_page');
		
		
		var index = ($(this).attr('id')).substr(4,($(this).attr('id')).length);
		$(this).addClass('current_page');
		var current = $("div#actu_accueil_"+index);
		current.addClass('current_page');
		modifUrlActuAccueil();
		$('#liste_actu .SlideTab').tabSwitch('moveTo',{index: parseInt(index)});
		
		e.preventDefault();
			
	});
	
	

	
	function iniPage() {
		
		// diapo
		var firstImg= $('.image_diapo:first');
		firstImg.addClass("current_page");
		
		// Actu
		var nbActu = $('.bloc_actu_accueil').size();
		
		if (nbActu <= 0) {
			$("#liste_actu").css("display","none");
		} else {
			
			if (nbActu == 1 ) {
				$("#pagination_actu").css("display","none");
			}
			
			if (nbActu == 2 ) {
				$("#pag_2").css("display","none");
			}

			var firstActu = $('.bloc_actu_accueil:first');
			firstActu.addClass("current_page");
			modifUrlActuAccueil();
			
		}
		
		
		
		
		
		
		
		
	}
	iniPage();
	
	
	function modifUrlActuAccueil() {
		var url = $('.current_page .lire_actu_accueil').attr("href");
		
		$('#lire_article_accueil').attr("href",url);
	
		
	}
	
	
	
	$('#page_corps_bas .bordure').height($('#page_corps_bas').height());
	
	/* Sans effet fadeIn*/
	/*
	$('ul#menu_niveau_un li').hover(function(e){
	    var fade = $('>	a.rollover img.survol', this);
		fade.css("display","block");	
	 }, function(){
	    var fade = $('> a.rollover img.survol', this);	
		fade.css("display","none")	
	});
	
		
*/
	
/*Fin du menu catÃ©dorie */
	
	/* 
	 * 
	 * Recherche
	 */


	
	
});