
Type.registerNamespace("Demo");

Demo.SlideShow=function()
{
    this._slides=new Array();
    this._delay=500;
    this._currentIndex=0;
    this._pause=false;
}

Demo.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(imgCtrlID, hlinkCtrlID, teamNameCtrlID)
    {
        this._pause=false;
        window.setTimeout("slideshow.ShowImage('" + imgCtrlID + "', '" + hlinkCtrlID + "', '" + teamNameCtrlID + "')",
	    this.get_Delay());
    },
    
    ShowFirst:function()
    {
        this._currentIndex=0;
        this.ShowImage();
    },
    
    ShowLast:function()
    {
        this._currentIndex=this._slides.length-1;
        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(imgCtrlID, hlinkCtrlID, teamNameCtrlID)
    {
        var img=document.getElementById(imgCtrlID);
        
	    if(img.style.visibility=="hidden") 
	    { 
	        img.style.visibility="visible";
	    }
	     
        var slides=this.get_Slides();
        var curIndex=this.get_CurrentIndex();
        //this.fadeIn(img);
        img.src=slides[curIndex][0];
        
        //if(this.get_IsPaused()==false)
        //{
            this.set_CurrentIndex(curIndex+1);
            //this.fadeOut(img);
            var hlink=document.getElementById(hlinkCtrlID);
            hlink.innerHTML=slides[curIndex][1];
            hlink.href = slides[curIndex][3];
            var lbl=document.getElementById(teamNameCtrlID);
            lbl.innerHTML=slides[curIndex][2];
            this.Play(imgCtrlID, hlinkCtrlID, teamNameCtrlID);
       // }        
    },    
    fadeOut:function(img) 
    {
        img.style.filter="blendTrans(duration=2)";
        // Make sure the filter is not playing.
        if (img.filters.blendTrans.status != 2) {
            img.filters.blendTrans.apply();
            img.style.visibility="hidden";
            img.filters.blendTrans.play();
        }
    },
    
    fadeIn:function(img) 
    {
        img.style.filter="blendTrans(duration=2)";
        // Make sure the filter is not playing.
        if (img.filters.blendTrans.status != 2) {
            img.filters.blendTrans.apply();
            img.style.visibility="visible";
            img.filters.blendTrans.play();
        }
    }

}

Demo.SlideShow.registerClass("Demo.SlideShow");

var slideshow=new Demo.SlideShow();

