$$('.thumb_li').each(function(elem) { elem.onclick = makeActive })

if ($$('.thumb_li').length) {
	new Insertion.Bottom($('zoom'), '<img id="magnifier" src="images/icon-magnifier.png" alt="" />')
	$('current_image').onclick = zoom
	$('magnifier').onclick = zoom
}

function makeActive() {

	$$(".thumb_li").each(function(elem) {
		if (elem.className.indexOf('active') > 0) {
			elem.className = elem.className.replace(' active', '')
		}
	})

	this.className += " active"
	var img = $(this.id.replace('l', 't'))
	var src = img.src.replace('thumb', 'middle')

	loadImage(src)

}

function loadImage(src) {
	$('current_image').src = src;
}

function zoom() {

	var url = base_url + "views/view_image.php?filename=" + $('current_image').src.replace('middle', 'normal')
	var img = window.open(url, "img", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=200, height=200")
	img.focus()
}
