<!-- Begin
var interval = 5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes

var image_index = 0;
var id;
image_list = new Array();
//image_list[image_index++] = new imageItem("ycvalentinespromo.jpg", '1578', 'Young Couples Valentine\'s Banquet', '2010-02-09', '2010-02-09');
//image_list[image_index++] = new imageItem("singles_1.jpg", '1575', 'Valentine Luncheon for Singles 40 and over', '2010-02-14', '2010-02-14');
//image_list[image_index++] = new imageItem("singles_2.jpg", '1576', 'Valentine Social for Singles under 39', '2010-02-14', '2010-02-14');
//image_list[image_index++] = new imageItem("frienddaypromo.jpg", '0', 'Friend Day', '2010-03-07', '2010-03-07');
//image_list[image_index++] = new imageItem("lifetouch2010.jpg", '1542', 'Church Directory Pictures', '2010-01-18', '2010-01-23');
//image_list[image_index++] = new imageItem("2010Eggstreme.jpg", '0', 'Easter Eggstreme', '2010-03-27', '2010-03-27');
//image_list[image_index++] = new imageItem("financialpeacescreen.jpg", '1540', 'Dave Ramsey\'s Financial Peace University', '2009-01-01', '2009-03-31');
//image_list[image_index++] = new imageItem("creativeteamscreen.jpg", '0', 'Creative Team Meeting', '2010-04-10', '2010-40-10');
//image_list[image_index++] = new imageItem("2010Shane_Shane.jpg", '0', 'Shane and Shane in concert', '2010-04-18', '2010-04-18');
//image_list[image_index++] = new imageItem("bhh-2010-04-24.jpg", '1596', 'Butler, Hughes and Hayes in concert at Gospel Tabernacle', '2010-04-24', '2010-04-24');
//image_list[image_index++] = new imageItem("breakfastpastors_2010_04.jpg", '0', 'Breakfast with the Pastors', '2010-04-25', '2010-04-25');
//image_list[image_index++] = new imageItem("couplesgetaway2010.jpg", '1595', 'Couples Getaway', '2010-04-30', '2010-05-01');
//image_list[image_index++] = new imageItem("2010PrayerWalk.jpg", '1597', 'Community Prayer Walk', '2010-05-01', '2010-05-01');
//image_list[image_index++] = new imageItem("cleanupday.jpg", '0', 'Spring Cleanup Day', '2010-05-08', '2010-05-08');
//image_list[image_index++] = new imageItem("acts1-8daypromoversion2.jpg", '0', 'Acts 1:8 Day', '2010-05-16', '2010-05-16');
//image_list[image_index++] = new imageItem("golf_tourn.jpg", '0', 'CBC Golf Tournament', '2010-05-22', '2010-05-22');
//image_list[image_index++] = new imageItem("grad_sunday.jpg", '0', 'Graduation Sunday', '2010-05-23', '2010-05-23');
//image_list[image_index++] = new imageItem("letterstogodscreen.jpg", '1622', 'Movie Night: Letters to God', '2010-06-23', '2010-06-23');
//image_list[image_index++] = new imageItem("2010patrioticexplosion.jpg", '0', 'Patriotic Explosion', '2010-06-27', '2010-06-27');
//image_list[image_index++] = new imageItem("2010YouthSummerCamp.jpg", '1598', 'Youth Summer Camp', '2010-07-12', '2010-07-17');
//image_list[image_index++] = new imageItem("lighthousehome.jpg", '0', 'Lighthouse Children\'s Home', '2010-07-18', '2010-07-18');
//image_list[image_index++] = new imageItem("movie.jpg", '0', 'Movie Night: Letters to God', '2010-07-26', '2010-07-26');
image_list[image_index++] = new imageItem("breakfastpastorsscreen.jpg", '0', 'Breakfast with the Pastors', '2010-08-29', '2010-08-29');
image_list[image_index++] = new imageItem("jhouse2010.jpg", '1563', 'Judgement house', '2009-09-10', '2009-09-12');
image_list[image_index++] = new imageItem("YCdatenightTIMHAWKINSscreen.jpg", '0', 'Young Couples Date Night with Tim Hawkins', '2010-10-08', '2010-10-08');
image_list[image_index++] = new imageItem("TheaterCampusLogo.jpg", 'http://theater.cbcdunn.com/', 'Central\'s Theater Campus', '2009-06-09', '2009-08-31');
//image_list[image_index++] = new imageItem("lifetouch2010.jpg", '1543', 'Church Directory Pictures', '2010-01-18', '2010-01-23');
image_list[image_index++] = new imageItem("Mission.jpg", '0', 'Glorify God by Making Disciples of Jesus Christ', '2008-01-01', '2008-12-31');
image_list[image_index++] = new imageItem("jhouse2010.jpg", '1564', 'Judgement house', '2009-09-17', '2009-09-19');
image_list[image_index++] = new imageItem("bible_study.jpg", '0', 'Bible Study - Sunday mornings at 9:00am', '2008-01-01', '2008-12-31');
//image_list[image_index++] = new imageItem("lifetouch2010.jpg", '1543', 'Church Directory Pictures', '2010-01-18', '2010-01-23');
image_list[image_index++] = new imageItem("GloryCD2.jpg", '0', 'Order your Glory CD today', '2006-12-03', '2007-02-01');
image_list[image_index++] = new imageItem("mobile_promo.jpg", '0', 'Visit us on your cell phone or PDA!', '2006-12-03', '2007-02-01');

image_index = -1;
var number_of_image = image_list.length;

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function imageItem(image_location, calendar_link, alt, start_date, end_date) {
	var d = formatDate(new Date(),"yyyy-MM-dd");
	var a = compareDates(start_date,'yyyy-MM-dd',d,'yyyy-MM-dd');
	var b = compareDates(end_date,'yyyy-MM-dd',d,'yyyy-MM-dd');
	// Make sure starting date and ending date is in the future
	if (a=='1' && b=='1') {
	}
	this.image_item = new Image();
	this.image_item.src = "/events/" + image_location;
	
	if (IsNumeric(calendar_link)) {
		if (calendar_link > 0) this.image_item.link = calendar_link;
	}
	else {
		this.image_item.link = calendar_link;
	}
	this.image_item.alt = alt;
}

function get_ImageItemLocation(imageObj) {
	return(imageObj.image_item.src)
}

function get_ImageItemLink(imageObj) {
	return(imageObj.image_item.link)
}

function get_ImageItemText(imageObj) {
	return(imageObj.image_item.alt)
}

function generate(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function getNextImage() {
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}
		else {
	image_index = (image_index+1) % number_of_image;
	}
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}

function getPrevImage() {
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}
		else {
	image_index = (image_index-1) % number_of_image;
	}
	if (image_index < 0)
		image_index = number_of_image-1;
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}

function ClickNextImage(place) {
	var new_image = getNextImage();
	document[place].src = new_image;
}

function ClickPrevImage(place) {
	var new_image = getPrevImage();
	document[place].src = new_image;
}

function rotateImage(place, dir) {
	var new_image;
	if (dir == 1)
		new_image = getNextImage();
	else
		new_image = getPrevImage();
	document[place].src = new_image;
	document[place].alt = get_ImageItemText(image_list[image_index]);
	var event_id = get_ImageItemLink(image_list[image_index]);
	if (event_id > 0)
		document[place].alt = document[place].alt + '. Click here for more information.'
	var recur_call = "rotateImage('"+place+"',1)";
	if (id != undefined)
		clearTimeout(id);
	id = setTimeout(recur_call, interval * 1000);
}

function clickImage() {
	var event_id = get_ImageItemLink(image_list[image_index]);
	if (event_id != undefined) {
		if (IsNumeric(event_id) && (event_id > 0)) {
			return EventDetail('EventDetail.asp?id='+event_id);
		}
		else {
			return MM_openBrWindow(event_id);
		}
	}
}

function initEventRotator() {
	var dv = MM_findObj("dynamicEventsRotator");
	if (dv != null) {
		var s = '';
		s = s + '<table style="width:272px;height:208px" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle">';
		s = s + '  <table border="0" cellspacing="0" cellpadding="0" width="100%">';
		s = s + '    <tr class="smalltext"><td style="background-color:#333431" colspan="4"><img style="border:0" src="images/spacer.gif" width="1" height="1" alt=""></td></tr>';
		s = s + '    <tr class="smalltext">';
		s = s + '      <td style="background-color:#333431;width:1px"><img style="border:0" src="images/spacer.gif" width="1" height="1" alt=""></td>';
		s = s + '      <td style="width:100%" colspan="2" align="center" valign="middle"><a href="#" onclick="clickImage();"><img name="rImage" id="rImage" style="border:0" src="images/spacer.gif" width="272" height="199" alt=""></a></td>';
		s = s + '      <td style="background-color:#333431;width:1px"><img style="border:0" src="images/spacer.gif" width="1" height="1" alt=""></td>';
		s = s + '    </tr>';
		s = s + '  </table>';
		s = s + '';
		s = s + '';
		s = s + '  <table border="0" cellspacing="0" cellpadding="0" width="100%">';
		s = s + '    <tr class="smalltext">';
		s = s + '      <td colspan="2" style="background-color:#333431" align="left">&nbsp;&nbsp;<a class="white" href="javascript:void(0)" onclick="rotateImage(\'rImage\',0);">&lt; back</a>&nbsp;&nbsp;</td>';
		s = s + '      <td colspan="2" style="background-color:#333431" align="right">&nbsp;&nbsp;<a class="white" href="javascript:void(0)" onclick="rotateImage(\'rImage\',1);">next &gt;</a>&nbsp;&nbsp;</td>';
		s = s + '    </tr>';
		s = s + '    <tr class="smalltext"><td colspan="4" style="background-color:#333431"><img style="border:0" src="images/spacer.gif" width="1" height="4" alt=""></td></tr>';
		s = s + '  </table>';
		s = s + '</td></tr></table>';
			
		dv.innerHTML = s;
		var er = MM_findObj("rImage");
		if (er != null) rotateImage('rImage',1);
	//	setup();
		//window.setInterval("smoothMove()",20);
	}
}


//  End -->