window.onload = function () {
	addOnClicktoColours();
	addOnClicktoItem();
}

function addOnClicktoItem() {
	if (document.getElementById && document.getElementById('item')) {
		var link = document.getElementById('item').parentNode;
		link.onclick = popupImageItem;
	}
}

function popupImageItem() {
	if (document.getElementById && window.open) {
		var thisdate = new Date();
		var url = this.href;
		var popup = window.open(url,thisdate,"width=440,height=650,left=200,top=0,resizable=yes,scrollbars=yes");
		if (window.focus) {
			popup.focus();
		}
		return false;
	} else {
		return true;
	}
}

function addOnClicktoColours() {
	if (document.getElementById && document.getElementById('colours')) {
		var children = document.getElementById('colours').getElementsByTagName('a');
		if (0 < children.length) {
		for (i = 0; i < children.length; i++) {
			children[i].onclick = showPic;
		}
		}
	}
}

function showPic () {
	if (document.getElementById && document.getElementById('item')) {
		var image = document.getElementById('item');
		image.src = this.href;
		image.parentNode.href = this.href;
		if (this.title) {
			document.getElementById('caption').childNodes[0].nodeValue = this.title;
		}
		return false;
	} else {
		return true;
	}
}