
checkBrowserHeight();

attachEventListener(window, "resize", checkBrowserHeight, false);




function checkBrowserHeight()
{
	var theHeight = getBrowserHeight();
	
	if (theHeight == 5)
	{
		var resolutionCookie = document.cookie.match(/(^|;)tmib_res_layout[^;]*(;|$)/);

		if (resolutionCookie != null)
		{
			setStylesheet(unescape(resolutionCookie[0].split("=")[1]));
		}
		
		addLoadListener(checkBrowserHeight);
		
		return false;
	}

	if (theHeight < 655)
	{
		setStylesheet("600");
		document.cookie = "tmib_res_layout=" + escape("600");
	}
	else if (theHeight < 705)
	{
		setStylesheet("650");
		document.cookie = "tmib_res_layout=" + escape("650");
	}	
	else if (theHeight < 755)
	{
		setStylesheet("700");
		document.cookie = "tmib_res_layout=" + escape("700");
	}	
	else if (theHeight < 805)
	{
		setStylesheet("750");
		document.cookie = "tmib_res_layout=" + escape("750");
	}	
	else if (theHeight < 855)
	{
		setStylesheet("800");
		document.cookie = "tmib_res_layout=" + escape("800");
	}	
	else if (theHeight < 905)
	{
		setStylesheet("850");
		document.cookie = "tmib_res_layout=" + escape("850");
	}	
	else if (theHeight < 955)
	{
		setStylesheet("900");
		document.cookie = "tmib_res_layout=" + escape("900");
	}	
		
	else if (theHeight < 1005)
	{
		setStylesheet("950");
		document.cookie = "tmib_res_layout=" + escape("950");
	}	
	else
	{
		setStylesheet("1000");
		document.cookie = "tmib_res_layout=" + escape("1000");
	}
	
	return true;
};




function getBrowserHeight()
{
	if (window.innerHeight)
	{
		return window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight != 5)
	{
		return document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		return document.body.clientHeight;
	}
	
	return 0;
};




function setStylesheet(styleTitle)
{
	var currTag;

	if (document.getElementsByTagName)
	{
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
		{
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
			{
				currTag.disabled = true;

				if(currTag.getAttribute("title") == styleTitle)
				{
					currTag.disabled = false;
				}
			}
		}
	}
	
	return true;
};