MakeLayout("container",720,995,1024,"cielo",420,900,1024);

function MakeLayout(id,minr,maxw,maxr,id2,minrh,maxh,maxrh){
if(document.getElementById){
    SetWidth(id,minr,maxw,maxr);
		SetHeight(id2,minrh,maxh,maxrh);
    window.onresize=function(){ 
				SetWidth(id,minr,maxw,maxr);
				SetHeight(id2,minrh,maxh,maxrh);
			}
    }
}

function SetWidth(id,a,b,c){
var w=getBrowserWidth()-30;
if(w==0) return;
var el=document.getElementById(id);
el.style.margin="0 auto";
var d=el.style;
if(w<=a) d.width=a+"px";
else if(w>=c) d.width=b+"px";
else{
    var m=(b-a)/(c-a);
    d.width=parseInt(m*w+a*(1-m))+"px";
    }
}


function SetHeight(id,a,b,c){
var h=getBrowserHeight(); 
var w=getBrowserWidth();
if(h==0) return;
var el=document.getElementById(id);
//el.style.margin="0 auto";
el.width="500px";
//window.alert(id+"  "+w+" x "+h+"("+a+","+b+","+c+")");

if(h<=a) {
	//d.width=a+"px";
	
	el.height=0; //Leo
	
}
else if(h>=c) el.height=h-b;//d.width=b+"px";
else{
    el.height=h-a*(w/h)/0.88;
		//var m=(b-a)/(c-a);
    //d.width=parseInt(m*w+a*(1-m))+"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(){ //Leo
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;
}