window.onload = function() {
     
	ResizeAllBlogBills();
	ResizeHeight();
    
}

window.onresize = function() {
     
    ResizeAllBlogBills();
    ResizeHeight();
    
}


function ResizeHeight() {

    //calcul hauteur content. 290 = hauteur du header 54 = hauteur du bottom
    var hauteur_content = document.getElementById("content_panel").offsetHeight; 
    hauteur_content += 290+54;
    
    //calcul position basse de la dernière image du content.
    var tabImgHeight = new Array ();
    var divContent = document.getElementById("content_panel");
    var tabImgElmt = divContent.getElementsByTagName("img");  

    var max = 0;  
    for(var i=0; i<tabImgElmt.length; i++){
        lastImg = tabImgElmt[i];
        hauteur_image = lastImg.offsetTop + lastImg.height + 100;
        if (hauteur_image>max)
            max = hauteur_image;
    }
    
    maxHeightImg = max + 290 + 54;  
    
    
    //calcul position basse de la dernière image du content    
    var max = Math.max(maxHeightImg,hauteur_content);    
    
    
    var hauteur_content = Math.max(hauteur_content,max);
    
     var hauteur_menu_gauche = document.getElementById("menu_gauche").offsetHeight; 
    hauteur_menu_gauche += 108+54;
       
    var hauteur_page = (document.body.clientHeight);
    
    var max = Math.max(hauteur_content,hauteur_menu_gauche);
    var max = Math.max(hauteur_page,max);
    max = max+30;
    
  
    document.getElementById("menu_gauche_ombrage_bas_droite").style.top = max-170+"px";    
    document.getElementById("background_left_bottom_column").style.top = max-54+"px";    
    document.getElementById("bottom_panel").style.top = max-54+"px";    
    document.getElementById("menu_gauche").style.height = max-108-54+"px";        
    document.getElementById("ombrage_bas_droit").style.top = max-170+"px";    
    document.getElementById("bottom_background").style.top = max-54+"px";
    
        
    //Redimension largeur pour ie7
    var strChNav = navigator.userAgent;
    
    //IE7            
    var isIE = strChNav.indexOf("MSIE");
	if(isIE != -1) 
	{
		var versionNb = strChNav.substring(isIE+5, isIE+8);
		if (versionNb >= 7)
		{
			var largeur = 686;
	         if (document.body.clientWidth < 1050)
	            largeur = 686;
	        else if (document.body.clientWidth < 1100)
	            largeur = 736;
	        else if (document.body.clientWidth < 1150)
	            largeur = 786;
	        else if (document.body.clientWidth < 1200)
	            largeur = 836;
	        else if (document.body.clientWidth < 1250)
	            largeur = 886;
            else if (document.body.clientWidth < 1290)
                largeur = 940;    
	        else if (document.body.clientWidth >= 1250)
	            largeur = 986;
	
	        document.getElementById("content_panel").style.width = largeur+"px";
        }
	}
    
    
    document.getElementById("bottom_panel").style.visibility = "visible"; 
    document.getElementById("menu_gauche").style.visibility = "visible";    
    document.getElementById("ombrage_bas_droit").style.visibility = "visible"; 
    document.getElementById("bottom_background").style.visibility = "visible"; 
  
    document.getElementById("menu_gauche_ombrage_bas_droite").style.visibility = "visible"; 
    document.getElementById("background_left_bottom_column").style.visibility = "visible"; 
    
}

function ResizeAllBlogBills()
{
      jQuery("div.blog_bill").each(function (i) {
            ResizeBlogBillsWidth(this.id.substring(5));
      });
}

function ResizeBlogBillsWidth(billId)
{
    //alert(billId);
    var billwidth = jQuery("#blog_right_column").offset().left - jQuery("#bill_"+billId).offset().left - 50;
    
    if (document.getElementById("bill_"+billId) != null)
        document.getElementById("bill_"+billId).style.width = billwidth + "px";    
    
    setTimeout(function(){ ResizeAdminZone(billId, billwidth); }, 100);
    
}
function ResizeAdminZone(billId, billwidth)
{
    var azeName = "admin_zone_edit_" + billId;    
    if (document.getElementById(azeName) != null)
        document.getElementById(azeName).style.width = billwidth + "px";
    
    var commentName = "bill_comment_link_" + billId; 
    billwidth += 10; 
    if (document.getElementById(commentName) != null)
        document.getElementById(commentName).style.width = billwidth + "px";
}


    