// Fonctions ANACT

$(document).ready(function() {
	$('body').addClass("hazJS");
	initFormulaire();
	initCufon();
	initHauteur();

});

function initCufon(){
	if (!$.browser.msie) {
			Cufon.replace('.cuf');
	};
	// alert($.browser.version);
	if ($.browser.msie) {
		Cufon.replace('#home #top .cuf, #bannerCopenhague .cuf, h1.cuf');
	};

}

function initHauteur(){
	// Hauteur égale pour les blocs de une centraux
	var biggestHeight = 0;
	var $center_Une = $('#center .une');
	var nUne = $center_Une.length;
	for (var i=0; i<nUne; i++) {
		var lastHeight = $center_Une.eq(i).height();
		if ( lastHeight > biggestHeight) {
			biggestHeight = lastHeight;
		};
	}
	if (biggestHeight !=0) {
		$center_Une.height(biggestHeight);
	};
	
}

function initFormulaire(){
	// Mise en forme formulaires
	$('input:text').addClass('inptTxt');
	$('input:button').addClass('inptBtn');

	// Accès au formulaire de commentaires
	if (!$.browser.msie) {
		var boiteAcom = $('#makeComment');
		var titreComs = $('#accesCom');	
		
		boiteAcom.hide();
		titreComs.text("+ " + titreComs.text()).wrapInner('<a href="#"></a>').find('a').click(function() {
			if (boiteAcom.is(":hidden")) {
				boiteAcom.slideDown();
			} else {
				boiteAcom.slideUp();
			}
			return false;
		});
	}



	// Affichage des commentaire suivants
	var comments = $('#comList .com');
	if(comments.length>3){
		$('#comList:last').append('<div id="nextComs"><a href="#">› Commentaires suivants</a></div>');
		for(var i=3;i<comments.length;i++){
			$(comments[i]).hide();
		}

		$('#nextComs').click(function(){
			var comments = $('#comList .com');
			$(comments).each(function(){$(this).show()});
			$('#nextComs').hide();
			return false;
		});

	}
}



