function getBrowserWindowHeight() {
  if( typeof( window.innerHeight) == 'number' ) {
    //Non-IE
    return window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight) {
    //IE 4 compatible
    return document.body.clientHeight;
  }
}


function getBrowserWindowWidth() {
  if( typeof( window.innerWidth) == 'number' ) {
    //Non-IE
    return window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth) {
    //IE 6+ in 'standards compliant mode'
    return document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth) {
    //IE 4 compatible
    return document.body.clientWidth;
  }
}

function getBrowserScrollTop() {
  if( typeof(window.pageYOffset) == 'number' ) {
    //Netscape compliant
    return window.pageYOffset;
  } else if(document.body && document.body.scrollTop) {
    //DOM compliant
    return document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop) {
    //IE6 standards compliant mode
    return document.documentElement.scrollTop;
  } else {
  	return 0;
  }
}

function getBrowserScrollLeft() {
  if( typeof( window.pageXOffset ) == 'number' ) {
    //Netscape compliant
	return window.pageXOffset;
  } else if( document.body && document.body.scrollLeft) {
    //DOM compliant
	return document.body.scrollLeft;
  } else if( document.documentElement && document.documentElement.scrollTop) {
    //IE6 standards compliant mode
   	return document.documentElement.scrollLeft;
  } else {
  	return 0;
  }
}

/* works in ie and firefox - not in opera*/
/*function getDocumentHeight() {
	if (document.documentElement.scrollHeight) {
		return document.documentElement.scrollHeight;
	} else if (document.body.scrollHeight){
		return document.documentElement.clientHeight;
	} else {
		return document.body.offsetHeight;
	}
}*/

/*
function getDocumentHeight() {
	if( window.innerHeight && window.scrollMaxY ) {
		// Firefox 
		return window.innerHeight + window.scrollMaxY;
	} else if( document.body.scrollHeight > document.body.offsetHeight ) {
		 // all but Explorer Mac
		return document.body.scrollHeight;
	} else { 
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		return document.body.offsetHeight + document.body.offsetTop; 
	}
}*/

function getDocumentHeight() {
	return(document.getElementById('main').offsetHeight);
}

DivUtils=new Object();

DivUtils.clear=function(divObj) {
	while (divObj.hasChildNodes()) {
		divObj.removeChild(divObj.firstChild);
	}
}

DivUtils.centerOnPage=function(divObj) {
	divObj.style.left=(Math.round((getBrowserWindowWidth()-divObj.offsetWidth)/2)+getBrowserScrollLeft())+"px";
	var verticalPos=Math.round((getBrowserWindowHeight()-divObj.offsetHeight)/2)+getBrowserScrollTop();
	if (verticalPos+divObj.offsetHeight>getDocumentHeight()) {
		divObj.style.top=(getDocumentHeight()-divObj.offsetHeight)+"px";
	} else {
		divObj.style.top=verticalPos+"px";
	}
}
