// Gallery
function showPic (whichpic, thumb) { 

	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
		} else { 
			//document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
		} 
		thumbcurrent(thumb);
		
		
		return false; 
		} else { 
		return true; 
	}
}

// Vertically centre images if less than max height
function addPadding(img){
	//
	var currImg = document.getElementById(img);
	var h = currImg.height;
	var maxHeight = 355;
	var imgMargin = ((maxHeight - h)/2);
	//
	currImg.style.visibility="hidden";
	//
	if (h < maxHeight){
		currImg.style.margin = imgMargin+"px 0 0 0";
		currImg.style.visibility = "visible"
	} else {
		currImg.style.margin = "0";
		currImg.style.visibility = "visible"
	}
}

// Current thumbnail
function thumbcurrent (thumb){

if(document[strcurrent] != undefined){
	document[strcurrent].src = eval(strcurrent + "off.src");
	document[thumb].src = eval(thumb + "on.src");
	strcurrent = thumb;
	}
}

// Thumbnail rollover
function thumbroll (thumb, state){
	if (thumb !=strcurrent)
		document[thumb].src = eval(thumb + state + ".src");
}

// Variables
var strcurrent = 'img0';

// Hide Div 
function showHide(show, hide){
	document.getElementById(show).style.display = "block";
	document.getElementById(hide).style.display = "none";
}

// Attach window events
if (window.attachEvent)
	window.attachEvent("onload", init);
else if (window.addEventListener)
	window.addEventListener("load", init, false);

// Initialise loading functions
function init() {
	preload();
	thumbcurrent('img0');
}

// Recent Images Gallery
function showRecentPic (whichpic, thumb) { 
	document.getElementById('img').style.display = "block";
	document.getElementById('PageText').style.display = "none";
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title; 
		} else { 
			//document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
		} 
		thumbcurrent(thumb);
		
		
		return false; 
		} else { 
		return true; 
	}
}

// Toggle 'Recent Work' content
function ShowImages() {
	document.getElementById('img').style.display = "block";
	document.getElementById('PageText').style.display = "none";
}