function init() {
	if ($('.article-content').size()) {
		initArticles();
	}
	if ($('#universe-selector')) {
		initUniversesSelector();
	}
	if ($('.datepicker')) {
		initDatePicker();
	}
	initLang();
	equalize();
	
	sfhover();
	
	initSlideshow();
	
}

function sfhover() {
	sfHover = function() {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
}

function initDatePicker()
{
	//console.log('test');
	$.datepicker.setDefaults($.datepicker.regional['fr']);
	$('#date_visit').datepicker({ dateFormat: 'dd/mm/yy' });
}

function initArticles(){
	$(".article-sections").accordion({ 
		collapsible: true, 
		active: false,
		autoHeight : false
	});
}

function initSlideshow() {
	if($('#main-presentation').length) {
		
	$('#main-presentation').lofJSidernews( {
		wapperSelector		: '#wrapper-slide',
		navItemsSelector    : '#nav-slide li',
		interval			: 7000,
		easing				: 'easeInOutQuad',
		duration			: 1200,
		auto				: true,
		maxItemDisplay		: 4,
		startItem			: 0,
		navPosition			: 'vertical', // horizontal
		navigatorHeight		: 25,
		navigatorWidth		: 25,
		mainWidth			: 970
	});
	
	}
}

function initLang() {
	$('#lang-list').hide();
		
	 $('#trigger').click(function(event){
		$('#lang-list').stop(true,true).slideToggle();  
	});
}

function equalize() {
	if($('.equalize').length) $('.equalize').equalHeightColumns();
}


function initUniversesSelector()
{
	var ulSize = 0;

	$('#universe-selector li').each(function(index, element){
	    ulSize += $(element).outerWidth();
	});
	
	$('#universe-selector ul').css('width', ulSize);
	var activeIndex = 0;
	$('#universe-selector li').each(function(index, element){
		if ($(element).hasClass('active')) {
			activeIndex = index;
		}
	});
	
	$('#universe-selector').serialScroll({
		items:'li',
		prev:'#universe-selector-prev',
		next:'#universe-selector-next',
//		offset:-230, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:activeIndex, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});
}
$(init);
