window.onload = loadData;


var calendarNew = new Array(
"Sunday Worship at 9:45 AM in the sanctuary.  Children are always welcome.",
"Christian Education for children and adults on Sunday at 11:30 AM following Christian Fellowship.",
"United Methodist Women at 10:00 AM on the fourth Monday of each month",
"New Life Praise Band rehearsal on Tuesday at 7:30PM. All instruments and voices are encouraged to join.",
"Prayer Circle on Wednesday at 6:45 PM. Includes Scripture, Taize chant, PrayerSong, silence, Eucharist, and intercessory prayer.",
"Christian Men's Fellowship on the second Wednesday of each month at 7:30 PM.",
"Choir rehearsal on Thursday evening at 7:30 PM.  All voices are needed and welcomed.",
"Bible Study - Friday at 1:00 PM in the Education Building.  Currently studying Ezekiel"
);

var thisCalendar=0;
var calendarList=null;
var timerID = null;
var reflectWindow = null;

function loadData() {
	loadCalendar(calendarNew);
	choosePic();
}

function loadCalendar(thisList) {
	calendarList=thisList;
	clearTimeout(timerID);
	thisCalendar= -1;
	
	rotateCalendar();
}

function rotateCalendar() {
	thisCalendar++;
	if(thisCalendar==calendarNew.length) {
		thisCalendar = 0;
	}
	document.getElementById("calendar").innerHTML=calendarNew[thisCalendar];

	timerID=setTimeout("rotateCalendar()", 8*1000);
}

function nextCalendar() {
	if(calendarList==null){
		loadCalendar(calendarNew);
	}
	else {
	thisCalendar++;
	if(thisCalendar==calendarNew.length) {
		thisCalendar = 0;
	}
	document.getElementById("calendar").innerHTML=calendarNew[thisCalendar];
	clearTimeout(timerID);
	timerID=setTimeout("rotateCalendar()", 8*1000);
	}
}

function prevCalendar() {
	if(calendarList==null){
		loadCalendar(calendarNew);
	}
	else {
	thisCalendar--;
	if(thisCalendar<0) {
		thisCalendar = calendarNew.length-1;
	}
	document.getElementById("calendar").innerHTML=calendarNew[thisCalendar];
	clearTimeout(timerID);
	timerID=setTimeout("rotateCalendar()", 8*1000);
	}
}

function closeWin(thisWindow){
	if (thisWindow!= null){
		if(!thisWindow.closed)
			thisWindow.close();
	}
}

function openReflections(url, width, height){
	closeWin(reflectWindow);

	var settings="";
	settings="toolbar=yes,location=yes,directories=yes,"+
	"status=no,menubar=yes,scrollbars=yes,"+
	"resizable=yes,left=50,top=100,width="+width+",height="+height;
	
	reflectWindow=window.open(url, 'reflectWin', settings);
	reflectWindow.focus();
}


