function gridInit() {
	var eGrid = document.getElementById('grid');
	if(!eGrid) return;

	window['oActiveFull'] = null;
	window['oContainer'] = document.getElementById('content');
	window['oGrid'] = document.getElementById('grid');
	window['oZoom'] = document.getElementById('zoom');
	window['oReduce'] = document.getElementById('reduce');

	for(var i=0, cImgs = eGrid.getElementsByTagName('IMG'); i<cImgs.length; i++) {
		cImgs[i].onclick = function() {
			var baseOffsetLeft = oContainer.offsetLeft + oGrid.offsetLeft + this.offsetLeft + 2;
			var baseOffsetTop = oContainer.offsetTop + oGrid.offsetTop + this.offsetTop + 2;
			var iImgID = this.src.substring(this.src.indexOf('thumb_') +6, this.src.indexOf('.jpg'));
			
			// safari disagrees about offsetTop - not sure why, so im just hardcoding this value since it shouldn't change anyway.
			baseOffsetTop = 187;
			
			oZoom.style.left = baseOffsetLeft + "px";
			oZoom.style.top = baseOffsetTop + "px";

			if(oActiveFull != null) {
				document.getElementById(oActiveFull).style.display = 'none';
			}
			
			document.getElementById('img' + iImgID).style.display = 'block';
			oReduce.style.display = 'block';
			oActiveFull = 'img' + iImgID;
			
		}
	}
	
	for(var j=0, oZoomImgs = oZoom.getElementsByTagName('IMG'); j<oZoomImgs.length; j++) {
		oZoomImgs[j].onclick = function() {
			oReduce.style.display = 'none';
			if(oActiveFull != null) {
				document.getElementById(oActiveFull).style.display = 'none';
			}
		}
	}
}

if(typeof addEvent == 'function') addEvent(window, 'load', gridInit);