﻿Type.registerNamespace("ChurchSession");

ChurchSession.SlideShow=function()
{
    this._slides=new Array();
    this._delay=10;
    this._currentIndex=0;
    this._pause=true;
}

ChurchSession.SlideShow.prototype=
{
    get_Slides:function()
    {
        return this._slides;
    },
    
    set_Slides:function(value)
    {
        this._slides=value;
    },
    
    get_Delay:function()
    {
        return this._delay;
    },
    
    set_Delay:function(value)
    {
        this._delay=value;
    },
    
    get_CurrentIndex:function()
    {
        return this._currentIndex;
    },
    
    set_CurrentIndex:function(value)
    {
        if(value<0)
        {
            this._currentIndex=this._slides.length-1;
            return;
        }
        if(value>=this._slides.length)
        {
            this._currentIndex=0;
        }
        else
        {
            this._currentIndex=value;
        }
    },
    
    get_IsPaused:function()
    {
        return this._pause;
    },
    
    set_IsPaused:function(value)
    {
        this.pause=value;
    },
    
    Pause:function()
    {
        this._pause=true;
    },
    
    Play:function()
    {
        this._pause=false;
        window.setTimeout("slideshow.ShowImage()",this.get_Delay());
    },
    
    ShowFirst:function()
    {
        this._currentIndex=0;
        this.ShowImage();
    },
    
    ShowLast:function()
    {
        this._currentIndex=this._slides.length-1;
        this.ShowImage();
    },

    ShowSpecific:function(value)
    {
        if(value<0)
        {
            this._currentIndex=0;
	        this.ShowImage();
            return;
        }
        if(value>=this._slides.length)
        {
            this._currentIndex=0;
        }
        else
        {
            this._currentIndex=value;
        }
        
        this.ShowImage();
    },
    
    ShowNext:function()
    {
        var newIndex=this._currentIndex +1;
        this.set_CurrentIndex(newIndex);
        this.ShowImage();
    },
    
    ShowPrevious:function()
    {
        var newIndex=this._currentIndex -1;
        this.set_CurrentIndex(newIndex);
        this.ShowImage();
    },
    
    ShowImage:function()
    {
        var img=$get("Image1");
        var aProperties = new Array(); 
        
        if(img.style.visibility=="hidden")
        {
            img.style.visibility="visible";
        }
        var slides=this.get_Slides();
        var curIndex=this.get_CurrentIndex();
        aProperties = slides[curIndex].split("|"); 

//		img.src=slides[curIndex]
//		lblName.value=aProperties[1];
        img.src=aProperties[0];
		document.getElementById("MemberName").innerHTML=aProperties[1];
		document.getElementById("WhereBorn").innerHTML=aProperties[2];
		document.getElementById("WhenJoined").innerHTML=aProperties[3];
		document.getElementById("Hobbies").innerHTML=aProperties[4];
		
        if(this.get_IsPaused()==false)
        {
            this.set_CurrentIndex(curIndex+1);
            this.Play();
        }
    }
}

ChurchSession.SlideShow.registerClass("ChurchSession.SlideShow");

var slideshow=new ChurchSession.SlideShow();
