// 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("Terra Oaks Pro Shop entrance.", "Checking in at the Pro Shop. ", "CHAMPIONS Team Riverbend from left to right, Ed Knight, Ray Dawson, Paul Lendman and Larry Paschen.", "Second Place Team Allen's from left to right DJ Hovater, Chuck Lynn, Rich Africa and Joe Martinez.", "Third Place Team Churn Creek from left, David Cantwell, Dave Spinks, Kenneth Gunter and Brandon Ketchum.", " Fourth Place Team Palo Cedro left to right, Rob Berry, Richard Cooledge, Mark Mikko and Ray Stevens.", "Ladies Champion Team Palo Cedro from left to right, Kay King, Nancy Stevens, Bev Nelson and June Brunelli.", "Going over the rules.","The Trophies.", "All lined up and ready to go.", "First Tee at Terra.","Now where is that ball?","Brando Ketchum waiting to start the show.","Beautiful walk up #2","Palo Cedros Nancy Stevens shows how it's done.","DJ Hovater sinks his putt.","Allen's Rich Africa putts one from a long way out that almost goes in the hole.","Beverage cart lady Rachel serving it up.","Brandon Ketchum pitches it close. Can you see the ball?","Palo Cedros Bev Nelson pitches it up to the green as June Brunelli looks on.","PC's lady June Brunelli pitches it up to the green.","Beverage Cart operator Merry Wall","# 16 at Terra.","I'm Out!!!!!!!!!!!!!","Just another beautiful hole.","PC's Rob Berry makes big putt.","Ray Dwson and Richard Cooledge eye the hole.","The House.","Churn Creeks David Cantwell sends one to the hole.","Ladies on horseback","PC's Ray Stevens attempts long one.","PC's Richard Cooledge sinks putt from way out there.","Kenneth Gunter practicing chipping","Checking the weapons!","Riverbends Larry Parschen sends it towards the hole on #3","Riverbends Paul Lindman from a long, long way out.","Palo Cedros Mark Mikko in a tough spot on #3","The boys packing more ice.","Allen's Joe Martinez makes big putt.","Four Balls on Three","Allen's boys waiting for the last group.","Pro Shop at Terra Oaks","Get away from me I'm hungry...","Churn Creeks Kenneth Gunter is ready to graze.","Riverbend member Larry Parschen chows down after long day.","Riverbend members Paul Lendman and Ed Knight enjoy the food.","Terra Oaks Tournament Director Mark Baxter presents the ladies Championsip Trophy","Champions from Riverbend show off trophy.","A big thanks to Tournament Director Mark Baxter (left) and General Manger Zac Weinberg (right) for a great tournament")
							
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/Terra Oaks/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;	
}




