function checkStreamTimeout() {
    try {
        getStreamTimeout(g_SAStationID);
    
        //alert(g_StreamTimeoutEnabled + " - " + g_StreamTimeoutValue);
        
        if(g_StreamTimeoutEnabled == 1 && g_StreamTimeoutValue > 0)
        {
    
            g_StreamTimeoutValue = g_StreamTimeoutValue * 1000; //milliseconds
    
            clearTimeout(g_StreamTimeoutTimerID)
             
            g_StreamTimeoutTimerID = setTimeout("onStreamTimeout()", g_StreamTimeoutValue); 
        }
    }
    catch(e)
    {}
}

function onStreamTimeout()
{
    try 
    {       
        clearTimeout(g_StreamTimeoutTimerID); 
        
        clearTimeout(g_StreamTimeoutCountdownTimerID);
        
        g_StreamTimeoutCountdownTimerID = setTimeout("onStreamTimeoutCountdown("+g_StreamTimeoutCountdownValue+")", 1000);    
    }
    catch (e)
    {
    }
    
}

function onStreamTimeoutContinueStreaming()
{
    try 
    {
        clearTimeout(g_StreamTimeoutTimerID); 
        
        clearTimeout(g_StreamTimeoutCountdownTimerID);
        
        $("#" + g_dvStreamTimeout).hide();
        
        g_StreamTimeoutTimerID = setTimeout("onStreamTimeout()", g_StreamTimeoutValue);
    }
    catch (e)
    {
    }
}

function onStreamTimeoutCountdown(countdownValue)
{   
    try 
    {       
        clearTimeout(g_StreamTimeoutCountdownTimerID);
    
        var div = $("#" + g_dvStreamTimeout);
            
        var htmlContent = "<table border='0' cellpadding='3' cellspacing='3' bgcolor='#FFFFFF'>";
        
        if(countdownValue > 0)
        {           
            htmlContent = htmlContent + "<tr><td style='font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif' bgcolor='#FFFFFF'>Thanks for listening! " + 
                        " Please verify you want to continue by clicking on the button below" + 
                        " or this session will automatically time out in <strong> " + 
                        countdownValue + 
                        "</strong> seconds." + 
                        "</td></tr>"  +
                        "<tr><td style='font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif' bgcolor='#FFFFFF'><input name='StreamTimeoutContinue' type='button' id='StreamTimeoutContinue'" + 
                        " onClick='javascript:onStreamTimeoutContinueStreaming()' value='Click here to keep streaming'></td></tr>";
            
            countdownValue = countdownValue - 1;
            
            //alert(countdownValue);
            
            g_StreamTimeoutCountdownTimerID = setTimeout("onStreamTimeoutCountdown(" + countdownValue + ")", 1000);
        }
        else 
        {
            htmlContent = htmlContent + "<tr><td style='font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif' bgcolor='#FFFFFF'>Your streaming session has automatically timed out." +
                            " You can restart our stream by restarting the player. Thanks!</td></tr><tr><td>&nbsp;</td></tr>";
            div.html("");  
            stop();
        }
        
        htmlContent = htmlContent + "</table>";
            
        //alert(htmlContent);
        
        //alert(div.html());
        
        div.html(htmlContent);
        div.show();
    }
    catch (e)
    {
    }
}