/*
	------------------------------------------------------------------
	Thumbnail Magic
	------------------------------------------------------------------
*/
function updateCurrentThumbs(link_id) {
	var thumbs_section = document.getElementById('thumbs_section');
	var thumbs_a = thumbs_section.getElementsByTagName('a');
	for (x=0; x<thumbs_a.length; x++) {
		if (thumbs_a[x].getAttribute('id') == link_id) {
			var the_item = thumbs_a[x].getElementsByTagName('img')[0];
			the_item.setAttribute('id', 'thumbs_current');
			return true;
		}
	}
}

function prepare_thumbs() {
	var main_img = document.getElementById('main_img');
	var main_img_title = document.getElementById('main_img_heading');
	var thumbs_imgs = document.getElementById('thumbs_section');
	links = thumbs_imgs.getElementsByTagName('a');
	for (x=0; x<links.length; x++) {
		links[x].onclick = function() {
			main_img.setAttribute('src', this.getAttribute('id'));
			main_img_title.innerHTML = this.getAttribute('name');
			var old_img = document.getElementById('thumbs_current');
			old_img.setAttribute('id','');
			updateCurrentThumbs(this.getAttribute('id'));
			this.blur();
			return false;
		}
	}
}

window.onload = prepare_thumbs;
