// JavaScript Document

$(document).ready(function(){

	$("#prj_colab").click(function(){
		if($(this).is(":checked")) $("#colab").slideDown();
		else $("#colab").slideUp();
	});
	
	
	// Ouverture/fermeture des thématiques
	$("#thematiques h5 a").click(function(){
		if($(this).parent().next().css("display") == "block"){
			$(this).parent().next().slideUp();
			$(this).parent().find("img").attr("src",$(this).parent().find("img").attr("src").replace("moins","plus"));
		}else{
			$(this).parent().next().slideDown();
			$(this).parent().find("img").attr("src",$(this).parent().find("img").attr("src").replace("plus","moins"));
		}
		return false;
	});
	
	// Ouverture en blank
	$("a.blank").click(function(){
		$(this).attr("target","_blank");							
	});
	
	
	// Ouverture du textarea
	
	$("textarea").keyup(function(){
		var long = $(this).val().length;
		var id = $(this).attr("id");
		var total = $("#compteur_" + id + " span.total").html();
		var reste = total - long;
		
		//console.log("long : "+long+" / id : "+ id +" /  total : "+total+" / reste :" + reste);
		
		if(reste < 0) $(this).val($(this).val().substring(0,total));
		else $("#compteur_" + id + " span.nb").html(reste);
	});
	
	$(".fr .stbuttontext").html("Partagez");
						   
});