// JavaScript Document slideshow 
addOnload(initAll);
addOnload(initMenu);


function addOnload(newFunction) {
	 var oldOnload = window.onload;
	 
	 if (typeof oldOnload == "function") {
	window.onload = function() {
		if (oldOnload) {
			oldOnload();
		} 
		newFunction();
		}
	}
	 else {
		 window.onload = newFunction; 
	 }
}




var currImg = 0;
var captionText = new Array("Getting Ready for a day at Bailey Creek", "Front entrance at Bailey Creek Resort.", "Driving Range at Bailey", "Practice putting green #1 at Bailey", "Ohhhh so close!", "CCGA lines up for the start at Bailey Creek","Another fantastic view at Bailey Creek","We are ready lets go!!!!","Looking up at the #8 Tee Box at the entrance to Bailey Creek","Patio area at Bailley Creek Resort","Tom Baird and Charles Gilbreath at Bailey Creek ","# 1 green looking from the # 2 tee box at Bailey","View of the # 2 fairway and the Will Adams Poderosa.","Jim Reyes, Charles Gilbreath, Elmer Winfree, Dave Cantwell, John Benson, Mike Canavan, and Keith Cunnington.","Rick Faller is off the first Tee down the middle","# 3 bunker and green side view at Bailey","Craig Burkett, Jim McClure, Joe Cook and Steve Beaton #1","Shootin the breeze on the first Tee at Bailey","Can you guess which hole this is at Bailey Creek?","Will Adams watches as Larry Andrews makes his approach shot on #2.","Will Adams, Rick Faller, Larry Andrews, and Tom Baird at Bailey","Did I show you Ricks ball laying two on #17","David Cantwell waiting for the start at Bailey Creek","Looking back at the #3 Tee Box","Tom Baird looking good on the first tee at Bailey","Jim Reyes and John Benson at Bailey")


							
function initAll(){
	document.getElementById("imgText").innerHTML = captionText[0];
	document.getElementById("prevLink").onclick = processPrevious;
	document.getElementById("nextLink").onclick = processNext;
}
function processPrevious() {
	newSlide(-1);	
}
function processNext() {
	newSlide(1);	
}

function newSlide(direction){
	var imgCt = captionText.length;
	
	currImg = currImg + direction;
	if (currImg <0) {
		currImg = imgCt-1;	
	}
	if (currImg == imgCt) {
		currImg = 0;	
	}
	document.getElementById("slideshow").src = "images Churn Creek Golf Club/BaileyCreek2009/slide" + currImg +".jpg";
	document.getElementById("imgText").innerHTML = captionText[currImg];
}







function initMenu() {
	var allLinks = document.getElementsByTagName("a");
	
	
	for (var i=0;i<allLinks.length; i++) {
		if (allLinks[i].className.indexOf("menuLink") > -1) {
			allLinks[i].onclick = retFalse;	
			allLinks[i].onmouseover = toggleMenu;
			 
		}
	}
}

function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);
	
	document.getElementById(thisMenuName).style.display = "block";
	
	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleDivOff;
	this.parentNode.onmouseover = toggleDivon;
}

function toggleDivon() {
	document.getElementById(this.className).style.display = "block";	
}

function toggleDivOff() {
	document.getElementById(this.className).style.display = "none";	
}

function retFalse() {
	return false;	
}




