/* Copyright Courtney Albright 2008 */

function $(el){
	if (!el) return null;
	if(el.tagName) return el;
	if (typeof el == 'string'){
		el = document.getElementById(el);
		if(el) return el;
	}
	return null;
};

function switchImage(oItem){
	var oImage = $('feature');
	if(oImage && oItem){
		var sIndex = oItem.getAttribute('href');
		sIndex = sIndex.substr(sIndex.length-1,1);
		var sImage = oImage.getAttribute('src');
		sImage = sImage.substr(0,sImage.lastIndexOf('.')-1) + sIndex + sImage.substr(sImage.lastIndexOf('.'),sImage.length-1);
		oImage.src = sImage;
	}
	return false;
}

function load(){
	var oImage = $('feature');
	var oColors = $('colors');
	if(oImage && oColors){
		var oColorList = oColors.getElementsByTagName('a');
		for(var i=0, c=oColorList.length; i<c; i++){
			oColorList[i].onclick = function(){
				return switchImage(this);
			};
		}
	}
}
window.onload = load;
