function initSite() {
	// Pour IE on n'ajoute pas d'évènement onmouseover cause problèmes...
	if(!window.ActiveXObject)
		$('#contenu').mouseout(hideAll);
	else
		$('#contenu').click(hideAll);
		
	// Masque les liens vers Webimm
	var regexp = /h=y/;
	if (window.location.search.match(regexp)) {
		$('.moteur').hide();
		CreationCookie('hide','y',false);
	}
	var t = ScanCookie('hide');
	if (ScanCookie('hide') == 'y') {
		$('.moteur').hide();
	}
	
	// Fonction de l'accordéon sur certaine page
	accordion();
	
	// Scroll des actus
	height = $('#news_content ul').height();
	var html = $('#news ul').html();

	$('#news_content').css('position', 'relative');
	$('#news_content').css('height', 230);
	$('#news_content').css('overflow', 'hidden');
	$('#news_content').css('z-index', '11');
	
	$('#news ul').html(html+html);
	$('#news ul').css('position', 'absolute');
	$('#news ul').css('z-index', '10');
	timer = setTimeout('scroll()',100);
    
	$('#news ul').hover(
      function () {
        clearTimeout(timer);
      }, 
      function () {
        scroll();
      }
    );
}

function hideAll() {
	$('.ssmenu').hide();
	$('.menu').removeClass("hover");
}
function show(elem) {
	hideAll();
	$('#'+elem.id).addClass("hover");
	$('#s'+elem.id).show();
}



function hideAllSS() {
	$('.Sssmenu').hide();
	$('.menu').removeClass("hover");
}
function showSS(elem) {
	hideAllSS();
	$('#'+elem.id).addClass("hover");
	$('#s'+elem.id).show();
}


// Tue l'animation
function killMe() {
	CreationCookie('vdm','animation',false);
	$('#anim').remove();
}
// Vérifié la présence d'une variable dans un cookie
function ScanCookie(variable) {
	cook = document.cookie;
	variable += "=";
	place = cook.indexOf(variable,0);
	if (place <= -1)
		return("0");
	else {
		end = cook.indexOf(";",place)
		if (end <= -1)
			return(unescape(cook.substring(place+variable.length,cook.length)));
		else
			return(unescape(cook.substring(place+variable.length,end)));
	}
}
// Pose une variable dans un cookie
function CreationCookie(nom,valeur,permanent) {
	if(permanent) {
		dateExp = new Date(2020,11,11);
		dateExp = dateExp.toGMTString();
		ifpermanent = '; expires=' + dateExp + ';';
	} else
		ifpermanent = '';
	document.cookie = nom + '=' + escape(valeur) + ifpermanent;
}
function accordion() {
	$('#accordion > div').hide();
	$('#accordion h3 a').each(function(){
		$(this).click(function(){
			$('#accordion > div').hide();
			$(this).parent().next().slideDown();
			return false;
		});
	});
	//$('#accordion > div:first').slideDown();
}

var timer = null;
var height = null;
function animation_news() {

}
function scroll() {

	clearTimeout(timer);
	var top = $('#news_content ul').css('margin-top');
	top = top.replace('px','');
	top -= 2;

	if(-top > height)
		top = 0;

	$('#news ul').css('margin-top', top);
	timer = setTimeout('scroll()',100);
}
$(document).ready(initSite);

