// JavaScript Document

function layoutFix(frame) {
	frame.style.height = getInnerHeight(frame);
	fix();
}

function layoutFix2(frame) {
	var dims = getDimensions ( this);

	frame.style.height = getInnerHeight(frame);

	document.body.style.height = (dims.windowHeight ) + "px";
}
function layoutFix3() {
	var dims = getDimensions ( this);
	document.body.style.height = (dims.windowHeight ) + "px";
}

function fix() {
	var dims = getDimensions ( this);
	document.getElementById("content").style.height =  (dims.windowHeight-350) + "px";
	document.getElementById("mainc").style.height =  (dims.windowHeight-350) + "px";
}

function getInnerHeight(iframe){
 var d=iframe.contentWindow ?
         iframe.contentWindow.document :
         iframe.contentDocument;
 var h=0;
 if(d){
  if(d.documentElement && d.compatMode &&
     d.compatMode=="CSS1Compat")
   h=d.documentElement.scrollHeight;
  else if(d.body)
   h=d.body.scrollHeight;
  if(h) h+=getInsets(d);
 } return (h||300)+"px"; //300 is a default value
}

function getInsets(d){
/* if(d.body.currentStyle)
  with (d.body.currentStyle)
   return (parseInt(marginTop)||0) + 
          (parseInt(marginBottom)||0) +
          (parseInt(paddingTop)||0) + 
          (parseInt(paddingBottom)||0);
 if(d.defaultView && d.defaultView.getComputedStyle)
  with (d.defaultView)
   return parseInt(getComputedStyle(d.body,"").
            getPropertyValue("margin-top"))+
          parseInt(getComputedStyle(d.body,"").
            getPropertyValue("margin-bottom"))+
          parseInt(getComputedStyle(d.body,"").
            getPropertyValue("padding-top"))+
          parseInt(getComputedStyle(d.body,"").
            getPropertyValue("padding-bottom"));*/
 return 0;
}

function getDimensions (windowOrFrame) {
   var dims = { };
   if (typeof windowOrFrame.innerHeight != 'undefined') {
     dims.windowWidth = windowOrFrame.innerWidth;
     dims.windowHeight = windowOrFrame.innerHeight;
     dims.documentWidth = windowOrFrame.document.width;
     dims.documentHeight = windowOrFrame.document.height;
   } else if ( windowOrFrame.document.body && typeof windowOrFrame.document.body.offsetWidth != 'undefined') {
     var doc = windowOrFrame.document;
     if (doc.compatMode && doc.compatMode != 'BackCompat') {
       dims.windowWidth = doc.documentElement.offsetWidth;
       dims.windowHeight = doc.documentElement.offsetHeight;
       dims.documentWidth = doc.documentElement.scrollWidth;
       dims.documentHeight = doc.documentElement.scrollHeight;
     } else {
       dims.windowWidth = doc.body.offsetWidth;
       dims.windowHeight = doc.body.offsetHeight;
       dims.documentWidth = doc.body.scrollWidth;
       dims.documentHeight = doc.body.scrollHeight;
     }
   } return dims;
}

