function get_url(el)
{
	var a = el.getElementsByTagName("a");
	if (a[0]) {
		return a[0].getAttribute('href');
	}
}

var colors =    ["#484", "#080", "#660", "#840", "#066", "#555"];
var colors_hi = ["#696", "#2a2", "#882", "#a62", "#188", "#777"];
var color_table = [];

function my_random()
{
	my_random.seed = (my_random.seed * 9301 + 49297) % 233280;
	return my_random.seed;
}

my_random.seed = 123;

function el_id(el)
{
	if (! el.id) {
		el.id = "elid" + (++el_id.counter);
	}

	return el.id;
}

el_id.counter = 0;

function config_blk(li, i)
{
	var el = li[i];
	var k = my_random() % colors.length;
	window.color_table[i] = k;
	var url = get_url(el);

	if (url) {
		el.onmouseup = function () {
			document.location = url;
		};
	}

	el.style.cursor = "pointer";
	el.style.backgroundColor = window.colors[k];

	/*
	var id = el_id(el);
	var st = document.getElementsByTagName('style');
	var hov = "#" + id +
		":hover { background-color: " +
		window.colors_hi[k] + "; }";
	var ho = document.createTextNode(hov);
	st[0].appendChild(ho);
	*/

	el.onmouseover = function () {
		el.style.backgroundColor = window.colors_hi[k];
	};

	el.onmouseout = function () {
		el.style.backgroundColor = window.colors[k];
	};
}

function init_page()
{
	if (document.getElementsByClassName == undefined) {
		document.getElementsByClassName = function(className)
		{
			var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
			var allElements = document.getElementsByTagName("*");
			var results = [];

			var element;
			for (var i = 0; (element = allElements[i]) != null; i++) {
				var elementClass = element.className;
				if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
					results.push(element);
			}

			return results;
		}
	}

	var li = document.getElementsByClassName('homeblk2');

	for (var i = 0; i < li.length; ++i) {
		config_blk(li, i);
	}
}

window.onload = init_page;

