var $soumenucourant = 'aikido';

$(document).ready(function() {

	// 
	if ($PagePrincipale != '')
		$('#'+$PagePrincipale).slideDown(3000,
			function () { 
				if(document.getElementById('UnFlash')){
					$( "#UnFlash" ).show(4000).animate({ opacity: 0.1 }, {duration: 14000 }).hide("fast") ;
					var flashinfo_var = GetCookie("flashinfo");
					var flashinfo_nb = 0;
					if (flashinfo_var != null) 
						flashinfo_nb = parseInt(flashinfo_var) + 1;
					duree = 3;  
					date_expire = new Date();
					date_expire.setTime(date_expire.getTime() + (duree*3600*24*1000));
					SetCookie("flashinfo",flashinfo_nb,date_expire);
				}
			});

    function getCookieVal (offset) {
      var endstr = document.cookie.indexOf (";", offset);
      if (endstr == -1)
        endstr = document.cookie.length;
      return unescape(document.cookie.substring(offset, endstr));
    }
    function GetCookie (name) {
      var arg = name + "=";
      var alen = arg.length;
      var clen = document.cookie.length;
      var i = 0;
      while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
    	i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
      }
      return null;
    }
    function SetCookie (name,value,expires,path,domain,secure) {
      document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    }

			
	// click sur un sous-menu, appel ajax pour remplacement de la div
	$('a.changeursousmenu[href^=#]').click(function() {
		var IDDestination = $(this).attr('rel'); // ici DIV qui contiendra la page chargée
		var urlContenu = $(this).attr('url'); // url du contenu à récupérer du serveur et à mettre dans la DIV

		if ($soumenucourant != IDDestination) // on a pas recliqué sur le même
		{
			lCurrent = $(this);
			if ((urlContenu != null) && ($('#'+IDDestination).html()==''))// premier chargement de la page
				$.ajax({
					type : 'GET', // envoi des données en GET ou POST
					url : urlContenu , // url du fichier de traitement
					success : function(data){ // 
						$('#' + IDDestination).html(data); 
						$('#'+$soumenucourant).hide(0,function() {
							$('#'+IDDestination).slideDown(3000,function() {
								$soumenucourant = IDDestination;	
								$('.changeursousmenu').removeClass("current");
								lCurrent.addClass("current");
							});
						});
					}
				});
			else
				$('#'+$soumenucourant).hide(0,function() {
					$('#'+IDDestination).slideDown(3000,function() {
						$soumenucourant = IDDestination;	
						$('.changeursousmenu').removeClass("current");
						lCurrent.addClass("current");
					});
				});
		}
		
		return false;
	});	
	
}); 

function ajax(pUrl,destination,decVar)
{
	if ($.trim($('#' + destination).text()) == '')
	{
		$.ajax({
			type : 'GET', // envoi des données en GET ou POST
			url : pUrl , // url du fichier de traitement
			success : function(data){ // 
				$('#' + destination).html(data); 
			}
		});
	}
}




