initStylesheets();

schedule("styleSwitcher", initStyleSwitcher);




function initStylesheets()
{

	setStylesheet("JavaScript", false, true);
	
	if (getCookie("styleWhite") == "true")
	{
		setStylesheet("White", false, false);
	}
	
	return true;
}





function initStyleSwitcher()
{
	var theBlack = document.getElementById("styleSwitcherBlack").getElementsByTagName("a")[0];
	var theWhite = document.getElementById("styleSwitcherWhite").getElementsByTagName("a")[0];
	
	theBlack.onclick = switchBlack;
	theBlack.onmouseover = setStatus;
	theBlack.onmouseout = function()
		{
			setStatus(true);
			
			return true;
		};
		
	theWhite.onclick = switchWhite;
	theWhite.onmouseover = setStatus;
	theWhite.onmouseout = function()
		{
			setStatus(true);
			
			return true;
		};
	
	return true;
}




function setStylesheet(styleTitle, styleStatus, reset)
{
	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"))
			{
				if (reset)
				{
					currTag.disabled = true;
				}

				if(currTag.title == styleTitle)
				{
					if (styleStatus == "switch" && currTag.disabled == true)
					{
						currTag.disabled = false;
					}
					else if (styleStatus == "switch")
					{
						currTag.disabled = true;
					}
					else
					{
						currTag.disabled = styleStatus;
					}
				}
			}
		}
	}
	
	return true;
}




function setStatus(reset)
{
	if (reset)
	{
		window.status = "";
	}
	else
	{
		window.status = this.title;
	}
	
	return true;
}




function switchBlack()
{
	setStylesheet("White", true, false);
	document.getElementsByTagName("body")[0].style.backgroundColor = "#000000";
	
	return false;
}




function switchWhite()
{
	setStylesheet("White", false, false);
	document.getElementsByTagName("body")[0].style.backgroundColor = "#FFFFFF";
	
	return false;
}
