document.addEventListener('DOMContentLoaded', function() 
    {
    var tabs = document.getElementsByClassName('sst-title');
    for (i = 0; i < tabs.length; i++) 
        tabs[i].addEventListener('click', sst_click);
    var tabs_to_open = document.getElementsByClassName('sstt-iopen');
    for (i = 0; i < tabs_to_open.length; i++) 
        sst_click.call(tabs_to_open[i]);
    if (window.location.hash)
        {
        var hash = window.location.hash.substr(1);
        var hash_tab = document.querySelectorAll('[data-alias="'+hash+'"]');
        if (hash_tab.length)
            sst_click.call(hash_tab[0]);
        }
    }
);

function sst_click() 
{
   var set_num = this.getAttribute('data-set');
   var tab_num = this.getAttribute('data-tab');
   if (set_num && tab_num)
       sst_open(set_num, tab_num);
}

function sst_open(set_num, tab_num) 
{   
   var i, content, contents, tabs, iframes;
   content = document.getElementById('sstc-'+set_num+'-'+tab_num);
   if (!content)
       return;
   contents = document.getElementsByClassName('sstc-'+set_num);
   for (i = 0; i < contents.length; i++) 
        contents[i].style.display = 'none';
   content.style.display = 'block';
   tabs = document.getElementsByClassName('sstt-'+set_num);
   for (i = 0; i < tabs.length; i++) 
        tabs[i].className = tabs[i].className.replace(' active','');
   document.getElementById('sstt-'+set_num+'-'+tab_num).className += ' active';
   iframes = content.querySelectorAll('iframe');
   for (i = 0; i < iframes.length; i++) 
        {
        if (!content.getAttribute('data-loaded'))
        iframes[i].src += '';
        content.setAttribute('data-loaded', true);
        }
}