$(document).ready(function(){								
	var islist;
	var listhtml;
	
	listhtml = $('#midlist').html();

		$("#midlist img, #liens img").css("opacity","0.88");
		
		$("#midlist img, #liens img").bind("mouseover", function(e){
													 var t=$(this);
													 t.css("opacity","1");
													 });	
		$("#midlist img, #liens img").bind("mouseout", function(e){
													 var t=$(this);
													 t.css("opacity","0.88");
													 });	

	if (listhtml!=null) {
	
		islist = true;
		
		var tdcount = $('#midlist tr td').length;
		var currentWidth = 185*(tdcount+1);
		var s = $('#midlist tr td:last img').attr('src');
		
		 $("#midlist").css("width",currentWidth+"px");
		 
			var o = $('#midlist tr td').eq(0).find('img');						 		
				o.attr('src',o.attr('srcok'));
				o.attr('srcok','');
				o = $('#midlist tr td').eq(6).find('img');						 		
				o.attr('src',o.attr('srcok'));
				o.attr('srcok','')				


			 $("#flechedroite a").bind("click", function(e){	 	 
					e.preventDefault();	
					$(this).blur();
					
					$('#midlist').stop(false,true);
	
					var currentMargin = $("#midlist").css("margin-left");
					currentMargin = Number(currentMargin.replace("px",""));
					
					var newMargin = currentMargin-185;

					$("#midlist").animate({ 
						marginLeft: newMargin+"px"			
					  }, 500, "", function() {		
							var o = $('#midlist tr td').eq(7).find('img');						 
							if (o.attr('srcok')!='') {
								o.attr('src',o.attr('srcok'));
								o.attr('srcok','')
							}
							$('#midlist').css("margin-left",currentMargin+'px');
							$('#midlist tr').append($('#midlist tr td:first'));
							
					  });
			});
			 
		 $("#flechegauche a").bind("click", function(e){	 	 
				e.preventDefault();	
				$(this).blur();
				
			    $('#midlist').stop(false,true);
				
				var currentMargin = $("#midlist").css("margin-left");
				currentMargin = Number(currentMargin.replace("px",""));
							
				var newMargin = currentMargin+185;
												
				$("#midlist").animate({ 
					marginLeft: newMargin+"px"			
				  }, 500, "", function() {
						  $('#midlist tr').prepend($('#midlist tr td:last'));
							var o = $('#midlist tr td:first img');
							if (o.attr('srcok')!='') {
								o.attr('src',o.attr('srcok'));
								o.attr('srcok','')
							}
							$('#midlist').css("margin-left",currentMargin+'px');
							
						
				  });
		});	
		 
		 
		
		 
	} else {
		islist = false;
		
		var divdescription = $('#fichedescription').html();
		if (divdescription!=null) {
			$('#fichedescription').css('overflow','hidden');
			
			var texteheight = $('#fichedescription div').height();
			
			var currentMargin = $("#fichedescription div").css("margin-top");
			currentMargin = Number(currentMargin.replace("px",""));
								
			if (texteheight>120) {
				//ajoute fleche scrolling
				$("#grandeflechedroite").append('<ul id="petiteflechebas"><li id="flechebas"><a href=""></a></li></ul>');
				$("#grandeflechedroite").append('<ul id="petiteflechehaut"><li id="flechehaut"><a href=""></a></li></ul>');
				$("#flechehaut").hide();
				
				//ajout on click sur cette fleche				
				
				 $("#flechebas a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#fichedescription div').height();
						
						var currentMargin = $("#fichedescription div").css("margin-top");
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = -texteheight+120;
						
						var newMargin = Math.max(currentMargin-115,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechebas").hide();					
						} 

						if (newMargin<0) {
							$("#flechehaut").show();					
						} else {
							$("#flechehaut").hide();
						}
						
						$("#fichedescription div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
				});

				 $("#flechehaut a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#fichedescription div').height();
						
						var currentMargin = $("#fichedescription div").css("margin-top");
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = 0;
						
						var newMargin = Math.min(currentMargin+115,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechehaut").hide();					
						} 

							$("#flechebas").show();
						
						
						$("#fichedescription div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
				});
				 
			}				
			
		}
		
	 
	}
	
	 var isnewspage = $('#nouvellestitres').html();
		if (isnewspage!=null) {	
		
			$('#nouvellestitres').css('overflow','hidden');
			$('#nouvellesdetails').css('overflow','hidden');
			$("#nouvellestitres div").css("margin-top","0px");
			$("#nouvellesdetails div").css("margin-top","0px");
			
			//== ajoute fleche section titre nouvelle
			
			var texteheight = $('#nouvellestitres div').height();			
			var currentMargin = $("#nouvellestitres div").css("margin-top");
			currentMargin = Number(currentMargin.replace("px",""));
								
			if (texteheight>240) {
				//ajoute fleche scrolling
				$("#nouvellesbottom").html('<ul id="petiteflechebas"><li id="flechebas"><a href=""></a></li></ul>');
				$("#nouvellestop").html('<ul id="petiteflechehaut"><li id="flechehaut"><a href=""></a></li></ul>');
				$("#flechehaut").hide();
				$("#flechehaut").css('left','150px').css('top','20px');
				$("#flechebas").css('left','160px').css('top','20px');
					
				
				//ajout on click sur cette fleche				
				
				 $("#flechebas a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#nouvellestitres div').height();
						
						var currentMargin = $("#nouvellestitres div").css("margin-top");						
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = -texteheight+240;
						
						var newMargin = Math.max(currentMargin-235,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechebas").hide();					
						} 
						

						if (newMargin<0) {
							$("#flechehaut").show();					
						} else {
							$("#flechehaut").hide();
						}
						
						
						$("#nouvellestitres div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
						
				});

				 $("#flechehaut a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#nouvellestitres div').height();
						
						var currentMargin = $("#nouvellestitres div").css("margin-top");
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = 0;
						
						var newMargin = Math.min(currentMargin+235,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechehaut").hide();					
						} 

							$("#flechebas").show();
						
						
						$("#nouvellestitres div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
				});
			}
			
			//== ajoute fleche section details nouvelle
			var texteheight = $('#nouvellesdetails div').height();			
			var currentMargin = $("#nouvellesdetails div").css("margin-top");
			currentMargin = Number(currentMargin.replace("px",""));
								
			if (texteheight>240) {
				//ajoute fleche scrolling
				$("#nouvellesbottom").append('<ul id="petiteflechebas2"><li id="flechebas2"><a href=""></a></li></ul>');
				$("#nouvellestop").append('<ul id="petiteflechehaut2"><li id="flechehaut2"><a href=""></a></li></ul>');
				$("#flechehaut2").hide();
				$("#flechehaut2").css('left','696px').css('top','12px');
				$("#flechebas2").css('left','696px').css('top','12px');
					
				
				//ajout on click sur cette fleche				
				
				 $("#flechebas2 a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#nouvellesdetails div').height();
						
						var currentMargin = $("#nouvellesdetails div").css("margin-top");						
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = -texteheight+240;
						
						var newMargin = Math.max(currentMargin-235,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechebas2").hide();					
						} 
						

						if (newMargin<0) {
							$("#flechehaut2").show();					
						} else {
							$("#flechehaut2").hide();
						}
						
						
						$("#nouvellesdetails div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
						
				});

				 $("#flechehaut2 a").bind("click", function(e){	 	 
						e.preventDefault();	
						$(this).blur();
						
						var texteheight = $('#nouvellesdetails div').height();
						
						var currentMargin = $("#nouvellesdetails div").css("margin-top");
						currentMargin = Number(currentMargin.replace("px",""));
						
						var maxMargin = 0;
						
						var newMargin = Math.min(currentMargin+235,maxMargin);
						if (newMargin==maxMargin) {
							$("#flechehaut2").hide();					
						} 

							$("#flechebas2").show();
						
						
						$("#nouvellesdetails div").animate({ 
							marginTop: newMargin+"px"			
						  }, 500 );
				});
			}			
		}

});