//used to initialise and manipulate accent photo actions

function loadPathGlobals() {
	photoPathRoot = document.images[2].src.substring(0,document.images[2].src.indexOf("clear.gif"));
	photoNumber = Math.round(Math.random() * (photoInfo.length - 1));
}


function setAccentImage() {
	document.images[2].src = "Images/photos/gallery_thumbnail/" + photoInfo[1].file;
}

function thumbnailByNumber(i) {  //returns image by number from randomised photoInfo file
	var imagepre = '<img src="Images/photos/gallery_thumbnail/';
	var imagepost = '" alt="" width="190" height="125" border="0" href="javascript:showFullPicture(' + i + ')">';
	return imagepre + photoInfo[i].file + imagepost;
}

function addLeading0s(input,digits) {
	var pad = "";
	while (input.toString().length + pad.length < digits) pad += "0";
	return pad + input;
}


// ------------------------- FULL PICTURE STUFF

function showFullPicture(i) {
	if (i == null){
		i=1;
	}
	photoWindow=window.open("","photo_Window","scrollbars=no,resizable,dependent");
	photoWindow.resizeTo(photoInfo[i].x+16,photoInfo[i].y+96);
	photoWindow.document.open()
 	photoWindow.document.write("<HEAD><TITLE>Photo " + photoInfo[i].file + "</TITLE></HEAD>");
	photoWindow.document.write("<BODY bgcolor='#fff1d1'" 
		+ " onBlur='self.close()'>"
		+ "<center>"
		+ "<img width=" + photoInfo[i].x
		+ " height=" + photoInfo[i].y
		+ " src=" + "Images/photos/gallery_full_size/" + photoInfo[i].file + "><br><br>"
		+ constructCredit(i)
		+ "</center>"
		+ "</BODY>");
	photoWindow.focus();
}

function constructCredit(i){
	function title() { return (photoInfo[i].caption) ? photoInfo[i].caption + "<br>" : "" ;}
	if (photoInfo[i].photographer) {return title() + "photo by " + photoInfo[i].photographer;}
	else { return title();}
}