var lines = new Array(new Array(1, 2, 3),
        new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19),
        new Array(40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57),
        new Array(69, 82, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111),
        new Array(20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39),
        new Array(143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154),
        new Array(118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 157, 158, 159, 160, 161),
        new Array(67, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94),
        new Array(83, 112, 113, 114, 115, 116, 117, 162),
        new Array(6, 13, 51, 72, 26, 71, 70, 145, 31, 68, 67, 69),
        new Array(11, 49, 50, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 129, 163, 164),
        new Array(34, 155, 156),
        new Array(27, 127, 80, 7, 28, 104, 128, 8, 81, 144, 105, 9, 82, 10, 29, 48, 50, 164, 49, 83, 30, 66, 11, 163, 129, 12, 130),
        new Array(85, 15, 64, 62, 101, 125, 79, 5, 46, 148, 32, 107, 25, 116, 146, 132));
var flashMovie = null;
function getMovie(movieName)
{
    var isIE = navigator.appName.indexOf('Microsoft') != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function init()
{
    if (document.getElementById)
        flashMovie = document.getElementById("flash_id");

    if (flashMovie == null)
        flashMovie = getMovie("flash_id");
}

function selectStations(m_id)
{
    handler_selectStation(m_id);
}
function selectLines(l_id)
{

    RERENDER_ENABLED = false;

//alert('selectLines('+l_id+')')
    var fLine = lines[l_id];
//TODO: here handling of filtering conditions;
    //result: modified fLine
    //updating view:
    var i = 0;
    for (i = 0; i < fLine.length; i++)
    {
        selectswf(fLine[i]);
        handler_selectStation(fLine[i]);
    }

    handler_selectLine(l_id);

    RERENDER_ENABLED = true;
    sel_metros();

}//end of selectLinesfunction deselectStations(id)
function deselectLines(l_id)
{
    RERENDER_ENABLED = false;

    handler_deselectLine(l_id);
//alert('deselectLines('+l_id+')')
    var fLine = lines[l_id];
//TODO: here handling of filtering conditions;
    //result: modified fLine
    //updating view:
    var i = 0;
    for (i = 0; i < fLine.length; i++)
    {
        deselectswf(fLine[i]);
        deselectStations(fLine[i])
    }
    RERENDER_ENABLED = true;
    sel_metros();

}
function addLoadEvent(func)
{
    // Adds event to window.onload without overwriting currently
    // assigned onload functions.
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    }
    else
    {
        window.onload = function()
        {
            oldonload();
            func();
        }
    }
}
addLoadEvent(init);
function selectswf(id) {
    if ($('#flash').css('display') == 'none') {
        console_log('no display');
        return;
    }
    console_log('selectswf:' + id);
	//alert('selectswf('+id+')');
    if (!flashMovie)
        flashMovie = getMovie("flash_id");

    if (!flashMovie)
        return;

    if (!flashMovie.selectswf)
        return;

    if (flashMovie)
        flashMovie.selectswf(id);
    else
        alert('No communication with Flash-player!');

}
function deselectswf(id) {
    if ($('#flash').css('display') == 'none')
        return;
//alert('deselectswf('+id+')');
    console_log('deselectswf:' + id);
    if (flashMovie == null)
        flashMovie = getMovie("flash_id");

    if (!flashMovie.deselectswf)
        return;

    if (flashMovie)
        flashMovie.deselectswf(id);
    else
        alert('No communication with Flash-player!');

}


