window.onload 	= onWindowResize;
window.onresize = onWindowResize;

var flashWidth 	= 960;
var flashHeight = 690;

function message() {
  alert("The window has been resized!");
}


function onWindowResize(){
	var windowD = getWindowDimensions();
	var documentD = getDocumentDimensions();
	changePositions( windowD[0], windowD[1], documentD[0], documentD[1] );
}


/* changePositions
 * changes the position of the flash movie and the background image
 */
function changePositions( windowW, windowH, documentW, documentH ){
	
	//alert( documentW + " - " + documentH );
	
	var x = (windowW-flashWidth)/2;
	var y = (windowH-flashHeight)/2;
	
	if( x < 0 ) x = 0;
	if( y < 0 ) y = 0;
	
	var highlightWrapper = document.getElementById("highlightWrapper");	
	var highlight = document.getElementById("highlight");
	var flash = document.getElementById("wrapper");
	
	if( windowW < flashWidth ) {
		highlightWrapper.style.width = flashWidth+"px";
	}else{
		highlightWrapper.style.width = "100%";
	}
	if( windowH < flashHeight ) {
		highlightWrapper.style.height = flashHeight+"px";
	}else{
		highlightWrapper.style.height = "100%";
	}
	
	flash.style.position = "absolute";
	flash.style.marginLeft = "-"+(flashWidth/2)+"px";
	flash.style.marginTop = "-"+(flashHeight/2)+"px";
	flash.style.left = ((flashWidth/2) + x) +"px";
	flash.style.top = ((flashHeight/2) + y) + "px";
	
	highlight.style.marginLeft= "-1443px";
	highlight.style.marginTop = "-1243px";
	highlight.style.top = ((flashHeight/2) + y) + "px";
	highlight.style.left = ((flashWidth/2) + x) + "px";		
	
}



function getDocumentDimensions(){
	
	var D = document;
	
	var dWidth = 0, dHeight = 0;
	
	dWidth = Math.max(
		Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
	);
	
	dHeight =  Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
    
    return[dWidth, dHeight];

}



/* getWindowDimensions
 * returns the window dimension
 */
function getWindowDimensions(){

  var myWidth = 0, myHeight = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return [ myWidth, myHeight ];
}