// (C) 2002 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 10000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var aUrl = new Array();
var aTitle = new Array();
var aTarget = new Array();

// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = '';
Picture[2]  = '';
Picture[3]  = '';
Picture[4]  = '';
Picture[5]  = '';

// Specify the URL's...
//aUrl[1] = "";
//aUrl[2] = "";
//aUrl[3] = "";
//aUrl[4] = "";
//aUrl[5] = "";

// Specify the Titles...
//aTitle[1] = "";
//aTitle[2] = "";
//aTitle[3] = "";
//aTitle[4] = "";
//aTitle[5] = "";

//aTarget[1] = "";
//aTarget[2] = "";
//aTarget[3] = "";
//aTarget[4] = "";
//aTarget[5] = "";


//initSlideShow('http://www.moodyministries.net/uploadedimages/home-fromthewordtolife.jpg','http://www.google.com','From the Word. To Life.','http://www.moodyministries.net/uploadedimages/test2.jpg','http://www.fairwaycrc.org/tiyamike','Lunch at Tiyamike Mulungu Center','http://www.moodyministries.net/uploadedimages/test3.jpg','http://www.yahoo.com','Malawi, Africa')

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

//Caption[1]  = "This is the first caption.";
//Caption[2]  = "This is the second caption.";
//Caption[3]  = "This is the third caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 1;
var pss = 5; //Picture.length-1;
var paused = false;
var init = false;
var max = 5;

var preLoad = new Array();
//for (iss = 1; iss < pss+1; iss++){
//preLoad[iss] = new Image();
//preLoad[iss].src = Picture[iss];}

function initSlideShow(thismax,datastring){
  try{
    max = thismax;
    aPhotos = datastring.split(";");
   /* if (max>1){
      for (i=0;i<max;i++){
        document.getElementById('PictureBox-btn'+(i+1)).style.display = "inline";
      }
      document.getElementById('home-slideshow-links').style.display = "inline";
    }*/
    for (i=0;i<max;i++){
      aPhotoItems  = aPhotos[i].split("|");
      Picture[i+1] = aPhotoItems[0];
      aUrl[i+1]    = aPhotoItems[1];
      aTitle[i+1]  = aPhotoItems[2];
      aTarget[i+1] = aPhotoItems[3];
    }
    for (iss = 1; iss <= max; iss++){
      preLoad[iss] = new Image();
      preLoad[iss].src = Picture[iss];
    }
    runSlideShow(max);
  }
  catch(err){
    /*if (max>1){
      for (i=0;i<max;i++){
        document.getElementById('PictureBox-btn'+(i+1)).style.display = "none";
      }
      document.getElementById('home-slideshow-links').style.display = "none";
    }*/
  }
}
function runSlideShow(){
    if (!(init)){
      /*for (i=1;i<=max;i++){
        document.getElementById('PictureLink'+i).href = aUrl[i];
        document.getElementById('PictureLink'+i).title = aTitle[i];
        if (aTarget[i]=="_blank"){document.getElementById('PictureLink'+i).target = aTarget[i];}
      }*/
      init=true;
    }
    if (document.all){
        document.images.PictureBox.style.filter="blendTrans(duration=2)";
        document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
        document.images.PictureBox.filters.blendTrans.Apply();
    }
    document.images.PictureBox.src = preLoad[jss].src;
    document.images.PictureBox.alt = aTitle[jss];
    document.images.PictureBox.title = aTitle[jss];
	
	/*for (i=1;i<=max;i++){
	    document.getElementById('PictureLink'+i).className = "";
	}
	document.getElementById('PictureLink' + jss).className = "selected";*/
	
    if (aTarget[jss]=="_blank"){
      document.getElementById('PictureBox').onclick = new Function("window.open('"+aUrl[jss]+"')");
    }else{
      document.getElementById('PictureBox').onclick = new Function("location.href='"+aUrl[jss]+"'");
    }

    if (document.all) document.images.PictureBox.filters.blendTrans.Play();
    jss = jss + 1;
    if (jss > (max)) jss=1;
    if (!(paused)) tss = setTimeout('runSlideShow('+max+')', SlideShowSpeed);
}



function initSlideShow2(pic1,url1,title1,target1,pic2,url2,title2,target2,pic3,url3,title3,target3){
    try{
        document.getElementById('PictureBox-btn1').style.display = "inline";
        document.getElementById('PictureBox-btn2').style.display = "inline";
        document.getElementById('PictureBox-btn3').style.display = "inline";
        document.getElementById('home-slideshow-links').style.display = "inline";

        Picture[1] = pic1;
        Picture[2] = pic2;
        Picture[3] = pic3;

        aUrl[1] = url1;
        aUrl[2] = url2;
        aUrl[3] = url3;

        aTitle[1] = title1;
        aTitle[2] = title2;
        aTitle[3] = title3;
        
        aTarget[1] = target1;
        aTarget[2] = target2;
        aTarget[3] = target3;

        for (iss = 1; iss < pss+1; iss++){
          preLoad[iss] = new Image();
          preLoad[iss].src = Picture[iss];
        }

        runSlideShow();
    }
    catch(err){
        document.getElementById('PictureBox-btn1').style.display = "none";
        document.getElementById('PictureBox-btn2').style.display = "none";
        document.getElementById('PictureBox-btn3').style.display = "none";
        document.getElementById('home-slideshow-links').style.display = "none";
        //alert(err.description);
    }
}

function runSlideShow2(){
    if (!(init)){
        document.getElementById('PictureLink1').href = aUrl[1];
        document.getElementById('PictureLink2').href = aUrl[2];
        document.getElementById('PictureLink3').href = aUrl[3];
        document.getElementById('PictureLink1').title = aTitle[1];
        document.getElementById('PictureLink2').title = aTitle[2];
        document.getElementById('PictureLink3').title = aTitle[3];
        if (aTarget[1]=="_blank"){document.getElementById('PictureLink1').target = aTarget[1];}
        if (aTarget[2]=="_blank"){document.getElementById('PictureLink2').target = aTarget[2];}
        if (aTarget[3]=="_blank"){document.getElementById('PictureLink3').target = aTarget[3];}
        init=true;
    }
    if (document.all){
        document.images.PictureBox.style.filter="blendTrans(duration=2)";
        document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
        document.images.PictureBox.filters.blendTrans.Apply();
    }
    document.images.PictureBox.src = preLoad[jss].src;
    document.images.PictureBox.alt = aTitle[jss];
    document.images.PictureBox.title = aTitle[jss];
    if (aTarget[jss]=="_blank"){
      document.getElementById('PictureBox').onclick = new Function("window.open('"+aUrl[jss]+"')");
    }else{
      document.getElementById('PictureBox').onclick = new Function("location.href='"+aUrl[jss]+"'");
    }

    if (document.all) document.images.PictureBox.filters.blendTrans.Play();
    jss = jss + 1;
    if (jss > (pss)) jss=1;
    if (!(paused)) tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function pauseit(i,bool){
    try{
        clearTimeout(tss);
        paused = bool;
        jss = i;
        runSlideShow();
    }catch(err){
        //alert(err.description);
    }
}

function StoryLink(){
	try{
	    imgTag = document.getElementById("home-profile-link").innerHTML;
	    imgHref = imgTag.substr(imgTag.indexOf("href=")+6);
	    imgUrl = imgHref.substr(0,imgHref.indexOf("\""));
	    if (document.all){
	        imgTitle = document.getElementById("home-profile-caption").innerText;
	    }else{
	        imgTitle = document.getElementById("home-profile-caption").textContent;
	    }
	    StoryBlock = document.getElementById("home-profile");
	    StoryBlock.style.cursor = "pointer";
	    StoryBlock.title = imgTitle;
	    StoryBlock.onclick = new Function("location.href='"+imgUrl+"'");
	}
	catch(err){
	}
}
