//pass min and max -measured against window width
function P7_MinMaxW(a,b){
	var nw="auto",w=document.documentElement.clientWidth;
	if(w>=b){nw=b+"px";}if(w<=a){nw=a+"px";}return nw;
}

////////////////////////////////

// Be sure we're working under DOM.
var DHTML = (document.getElementById || document.all);

function initScrolls() {
	var holder1= new getObj('holder1'); //document.getElementById('holder1');
  initScrollLayers(holder1.obj.offsetHeight);
  
  adjustContent();
}

function adjustContent() {
	if (!DHTML) return;
	
	if (!window.innerWidth){
    var oWinSize = getWinSize();
  } else {
    var oWinSize = getBrowserSize();
  }
	
	var oPagewrapper = new getObj('pagewrapper');
	
	if(oWinSize.height > oPagewrapper.obj.offsetHeight) {
  	var vAboveHeight = (oWinSize.height - oPagewrapper.obj.offsetHeight) / 2;
	} else {
    var vAboveHeight = 0;
  }
  
  var oTopadjustmentator = new getObj('topadjustmentator');
  oTopadjustmentator.style.height = vAboveHeight + "px";
}
	
function adjustContent_bak() {
if (!DHTML) return;
  
var oHeader = new getObj('header');
var oContent = new getObj('main');
var oFooter = new getObj('footer');
var oSidebarleft = new getObj('sidebarleft');
var oSidebarright = new getObj('sidebarright');

var oPagewrapper = new getObj('pagewrapper');


  if (!window.innerWidth){
    var oWinSize = getWinSize();
  } else {
    var oWinSize = getBrowserSize();
  }
  
  if(oWinSize.height > oPagewrapper.obj.getAttribute('maxHeight')) {
  	var vContentheight = oPagewrapper.obj.getAttribute('maxHeight') - (oHeader.obj.offsetHeight + oFooter.obj.offsetHeight + 35);
	} else {
    var vContentheight = oWinSize.height - (oHeader.obj.offsetHeight + oFooter.obj.offsetHeight + 35);
  }
  
  var vContentheight = oWinSize.height - (oHeader.obj.offsetHeight + oFooter.obj.offsetHeight + 35);
  
  // update content div height
  oContent.style.height = vContentheight + "px";
  
  oSidebarleft.style.height = vContentheight + "px";
  oSidebarright.style.height = vContentheight + "px";

  // update right div height (fix firefox container height)
  var leftmiddle= new getObj('leftmiddle'); //document.getElementById('leftmiddle');
  var menu_vert= new getObj('menu_vert'); //document.getElementById('menu_vert');
  leftmiddle.style.height = menu_vert.obj.offsetHeight + "px";

  // update right div height (fix firefox container height)
  var rightmiddle= new getObj('rightmiddle'); //document.getElementById('rightmiddle');
  var rightcenter= new getObj('rightcenter'); //document.getElementById('rightcenter');
  rightmiddle.style.height = rightcenter.obj.offsetHeight + "px";

  // update right div height (fix firefox container height)
  var holder1= new getObj('holder1'); //document.getElementById('holder1');
  var wn1= new getObj('wn1'); //document.getElementById('wn1');
  var scrollHeight = oContent.obj.offsetHeight - 50;
  holder1.style.height = scrollHeight + "px";
  wn1.style.height = scrollHeight + "px"; 

  initScrollLayers(scrollHeight);
}

// Create an object to reference a div element.
function getObj(name){
  if (document.getElementById){
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
  }
  else if (document.all){
    this.obj = document.all[name];
    this.style = document.all[name].style;
  }
}

// Determine the height and width of the viewport.

function getWinSize(){
var iWidth = 0, iHeight = 0;

if (document.documentElement && document.documentElement.clientHeight){
iWidth = parseInt(document.documentElement.offsetWidth,10);
iHeight = parseInt(document.documentElement.offsetHeight,10);
}
else if (document.body){
iWidth = parseInt(document.body.offsetWidth,10);
iHeight = parseInt(document.body.offsetHeight,10);
}

return {width:iWidth, height:iHeight};
}

// Determine the height and width of the viewport.
function getBrowserSize(){
var iWidth = 0, iHeight = 0;

if (document.documentElement.clientHeight){
iWidth = parseInt(document.documentElement.clientWidth,10);
iHeight = parseInt(document.documentElement.clientHeight,10);
}
else if (document.body){
iWidth = parseInt(document.body.offsetWidth,10);
iHeight = parseInt(document.body.offsetHeight,10);
}

return {width:iWidth, height:iHeight};
}

// Total up any border and padding applied to the right and left sides of the content division.
// These must be removed from the window offsetWidth to set the style.width for the content
// division in IE. Note that borders and padding *must* be specified in pixels for this to
// work properly.

function getExcessWidth(oContent){
var iExcess = 0;

if (window.getComputedStyle) {
iExcess = parseInt('0' + window.getComputedStyle(oContent.obj, null).getPropertyValue("padding-left"),10) +
parseInt('0' + window.getComputedStyle(oContent.obj, null).getPropertyValue("padding-right"),10) +
parseInt('0' + window.getComputedStyle(oContent.obj, null).getPropertyValue("border-left"),10) +
parseInt('0' + window.getComputedStyle(oContent.obj, null).getPropertyValue("border-right"),10);
}
else if (oContent.obj.currentStyle) {
iExcess = parseInt('0' + oContent.obj.currentStyle.paddingLeft,10) +
parseInt('0' + oContent.obj.currentStyle.paddingLeft,10) +
parseInt('0' + oContent.obj.currentStyle.borderLeft,10) +
parseInt('0' + oContent.obj.currentStyle.borderRight,10);
}

return (iExcess);
}

