// Otwieranie nowego okienka z parametrami
function OpenWindow(url)
{
    var Okno = window.open(url, "OpenWindow");

}

function OpenWindowParam(url)
{
    var Okno = window.open(url, "OpenWindow", 'width=200,height=100,top=0,left=0,resizable=0,scrollbars=no,menubar=no,status=no');

}

// Zamykanie okienka
function CloseWindow()
{
    var Okno = window.close();
}



function show(targetId)
{
    if(document.getElementById)
    {
        target = document.getElementById(targetId);

            if (target.style.display == "none" ) {
                target.style.display = "";

            } else {
                target.style.display = "none";
            }
    }
}


function schedule_switcher(current_block)
{
    if (current_block == undefined)
        current_block = 'all';

    // Dodawanie onclick do wybranych linkow
    if (document.getElementById('days'))
    {
        var anchors = document.getElementById('days').getElementsByTagName('a');
        for(i=0; i < anchors.length; i++)
        {
            anchors[i].onclick = function() {schedule_switcher(this.id); return false;}
            
            if (anchors[i].id == current_block)
                anchors[i].setAttribute('class', 'current-day');
            else
                anchors[i].removeAttribute('class');
        }
    }
    
      
    var blocks = document.getElementById('content').getElementsByTagName('table');
    for(i=0; i < blocks.length; i++)
    {    
        if (blocks[i].className == 'schedule')
        {
            if ( (blocks[i].id == 'sch_' + current_block) || (current_block == 'all') )
                blocks[i].style.display = 'block';
            else
                blocks[i].style.display = 'none';
        }
    }

}


// Operacje wykonywane po zaladowaniu strony
function init()
{
    
    // Dodawanie onclick do wybranych linkow
    var links = document.getElementsByTagName('a');

    for(i=0; i < links.length; i++)
    {
        if( links[i].className == 'newWinParam')
        {
            links[i].onclick = function() {OpenWindowParam(this.href + '&js=1'); return false;}
        }
        
        if( links[i].className == 'newWin')
        {
            links[i].onclick = function() {OpenWindow(this.href); return false;}
        }
    }
    
    var subscribe = document.getElementById('subscribe');
    subscribe.onclick = function() {OpenWindow(this.href + '&js=1'); return false;}
    
    
    // Ukrywanie divow
    schedule_switcher();

}

window.onload = function()
{
  init();
}
