jQuery(document).ready(function(){

	//Page sans sidebar (caché la sidebar et grossir le content)
	/*if(jQuery("#sidebar").is(':empty')){
		jQuery("#sidebar").hide();
		jQuery("#container").addClass("full");
		jQuery("#content").addClass("full");
	}*/
	
	
	/* go to top btn */
	//Hide ScrollTop Button
	jQuery('#gototop').hide();
	
	//Scroll to top function
	jQuery('#gototop').click(function(){
		jQuery('html, body' ).animate( { scrollTop: 0 }, "fast" );
	});
	
	jQuery(window).scroll(function() {		
		if(jQuery(window).height() >= jQuery(document).height()) jQuery('#gototop').hide();
		else jQuery('#gototop').show();	
	});
	
	
	//TXT RESIZE a/A + cookie
	var COOKIE_NAME = 'fontsize';
	var COOKIE_OPTIONS = { path: '/', expires: 365 };
	var COOKIE_SET = jQuery.cookie(COOKIE_NAME);
	var fsize;
	
	if(COOKIE_SET == null){
		jQuery("body").css({"font-size":"15px"});
		fsize= "15px";
	}else{
		jQuery("body").css({"font-size":COOKIE_SET});
		fsize= COOKIE_SET;
	}
		
	jQuery("a.textsize").click(
	function(){		
		if(fsize== "15px"){
			fsize= "18px";
			jQuery("body").css({"font-size":fsize});
			jQuery.cookie(COOKIE_NAME, fsize, COOKIE_OPTIONS);
			return false;
		}else{		
			fsize= "15px";
			jQuery("body").css({"font-size":fsize});
			jQuery.cookie(COOKIE_NAME, fsize, COOKIE_OPTIONS);
			return false;
		}
	});	
	
	
	
	// INDEX NEWS CYCLE
	jQuery('#nouvelles').cycle({ 
		fx:'scrollHorz',
	    timeout: 0, 
	    speed:500,
	    cleartype: true,
	    cleartypeNoBg:true,
	    next:'#newsNav a.next',
	    prev:'#newsNav a.prev',
	    nowrap:true,
	    fit:true,
		after: nouAfter
   	});

});

function nouAfter(curr, next, opts) {
		var index = opts.currSlide;
    	jQuery('#newsNav a.prev').css('background-position',[index == 0 ? 'bottom' : 'top']);
		jQuery('#newsNav a.next').css('background-position',[index == opts.slideCount - 1 ? 'bottom' : 'top']);
}

