function styleForum(x){
	var height	= $("forum"+x).getStyle("height");
	if(height!="0px"){
		$("forum"+x).setStyle("height","0px");
		$("forum"+x).setStyle("overflow","hidden");
	}else{
		$("forum"+x).setStyle("height","auto");
		$("forum"+x).setStyle("overflow","visible");
	}
}
function styleTopic(x){
	var height	= $("cat"+x).getStyle("height");
	if(height!="0px"){
		$("cat"+x).setStyle("height","0px");
		$("cat"+x).setStyle("overflow","hidden");
		$("cat"+x).setStyle("display","none");
		$('reduir'+x).style.backgroundPosition	= "-176px 0px";
	}else{
		$("cat"+x).setStyle("height","auto");
		$("cat"+x).setStyle("overflow","visible");
		$("cat"+x).setStyle("display","block");
		$('reduir'+x).style.backgroundPosition	= "-189px 0px";
	}
}
function updateDateConnexion(){
	var XHR = new XHRConnection();
	XHR.appendData("d", "");
	XHR.sendAndLoad(URL_WEB+"content/php/userDateConnexion.php", "POST", afficherUpdate);
}
function afficherUpdate(obj){
	tabResult = obj.responseXML.getElementsByTagName('retour');
	switch(tabResult[0].firstChild.data){
		case'1':
			tabResult = obj.responseXML.getElementsByTagName('html');
			ouvrirPopIn(tabResult[0].firstChild.data,200,50);
			break;
		case'0':
			ouvrirPopIn('Echec de l\'action.',200,50);
			break;
	}
}
function initContentMenu(){
	$('menu').setStyle("width",32);
	$$('#menu .pub').setStyle('display','none');
	$('content').setStyle("width",956);
	fx4 = new Fx.Styles($('menu'), {wait: false, fps:20, duration: 300});
	fx5 = new Fx.Styles($('content'), {wait: false, fps:20, duration: 240});
	$('menu').addEvent("mouseenter", function(event) {
		fx4.stop();
		fx4 = new Fx.Styles($('menu'), {wait: false, fps:20, duration: 300});
		fx4.start({'width' : 260}).chain(function(){
			$$('#menu .pub').setStyle('display','block');
		});
		fx5.stop();
		fx5 = new Fx.Styles($('content'), {wait: false, fps:20, duration: 240});
		fx5.start({'width' : 728});
	});
	$('menu').addEvent("mouseleave", function(event) {
		fx4.stop();
		fx4 = new Fx.Styles($('menu'), {wait: false, fps:20, duration: 240});
		$$('#menu .pub').setStyle('display','none');
		fx4.start({'width' : 32});
		fx5.stop();
		fx5 = new Fx.Styles($('content'), {wait: false, fps:20, duration: 300});
		fx5.start({'width' : 956});
	});
}
function loadListeForum(){
	var szFull3		= [];
	var szSmall3	= [];

	// messages
	var messages = $$(".messageDetail");
	if(messages.length>0){
		// ferme les autres topics
		/*var topic	= $$(".cat");
		if(topic){
			topic.each(function(top, i) {
				if(messages[0].parentNode.parentNode.id!=top.getLast(".forum").id){
					var link	= top.getFirst(".titre").getFirst(".nom").getFirst();
					document.location.href    = link.href;
				}
			});
		}*/
		// action sur les messages
		fx3 = new Fx.Elements(messages, {wait: false, duration: 700, transition: Fx.Transitions.Expo.easeOut});
		if(messageActuel3=="" && messages[0])
			messageActuel3	= messages[0].id;

		var o = {};
		messages.each(function(mess, i) {
			szFull3[i]	= mess.getStyle("height").toInt();
			var titre	= mess.getElements('.titre')[0];
			szSmall3[i]	= titre.getStyle("height").toInt();
			szSmall3[i]	+= titre.getStyle("paddingTop").toInt();
			szSmall3[i]	+= titre.getStyle("paddingBottom").toInt();
			var option	= mess.getElements('.option')[0];
			szSmall3[i]	+= option.getStyle("height").toInt();
			szSmall3[i]	+= option.getStyle("paddingTop").toInt();
			szSmall3[i]	+= option.getStyle("paddingBottom").toInt();
			if(mess.id!=messageActuel3){
				o[i] = {height: [szFull3[i], szSmall3[i]]}
			}
		});
		fx3.start(o);

		messages.each(function(mess, i) {
			mess.addEvent("mouseenter", function(event) {
				fx3.stop();
				var o = {};
				if(mess.id!=messageActuel3)
					o[i] = {height: [mess.getStyle("height").toInt(), szFull3[i]]};
				messages.each(function(other, j) {
					if(i != j && other.id!=messageActuel3) {
						var w = other.getStyle("height").toInt();
						if(w != szSmall3[j]) o[j] = {height: [other.getStyle("height").toInt(), szSmall3[j]]};
					}else if(other.id==messageActuel3)
						o[j] = {height: [other.getStyle("height").toInt(), szFull3[j]]};
				});
				fx3.start(o);
			});
			mess.addEvent("mouseleave", function(event) {
				fx3.stop();
				var o = {};
				if(mess.id!=messageActuel3)
					o[i] = {height: [mess.getStyle("height").toInt(), szSmall3[i]]}
				messages.each(function(other, j) {
					if(i != j && other.id!=messageActuel3) {
						var w = other.getStyle("height").toInt();
						if(w != szSmall) o[j] = {height: [other.getStyle("height").toInt(), szSmall3[j]]};
					}else if(other.id==messageActuel3)
						o[j] = {height: [other.getStyle("height").toInt(), szFull3[j]]};
				});
				fx3.start(o);
			});
		});
	}
}

window.addEvent('domready', function(){
	// mise en place de l'effet avec le menu pour agrandir le forum
	initContentMenu();
	// chargement des roll-over de forum sur le load du DOM
	if($$('#milieu .cat').length>1)
		loadListeForum();
});