﻿    var CurrIndex = 0;
    var c_interval = 5000;
    var timerID ;    
    var running = false;       
                 
    function ReceiveServerData(rValue)
    {
     
        var wds = rValue.split("#@#@#");

   
        document.getElementById("HomeSlideShow_photo").style.filter = wds[2];
        
              
        var img  = new Image();
        img.src = wds[0];                      
        
        img.onload = function()
        { 
        imageLoaded(this); 
        
        }
        img.onerror = function()
        { 
        imageError(this); 
        }
        img.onabort = function()
        { 
        imageError(this); 
        }
                 
        
        var _imgPhoto = document.getElementById("HomeSlideShow_photo");
        
        if(_imgPhoto != null)
          _imgPhoto.src = wds[0];
    
        var _hdnfield = document.getElementById('HomeSlideShow_hdnCurrIndex');
        if(_hdnfield != null)
        {
           _hdnfield.value  = wds[1];
        
        }           
        var _CurrPhotoIndex = document.getElementById('HomeSlideShow_lblCurrPhotoIndex'); 
       
        if(_CurrPhotoIndex != null)
        {
           _CurrPhotoIndex.innerHTML =  parseInt(wds[1]) + parseInt('1');
    
        }   
        var _CurrPhotoKicker = document.getElementById('HomeSlideShow_lblKicker'); 
        if(_CurrPhotoKicker != null)
        {           
        _CurrPhotoKicker .innerHTML = wds[8];          
  }                  
       
       
    }
        
   
    
   function getNextImage()
    {      
 
         
        var _index = document.getElementById('HomeSlideShow_hdnCurrIndex');       
        if (running) 
     
        {
          CallServer(document.getElementById("HomeSlideShow_photo").src + "," +  "NEXT" + "," +  _index.value + "," + "0", "");          
       
    
        }
    }   
  
  
  function SliderNext()
    {
               
        running = false;
        document.getElementById('HomeSlideShow_imgPausePlayBottom').src = "images/play.gif";         
        var _index =document.getElementById("HomeSlideShow_hdnCurrIndex");   
             
       CallServer(document.getElementById("HomeSlideShow_photo").src + "," +  "NEXT" + "," +  _index.value + "," + "0", "");          
    
    } 


     function SliderPrevious()
    {
    
        
        running=false;
        document.getElementById('HomeSlideShow_imgPausePlayBottom').src = "images/play.gif";     
        var _index = document.getElementById('HomeSlideShow_hdnCurrIndex');
        CallServer(document.getElementById("HomeSlideShow_photo").src + "," +  "PREV" + "," +  _index.value + "," + "0", "");          
    }

   function SliderPause()
    {
    
       if (running)
        {
          running=false;
          window.clearTimeout(timerID);
          timerID =0;
          document.getElementById('HomeSlideShow_imgPausePlayBottom').src = "images/play.gif"; 
          
        } 
       else
       {
          running = true;
          window.setInterval("getNextImage()", c_interval);
          document.getElementById('HomeSlideShow_imgPausePlayBottom').src = "images/pause.gif"; 
           
       }
    }

  function AOnMouseOut(id)
   {
      document.getElementById(id).style.textDecoration = 'none';
   }

   function AOnMouseOver(id)
   {
       document.getElementById(id).style.cursor = 'pointer';
   }

    
     function imageLoaded(img)
    {
        var photo = document.getElementById("HomeSlideShow_photo"); 
     
        photo.src = img.src;      
        photo.filters[0].apply();                
        photo.filters[0].play();   
        
    }
    
    
    function imageError(img)
    {
        alert('Error Occurs.');
        //If image download errors occur, this function will be called.
        window.setInterval("getNextImage()", c_interval);
    }
       
  
