


attachEventListener(window, "resize", checkBrowserWidth, false);
attachEventListener(window, "maximize", checkBrowserWidth, false);
attachEventListener(window, "motion", checkBrowserWidth, false);

function fixElements() 
{
  var height = 0;
  var target = document.getElementById('visual');
  
  if (target) {
    height = target.offsetHeight;
  }

  if (height > 20) {
    target.style.display = 'block';
  }
  else {
    target.style.display = 'none';
  }
	
}

function checkBrowserWidth()
{
	var theWidth = getBrowserWidth();
	
	if (theWidth == 0)
	{
		addLoadListener(checkBrowserWidth);
		
		return false;
	}

	var theHeight = 0;

	var target = document.getElementById('sidebar');
	if (target) {
	  theHeight = target.offsetHeight;
	} 

	if ((theWidth > 990) )
	{
	  var target = document.getElementById('container');
	  if (target) {
	    target.className = "container";
	  }
	  var target = document.getElementById('sidebar');
	  if (target) {
	    target.className = "sidebar";
	  }
	}
	else
	{
	  var target = document.getElementById('container');
	  if (target)
	  {
	    target.className = "containersmall";
	  }
	  var target = document.getElementById('sidebar');
	  if (target)
	  {
	    target.className = "sidebarbottom";
	  }
	}

	return true;
};




function getBrowserWidth()
{
	if (window.innerWidth)
	{
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0)
	{
		return document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		return document.body.clientWidth;
	}
	
	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;
};
