// 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 loose on the Driving Range", "Joe Watson starts it off for the defending Champs", "Auggie sharpens his putting skills", "J.R. and Pat Bott happy it's over!", "Vice President 'Woody' says: Missed it by that much!", "Don Fox takes pleasure counting the cash for the Zone Qualifier.", "Lee Lamp, Kenneth Gunter, Woody, and Don Fox adding up the scores.", "Dick Ferguson tries his hand at addition.","Lee Lamp calls for the start of the tournament", "the boys discussing the day's event.", "the official scorers.")
							
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/ZoneQualifier2009/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;	
}




