$(document).ready(function(){
  MakeLayout("container","content",800,1200,1600);
});

function MakeLayout(id,id2,minr,maxw,maxr){
  if(document.getElementById){
    SetHeight(id,id2,minr,maxw,maxr);
    window.onresize=function(){SetHeight(id,id2,minr,maxw,maxr);}
    }
}

function SetHeight(id,id2,a,b,c){
  var w=getBrowserHeight();
  
  if (w <= 600){
    var barra_top  = 40;
    var barra_down = 40;
  }
  else{
    var barra_top  = 70;
    var barra_down = 70;
  }

  var content_home_height = w-barra_top-barra_down;
  
  if (document.getElementById("content_top1"))
    document.getElementById("content_top1").style.height  = barra_top+"px";
  
  if (document.getElementById("content_top2")){
    document.getElementById("content_top2").style.height  = barra_top+"px";
    document.getElementById("header").style.paddingTop = (barra_top-40)+"px";  
  }

  
  if (document.getElementById("content_down1"))
    document.getElementById("content_down1").style.height = barra_down+"px";
  
  if (document.getElementById("content_down2"))
    document.getElementById("content_down2").style.height = barra_down+"px";
  
  document.getElementById("content_body").style.height = content_home_height+"px";
  
  if (document.getElementById("content_index")){
    document.getElementById("content_index").style.height = (content_home_height)+"px";
    document.getElementById("content_index").style.marginTop = ((content_home_height-254)/2)+"px";
  }
  
  if (document.getElementById("content_home")){
    document.getElementById("content_home").style.height = (content_home_height)+"px";
  }
  
  if (document.getElementById("content")){
    document.getElementById("content").style.height = (content_home_height)+"px";
    document.getElementById("content").style.marginTop = ((content_home_height-415)/2)+"px";
  }
  
  if (document.getElementById("content2")){
    document.getElementById("content2").style.height = (content_home_height)+"px";
    document.getElementById("content2").style.marginTop = ((content_home_height-415)/2)+"px";
  }
  
  if (document.getElementById("contatti")){
    document.getElementById("contatti").style.height = (content_home_height)+"px";
    document.getElementById("contatti").style.marginTop = ((content_home_height-415)/2)+"px";
  }
  
  if (document.getElementById("notizie")){
    document.getElementById("notizie").style.height = (content_home_height)+"px";
    document.getElementById("notizie").style.marginTop = ((content_home_height-415)/2)+"px";
  }
  
  if (document.getElementById("lavora-con-noi")){
    document.getElementById("lavora-con-noi").style.height = (content_home_height)+"px";
    document.getElementById("lavora-con-noi").style.marginTop = ((content_home_height-415)/2)+"px";
  }
  
  if (document.getElementById("break_home"))
    document.getElementById("break_home").style.height = (content_home_height-50)+"px"; 
}

function getBrowserWidth(){
  if (window.innerWidth) return window.innerWidth;
  else if (document.documentElement && document.documentElement.clientWidth!=0)
      return document.documentElement.clientWidth;
  else if (document.body) return document.body.clientWidth;
  return 0;
}

function getBrowserHeight(){
  if (window.innerHeight) return window.innerHeight;
  else if (document.documentElement && document.documentElement.clientHeight!=0)
      return document.documentElement.clientHeight;
  else if (document.body) return document.body.clientHeight;
  return 0;
}