// 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("Bob McAllister 2009 Senior Gross Champion", "Steve Beaton 2009 Open Net Champion", "Rick Faller 2009 Senior Low Net Champion", "Marvin Wittner 2nd place Senior Net", "Ralph White 2nd place Open Net", "Tom Baird ready to go.", "Benny Lentz, Glen Roberts and Dennis Ferguson at the turn.", "Kenneth Gunter in the Hazzard on 9th hole.","Heading up the 6th fairway.", "Ketchum just misses.", "Relaxing at the end of the round on 1st day.", "Lee Lamp and Grandson going for a ride.","Forsyth and Gunter checking cards.","Brandon Ketchum explains options to Putter White.","Bob Divine ready to serve.","Lamp goes over the rules.","Beaton draws his weapon of choice.","Day two a clear day.","Craig Burkett checks his card.","Don Carver going for the hole.","Alvin Myers","Jim McClure","Mike Denton","Myers, Loucks and Carver on the 9th green.","Craig Burkett trying to wake up.","Dan Harrison","Forsyth chips up.")
							
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/Club_Championship/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;	
}




