// Global variables for the tickertape methods
var tickerTapeItems;
var tickerTapeIndex = 0
var tickerTapeDiv;

// The initialize method to start the tickertape
function InitializeTickerTape( tickerTapeString, separator, targetDiv )
{   
    tickerTapeItems = tickerTapeString.split(separator);
    tickerTapeDiv = document.getElementById( targetDiv );
    
    CycleTickerTape();
}

// The method that cycles items in the tickertape
// Currently this method is not really useful as only one item is added to the array
// Initially this was meant to cycle through items but this functionality is currently disabled
function CycleTickerTape()
{
    if( tickerTapeDiv != null )
    {
        if( tickerTapeIndex >= tickerTapeItems.length )
        {
            tickerTapeIndex = 0;
        }
        
        tickerTapeDiv.innerHTML = tickerTapeItems[tickerTapeIndex];
        tickerTapeIndex++;
    }
    
    setTimeout( 'CycleTickerTape()', 3500 );
}

// Global variables for the tabs on the homepage
var Tab1 = 'Tabs_tab1';
var Tab2 = 'Tabs_tab2';
//var Image1 = 'Tabs_tab1image';
//var Image2 = 'Tabs_tab2image';
var Image1 = '_ctl0_SpecializedPage_TabBlock1_Tabs_tab1image';
var Image2 = '_ctl0_SpecializedPage_TabBlock1_Tabs_tab2image';

// Method that shows the first tab
function ShowTab1(language)
{
    var Tab1El = document.getElementById( Tab1 );
    var Tab2El = document.getElementById( Tab2 );
    
    var Tab1ImageEl = document.getElementById( Image1 );
    var Tab2ImageEl = document.getElementById( Image2 );
    
    if( Tab1El != null )
    {
        Tab1El.style.visibility = '';
        Tab1El.style.display = '';
    }
       
    if( Tab2El != null )
    {
        Tab2El.style.visibility = 'hidden';
        Tab2El.style.display = 'none';
    }
    
    if( Tab1ImageEl != null )
    {
        Tab1ImageEl.src = '/BS.Online.Website.Web/Images/' + language + '/tab1_h.jpg';   
    }
    
    if( Tab2ImageEl != null )
    {
        Tab2ImageEl.src = '/BS.Online.Website.Web/Images/' + language + '/tab2.jpg';   
    }
}

// Method that shows the second tab
function ShowTab2(language)
{
    var Tab1El = document.getElementById( Tab1 );
    var Tab2El = document.getElementById( Tab2 );
    
    var Tab1ImageEl = document.getElementById( Image1 );
    var Tab2ImageEl = document.getElementById( Image2 );
    
    if( Tab2El != null )
    {
        Tab2El.style.visibility = '';
        Tab2El.style.display = '';
    }
       
    if( Tab1El != null )
    {
        Tab1El.style.visibility = 'hidden';
        Tab1El.style.display = 'none';
    }
    
    if( Tab1ImageEl != null )
    {
        Tab1ImageEl.src = '/BS.Online.Website.Web/Images/' + language + '/tab1.jpg';   
    }
    
    if( Tab2ImageEl != null )
    {
        Tab2ImageEl.src = '/BS.Online.Website.Web/Images/' + language + '/tab2_h.jpg';   
    }
}

// This method replaces the default form action with an ssl action
function SwitchToSsl(sslUrl)
{
    if(__CMS_CurrentUrl != null && !__CMS_CurrentUrl.match(sslUrl))
    {
        __CMS_CurrentUrl = sslUrl + __CMS_CurrentUrl;
    }
}
