
$(document).ready(function(){
	
	constructFranchiseBlock();
	constructGalleryFade();

});


function constructFranchiseBlock(){


	$('.franchiseCol-1 div[class^=blockFranchise-]').each(function(){

		var blockEl = $(this);
		var textEl = blockEl.find('.textContinue');
		var textElHeight = textEl.height();

		if(isIE){
			textEl.css({
				height:0
			});
		}else{
			textEl.css({
				opacity:0,
				height:0
			});
		}
		var buttonEl = blockEl.find('a.jsReadMore');

		buttonEl.unbind('click').click(function(){
			if(buttonEl.hasClass('activ')){
				buttonEl.removeClass('activ');
				if(isIE){
					textEl.animate({
						height: 0
					},500,function(){
						textEl.css('display','none');
					});
				}else{
					textEl.animate({
						height: 0,
						opacity: 0
					},500);
				}
				buttonEl.find('span').html('Lire la suite');
				buttonEl.closest('div').removeClass('btnFoldUp');
			}else{
				buttonEl.addClass('activ');
				if(isIE){
					textEl.animate({
						height: textElHeight
					},500,function(){
						textEl.css('height','auto');
					});
				}else{
					textEl.animate({
						height: textElHeight,
						opacity: 1
					},500);
				}
				buttonEl.find('span').html('Replier');
				buttonEl.closest('div').addClass('btnFoldUp');
			}
			return false;
		});


	});

}

function constructGalleryFade(){

	$('.franchiseCol-1 div[class^=blockFranchise-] div.imageGallery').fadingGallery({
			fadeTime: 600,
			stayTime: 4500	
	});

}



