
function init() {
	var thumbnails = document.getElementById('thumbnails').getElementsByTagName('img');
	
	for(var i=0; i< thumbnails.length; i++) {
		if (!thumbnails[i].src.match("-v")) {
			thumbnails[i].onmouseover = function () {
				changeBackground(this.src.replace(/-thumb/,""),this.alt);
			}
		}
	}
}

function changeBackground(filename,text) {
	var viewerbox = document.getElementById('viewerbox');
	var viewer = document.getElementById('viewer');
	var viewertext = document.getElementById('viewertext');
	var portfolio = document.getElementById('portfolio');
	viewer.style.backgroundImage = 'url('+filename+')';
	viewertext.innerHTML = text;
	if (filename.match("-b")) {
		portfolio.style.backgroundColor='#000';
		viewerbox.style.backgroundImage = 'url(loading-b.gif)';
	} else {
		portfolio.style.backgroundColor='#fff';
		viewerbox.style.backgroundImage = 'url(loading.gif)';
	}
}

window.onload = init;
