// JavaScript Document
var timeOutlstLangues = null;
var timeOutlstSites = null;

function ieSpec()
  {
	//$('.sousmenu li').each(function() {$(this).css('width',$(this).parents('.soumenu').width());});
	$('.sousmenu .haut').each(function() {$(this).css('width',$(this).parents('div').width());});
	$('.sousmenu li').each(function() {$(this).css('width',$(this).parents('div').width());});
	$('#lstSites li').each(function() {$(this).css('width',$(this).parents('div').width());});
	$('#lstLangues li').each(function() {$(this).css('width',$(this).parents('div').width());});
	if($.browser.version.indexOf('7')>-1)
	  {
		$('#lstSites').each(function() {$('#lstSites').css('margin-left', - $('#triggerlstSites').width()).css('margin-top','17px');});
		$('#lstLangues').each(function() {$('#lstLangues').css('margin-left', - $('#triggerlstLangues').width()).css('margin-top','17px');});
	  }
  }

function init()
  {
	setupAccroche();
	$('ul li:last-child').addClass('last');
	alignerHauteurPush();
	$('.scrUp').hover(
		function() {tmp = $(this).parent().attr('id').split('p');num = tmp[1];startScroll(num,1)},
		function() {tmp = $(this).parent().attr('id').split('p');num = tmp[1];stopScroll(num)}
	);
	$('.scrDown').hover(
		function() {tmp = $(this).parent().attr('id').split('p');num = tmp[1];startScroll(num,-1)},
		function() {tmp = $(this).parent().attr('id').split('p');num = tmp[1];stopScroll(num)}
	);
	$('#menu li').each(function() 
		{
		  $(this).hover(function() {$(this).find('.sousmenu').css('display','block');},function() {$(this).find('.sousmenu').css('display','none');});
		  if($(this).find('.sousmenu').outerWidth(true)<$(this).outerWidth(true))
		    {
			  $(this).find('.sousmenu li a').css('width',$(this).outerWidth(true)-20);
			}
		});
	//$('#lstLangues').css('width',$('#triggerlstLangues').innerWidth()-10);
	if($('#lstLangues').length>0)
	  {$('#triggerlstLangues').hover(function() {ouvrir('lstLangues');},function() {retarderFermeture('lstLangues');});}
	//$('#lstSites').css('width',$('#triggerlstSites').innerWidth()-15);
	$('#triggerlstSites').hover(function() {ouvrir('lstSites');},function() {retarderFermeture('lstSites');});
	$('#conteneurLienPlan a').click(function() {$('#planSite').toggle('blind');});
	if($.browser.msie)
	  {ieSpec();}
  }
function ouvrir(cible)
  {
	clearTimeout(window['timeOut'+cible]);
	if($('#'+cible).css('display')=="none")
	  {$('#'+cible).show('blind');}
  }
function fermer(cible)
  {
	clearTimeout(window['timeOut'+cible]);
	if($('#'+cible).css('display')=="block")
	  {$('#'+cible).hide('blind');}
  }
function retarderFermeture(cible)
  {
	window['timeOut'+cible] = setTimeout("fermer('"+cible+"')",500);
  }
function alignerHauteurPush()
  {
	$('.liste4pushs .push .scrolling .contenuInterne,.liste2pushs .push .scrolling .contenuInterne').each(
		function() 
		  {
			//alert($(this).attr('id')+" - "+$(this).height()+" - "+$(this).parent().height());
			tmp = $(this).attr('id').split('get');num = tmp[1];
			if($(this).height() - $(this).parent().height()>0)
			  {$('#scroll'+num).addClass('showMe');}
			else
			  {$('#scroll'+num).removeClass('showMe');}
/*
			  {$('#scroll'+num).css('display','block');}
			else
			  {$('#scroll'+num).css('display','none');}
*/
		  }
	);
  }
function startScroll(numBloc,sens)
  {
	timeScroll = setInterval ( "scrollMe('"+numBloc+"',"+sens+")", 15 );
  }
function stopScroll()
  {
	clearInterval(timeScroll);
  }
function scrollMe(numBloc,sens)
  {
	maxScroll = $('#scrollTarget'+numBloc).parent().height() - $('#scrollTarget'+numBloc).height();
	if(maxScroll<0)
	  {
		pAct = parseInt($('#scrollTarget'+numBloc).css('margin-top'));
		nPos = pAct + (sens*2);
		if(sens>0)
		  {
			if(nPos>0)
			 {$('#scrollTarget'+numBloc).css('margin-top','0px');}
			else
			  {$('#scrollTarget'+numBloc).css('margin-top',nPos+'px');}
		  }
		else
		  {
			if(nPos<maxScroll)
			  {$('#scrollTarget'+numBloc).css('margin-top',maxScroll+'px');}
			else
			  {$('#scrollTarget'+numBloc).css('margin-top',nPos+'px');}
		  }
	  }
  }


var accroche;
var current_accroche=0;
var first = true;

function setupAccroche(){
	accroche=$("[id^=accroche_]");
	if(accroche.length) {
		$('#slogan').html((accroche.eq(current_accroche).html()));
		loadAccroche();
		window.setInterval('loadAccroche()', 5000);
	}
}

function loadAccroche(){
	if (first) {
		first = false;
	}
	else {
		$('.slogan').fadeOut(400, function () {
			$('#slogan').html((accroche.eq(current_accroche).html()));
			$('.slogan').css ('top', '-400px');
			$('.slogan').css ('display', 'block');
			$('.slogan').animate({top: '14px'}, 600);
		});
		current_accroche=current_accroche+1;
	}
	if(current_accroche==5) {current_accroche=0;}
}
function increaseFont()
  {
	var currentFontSize = $('#contenu').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum+2;
    $('#contenu').css('font-size', newFontSize);
	alignerHauteurPush();
  }
  // Decrease Font Size
function decreaseFont()
  {
    var currentFontSize = $('#contenu').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum-2;
    $('#contenu').css('font-size', newFontSize);
	alignerHauteurPush();
  }

