
/* jquery.news-slider.js */
jQuery.fn.slideNews = function(settings) {
	settings = jQuery.extend({
		headline: "Top Stories",
		newsWidth: 250,
		newsHeight: 55,
		newsSpeed: "normal",
		nbItem: 4,
		scrollType: "horizontal"
	}, settings);
	return this.each(function(i){
		jQuery(".messaging",this).css("display","none");
		
		jQuery(".footer_logo",this).css("overflow","hidden");
		jQuery(".footer_logo_int",this).css("overflow","hidden");
		jQuery(".footer_logo_int",this).css("position","relative");
		jQuery(".container",this).css("left","0px");
		jQuery(".container",this).css("top","0px");
		jQuery(".container",this).css("position","relative");
		
		itemLength = jQuery(".item",this).length;
		
		if (settings.scrollType=='horizontal')
		{
			newsContainerSize = itemLength * settings.newsWidth;
			jQuery(".container",this).css("width",newsContainerSize + "px");
			jQuery(".footer_logo",this).css("width",settings.newsWidth * settings.nbItem + "px");
		}
		else
		{
			newsContainerSize = itemLength * settings.newsHeight;
			jQuery(".container",this).css("height",newsContainerSize + "px");
			jQuery(".footer_logo",this).css("height",settings.newsHeight * settings.nbItem + "px");
		}

		animating = false;
		jQuery(".next",this).click(function() {
			thisParent = jQuery(this).parent().parent();
			if (animating == false) {
				animating = true;
				if (settings.scrollType=='horizontal') {
					animate = parseInt(jQuery(".container",thisParent).css("left")) - (settings.newsWidth * settings.nbItem);
					if (animate + parseInt(jQuery(".container",thisParent).css("width")) > 0) {
						jQuery(".container",thisParent).animate({left: animate}, settings.newsSpeed, function() {
							jQuery(this).css("left",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				} else {
					animate = parseInt(jQuery(".container",thisParent).css("top")) - (settings.newsHeight * settings.nbItem);
					if (animate + parseInt(jQuery(".container",thisParent).css("height")) > 0) {
						jQuery(".container",thisParent).animate({top: animate}, settings.newsSpeed, function() {
							jQuery(this).css("top",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				}

			}

			return false;
		});
		jQuery(".prev",this).click(function() {
			thisParent = jQuery(this).parent().parent();
			if (animating == false) {
				animating = true;
				if (settings.scrollType=='horizontal') {
					animate = parseInt(jQuery(".container",thisParent).css("left")) + (settings.newsWidth * settings.nbItem);
					if ((animate + parseInt(jQuery(".container",thisParent).css("width"))) <= parseInt(jQuery(".container",thisParent).css("width"))) {
						jQuery(".container",thisParent).animate({left: animate}, settings.newsSpeed, function() {
							jQuery(this).css("left",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				} else {
					animate = parseInt(jQuery(".container",thisParent).css("top")) + (settings.newsHeight * settings.nbItem);
					if ((animate + parseInt(jQuery(".container",thisParent).css("height"))) <= parseInt(jQuery(".container",thisParent).css("height"))) {
						jQuery(".container",thisParent).animate({top: animate}, settings.newsSpeed, function() {
							jQuery(this).css("top",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				}
			}

			return false;
		});
	});
};







$(document).ready(function()
{
	
	// liens d'evitement
	$(".accessibilite").addClass('accessibilite_off');
	$(".accessibilite a").focus(function(){
		$("../../..", this).removeClass('accessibilite_off');
	});

	$(".accessibilite a").blur(function(){
		$("../../..", this).addClass('accessibilite_off');
	});
	
	//menu deroulant
	$(".nav_main ul li").hover(function() {
		$(this).toggleClass('active');
		$(this).addClass('item_on');
  	}, function() {
		$(this).toggleClass('active');
		$(this).removeClass('item_on');
	});
	


	
	$(".block_foldable").addClass('off');
	$(".block_foldable.view").removeClass('off');
	$(".block_foldable .title").click(function(){
		$(".. .block_foldable", this).toggleClass('off');
	}); 
	
	$(".view_all").click(function(){
		$(".block_foldable").removeClass('off');
	}); 
	
	$(".print").click(function(){
		window.print();
	}); 


	var options = {
		//newsWidth: 150,
		newsWidth: 150,
		newsHeight: 55,
		newsSpeed: "normal",
		nbItem: 4
	}
	$(".footer_logo").slideNews(options);

	//tableau triable, page capital investissement
	$("#sortedtable").tablesorter(
	{
		sortList: [[0,0], [1,0], [2,0]],
		cssAsc: "up",
		cssDesc: "down"
	}); 
});


