// JavaScript Document

function Rollover() {
	
	this.thumbImageSrcUrl = "uninitialized";
	this.thumbImageFileName = "uninitialized";
	this.fullImageCaption = "unitialized";
	this.fullImageSrcUrl = "uninitialized";
	
	this.processRollover = processRollover;
	this.updateSrcUrls = updateSrcUrls;
	this.updateCaption = updateCaption;
	this.updateView = updateView;
	
}

/* Called by onmouseover event fired by #thumb.img elements */
function processRollover(src,alt) {
	// 1. update value of thumbImageSrcUrl and fullImageSrcUrl.
	this.updateSrcUrls(src);
	// 2. Update value of fullImageCaption to value of event source alt
	this.updateCaption(alt);
	// 3. Update the content of the #caption element and the src of the #fullImage element
	this.updateView();
}

/* Updates value of fullImageCaption to value of event source alt */
function updateCaption(alt) {
	this.fullImageCaption = alt.toString();
}

/* Updates value of thumbImageSrcUrl and fullImageSrcUrl. */
function updateSrcUrls(src) {
	this.thumbImageSrcUrl = src.toString();
	this.fullImageSrcUrl = this.thumbImageSrcUrl.replace(/thumbs/, "fulls");
}

/* Updates the content of the #caption element and the src of the #fullImage element */
function updateView() {
	/*document.getElementById('caption').innerHTML = this.fullImageCaption;*/
	var captions = document.getElementsByName("caption");
	/*alert(captions.length);*/
	var element = captions[0];
	/*alert(element.innerHTML);*/
	element.innerHTML = this.fullImageCaption;
	document.getElementById('fullImage').src = this.fullImageSrcUrl;
}

rollover = new Rollover();