// JavaScript Document

window.GetHeight = function(){
	if( window.innerHeight != null ){
		return( window.innerHeight );
	}
	else{
		return document.body.clientHeight;
	}
}

window.GetWidth = function(){
	
	if( window.innerWidth != null ){
		return( window.innerWidth );
	}
	else{
		return document.body.clientWidth ;
	}
}

var imageHeight = 480;
var imageWidth = 640;

function ScaleImage(){
	var iHeight = window.GetHeight();
	var iWidth = window.GetWidth();
	var BgPhotoDiv = document.getElementById( "backgroundImageDiv" );
	var BgPhoto = document.getElementById( "backgroundImage" );
	var Stretcher = document.getElementById( "stretcher" );

	var newHeight = 0;
	var newWidth = 0;
	
	var differenceHeight = iHeight / imageHeight;
	var differenceWidth = iWidth / imageWidth;

		if( differenceWidth < differenceHeight)
		{
			newHeight = iHeight;
			newWidth = (iHeight * imageWidth) / imageHeight;
		}
		
		else
		{
			newHeight = (iWidth * imageHeight) / imageWidth;
			newWidth = iWidth;
		}
	
	BgPhoto.style.height = Math.ceil (newHeight) + "px";
	BgPhoto.style.width = Math.ceil (newWidth) + "px";
	
	BgPhotoDiv.style.height = Math.ceil (iHeight) + "px";
	BgPhotoDiv.style.width = Math.ceil (iWidth) + "px";

	Stretcher.style.height = Math.ceil (iHeight) + "px";
	Stretcher.style.width = Math.ceil (iWidth) + "px";
	window.onresize = ScaleImage;
}//end ScaleImage
