﻿/* Assign callback function to window.onload
	without overriding previously assigned callbacks from other scripts */
function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
			oldonload();
			func();
		}
	}
}

function prepareDocument()
{
	var colour_list = document.getElementById("colour_list");
	colour_list.className = "horizontal_list colour_list";
	
	var child = colour_list.firstChild;
	
	while (child != null)
	{
		while ((child != null) && ((child.tagName == null) || (child.tagName.toLowerCase() != "li")))
		{
			child = child.nextSibling;
		}
		
		if (child != null)
		{
			var theSpan = child.firstChild;
			while ((theSpan != null) && ((theSpan.tagName == null) || (theSpan.tagName.toLowerCase() != "span")))
			{
				theSpan = theSpan.nextSibling;
			}
			
			if (theSpan != null)
			{
				theSpan.onmouseover = changeColourInfo;
			}
			
			child = child.nextSibling;
		}
	}
	
	var colour_info = document.getElementById("colour_info");
	colour_info.className = "center_text colour_info";
}

function changeColourInfo()
{
	var colour_info = document.getElementById("colour_info");
	
	var colour = this.style.backgroundColor;
	var details = this.parentNode.innerHTML;
	details = details.substr(details.toLowerCase().indexOf('</span>') + 7);	
	
	if ((colour.toLowerCase() == "rgb(255, 255, 255)") || (colour.toLowerCase() == "#ffffff"))
	{
		colour += ";border:1px solid #000000;height:78px;width:78px";
	}	
	
	html = "<span style=\"float:left;height:80px;width:80px;margin-right:0.5em;background-color:" + colour + ";\">&nbsp;</span>" + details + "<br class=\"clear\" />";
	colour_info.innerHTML = html;
}

addLoadEvent(prepareDocument);