// 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("Players gather before the scramble", "Group waits for assignment","Woody hands out score cards at scramble", "Woody gets ready to announce team assignments", "Warming up for scramble night",  "Busy time after the scramble")
							
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/scramble2009/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;	
}




