﻿// JScript File - functionality for SlideshowPanel.aspx
// NB: to ensure changes to this code are rolled out immediately to all clients, change the ?v= parameter on the calling script tag to the date of the change

        var Panel_Timer;
        var CHANGE_RATE_INIT = 250;//ms
        var CHANGE_RATE = 7500;//ms
        
        var ActiveIndex=-1;
        var MaxIndex=2;
        var PreviousIndex=0;
        var Duration_ssp=0;
        var Initialised_ssp = false;

        var cmdChangeView; //have to cache the ClientID of this hidden buttons as we are in a .js file, that cannot easily see clientIDs
        
        var Pause_ssp = false; //This gets set to true by other controls to pause animation of the slideshow... for example tbStockSearch in StockSearch.ascx
        
        function Initialise_ssp(btn){
            cmdChangeView=btn;
            Initialised_ssp=true;
            GetPanelTimer();
        }
        
        function GetPanelTimer() {
            if (ActiveIndex<1) {
                Duration_ssp=ActiveIndex+1;
                Panel_Timer = setTimeout("ChangePanel()",CHANGE_RATE_INIT); }
            else {
                Duration_ssp=0.5;
                Panel_Timer = setTimeout("ChangePanel()",CHANGE_RATE); }
        }
        
        function ChangePanel(){
            if (Pause_ssp) { GetPanelTimer(); }
            else {
                PreviousIndex=ActiveIndex;
                ActiveIndex++;
                if (ActiveIndex>MaxIndex) {ActiveIndex=1};
                cmdChangeView.click();
            }
        }
        
        function getDuration_ssp(){
            return Duration_ssp;
        }
        
        function getViewID_Previous(){
            return 'View'+PreviousIndex;
        }
        function HideView_Previous(){
//            for (i=1; i<=6; i++){
//                if (i!=ActiveIndex){ //hide all other panels... could just hide previous, but hiding all others guarantees to elimate animation artifacts caused by other client side actions causing fades to not fully complete
//                    $get('View'+i).style.display="none";
//                }
//            }
            $get('View'+PreviousIndex).style.display="none";
        }
        function getViewID_Active(){ //if (ActiveIndex>0) {alert(ActiveIndex);}
            var id='View'+ActiveIndex;
            $get(id).style.display="";
            return id;
        }
        


