// GLOBALS
//var maxW = 1900; // Max Width the site is allowed to go
var minW = 960; // Min Width the site is allowed to go
//var maxH = 1200; // Max Height the site is allowed to go
var minH = 500; // Min Height the site is allowed to go

var sizeW = minW; // This will be the width of the content
var sizeH = minH; // This will be the height of the content
var viewW = minW; // This will be the width of the browser
var viewH = minH; // This will be the height of the browser
var padV = 0; // Vertical padding on the site sections
var padH = 0; // Horizontal padding on the site sections

// Adjust everything on the site based on the window size
function resize()
{
//	wrapper.style.width = "100%";
//	wrapper.style.height = "100%";
	$(barHandle).style.width = Math.ceil(wrapper.offsetWidth * 0.02) +"px";
	$(rightBar).style.left = $(barHandle).offsetWidth +"px";
	if(barShow) $(rightBarWrap).style.width = $(barHandle).offsetWidth + barWidth +"px";
	else $(rightBarWrap).style.width = $(barHandle).offsetWidth +"px";
	if($("left_"+currentPage))
	{
		$(leftNavActive).style.top = $("left_"+currentPage).offsetTop+"px";
		$(leftNavActive).style.height = $("left_"+currentPage).offsetHeight+"px";
	}
	
	viewW = wrapper.offsetWidth - ($(rightBarWrap).offsetWidth - $(barHandle).offsetWidth) - $(leftNavContainer).offsetWidth;
	viewH = wrapper.offsetHeight - $(topNavContainer).offsetHeight;
	
	if(viewW < minW) sizeW = minW;
//	else if(viewW > maxW) sizeW = maxW;
	else sizeW = viewW;
	if(viewH < minH) sizeH = minH;
//	else if(viewH > maxH) sizeH = maxH;
	else sizeH = viewH;
	if(sizeW / sizeH < 1.92) sizeH = Math.ceil(sizeW / 1.92);
	else if(sizeW / sizeH > 1.92) sizeW = Math.ceil(sizeH * 1.92);
	
	if(viewH - sizeH <= 0) padV = 0;
	else padV = Math.floor((viewH - sizeH) / 2);
	if(viewW - sizeW <= 0) padH = 0;
	else padH = Math.floor((viewW - sizeW) / 2);
	
	pages.each(function(page){
		page.style.width = sizeW +"px";
		page.style.height = sizeH +"px";
		page.style.margin = $(topNavContainer).offsetHeight +"px "+ padH +"px "+ (padV*2) +"px "+ (padH + $(leftNavContainer).offsetWidth) +"px";
	});
	topNavGroups.each(function(group){
		group.style.width = Math.ceil(wrapper.offsetWidth * 0.81) +"px";
	});
	
	if($("top_"+currentPage+"_"+currentSect[currentPage]))
	{
		$(topNavActive).style.left = $("top_"+currentPage+"_"+currentSect[currentPage]).offsetLeft + $(topNavBack).offsetWidth +"px";
		$(topNavWrap).style.width = topButtonsWidth * $(topNavWrap).getElements("."+topNavButtonsClass).length +"px";
	}
}
