function PicViewer() {
		
	var thumbnailContainer;
	var thumbnails;
	var selectedImage;
	var me = this;
	
	this.selectPicture = function(e) {
		
		for (x=0; x < thumbnails.length; x++) {
			thumbnails[x].className = "";
		}
		selectedImage = getEventTarget(e);
		selectedImage.className = "Selected";
//		document.getElementById("mainImage").src = selectedImage.src;
//		var srcString = document.getElementById("mainImage").src;
//		alert(srcString);
		document.getElementById("mainImage").src = selectedImage.src.replace("_tn","");
	}
	
	this.thumbnailOver = function(e) {

		var targetImage = getEventTarget(e);

		if (targetImage.className != "Selected") {
			targetImage.className = "Hover";
		}
	}
	
	this.thumbnailOut = function(e) {

		var targetImage = getEventTarget(e);

		if (targetImage.className != "Selected") {
			targetImage.className = "";
		}
	}
	
	this.initPage = function () {
		
		thumbnailContainer = document.getElementById("thumbnailContainer");
		
		thumbnails = thumbnailContainer.getElementsByTagName("IMG");
		
		for (x=0; x < thumbnails.length; x++) {
			
			addEvent(thumbnails[x],"mousedown",me.selectPicture,false);
			addEvent(thumbnails[x],"mouseover",me.thumbnailOver,false);
			addEvent(thumbnails[x],"mouseout",me.thumbnailOut,false);
		}
	}
}

var picViewer = new PicViewer();
addEvent(window,"load",picViewer.initPage,false);