

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);
	}
	
	
	if (window.innerWidth) {
		width = window.innerWidth;
	} else if (document.body.clientWidth) {
		width = document.body.clientWidth;
	}
}

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%";
	}
}

function determineHPos(hpWidth, hpMaxWidth)
{
	if (hpWidth > hpMaxWidth) {
		return parseInt((hpWidth - hpMaxWidth) / 2) + "px";
	} else {
		return 0;
	}
}