
/* Function to get the window width & height including the scrolling area */

function getPageSize( )
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY)
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;

	if (self.innerHeight)
	{	// all except Explorer
		if(document.documentElement.clientWidth)
			windowWidth = document.documentElement.clientWidth; 
		
		else
			windowWidth = self.innerWidth;
	
		windowHeight = self.innerHeight;
	}
	
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
		pageHeight = windowHeight;
		
	else 
		pageHeight = yScroll;

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
		pageWidth = xScroll;		
	
	else
		pageWidth = windowWidth;

	return [pageWidth,pageHeight];
}

/* End Function */

function height() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function check() {
  //alert('window height: '+height()+"\n\n"+'content height: '+(document.getElementById('content').offsetHeight+200));
  var bottom = document.getElementById('bottom');

  var background = document.getElementById('background');
  var backgroundquiz = document.getElementById('backgroundquiz');

  var content = document.getElementById('content');
	
  if((content.offsetHeight+300) < height()) {
    
    if (background)
    {
    	background.style.height = height()+'px';
    	background.style.overflow = 'hidden';
    }
    
    if (backgroundquiz)
    {
    	backgroundquiz.style.height = height()+'px';
    	backgroundquiz.style.overflow = 'hidden';
    }    
    
    bottom.style.position = 'absolute';
    bottom.style.bottom = '0px';
    bottom.style.left = '-451px';
    bottom.style.margin = '0px 0px 0px 50%';
  }
  
  else
  {
    if (background)
    {
    	if(height() < 701) background.style.overflow = 'hidden';
    	background.style.height = (content.offsetHeight+300)+'px';
    }
    
    if (backgroundquiz)
    {
    	if(height() < 701) backgroundquiz.style.overflow = 'hidden';
    	backgroundquiz.style.height = (content.offsetHeight+280)+'px';
    }    

    bottom.style.position = 'relative';
  }
  
  /* Code to adjust the position of the game */

  var game = document.getElementById('game');
  
  if (game)
  {
  	var iPageSize = getPageSize( );
  	game.style.display = "block";
  	game.style.left = ((((parseInt(iPageSize[0]) - 900) / 2) + 527) + "px");
  	game.style.top  = ((parseInt(iPageSize[1]) - 374) + "px");
  }

  /* End game code */
  
  setTimeout("check()", 100);
}

var set = 0;
function rollover(obj) {
  if(set == 0) {
    var name = obj.src.replace(".gif", "");
    obj.src = name+"over.gif";
    set = 1;
  } else {
    var name = obj.src.replace("over.gif", "");
    obj.src = name+".gif";
    set = 0;
  }
}


window.onload = function() {
	check();
}

