﻿function ss_config() {
      return [   
		['promo_new_believers_guide.jpg', 'http://www.ichristianlife.com/site/PageServer?pagename=new_believers_guide_intro', 'Start Here!', 'If you have prayed and asked Jesus Christ to be your Savior and Lord, congratulations! We encourage you to first visit this section of the site, <strong>"The New Believer\'s Guide"</strong>. It will teach you some basic Christian principles as you begin your exciting journey in following Jesus.', '›› Visit the New Believer\'s Guide'],
		
		['promo_icl_radio.jpg', 'http://www.ichristianliferadio.com', 'ICL Radio', 'Designed to inspire and inform you, <strong>iChristianLifeRadio has excellent worship music and Christian speakers</strong> in short segments. iChristianLifeRadio will help you grow in your relationship with Jesus Christ and help you transform your world.', '›› Listen to ICL Radio'],
		
		['promo_be_a_rebel.jpg', 'http://www.ichristianlife.com/site/PageServer?pagename=media#page:player;media:Rebel', 'All for Jesus', 'Don\'t conform to mediocrity! Be a risk taking rebel like the Apostle Paul who dared to pray for his captors while wrongfully in prison for preaching the gospel. <strong>Watch Malcom</strong> as he tells you his own risk taking adventure that led him to befriend and eventually move 3 men in a gang to profess Jesus Christ as their Savior.', '›› Watch this Video'],
		
        ['promo_prespectives.jpg', 'http://www.ichristianlife.com/site/PageServer?pagename=t__dan_lague__perspectives_fr__a_w_tozer', 'The Pursuit of God', 'In his classic, The Pursuit of God, <strong>A.W. Tozer</strong> spoke of the importance of continually directing the heart’s attention to Jesus Christ amidst everyday activities of life. <strong>Read and listen to the story of A.W. Tozer</strong>, a man shaped by God.', '›› Read and listen to his story'],
		
		['promo_study_the_bible.jpg', 'http://www.ichristianlife.com/site/PageServer?pagename=t__Amy_Weimer__Introductory_Bi__Be_Sure', 'Take a Simple Bible Study', 'The Bible is God\'s Word to us and is a foundation of our faith as Christians. These six short Bible studies will be immensely helpful to you to grow as a Christian and search for a fundamental understanding of the Scriptures.', '›› Take the first Bible study here']
		
     ];
}

var ss_current = -1
ss_timeout = false; 
var ss_imgs = ss_config(); 
var ss_mastertimer = null;
var ss2_current =0;
var currentPanel = $('.sd0');

function ss_setup()
{
    //var bullets = $("#bullets");
    var slides = document.getElementById("slides");
   
    for (i=0;i<ss_imgs.length;i++) {
        var imgs = ss_config();
		var ssbar = $('#ssbar');
		
        var alink = document.createElement("a");
		
		//var descriptionString = '<div id="slideshow_description" class="sd' + [i] + '"><p>' + ss_imgs[i][2] + '</p></div>';
		//$(ssbar).append(descriptionString);
		
		var descriptionString = '<div class="slideshow_description sd' + [i] + '">'
		descriptionString += '<a href="'+ ss_imgs[i][1] + '">'
		descriptionString += '<h1>' + ss_imgs[i][2] + '</h1>'
		descriptionString += '<h2>' + ss_imgs[i][3] + '</h2>'
		descriptionString += '<span>' + ss_imgs[i][4] + '</span>'
		descriptionString += '</a>'
		descriptionString += '</div>'
										 
		$('#headline_body').append(descriptionString);
		
		
        var imgstring="<img id='s" + i.toString() + "' ";
		
		if (i == 0 || i == 1) {
			imgstring += "src='../images/icl3/"+ss_imgs[i][0]+"' ";
		} else {
			imgstring += "src='' ";
		}
		imgstring += "class='slide' id='s"+i.toString()+"' style='top:0px; display:block; position:absolute;' />";
		alink.href = ss_imgs[i][1];
		$(alink).append(imgstring);
		slides.appendChild(alink);
		
		//bullets
		var div = $('<div></div>').attr('id','b' + i.toString()).addClass('bullet').attr('current',i);
		$('#bullets').append(div);
       
        $("#b" + i).bind("click", function() {slide(this);});
        $("#s" + i.toString()).hide();
        
    }
    
    ss_current =-1;
    
    getNext();
}

function slide(ele)
{
	var eleID = ele.getAttribute("current");
    slide_fromto(ss_current, eleID);
    ss_current = eleID;
    clearTimeout(ss_mastertimer);
    ss_mastertimer = setTimeout("getNext()", 20000);
}

function slide_fromto(from, to){
	var imgs = ss_config();
	if($("#s" + parseInt(to).toString()).attr("src") == '') {
		$("#s" + parseInt(to).toString()).attr("src","../images/icl3/" + ss_imgs[parseInt(to)][0]);
	}
	if($("#s" + (parseInt(to)+1).toString()).attr("src") == '') {
		$("#s" + (parseInt(to)+1).toString()).attr("src","../images/icl3/" + ss_imgs[(parseInt(to)+1)][0]);
	}
	
    $("#s" + from).fadeOut(1000);
	$(".sd" + from).fadeOut(1000);
    $("#b" + from).attr("class","bullet");
    
    $("#s" + to).attr("style","position:absolute;").hide().fadeIn(1000);
    $("#b" + to).attr("class","bullet_on");
	$(".sd" + to).fadeIn(1200);
	
	var oldPanel = $('.sd' + from);
	currentPanel = $('.sd' + to);
	oldPanel.hide();
	
	// Show description if user is currently hovering over slideshow
	/*if ($('#ssbar, #border_top').position().top < 280) {
		currentPanel.show();
	}*/
}

function getNext() {
	ss_current++;
	ss_previous = ss_current -1;
	
	if (ss_previous == -1) { 
		ss_previous = ss_imgs.length-1; 
	}
	
	if (ss_current == ss_imgs.length) {
		ss_current = 0;
	}
	slide_fromto(ss_previous, ss_current);
	ss_mastertimer = setTimeout("getNext()", 20000);
}

$(document).ready(function(){ 
    ss_setup(); 
	loadFeaturedMedia('');
});
