
//
// +---------------------------------------------------------------------+
// | STEVENWONGPHD.COM                                                   |
// +---------------------------------------------------------------------+
// | minwidthie.js                                                       |
// | javascript functions to emulate min-width in IE                     |
// |                                                                     |
// | Dtek Digital Media, dtek.net                                        |
// | 2005.08.05                                                          |
// |                                                                     |
// +---------------------------------------------------------------------+
//

function getViewPortWidth()
{
	if (self.innerWidth)
	{ 
		// all except Explorer
		return self.innerWidth;
	} 
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		// Explorer 6 Strict Mode
		return document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		// other Explorers
		return document.body.clientWidth;
	}
}

function setContentWidth()
{
	// use this script as minimally as possible: search for positive test
	// cases where it's definitely needed.  current list:
	//	Win/Mac IE 5+
	
	// detection script taken from "The Ultimate JavaScript Client Sniffer, 
	// Version 3.03:".  yes, it's deprecated, but so is this entire hack...
	
	var agt = navigator.userAgent.toLowerCase();

	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3    = (is_ie && (is_major < 4));
	var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4") != -1) );
	var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);

	if (is_ie5up && document.getElementById)
	{
		var viewPortWidth = getViewPortWidth();

		var containerElement = document.getElementById('container');

		if (viewPortWidth < 783) // container width + page margins
		{
			//alert("viewPortWidth: " + viewPortWidth);
			containerElement.style.width = '743px'; // needed by Mac/IE
		}
		else
		{
			containerElement.style.width = 'auto';
		}
	}
}

window.onload = function()
{
	setContentWidth();
}
window.onresize = function()
{
 	setContentWidth();
}

