// JavaScript Document
/* semaine type
------------------------------------------------------------------------------*/

function showCalendrierVoyageur(url)
{
    var ancre = "";
    if (url.indexOf("?") > -1) 
    {
        ancre = url.substring(url.indexOf("?"));
    }
    if (ancre.indexOf("&") > -1) 
    {
        ancre = ancre.substring(0, ancre.indexOf("&"));
    }
    if (ancre.indexOf("#") > -1) 
    {
        ancre = ancre.substring(0, ancre.indexOf("#"));
    }
    ancre = ancre.replace("?", "#");
    
    // On teste si c'est un onglet ou un ongletParticulier
    if (ancre != "")
    {
        // Onglet particulier: on affiche le bon onglet particulier et le premier onglet normal
        if ($(ancre).hasClass("ongletParticulier"))
        {
            $(".heure, .ongletParticulier").hide();
		    $(ancre).show();
		    $(ancre).prev(".heure").show();
            $(".heures, .onglet").hide();
            $(".onglet:first").show();
            $(".onglet:first").prev(".heures").show();
        }
        
        // Onglet normal: on affiche le bon onglet normal et le premier onglet particulier
        else if ($(ancre).hasClass("onglet"))
        {
            $(".heures, .onglet").hide();
            $(ancre).show();
            $(ancre).prev(".heures").show();
            $(".heure, .ongletParticulier").hide();
            $(".ongletParticulier:first").show();
            $(".ongletParticulier:first").prev(".heure").show();
        }
    }
    // On affiche les premiers onglet de chaque
    else
    {
        $(".heures, .onglet").hide();
        $(".heures:first, .onglet:first").show();
        $(".heure, .ongletParticulier").hide();
        $(".heure:first, .ongletParticulier:first").show();
    }

    return(false);
}

$(document).ready(function(){
    showCalendrierVoyageur(self.location.href)
}) ;


$(document).ready(function(){
	//$(".heures, .onglet").hide();
	//$(".heures:first, .onglet:first").show();
	
	$(".heures a").click(function(){
		$(".heures, .onglet").hide();
		$($(this).attr("href")).show();
		
		$($(this).attr("href")).prev(".heures").show();
		$($(this).attr("href")).prev(".heures").find('.actif a').focus();
		
		$(this).blur();
		return(false);
	});
	$("ul.subMenu:not('.open_at_load')").hide();
	$("li.toggleSubMenu span").each( function () {
		var TexteSpan = $(this).text();
		$(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '</a>') ;
	} ) ;
	$('.open_at_load').prev("a").attr("title", "Masquer le sous-menu");
	$("li.toggleSubMenu > a").click( function () {
		if ($(this).next("ul.subMenu:visible").length != 0) {
			$(this).next("ul.subMenu").slideUp("slow", function() {
				$(this).parent().removeClass("open");
				$(this).prev("a").attr("title", "Afficher le sous-menu");
			});
			$(".open a").attr("title", "Masquer le sous-menu");
		}
		else {
			$("ul.subMenu").slideUp("slow", function () { $(this).parent().removeClass("open") } );
			$(this).next("ul.subMenu").slideDown("slow", function () {
				$(this).parent().addClass("open");
				$(this).prev("a").attr("title", "Masquer le sous-menu");
			});
			$(".open a").attr("title", "Afficher le sous-menu");
		}
		return false;
	});
	
	
	$('.date-pick').datePicker();
	$('.date-pick').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_aller option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_aller option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_aller option[value='" + v[2] + "']").attr("selected", true);
	});	
	
	
	$('.date-pick2').datePicker();
	$('.date-pick2').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_retour option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_retour option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_retour option[value='" + v[2] + "']").attr("selected", true);
    });

    $('.date-pick3').datePicker();
    $('.date-pick3').change(function() {
        v = $(this).attr("value");
        v = v.split(/\//);
        $(".validite").attr("value", v[0] + '/' + v[1] + '/' + v[2]);
    });

    $('.date-pick4').datePicker();
    $('.date-pick4').change(function() {
        v = $(this).attr("value");
        v = v.split(/\//);
        $(".validite2").attr("value", v[0] + '/' + v[1] + '/' + v[2]);
    });
} ) ;

// JavaScript Document
/* jour particulier
------------------------------------------------------------------------------*/

$(document).ready(function(){
	//$(".heure, .ongletParticulier").hide();
	//$(".heure:first, .ongletParticulier:first").show();
	
	$(".heure a").click(function(){
		$(".heure, .ongletParticulier").hide();
		$($(this).attr("href")).show();
		
		$($(this).attr("href")).prev(".heure").show();
		$($(this).attr("href")).prev(".heure").find('.actif a').focus();
		
		$(this).blur();
		return(false);
	});
	$("ul.subMenu:not('.open_at_load')").hide();
	$("li.toggleSubMenu span").each( function () {
		var TexteSpan = $(this).text();
		$(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '</a>') ;
	} ) ;
	$('.open_at_load').prev("a").attr("title", "Masquer le sous-menu");
	$("li.toggleSubMenu > a").click( function () {
		if ($(this).next("ul.subMenu:visible").length != 0) {
			$(this).next("ul.subMenu").slideUp("slow", function() {
				$(this).parent().removeClass("open");
				$(this).prev("a").attr("title", "Afficher le sous-menu");
			});
			$(".open a").attr("title", "Masquer le sous-menu");
		}
		else {
			$("ul.subMenu").slideUp("slow", function () { $(this).parent().removeClass("open") } );
			$(this).next("ul.subMenu").slideDown("slow", function () {
				$(this).parent().addClass("open");
				$(this).prev("a").attr("title", "Masquer le sous-menu");
			});
			$(".open a").attr("title", "Afficher le sous-menu");
		}
		return false;
	});
	
	
	$('.date-pick').datePicker();
	$('.date-pick').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_aller option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_aller option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_aller option[value='" + v[2] + "']").attr("selected", true);
	});	
	
	
	$('.date-pick2').datePicker();
	$('.date-pick2').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_retour option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_retour option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_retour option[value='" + v[2] + "']").attr("selected", true);
	});

} ) ;

// JavaScript Document
/* calendrier scolaire
------------------------------------------------------------------------------*/

$(document).ready(function(){
	$(".te_zone, .te_zoneTableau").hide();
	$(".te_zone:first, .te_zoneTableau:first").show();
	
	$(".te_zone a").click(function(){
		$(".te_zone, .te_zoneTableau").hide();
		$($(this).attr("href")).show();
		
		$($(this).attr("href")).prev(".te_zone").show();
		$($(this).attr("href")).prev(".te_zone").find('.actif a').focus();
		
		$(this).blur();
		return(false);
	});
	$("ul.subMenu:not('.open_at_load')").hide();
	$("li.toggleSubMenu span").each( function () {
		var TexteSpan = $(this).text();
		$(this).replaceWith('<a href="" title="Afficher le sous-menu">' + TexteSpan + '</a>') ;
	} ) ;
	$('.open_at_load').prev("a").attr("title", "Masquer le sous-menu");
	$("li.toggleSubMenu > a").click( function () {
		if ($(this).next("ul.subMenu:visible").length != 0) {
			$(this).next("ul.subMenu").slideUp("slow", function() {
				$(this).parent().removeClass("open");
				$(this).prev("a").attr("title", "Afficher le sous-menu");
			});
			$(".open a").attr("title", "Masquer le sous-menu");
		}
		else {
			$("ul.subMenu").slideUp("slow", function () { $(this).parent().removeClass("open") } );
			$(this).next("ul.subMenu").slideDown("slow", function () {
				$(this).parent().addClass("open");
				$(this).prev("a").attr("title", "Masquer le sous-menu");
			});
			$(".open a").attr("title", "Afficher le sous-menu");
		}
		return false;
	});
	
	
	$('.date-pick').datePicker();
	$('.date-pick').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_aller option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_aller option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_aller option[value='" + v[2] + "']").attr("selected", true);
	});	
	
	
	$('.date-pick2').datePicker();
	$('.date-pick2').change(function() {
		v = $(this).attr("value");
		v = v.split(/\//);
		$("#date_retour option[value='" + v[0] + "']").attr("selected", true);
		$("#mois_retour option[value='" + v[1] + "']").attr("selected", true);
		$("#annee_retour option[value='" + v[2] + "']").attr("selected", true);
	});

} ) ;
