    var timeoutid;
    var showticker;

    function toint( s ) { return s.substring( 0, s.length - 2 ); }
    
    function init()
    {
        if  ( $('ticker_v2006') && !Element.hasClassName( 'ticker_v2006', 'noticker' ) )
        {
            oslider = new Control.Slider( 'handle', 'slider', { onSlide:slideTimeline } )
            new Ajax.Updater( 'megye', 'http://index.hu/api/2006/ValasztasReal/ticker.html?rnd=' + Math.random( 1, 1000000 ), { evalScripts:true } );
        }
    }

    function scroll_ticker()
    {
        if ( ( Math.round( toint( $('handle').style.left ) ) < Math.round( toint( $('slider').style.width ) ) ) && ( $( 'megye' ).clientWidth > 760 ) )
        {
            pos = toint( $('megye').style.left ) - 2;
            full = $( 'megye' ).clientWidth;
            sliderw = toint( $('slider').style.width );
            $('megye').style.left = pos + 'px';
            v = ( -pos / ( full - 760 ) ) * sliderw;
            $( 'handle' ).style.left = v + 'px';
            timeoutid = window.setTimeout( 'scroll_ticker()', 25 );
        }
        else
        {
            new Ajax.Updater( 'megye', 'http://index.hu/api/2006/ValasztasReal/ticker.html?rnd=' + Math.random( 1, 1000000 ), { evalScripts:true } );
            $( 'handle' ).style.left = '0';
            $('megye').style.left = '0';
        }
    }
    
    function slideTimeline( v )
    {
        pos = Math.round( -v * ( ( $( 'megye' ).clientWidth - ( $( 'ticker_v2006' ).clientWidth ) ) / toint( $('slider').style.width ) ) ) + 'px';
        $('megye').style.left = pos;
    }

    function printfire()
    {
        if (document.createEvent)
        {
            printfire.args = arguments;
            var ev = document.createEvent("Events");
            ev.initEvent("printfire", false, true);
            dispatchEvent(ev);
        }
    }

    function eredmeny()
    {
        document.write('<object style="margin-left: 0px; margin-top: 10px; width: 148px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="148" height="100" id="eredmeny" align="middle">\
                                <param name="allowScriptAccess" value="sameDomain" />\
                                <param name="movie" value="http://index.hu/img/assets/politika/belfold/2006/valasztas/terkep/eredmeny_s.swf" />\
                                <param name="quality" value="high" />\
                                <param name="bgcolor" value="#d6ebeb" />\
                                <embed src="http://index.hu/img/assets/politika/belfold/2006/valasztas/terkep/eredmeny_s.swf" quality="high" bgcolor="#d6ebeb" width="148" height="100" name="eredmeny" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
                            </object>');
    }

    function patko()
    {
        document.write('<object style="margin-left: 0px; margin-top: 10px; width: 148px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="148" height="150" id="parlamenti_patko" align="middle">\
                                <param name="allowScriptAccess" value="sameDomain" />\
                                <param name="movie" value="http://img.index.hu/assets/politika/belfold/2006/valasztas/patko/parlamenti_patko.swf" />\
                                <param name="quality" value="high" />\
                                <param name="bgcolor" value="#d6ebeb" />\
                                <embed src="http://img.index.hu/assets/politika/belfold/2006/valasztas/patko/parlamenti_patko.swf" quality="high" bgcolor="#d6ebeb" width="148" height="150" name="parlamenti_patko" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
                            </object>');
    }

    window.onload = init;
