var stopAnim = false;
var resetAnim = false;
var resetIndex = -1;
var callback = function(title, content, index){
	if (!stopAnim) {
		for (n = 0; n < 4; n++) {
			if (index==n) {
				document.getElementById("num" + (n+1)).style.backgroundColor = "#333333";
			}else{
				document.getElementById("num" + (n+1)).style.backgroundColor = "#000000";
			}
		}
		/*
		if(index == 2){
			$("#homeTitle").css('color', "#000000");
		}
		else{
			$("#homeTitle").css('color', "#FFFFFF");
		}*/
		$("#homeTitle").html(title);
		$("#homeContent").html(content);
	}
}
var resumeSlide = function(){
	stopAnim = false;
	resetAnim = true;
}
var showSlide = function(slideNum){
	//stopAnim = true;
	if(slideNum == 1){
		// img3
		resetIndex = 3;
		for(var i = 0; i < 4; ++i){
			if (i == 3) {
				$("#img" + i).css({'visibility': 'visible'});
				$("#img" + i).css({'opacity': '1'});
			}
			else {
				$("#img" + i).css({'visibility': 'hidden'});
				$("#img" + i).css({'opacity': '0'});
			}
		}
		//$("#webinarVid").css({'visibility': 'hidden'});
		//$("#homeTitle").css('color', "#FFFFFF");
		//$("#homeTitle").html('The Transformational Giving Approach to Major Donor Fundraising');
		//$("#homeContent").html('<h3>Learn how a parable about cookies can help you change "ordinary" donors into champions in this Transformational Giving approach to Major Donor fundraising. <a href="http://www.coachyourchampions.com" target="_blank">Learn More</a></h3>');
		$("#homeTitle").html('');
		//$("#homeContent").html("<h3>Does Transformational Giving work? Hear from several organizations who have seen the fruit of implementing Transformational Giving principles.<br><a href='index.cfm?action=general.trainingResources'>Click here</a> to learn more.</h3>");
		$("#homeContent").html('<h3>Baylor University published an in-depth case study of Mission Increase Foundation\'s model and philosophy and found that 98% of grantees increased their revenue over time.<br><a href="index.cfm?action=general.surveys">Read more</a></h3>');
		//$("#homeContent").html("<h3>We're energized and excited to announce our new relationship and merger with the Barnabas Way Foundation in Raleigh, N.C<br><a href='/barnabasway/qa.html'>Learn More</a></h3>");
	}
	else if(slideNum == 2){
		// img2
		resetIndex = 2;
		for(var i = 0; i < 4; ++i){
			if(i == 2) {
				/*
				var so = new SWFObject('/media/playerNoViral.swf','mpl','530','221','9');
				so.addVariable('icons','false');
				so.addParam('wmode','opaque');
				so.addVariable('file','/includes/Webinar.flv');
				so.addVariable('stretching','exactfit');
				so.addVariable("autostart", "true");
				so.addVariable("controlbar", "none");
				so.write('webinarVid');
				//$('#webinarVid').append("<br><div style='border: 1px solid black; width:528px; height: 14px; background-color:#000000;'>&nbsp;</div>")
				$("#webinarVid").css({'visibility': 'visible'});
				$("#webinarVid").css({'opacity': '1'});
				$('#webinarVid').css('opacity', 1)
				*/
				$("#img" + i).css({'visibility': 'visible'});
				$("#img" + i).css({'opacity': '1'});
			}
			else {
				$("#img" + i).css({'visibility': 'hidden'});
				$("#img" + i).css({'opacity': '0'});
			}
		}
		//$("#homeTitle").css('color', "#000000");
		$("#homeTitle").html('Upcoming Events');//Practical Biblical Training to Help You Grow
		$("#homeContent").html('<h3>The Bible holds a radically different approach to fundraising than what is commonly taught and practiced in the nonprofit world. <a href="index.cfm?action=general.upcomingEvents">Click here</a> to see our upcoming topics.<br><a href="index.cfm?action=general.upcomingEvents">Learn More</a></h3>');
	}
	else if(slideNum == 3){
		// img1
		resetIndex = 1;
		for(var i = 0; i < 4; ++i){
			if(i == 1) {
				$("#img" + i).css({'visibility': 'visible'});
				$("#img" + i).css({'opacity': '1'});
			}
			else {
				$("#img" + i).css({'visibility': 'hidden'});
				$("#img" + i).css({'opacity': '0'});
			}
		}
		//$("#webinarVid").css({'visibility': 'hidden'});
		//$("#homeTitle").css('color', "#FFFFFF");
		//$("#homeTitle").html('Tools to Transform Your Ministry');
		//$("#homeContent").html('<h3>God has called people to join your ministry. Get the tools to transform your donors into ministry owners - and disciple them! <a href="index.cfm?action=general.trainingResources">Learn More</a></h3>');
		$("#homeTitle").html('');
		$("#homeContent").html('<h3>Our 2010 board survey explores common myths regarding small and midsize Christian nonprofits and their boards.<br><a href="/media/2010 MIF Board Survey.pdf" target="_blank">Read More</a></h3>');

		//$("#homeTitle").html('<font color="#000000">Transformational Giving</font>');
		//$("#homeContent").html('<h3>Transformational Giving has the power to sustain and grow your ministry - and so much more! This model focuses on the personal growth and discipleship of the giver, rather than on the dollars of a donation.<br><a href="index.cfm?action=general.eventDetail&eventID=1448">Learn More</a></h3>');
	}
	else if(slideNum == 4){
		// img0
		resetIndex = 0;
		for(var i = 0; i < 4; ++i){
			if(i == 0) {
				$("#img" + i).css({'visibility': 'visible'});
				$("#img" + i).css({'opacity': '1'});
			}
			else {
				$("#img" + i).css({'visibility': 'hidden'});
				$("#img" + i).css({'opacity': '0'});
			}
		}
		//$("#webinarVid").css({'visibility': 'hidden'});
		//$("#homeTitle").css('color', "#FFFFFF");
		$("#homeTitle").html('Transforming Lives for Christ through Effective Training and Giving');
		$("#homeContent").html('<h3>Through training and leveraged grants, ministries can see a four or five-fold return and become better stewards of Kingdom resources. <a href="index.cfm?action=general.whatWeDo">Learn More</a></h3>');
	}
}
$(document).ready(function(){
	$('#homeImg').crossSlide({
		sleep: 9, //10
		fade: 1
	}, [{
			src: 'images/home/transforming.jpg', dir: 'up', ctitle: 'Transforming Lives for Christ through Effective Training and Giving', content: '<h3>Through training and leveraged grants, ministries can see a four or five-fold return and become better stewards of Kingdom resources. <a href="index.cfm?action=general.whatWeDo">Learn More</a></h3>'
		},{
			src: 'images/home/Board Web Graphic copy.jpg',
			dir: 'down',
			ctitle: '',
			content: '<h3>Our 2010 board survey explores common myths regarding small and midsize Christian nonprofits and their boards.<br><a href="/media/2010 MIF Board Survey.pdf" target="_blank">Read More</a></h3>'
		},{
			src: 'images/home/upcoming_events.jpg', dir: 'up', ctitle: 'Upcoming Events', content: '<h3>The Bible holds a radically different approach to fundraising than what is commonly taught and practiced in the nonprofit world. <a href="index.cfm?action=general.upcomingEvents">Click here</a> to see our upcoming topics.<br><a href="index.cfm?action=general.upcomingEvents">Learn More</a></h3>'
		},{
			src: 'images/home/baylor.jpg', dir: 'down', ctitle: '', content: '<h3>Baylor University published an in-depth case study of Mission Increase Foundation\'s model and philosophy and found that 98% of grantees increased their revenue over time.<br><a href="index.cfm?action=general.surveys">Read more</a></h3>'
	}], callback);
});
/*
			//src: 'images/home/resources.jpg', dir: 'down', ctitle: 'Tools to Transform Your Ministry', content: '<h3>God has called people to join your ministry. Get the tools to transform your donors into ministry owners - and disciple them! <a href="index.cfm?action=general.trainingResources">Learn More</a></h3>'
			//src: 'images/home/raleigh_seminar.jpg', dir: 'down', ctitle: '<font color="#000000">Transformational Giving</font>', content: '<h3>Transformational Giving has the power to sustain and grow your ministry - and so much more! This model focuses on the personal growth and discipleship of the giver, rather than on the dollars of a donation.<br><a href="index.cfm?action=general.eventDetail&eventID=1448">Learn More</a></h3>'
		},{
		//src: 'images/home/barnabasway.jpg', dir: 'down', ctitle: '', content: '<h3>We\'re energized and excited to announce our new relationship and merger with the Barnabas Way Foundation in Raleigh, N.C<br><a href="/barnabasway/qa.html" target="_blank">Learn More</a></h3>'
			src: 'images/home/giving_approach.jpg', dir: 'down', ctitle: 'The Transformational Giving Approach to Major Donor Fundraising', content: '<h3>Learn how a parable about cookies can help you change "ordinary" donors into champions in this Transformational Giving approach to Major Donor fundraising. <a href="http://www.coachyourchampions.com" target="_blank">Learn More</a></h3>'
*/
/*
var homeImg = new Array();
var homeTitle = new Array();
var homeContent = new Array();

homeImg[0] = 'images/home/transforming.jpg';
homeTitle[0] = 'Transforming Lives for Christ through through Effective Training and Giving';
homeContent[0] = 'Through training and leveraged grants, ministries can see a four or five-fold return and become better stewards of Kingdom resources. <a href="index.cfm?action=general.whatWeDo">Learn More</a>';

homeImg[1] = 'images/home/resources.jpg';
homeTitle[1] = 'Resources and Information';
homeContent[1] = 'God has called people to join your ministry. Get the tools to transform your donors into ministry owners - and disciple them! <a href="index.cfm?action=general.trainingResources">Learn More</a>';

homeImg[2] = 'images/home/upcoming_events.jpg';
homeTitle[2] = 'Upcoming Events';
homeContent[2] = 'The Bible holds a radically different approach to fundraising than what is commonly taught and practiced in the nonprofit world. Click here to see our upcoming topics. <a href="index.cfm?action=general.upcomingEvents">Learn More</a>';

homeImg[3] = 'images/home/giving_approach.jpg';
homeTitle[3] = 'The Transformational Giving Approach to Major Donor Fundraising';
homeContent[3] = 'Learn how a parable about cookies can help you change "ordinary" donors into champions in this Transformational Giving approach to Major Donor fundraising. <a href="http://www.coachyourchampions.com" target="_blank">Learn More</a>';
var firstLoop = true;
function homeBanner(i) {
	var bgimage = homeImg[i];
	var outTime = 1000;
	var inTime = 1000;
	if (firstLoop) {
		outTime = 0;
		inTime = 0;
		firstLoop = false;
	}

	setTimeout(function(){
		document.getElementById("homeImg").style.backgroundImage = "url('" + bgimage + "')";
		var title = homeTitle[i];
		document.getElementById("homeTitle").innerHTML = title;
		var content = homeContent[i];
		document.getElementById("homeContent").innerHTML = content;
		for (n = 0; n < homeImg.length; n++) {
			if (i==n) {
				document.getElementById("num" + (n+1)).style.backgroundColor = "#333333";
			}else{
				document.getElementById("num" + (n+1)).style.backgroundColor = "#000000";
			}
		}
	}, outTime - 500);

	$("#homeImg").fadeOut(outTime, function(){
		$("#homeImg").fadeIn(inTime, function(){
		});
	});
}

var loop = 0;
function homeLoop() {
	if(loop == homeImg.length-1){
		homeBanner(loop);
		loop = 0;
	}else{
		homeBanner(loop);
		loop = loop + 1;
	}
}

function homeStart() {
	homeLoop()
	homeTimer = setInterval ( 'homeLoop()', 5000 );
}

function homeStop() {
	clearInterval ( homeTimer );
}
*/
