/* CALCULATING HIGH/WIDTH OF CONTENT */

var ie = true;
var moz = false;

if(navigator.userAgent.indexOf("Firefox") >= 0 || document.all){
	ie = false;
	moz = true;
}


/* 
calculates the height of a different divs.
should be added to window.resize event and also called after every postback.
is also called by calcwidth(), and calcwidth is on window.resize.
*/
function neuAufbau()
{
	var Hoehe = Fensterhoehe();
	
	var hheader = dom.gI("hiddenHeaderState");
	
	// if header is existing you have to make divs higher
	if(hheader != null)
		if(hheader.value == "none")
			Hoehe += 73;
			
	if(moz)
		Hoehe -= 10;
		
	if(dom.gI("subright") != null && Hoehe > 100)
		dom.gI("subright").style.height = (Hoehe - 143) + "px";
	if(dom.gI("subleft") != null && Hoehe > 100)
		dom.gI("subleft").style.height = (Hoehe - 143) + "px";
	if(dom.gI("sublistingdiv") != null && Hoehe > 100)
		dom.gI("sublistingdiv").style.height = (Hoehe - 175) + "px";
	if(dom.gI("subcontent") != null && Hoehe > 100)
		dom.gI("subcontent").style.height = (Hoehe - 182) + "px";
	if(dom.gI("pdfframe") != null && Hoehe > 100)
		dom.gI("pdfframe").style.height = (Hoehe - 184) + "px";
	if(dom.gI("pdfframefull") != null && Hoehe > 100)
		dom.gI("pdfframefull").style.height = (Hoehe - 29) + "px";
	if(dom.gI("resultsubfield") != null && Hoehe > 100)
		dom.gI("resultsubfield").style.height = (Hoehe - 221) + "px";
	if(dom.gI("resultfield") != null && Hoehe > 100)
		dom.gI("resultfield").style.height = (Hoehe - 143) + "px";
	if(dom.gI("bookmarksdiv") != null && Hoehe > 100)
		dom.gI("bookmarksdiv").style.height = (Hoehe - 550) + "px";
	if(dom.gI("subrightfirsthalf") != null && Hoehe > 645)
		dom.gI("subrightfirsthalf").style.height = (Hoehe - 465) + "px";
	if(dom.gI("profilesubcontent") != null && Hoehe > 100)
		dom.gI("profilesubcontent").style.height = (Hoehe - 310) + "px";
	
		
}


/* 
this function sets the width of the main div and lets shrink it only to a minimum width.
should be added to window.resize event.
*/
function calcwidth()
{
	// get width of screen
	var breite = Fensterbreite();
	
	// also calculate height
	neuAufbau();
	
	// set width header
	//dom.gI("headerback").style.width = (breite - 
	
	// how much from the right?
	var offset = 414;
	// if right column is hidden make content bigger.
	if(dom.gI("subright") == null)
		offset = 239;
		
	
	if(breite > 1000){
		dom.gI("contenttable").style.width = (breite - offset) + "px";
		if(moz)
			dom.gI("headerback").style.width = (breite - offset) + "px";
	}
		

	// set width of frontaufmacher, otherwise scrollbar is under right column
	offset = 472;	
	if(dom.gI("b1") != null){
		
		// if searchresults are opened make it thinner
		if(dom.gI("resultsubfield") != null)
			offset += 210;
		
		dom.gI("b1").style.width = (breite - offset) + "px";
	}
	

}

/* returns the width of the window */
function Fensterhoehe() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
    ie = false;
  } else if( document.documentElement &&
      ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  
  } else if( document.body &&  document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  
  return myHeight;
}

/* returns the height of the window */
function Fensterbreite() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body &&  document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  
  return myWidth;
}
