caleFooter = function () {
	//calage du footer avec le bas de la colonne de gauche
	var bottom = 0;
	var txt = "";
	for(var i = 0; i < $("#colgauche").children().length; i++) {
		var marge = parseInt($("#colgauche").children().gt(i-1).css("margin-top").substr(0, $("#colgauche").children().gt(i-1).css("margin-top").length -2));
//		showBloc(i+1, bottom, $("#colgauche").children().gt(i-1).height() + (!isNaN(marge) ? marge : 0));
		bottom += $("#colgauche").children().gt(i-1).height() + (!isNaN(marge) ? marge : 0);
		txt += $("#colgauche").children().gt(i-1).attr("id") + " + " + $("#colgauche").children().gt(i-1).height() + " + " + marge + "\n";
		
/*		var pos = bottom - ($.browser.msie ? $("#footer").height() : 0);
		window.alert($("#colgauche").children().gt(i-1).attr("id"));
		$("#footer").css("margin-top", pos+"px");*/
	}
	
	
	var pos = bottom - ($.browser.msie ? $("#footer").height() : 0);
	
	if($("#home").length > 0){
		pos -= $("#home").height();
		txt += "home - " + $("#home").height();
		
/*		window.alert("home = " + $("#home"));
		$("#footer").css("margin-top", pos+"px");*/
	}
	
	if($("#main").length > 0){
		pos -= $("#main").height();
		txt += "main - " + $("#main").height();
		
/*		window.alert("main");
		$("#footer").css("margin-top", pos+"px");*/
	}
	
	
	if(pos < 0) pos = 0;
	$("#footer").css("margin-top", pos+"px");
	
//	window.alert(txt + " - " +  $("#footer").height() + "\n\n" + $("#footer").css("margin-top"));
	
	
	//hauteur du fond de page
	var scrh = document.body.clientHeight;
	/*var contenth = $("#footer").height() + pos + parseInt($("#footer").css("margin-bottom").substr(0, $("#footer").css("margin-bottom").length -2));
	if($("#home").length > 0){
		contenth += $("#home").height();
	}
	if($("#main").length > 0){
		contenth += $("#main").height();
	}


	var h = Math.max($("#colgauche").height(), contenth);
	var pgh = scrh;

	if(!$.browser.msie) {
		h += parseInt($("#page").css("padding-bottom").substr(0, $("#page").css("padding-bottom").length -2));
		pgh -= parseInt($("#page").css("padding-bottom").substr(0, $("#page").css("padding-bottom").length -2));
	}// else h += 8;
	
	var debug = "Contenth = " + contenth + "\n"
	debug += "\ncolgauche :" + $("#colgauche").height() + "\n";
	debug += "\npage = " + $("#page").height() + "\n";
	debug += "\nMain :\n";
	debug += "h = " + $("#main").height() + "\n";
	debug += "mt = " + parseInt($("#main").css("margin-top").substr(0, $("#main").css("margin-top").length -2)) + "\n";
	debug += "mb = " + parseInt($("#main").css("margin-bottom").substr(0, $("#main").css("margin-bottom").length -2)) + "\n";
	debug += "pt = " + parseInt($("#main").css("padding-top").substr(0, $("#main").css("padding-top").length -2)) + "\n";
	debug += "pb = " + parseInt($("#main").css("padding-bottom").substr(0, $("#main").css("padding-bottom").length -2)) + "\n";
	debug += "\nFooter :\n";
	debug += "h = " + $("#footer").height() + "\n";
	debug += "mt = " + parseInt($("#footer").css("margin-top").substr(0, $("#footer").css("margin-top").length -2)) + "\n";
	debug += "mb = " + parseInt($("#footer").css("margin-bottom").substr(0, $("#footer").css("margin-bottom").length -2)) + "\n";
	debug += "pt = " + parseInt($("#footer").css("padding-top").substr(0, $("#footer").css("padding-top").length -2)) + "\n";
	debug += "pb = " + parseInt($("#footer").css("padding-bottom").substr(0, $("#footer").css("padding-bottom").length -2)) + "\n";
	debug += "\nh = " + h + "\n";
	debug += "\nscrh = " + scrh + "\n";
	debug += "\npgh = " + pgh + "\n";
	window.alert(debug);
	//window.alert("h = " + h + ", scrh = " + scrh + ", pgh = " + pgh);
	if(h < scrh) $("#page").height(pgh);*/
	
	if($("#page").height() < scrh) $("#page").height(scrh+5);
}

$(document).ready(caleFooter);

showBloc = function(idx, top, height, color) {
	if(color == null) color = "red";
	var bloc = document.createElement("div");
	bloc.id = "contour" + idx;
	document.body.appendChild(bloc);
	$("#" + bloc.id).css("position", "absolute").css("border", "1px "+color+" solid").css("width", "100px").css("top", top+"px").css("height", height+"px");
}
