var GlobalWidth, GlobalHeight;

/****************************************************************/
// Init - called from onload event
/****************************************************************/
function init() {
	
	getSize();
	handleResize(); 
}

/************************************
// Set CSS style value
************************************/
function setStyle (objid, style, value) {
	var e = document.getElementById(objid);
	if (e != null)
		e.style[style]= value;
}

/****************************************************************/
// Set div dimensions based on screen size
/****************************************************************/
function handleResize() {
	var w;

	getSize();     // get dimensions

	var height = GlobalHeight;  
	var width = GlobalWidth;    

	if (GlobalWidth > 860) 
		w = 800;
	else 
		w = GlobalWidth;

	if (w != 0)
	    setStyle('content', 'width', (w - 60) + 'px');	       
}  

/************************************
// Get window height
************************************/
/* function windowHeight() {
	// Standard browsers
	if (self.innerHeight)
		return self.innerHeight;
	// IE 6+
	if (document.documentElement && document.documentElement.clientHeight)
		return y = document.documentElement.clientHeight;
	// just in case
	return 0;
} */ 

/************************************
// Get window width
************************************/
/* function windowWidth() {
  	// Standard browsers
	if (self.innerWidth)
		return self.innerWidth;
	// IE 6+
	if (document.documentElement && document.documentElement.clientWidth)
		return y = document.documentElement.clientWidth;
	// just in case  
	return 0;
} */

/************************************
// Not sure why this is needed
************************************/
function resizeFunction() {
	handleResize()
}

/************************************
// getSize - Get window size
// from: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
************************************/
function getSize() {
  GlobalWidth = 0;
  GlobalHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    GlobalWidth = window.innerWidth;
    GlobalHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    GlobalWidth = document.documentElement.clientWidth;
    GlobalHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    GlobalWidth = document.body.clientWidth;
    GlobalHeight = document.body.clientHeight;
  }
  // window.alert( 'Width = ' + GlobalWidth );
  // window.alert( 'Height = ' + GlobalHeight );
}

/************************************/
/* Set window event procs           */
/************************************/
window.onload = init;
window.onresize = resizeFunction;
