var str_divClassName_container_3COL = "content_threecol_cont";
var str_divClassName_container_3COL_bis = "notice_threeCol";


if (typeof window.addEventListener == "function")
{		
	window.addEventListener("load", function(){setTimeout(function(){initLoad()}, 100)}, false);
}
else
{
	window.attachEvent("onload", function(){setTimeout(function(){initLoad()}, 100)}, false);
}



function initLoad()
{	
	// gestion_col();
	get_maxHeight_ofcontent();
	initXHR();// setTimeout("verifXhr()", 10)
}

function gestion_col()
{
	var elmt_colDroite = document.getElementById('coldroite');
	var elmt_colGauche = document.getElementById('colgauche');
	var elmt_content = document.getElementById('content');

	var with_colDroite = (elmt_colDroite !== null && elmt_colDroite !== undefined);
	var with_colGauche = (elmt_colGauche !== null && elmt_colGauche !== undefined);
	
	if (with_colDroite && with_colGauche)
	{
		//if (elmt_colDroite.clientHeight > elmt_content.clientHeight) {elmt_content.style.height = elmt_colDroite.clientHeight - 30 +"px";}
		//if (elmt_colGauche.clientHeight > elmt_content.clientHeight) {elmt_content.style.height = elmt_colGauche.clientHeight - 30 +"px";}
		
		
		if (elmt_content.clientHeight > elmt_colGauche.clientHeight){elmt_colGauche.style.height = elmt_content.clientHeight + 30  + "px";}
	}
	else if (with_colDroite)
	{
		if (elmt_colDroite.clientHeight > elmt_content.clientHeight) {elmt_content.style.height = elmt_colDroite.clientHeight - 30 +"px";}
	}
	else if (with_colGauche)
	{
		if (elmt_colGauche.clientHeight > elmt_content.clientHeight) {elmt_content.style.height = elmt_colGauche.clientHeight - 30 +"px";}
		if (elmt_content.clientHeight > elmt_colGauche.clientHeight){elmt_colGauche.style.height = elmt_content.clientHeight + 30  + "px";}if (elmt_content.clientHeight > elmt_colGauche.clientHeight){elmt_colGauche.style.height = elmt_content.clientHeight + 30  + "px";}
	}
}

function get_maxHeight_ofcontent()
{
	this.all_div = document.getElementsByTagName('div')
	this.tabDiv = new Array();
	this.tabDl = new Array();
	
	/* on récupere chaque div contenu dans le div container */
	this.getAllDiv_toResize = function()
	{
		this.tabDiv[this.tabDiv.length] = curDiv
	}
	
	//on analyse chaque div
	for (var i=0; i<all_div.length; i++) 
	{
		this.curDiv = all_div[i];
		
		if (this.curDiv.className.indexOf(str_divClassName_container_3COL) > -1 || this.curDiv.className.indexOf(str_divClassName_container_3COL_bis) > -1)
		{

			this.getAllDiv_toResize()
			
			for (var iNode=0; iNode < this.tabDiv[this.tabDiv.length -1].childNodes.length; iNode++)
			{
				if (tabDiv[0].childNodes[iNode].tagName == "DL")
				{
					
					this.tabDl[this.tabDl.length] = tabDiv[this.tabDiv.length -1].childNodes[iNode];
						
					if (this.tabDl.length == 3)
					{  
						for (var iNode_dl=0; iNode_dl < this.tabDl[0].childNodes.length; iNode_dl++)
						{
							redim_col(this.tabDl, iNode_dl);
						}
					}
					
					
					
				}
				if (this.tabDiv.length == 3) {redim_col(this.tabDiv, iNode);}
			}
			
			if (this.curDiv.className.indexOf(str_divClassName_container_3COL_bis) > -1)
			{ 
				this.tabDiv = new Array();
				this.tabDl = new Array();
			}
			else if (this.tabDl.length == 3)
			{
				this.tabDiv = new Array();
				this.tabDl = new Array();
			}
			
			
		}
	}
	
	
}

function redim_col(thisTab, iNode)
{
	if (thisTab[0] !== undefined && thisTab[1] !== undefined && thisTab[2] !== undefined && thisTab[0].childNodes[iNode].tagName !== undefined)
	{
		var iMax_1  = thisTab[0].childNodes[iNode].offsetHeight;
		var iMax_2  = thisTab[1].childNodes[iNode].offsetHeight;
		var iMax_3  = thisTab[2].childNodes[iNode].offsetHeight;

		var padding_top_1 = thisTab[0].childNodes[iNode].style.paddingTop.replace(/px/g, '');
		var padding_top_2 = thisTab[1].childNodes[iNode].style.paddingTop.replace(/px/g, '');
		var padding_top_3 = thisTab[2].childNodes[iNode].style.paddingTop.replace(/px/g, '');

		var padding_bottom_1 = thisTab[0].childNodes[iNode].style.paddingBottom.replace(/px/g, '');
		var padding_bottom_2 = thisTab[1].childNodes[iNode].style.paddingBottom.replace(/px/g, '');
		var padding_bottom_3 = thisTab[2].childNodes[iNode].style.paddingBottom.replace(/px/g, '');


		if (iMax_1 >= iMax_2 && iMax_1 >= iMax_3 )
		{
			if (iMax_1 > iMax_2)
			{thisTab[1].childNodes[iNode].style.paddingBottom = (iMax_1 - iMax_2 + padding_bottom_2) + "px";}
			
			if (iMax_1 > iMax_3)
			{thisTab[2].childNodes[iNode].style.paddingBottom = (iMax_1 - iMax_3 + padding_bottom_3) + "px";}
			
			
		}
		else if (iMax_2 >= iMax_1 && iMax_2 >= iMax_3)
		{
			if (thisTab[0].childNodes[iNode].tagName == "DT" && thisTab[0].childNodes[iNode].className == "img")
			{
				if (iMax_2 > iMax_1)
				{
					thisTab[0].childNodes[iNode].style.paddingTop = ((iMax_2 - iMax_1) / 2 + padding_top_1) + "px";
					thisTab[0].childNodes[iNode].style.paddingBottom = ((iMax_2 - iMax_1) / 2 + padding_bottom_1) + "px";
				}

						
				if (iMax_2 > iMax_3)
				{
					thisTab[2].childNodes[iNode].style.paddingTop = ((iMax_2 - iMax_1) / 2 + padding_top_3) + "px";
					thisTab[2].childNodes[iNode].style.paddingBottom = ((iMax_2 - iMax_1) / 2 + padding_bottom_3) + "px";
				}
			}
			else
			{
				if (iMax_2 > iMax_1)
				{thisTab[0].childNodes[iNode].style.paddingBottom = (iMax_2 - iMax_1 + padding_bottom_1) + "px";}

						
				if (iMax_2 > iMax_3)
				{thisTab[2].childNodes[iNode].style.paddingBottom = (iMax_2 - iMax_3 + padding_bottom_3) + "px";}
			}
		}
		else if (iMax_3 >= iMax_1 && iMax_3 >= iMax_2)
		{
			if (iMax_3 > iMax_1)
			{thisTab[0].childNodes[iNode].style.paddingBottom = (iMax_3 - iMax_1 + padding_bottom_1) + "px";}
			
			if (iMax_3 > iMax_2)
			{thisTab[1].childNodes[iNode].style.paddingBottom = (iMax_3 - iMax_2 + padding_bottom_2) + "px";}
			//thisTab[2].childNodes[iNode].style.height = iMax_3 + "px";
		}
	}
}
