var dest_x = 0;
var dest_y = 0;
window.onload = init;
function init() {
	if(!document.getElementById || !document.getElementById('imageContainer'))return;
	im = document.getElementById('imageContainer').getElementsByTagName('IMG');
	var ix = document.getElementById('image0');
	initDestination();
	initThumbnails();
	if(im.length>0){
	ix.className = 'clicked';
	ix.top = dest_y+'px';
	ix.left = dest_x+'px';
	ix.style.width= images['image0'][0]+'px';
	ix.style.height = images['image0'][1]+'px';
	}
}
function resetThumbs(){
	for(var i=0;i<im.length;i++) {
		im[i].className='';
		im[i].style.width = '40px';
		im[i].style.height = '40px';
	}
}
function initThumbnails() {
	for(var i=0;i<im.length;i++) {
		im[i].onclick = function(){
			resetThumbs();
			this.className = 'clicked';
			this.top = dest_y+'px';
			this.left = dest_x+'px';
			this.style.width= images[this.id][0]+'px';
			this.style.height = images[this.id][1]+'px';
		}
	}	
	resetThumbs();
	document.getElementById('imageContainer').style.display = 'block';
}
function initDestination(){
	var t=0,l=0,x = document.getElementById('imageDestination');
	while(x.offsetParent){
		l+=x.offsetLeft;
		t+=x.offsetTop;
		x = x.offsetParent;
	}
	dest_x = l;
	dest_y = t;
}