// JavaScript Document created 08/08/08 by Fraser Patullo

window.onload = setPage;

var picNum = 0;
var attributesArray;
var linkArray;
var nameArray;
var yardsArray;
var descripArray;
var siArray;

function setPage(){
	attributesArray = new Array("first.gif", "second.gif", "third.gif", "fourth.gif", "fifth.gif", "sixth.gif");
	nameArray = new Array("Auld Buck Hynd", "Wemyss Way", "Barn Corner", "Standing Stane", "Strawberry Dip", "Home Range");
	descripArray = new Array("A gentle beginning.  At only 65 yards this opening hole gives you a great chance to get off to a flyer.  With a small bunker guarding the left portion of the green, playing to the centre will give you a great chance of birdie.","162 yards straight down the hill.  To get it close, landing short is your best bet but beware, if you land too short a watery grave awaits.","Fraught with danger, this short par three is our signature hole.  The upturned saucer green is difficult enough to hit on its own but the pond guarding the front makes this a real challenge.  Beware of the crocs!!","Hit one club extra here as this hole plays straight uphill.  With bunkers left and right an accurate shot can set up a great birdie opportunity.","This is a hole not to be messed with.  A bogey is never a bad score here with out-of-bounds, bunkers trees and water hazards, a large score can be run up in a heartbeat.  Play it safe!!","A beautiful par 3 with an inviting target but don't be fooled.  A bunker  front-left, a hidden trap at the back and a tricky putting surface makes this a challenging finish.");
	yardsArray = new Array(65, 162, 81, 132, 181,119);
	siArray = new Array(6,2,4,3,1,5);
	var image= document.getElementById('placeholder');
	linkArray = document.getElementsByTagName('table')[0].getElementsByTagName('a');
	
	for (var i=0;  i<linkArray.length; i++)
	{
		linkArray[i].picNum = i;
		linkArray[i].onclick= function ()
		{
			showPic(this);
			return false;
		}
	}
	var picArray = document.getElementById('photoNav').getElementsByTagName('img');
	picArray[0].onmouseover = function(){this.src = "attributes/previousOver.gif";}
	picArray[1].onmouseover = function(){this.src = "attributes/nextOver.gif";}
	picArray[0].onmouseout = function(){this.src = "attributes/previous.png";}
	picArray[1].onmouseout = function(){this.src = "attributes/next.png";}
	picArray[0].onclick = function(){showPreviousPic();}
	picArray[1].onclick = function(){showNextPic();}
}

function showPic(aLink)
{
	var holeNum = document.getElementById("holeNum");
	picNum = aLink.picNum;
	var source = aLink.href;
	var placeHolder = document.getElementById("placeholder");
	placeHolder.src = source;
	holeNum.src = "attributes/course/"+attributesArray[picNum];
	document.getElementById("holeDescription").getElementsByTagName("h3")[0].firstChild.nodeValue = nameArray[picNum];
	document.getElementById("holeDescription").getElementsByTagName("p")[0].innerHTML = yardsArray[picNum]+" Yards || S.I "+siArray[picNum];
	document.getElementById("holeDescription").getElementsByTagName("p")[1].firstChild.nodeValue = descripArray[picNum];
}
function showNextPic(){
	
	if(picNum < 5){
	showPic(linkArray[picNum+1]);}
}
function showPreviousPic(){
	if(picNum > 0){
		showPic(linkArray[picNum-1]);}
}