

function initRestrictWidth()
{
	// Only use restrictWidth if screen is wide enough, saves CPU time for user
	if (screen.width > max_width) {
		/////////////////////////////////////// CHECK HERE IF ADDONLOAD/RESIZE FUNCTIONS EXIST
		window.addOnload(restrictWidth);
		window.addOnresize(restrictWidth);
	}
	// Add height positioning regardless of screen height
	window.addOnload(restrictHeight);
	window.addOnresize(restrictHeight);
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (document.body.clientWidth) {
		width = document.body.clientWidth;
	}
	
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (document.body.clientHeight) {
		height = document.body.clientHeight;
	} else if (document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	} else {
		alert("No Height");
	}
}

function restrictWidth()
{
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (document.body.clientWidth) {
		width = document.body.clientWidth;
	}

	if(width != prev_width) {
		if (width <= min_width) {
			//document.getElementById("restrict_width").style.width = min_width + "px";
			document.getElementById("restrict_width").style.left = 0;
		} else {
			// Determine width
			//document.getElementById("restrict_width").style.width = determineHSize(width, max_width);
			document.getElementById("restrict_width").style.left = determineHPos(width, max_width);
		}
		prev_width = width;
	}
}

function determineHSize(hsWidth, hsMaxWidth)
{
	if (hsWidth > hsMaxWidth) {
		// Client window is greater than the max width of the page
		return hsMaxWidth + "px";
	} else {
		// Client window is smaller than max width of page so use full width
		//return "100%";
		// Full width - 40
		return hsWidth + "px";
	}
}

function determineHPos(hpWidth, hpMaxWidth)
{
	if (hpWidth > hpMaxWidth) {
		return parseInt((hpWidth - hpMaxWidth) / 2) + "px";
	} else {
		return 0 + "px";
	}
}


function restrictHeight()
{
	if (window.innerHeight) {
		height = window.innerHeight;
	} else if (document.body.clientHeight) {
		height = document.body.clientHeight;
	} else if (document.documentElement.clientHeight) {
		height = document.documentElement.clientHeight;
	}

	if(height != prev_height) {
		if (height <= min_height) {
			//document.getElementById("restrict_height").style.height = min_height + "px";
			document.getElementById("restrict_width").style.top = 0;
		} else {
			// Determine height
			//document.getElementById("restrict_height").style.height = determineHSize(height, max_height);
			document.getElementById("restrict_width").style.top = determineVPos(height, max_height);
		}
		prev_height = height;
	}
}


function determineVPos(vpHeight, vpMaxHeight)
{
	if (vpHeight > vpMaxHeight) {
		return parseInt((vpHeight - vpMaxHeight) / 2) + "px";
	} else {
		return 0 + "px";
	}
}