window.onerror=null;

var strErrorInit="<b>Le formulaire n'a pas &eacute;t&eacute; envoy&eacute;, certains champs du formulaire posent un probl&egrave;me, veuillez les corriger et envoyer de nouveau le formulaire. Merci!</b><br/><br/>";

function textareaLimit(){
	$('.textarea1000').keyup(function(){
		var maxChars = 1000;
		var text = $(this).val(); 
		
		if(text.length > maxChars){
			$(this).val(text.substr(0, maxChars));
		}

		$(this).parent().find('.msglimitchars').html('Vous pouvez saisir encore <b>' + (maxChars - $(this).val().length) + '</b> caract&egrave;re(s).');
	});
	
	$('.textarea1000').keyup();
}

function zoomArticle(){
	$("a.slideshow").lightBox({
		imageBtnClose: '/img/lightbox-btn-close.gif',
		imageLoading: '/img/lightbox-ico-loading.gif',
		imageBtnPrev: '/img/lightbox-btn-prev.gif',
		imageBtnNext: '/img/lightbox-btn-next.gif',
		txtImage: 'Photo',
		txtOf: 'sur',
		fixedNavigation:true,
		overlayBgColor: '#e4d9bf'
	});
}

function zoomBloc(){
	$("a.slideshowbloc").lightBox({
		imageBtnClose: '/img/lightbox-btn-close.gif',
		imageLoading: '/img/lightbox-ico-loading.gif',
		imageBtnPrev: '/img/lightbox-btn-prev.gif',
		imageBtnNext: '/img/lightbox-btn-next.gif',
		txtImage: 'Photo',
		txtOf: 'sur',
		fixedNavigation:true,
		overlayBgColor: '#e4d9bf'
	});
}

var currentIdActivite = 1;
function slideshowActivitesStart(){
	setTimeout(slideshowActivites,2000);
}

function slideshowActivites(){
	var nextIdActivite = currentIdActivite + 1;
	var divNextSelected=document.getElementById("activite"+nextIdActivite);
	if(divNextSelected!=null){
		divNextSelected.style.display = "block";		
	}else{
		var nextIdActivite = 1;
		var divNextSelected=document.getElementById("activite"+nextIdActivite);
		if(divNextSelected!=null){
			divNextSelected.style.display = "block";
		}
	}
	
	var divCurrentSelected=document.getElementById("activite"+currentIdActivite);
	if(divCurrentSelected!=null){
		divCurrentSelected.style.display = "none";
	}
	
	currentIdActivite = nextIdActivite;
	
	setTimeout(slideshowActivites,2000);
}

$(document).ready(function(){
	textareaLimit();
	zoomArticle();
	zoomBloc();
	slideshowActivitesStart();
});