function thumb(e){
	if (document.getElementById){
		var targetEl;
	
		//ie hack
		if (!e) {
			e = event;
			targetEl = e.srcElement;
		}
		else {
			targetEl = e.target;
		}
		
		while (targetEl.tagName != "A") targetEl = targetEl.parentNode;
		
		var imgEl = targetEl.firstChild;
		while (imgEl.tagName != "IMG") imgEl = imgEl.nextSibling;
		
		var oldSrc = imgEl.src;
		imgEl.src = targetEl.href;
		targetEl.href = oldSrc;
		
		return false;
	}
	
}

function setup(){
	buildBehaviours(document.body);
}

function buildBehaviours(el){
	var behaviour;
	
	// cache this now because position in tree might change!
	var next;
	if (el.nextSibling) next = el.nextSibling;
	
	if (el.className) {
		if (el.className == "thumbnail"){
			el.onclick = thumb;
		}
		
		
	}
	if (el.firstChild) buildBehaviours(el.firstChild);
	if (next) buildBehaviours(next);
}


window.onload = setup;
