/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace('_up'+ftype, '_rollover'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_down'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function turnArrowOn(location) {
	var arrowPosition = document.getElementById(location);
	arrowPosition.setAttribute('src', 'media/images/navigation/navigationArrow.gif');
}

function turnArrowOff(location) {
	var arrowPosition = document.getElementById(location);
	arrowPosition.setAttribute('src', 'media/images/shim.gif');
}

function changeProjectImage(position) {
	var portfolio_image = document.getElementById('portfolio_image');
	var src = portfolio_image.getAttribute('src');
	var eof = src.lastIndexOf('.');
	var ftype = src.substring(eof, src.length);
	var prefix = src.substring(0, eof-2);
	
	portfolio_image.setAttribute('src', prefix+position+ftype);
	swapImagePage(position);
}

function swapImagePage(position) {
	if (activeImagePage == '')
		activeImagePage = document.getElementById('imagePage01');
	
	var src = activeImagePage.getAttribute('src');
	var ftype = src.substring(src.lastIndexOf('.'), src.length);
	activeImagePage.setAttribute('src', src.replace('_rollover'+ftype, '_up'+ftype));
	
	activeImagePage = document.getElementById('imagePage'+position);
}

function activateImagePage() {
	if (activeImagePage != ''){
		var src = activeImagePage.getAttribute('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		activeImagePage.setAttribute('src', src.replace('_up'+ftype, '_rollover'+ftype));
	}
}