Wiking.widgets = new function()
{
    /*
     * anty IE widget ;-)
     */
    function nIE()
    {
        var options = {
            'positioner': new TLeftTopPositionStrategy(new TPoint(150,14)),
            'style':{},
            'clickable': true,
            'size': new TSize(460,39)
        };
        var element = '<div style="text-align:center;background:orange;padding:3px;">Pobierz <a href="http://www.google.com/chrome?hl=pl">Chrome</a> lub <a href="http://www.mozilla-europe.org/pl/firefox/">Firefoxa</a> i ciesz się szybszym działaniem serwisu!</div>';
        TMapStaticLayer.prototype.constructor.apply(this,[options,element,Wiking.getMap()]);
        this.draw();
    }
	nIE.prototype = Wiking.inherit(TMapStaticLayer);
    /*
     * Waiter
     */
    function Waiter(){
        Wiking.Event.bindAsEventListener(this,'DataLoaderRequest',this.draw_);
        Wiking.Event.bindAsEventListener(this,'GetPositionsRequest',this.draw_);
        Wiking.Event.bindAsEventListener(this,'dataload',this.clear_);
        Wiking.Event.bindAsEventListener(this,'GotPositions',this.clear_);
        Wiking.Event.bindAsEventListener(this,'force_clear_only_waiter',this.only_clear_);
    }
    Waiter.prototype=new GControl();
    Waiter.prototype.selectable = function(){return false;}
    Waiter.prototype.printable = function(){return true;}
    Waiter.prototype.initialize = function(map){
        var ie = Prototype.Browser.IE ? 10 : 0;
        var html =     '<div style="float:left;font-size:1px;width:8px;height:8px;background:url(\'wimg/clefttop.png\')"></div>'+
                       '<div style="float:left;font-size:1px;background:url(\'wimg/ctop.png\');height:8px;width:'+(331-16)+'px"></div>'+
                       '<div style="float:left;font-size:1px;width:8px;height:8px;background:url(\'wimg/crighttop.png\')"></div>'+
                     '<div style="float:left;clear:left;">'+
                       '<div style="float:left;width:8px;background:url(\'wimg/cleft.png\');height:'+(100-16+ie)+'px"></div>'+
                       '<div style="float:left;background:#fff;height:'+(100-16+ie)+'px;width:'+(331-16)+'px">'+
                        //TREŚĆ
                           '<div style="padding:10px;">'+
                                '<p style="font-size:16px;font-weight:bold;text-align:center;">Pobieranie danych<br /><img src="/wimg/loader.gif" /></p>'+ 
                           '</div>'+
                       '</div>'+
                       '<div style="float:left;font-size:1px;width:8px;background:url(\'wimg/cright.png\');height:'+(100-16+ie)+'px"></div>'+
                      '</div>'+
                      '<div style="float:left;clear:left;">'+
                        //font size ie fix
                       '<div style="float:left;font-size:1px;width:8px;height:8px;background:url(\'wimg/cleftbottom.png\')"></div>'+
                       '<div style="float:left;font-size:1px;background:url(\'wimg/cbottom.png\');height:8px;width:'+(331-16)+'px"></div>'+
                       '<div style="float:left;font-size:1px;width:8px;height:8px;background:url(\'wimg/crightbottom.png\')"></div>'+
                      '</div>';
        var div = document.createElement('div');
        div.innerHTML=html;
        div.style.zIndex="300";
        map.getContainer().appendChild(div);
        return div;
    }
    Waiter.prototype.draw_ = function(){
    
        Wiking.widgets.BlackScreen.draw();
        Wiking.getMap().addControl(this);
    }
    Waiter.prototype.clear_ = function(){
        console.debug('clear waiter');
        Wiking.widgets.BlackScreen.clear();
        Wiking.getMap().removeControl(this);
        console.debug(this,"cleared");
    }
    Waiter.prototype.only_clear_ = function(){
        Wiking.getMap().removeControl(this);
    }
    Waiter.prototype.getDefaultPosition = function(){
        var size = Wiking.getMap().getSize();
        return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(size.width/2-157,size.height/2-50));
    }
    /*
     *  główne menu
     */
    this.MainMenu = new function()
    {
        var activeMenu = 'live';
        var menuinstance = null;
        var restore = null;
        //restore Layer;
        function Restore(){
            Wiking.getMap().addControl(this);
        }
        Restore.prototype = new GControl();
        Restore.prototype.initialize = function(map){
            var div = document.createElement('div');
            div.style.cssText="display:none;cursor:pointer;text-align:right;color:#999;font-size:10px;height:28px;width:115px;background:url(\'/wimg/restorebg.png\');";
            div.innerHTML='<a style="display:block;text-decoration:underline;padding-top:6px;padding-right:15px;">Przywróć menu</a>';
            GEvent.addDomListener(div,'click',this.restore.bind(this));
            this.div_ = div;
            map.getContainer().appendChild(div);
            return div;
        }
        Restore.prototype.selectable = function(){return false;}
        Restore.prototype.printable = function(){return true;}
        Restore.prototype.getDefaultPosition = function(){
            return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(19,60));
        }
        Restore.prototype.restore = function(e){
            menuinstance.show();
            Event.stop(e);
        }
        Restore.prototype.show = function(){
            this.div_.style.display='block';
        }
        Restore.prototype.hide = function(){
            this.div_.style.display='none';
        }
        //
        function MenuBody(){
            Wiking.getMap().addControl(this);
        }
        MenuBody.prototype = new GControl();
        MenuBody.prototype.selectable = function(){return true;}
        MenuBody.prototype.printable = function(){return true;}
        MenuBody.prototype.getDefaultPosition = function(){
            return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(19,60));
        }
        MenuBody.prototype.initialize = function(map){
            var ie = Prototype.Browser.IE ? 3 : 0;
            
                var html = '<div style="width:335px;text-align:right;color:#999;font-size:10px;height:28px;background:url(\'/wimg/menu1.png\');"><a style="display:block;cursor:pointer;text-decoration:underline;padding-top:6px;padding-right:15px;" id="menuX">Ukryj menu</a></div>'+
                       '<div id="menuBody" style="width:335px;background:url(\'/wimg/menu2.png\');">'+
                       '<div style="height:39px;width:319px;margin:0 8px 10px 8px;border-bottom:1px solid #e2e2e2;">'+
                         '<div id="buttonLive" style="cursor:pointer;background:url(\'/wimg/bbg2.png\') no-repeat;float:left;padding:10px 10px;margin:5px 3px 0 7px">Na żywo</div>'+
                         '<div id="buttonHistory" style="color:#aaa;cursor:pointer;background:url(\'/wimg/bbg1.png\') no-repeat;float:left;padding:10px 13px;margin:5px 0 0 0">Historia</div>'+
                         '<div id="buttonSearch" style="cursor:pointer;color:#555;background:url(\'/wimg/bbg4.png\') no-repeat;float:left;padding:10px 0px 10px 0px;width:103px;text-align:center;margin:5px 7px 0 3px">Miejsca i trasy</div>'+
                       '</div>'+
                       '<div id="liveMenu" style="display:none;">'+
                          '<div style="height:70px;width:305px;margin:0 15px">'+
                            '<div style="font-weight:bold;">Ostatnie dane:</div>'+
                            '<div id="liveLog" style="padding-top:4px;">'+
                                '<div></div>'+
                                '<div style="font-size:1px;margin:4px -5px 3px -5px; width:315px;height:1px;background:#ddd;"></div>'+
                                '<div></div>'+
                            '</div>'+
                          '</div>'+
                       '</div>'+
                       '<div id="historiaMenu" style="display:none;">'+
                         '<div style="height:60px;width:305px;margin:0 15px;">'+
                            '<div style="float:left;width:100px;">Poruszały się:</div>'+
                            '<div style="float:right;width:200px;text-align:right">'+
                                '<select style="border:1px solid #ccc;margin-top:-2px" id="historySelect">'+
                                    '<option>Dziś</option>'+
                                    '<option>Wczoraj</option>'+
                                    '<option>W tym tygodniu</option>'+  
                                    '<option>Ostatnie 7 dni</option>'+  
                                    '<option style="margin-top:3px;border-top:1px solid #eee;">Określ przedział</option>'+
                                '</select>'+
                                '<p style="font-size:10px;margin:3px 3px;" id="dateFrom">Od: 01-01-2000, 11:11</p>'+
                                '<p style="font-size:10px;margin:0 3px;" id="dateTo">Do: 02-01-2000, 11:11</p>'+
                            '</div>'+
                       '</div>'+
                       '<div style="height:49px;width:319px;margin:0 8px;background:url(\'/wimg/playerbg.png\') no-repeat;margin-bottom:5px;">'+
                         '<div style="background:url(\'/wimg/playercontrol.png\') bottom no-repeat; width:87px; height:27px; margin-left:10px;padding-top:13px;float:left;">'+
                            '<div id="play" title="Uruchom/Zatrzymaj odtwarzanie" style="cursor:pointer;height:21px;width:23px;text-align:center;float:left;padding-top:'+(4+ie)+'px;padding-left:'+(4+ie)+'px"><img src="/wimg/play.png" style="margin-left:2px;"></div>'+
                            '<div id="toNext" title="Przeskocz do końca/początku ruchu pojazdu" style="cursor:pointer;height:27px;width:26px;float:left;"></div>'+
                            '<div id="speed" title="Zmień prędkość" style="cursor:pointer;height:21px;width:26px;float:left;text-align:center;padding-top:4px;padding-left:'+(ie*2)+'px">1x</div>'+
                         '</div>'+
                         '<div id="barfather" style="float:left;width:125px;height:6px;border:1px solid #ccc;background:#fff;margin-top:27px;margin-left:16px;font-size:1px;">'+
                            '<div id="playerhand" style="cursor:pointer;position:absolute;width:21px;height:24px;background:url(\'wimg/playerhand.png\') no-repeat;margin-top:-20px;margin-left:-8px;"></div>'+
                            '<div id="bar" style="margin:1px;width:0px;height:4px;background:#c22f00;"></div>'+
                         '</div>'+
                         '<div style="float:right;width:66px; height:40px; margin-top:8px;margin-right:8px; text-align:center;" id="playerDate">'+
                         '</div>'+
                       '</div>'+
                       '</div>'+
                       '<div id="szukajMenu" style="display:none;overflow:hidden;width:315px;background:#f0f8fe;margin:0 10px;padding-bottom:10px">'+
                         '<div id="searchnavi" style="padding:10px 10px 0 10px">Wyszukaj: <strong>adres</strong>, <a href="javascript:Wiking.tools.searcher.setupDirections()">trasę</a></div>'+
                         '<div id="addressSearchButton" style="cursor:pointer;width:54px;height:24px;float:right;margin:12px 9px 0 0;background:url(\'wimg/sbutton.png\')"></div>'+
                         '<div id="searchExtended" style="display:none">'+
                           '<input id="addressfield2" style="margin:7px 0 -15px 15px;width:220px;border:1px solid #ccc;padding:3px;" type="text" />'+
                           //'<p style="margin:0 0 0 15px;color:#8a969c;font-size:10px;">Adres, np. Warszawa, Jutrzenki 177</p>'+
                         '</div>'+            
                         '<input id="addressfield" style="margin:12px 0 5px 15px;width:220px;border:1px solid #ccc;padding:3px;" type="text" />'+                         
                         '<p id="searchComment" style="margin:0 0 0 15px;color:#8a969c;font-size:10px;">Adres, np. Warszawa, Jutrzenki 177</p>'+
                       '</div>'+
                       '<div id="obiektyNav" style="height:41px;margin:0 8px;width:318px;background:url(\'/wimg/mbg1.png\') no-repeat;">'+
                         '<img src="wimg/widoczne_wszystkie_active.png" id="showall" style="position:absolute;margin-top:7px;margin-left:15px;" />'+
                         '<img src="wimg/sledz_wszystkie_passive.png" id="followall" style="position:absolute;margin-top:7px;margin-left:150px;" />'+
                       '</div>'+
                       '<div id="obiektyContainer" style="width:316px;border-left:1px solid #ccc;margin:-4px 8px 0px 8px;border-right:1px solid #ccc;">'+
                            '<div style="border-bottom:1px solid #ccc;padding:10px;">Wczytywanie listy urządzeń...</div>'+
                       '</div>'+
                       '<div id="searchContainer" style="width:310px;margin:5px 12px;display:none;">'+
                       '</div>'+                     
                       '<div style="clear:both;width:100%;height:1px;"></div>'+
                     '</div>'+
                     '<div style="width:335px;height:11px;background:url(\'/wimg/menu3.png\');font-size:1px;"></div>';
            var div = document.createElement('div');
            div.innerHTML=html;       
            this.div_ = div;
            map.getContainer().appendChild(div);
            
            $('addressSearchButton').observe('click',Wiking.tools.searcher.doSearch.bind(Wiking.tools.searcher));
            $('addressfield').observe('keypress',function(e){ if (e.keyCode==Event.KEY_RETURN) {Wiking.tools.searcher.doSearch();}});
                // end search
            GEvent.addDomListener(document.getElementById('menuX'),'click',this.hide.bind(this));
            return div;
        }
        MenuBody.prototype.show = function(){
            Wiking.Follow.setPadding({right:(445)});    
            this.div_.style.display='block';
            restore.hide();
        }
        MenuBody.prototype.hide = function(){
            Wiking.Follow.setPadding({right:50});
            this.div_.style.display='none';
            restore.show();
        }
        
        this.bindEvents = function()
        {
            $('buttonHistory').observe('click',this.goHistory.bind(this));
            $('buttonLive').observe('click',this.goLive.bind(this));
            $('buttonSearch').observe('click',this.goSearch.bind(this));
        }
        this.goHistory = function()
        {
            document.getElementById('historiaMenu').style.display='block';
            document.getElementById('liveMenu').style.display='none';
            document.getElementById('szukajMenu').style.display='none';
            document.getElementById('obiektyNav').style.display='block';
            document.getElementById('buttonHistory').style.color='#000';
            document.getElementById('buttonLive').style.color='#444';
            document.getElementById('buttonLive').style.background="url('/wimg/bbg2.png') no-repeat";
            document.getElementById('buttonHistory').style.background="url('/wimg/bbg1.png') no-repeat";
            document.getElementById('buttonSearch').style.color='#444';
            document.getElementById('buttonSearch').style.background="url('/wimg/bbg4.png') no-repeat";
            document.getElementById('searchContainer').style.display='none';
            document.getElementById('obiektyContainer').style.display='block';
            document.getElementById('obiektyContainer').style.height='auto';
            if (activeMenu!='history')
            {    
                document.getElementById('obiektyContainer').innerHTML='<div style="border-bottom:1px solid #ccc;padding:10px;">Wczytywanie listy urządzeń...</div>';
                activeMenu='history';
                Wiking.tools.runHistory();
            }
            Wiking.tools.ObjDivManager.plusMenuSize();
            //$('menuBody').style.height=(Wiking.getMap().vpsize.height-120)+'px';
        }
        this.isLive = function()
        {
            return (activeMenu=='live');
        }
        this.isHistory = function()
        {
            return (activeMenu=='history');
        }
        this.goLive = function()
        {
            document.getElementById('historiaMenu').style.display='none';
            document.getElementById('buttonSearch').style.background="url('/wimg/bbg4.png') no-repeat";
            document.getElementById('liveMenu').style.display='block';
            document.getElementById('szukajMenu').style.display='none';
            document.getElementById('obiektyNav').style.display='block';
            document.getElementById('buttonHistory').style.color='#444';
            document.getElementById('buttonLive').style.color='#000';
            document.getElementById('buttonSearch').style.color='#444';
            document.getElementById('buttonLive').style.background="url('/wimg/bbg1.png') no-repeat";
            document.getElementById('buttonHistory').style.background="url('/wimg/bbg2.png') no-repeat";
            document.getElementById('searchContainer').style.display='none';
            document.getElementById('obiektyContainer').style.display='block';
            document.getElementById('obiektyContainer').style.height='auto';
            if (activeMenu!='live')
            {    
                document.getElementById('obiektyContainer').innerHTML='Wczytywanie listy obiektów...';
                activeMenu='live';
                Wiking.tools.runLive();
            }
            Wiking.tools.ObjDivManager.plusMenuSize();
            //$('menuBody').style.height=(Wiking.getMap().vpsize.height-120)+'px';
        }
        this.goSearch = function()
        {
            document.getElementById('liveMenu').style.display='none';
            document.getElementById('historiaMenu').style.display='none';
            document.getElementById('szukajMenu').style.display='block';
            document.getElementById('obiektyNav').style.display='none';
            document.getElementById('buttonHistory').style.color='#444';
            document.getElementById('buttonLive').style.color='#444';
            document.getElementById('buttonLive').style.background="url('/wimg/bbg2.png') no-repeat";
            document.getElementById('buttonHistory').style.background="url('/wimg/bbg2.png') no-repeat";
            document.getElementById('buttonSearch').style.color='#000';
            document.getElementById('buttonSearch').style.background="url('/wimg/bbg3.png') no-repeat";
            document.getElementById('obiektyContainer').style.display='none';             
            document.getElementById('searchContainer').style.display='block';
            document.getElementById('obiektyContainer').style.height='auto';
            document.getElementById('menuBody').style.height='auto';
        }
        this.init = function()
        {
            restore = new Restore();
            menuinstance = new MenuBody();
              delete MenuBody;
            this.bindEvents();
              delete this.bindEvents;
            delete this.init;
        }
        this.getLngPosition = function()
        {
            var left = menuinstance.getStyle()['left'];
            return new TPoint(left,0).getViewPortLL(Wiking.getMap()).getLng();
        }
    }
    /*
     * inicjalizacja widgetów
     */
    this.init = function()
    {
        new Logo();
         delete Logo;
                 
        /* g */ //if (Prototype.Browser.IE){
        /* g */ //    new nIE(); 
        /* g */ //}
        /* g */ // delete nIE;
        this.MainMenu.init(); // sama funkcja sobie kasuje co trzeba
        
        new TopMenu();
        delete TopMenu;
         
        new Waiter();
        delete Waiter;
        
        this.Spider.init();
         
        //tylko jedna inicjacja jest więc po co nam ta funkcja
        delete this.init;
    }
}

Wiking.widgets.BlackInfo = (function(){
    function MsgControl(text,showX){
        this.text_ = text;
        this.showX_ = showX;
        Wiking.getMap().addControl(this); 
        Wiking.widgets.BlackScreen.setZ(301);
    }
    MsgControl.prototype = new GControl();
    MsgControl.prototype.selectable = function(){return false;}
    MsgControl.prototype.printable = function(){return true;}
    MsgControl.prototype.initialize = function(map){
        var size = new GSize(370,110);    
        var div = document.createElement('div');
        var html = '<div id="bX" style="cursor:pointer;position:absolute;left:'+(size.width-17)+'px;display:'+(this.showX_ ? 'block' : 'none')+'top:-9px;width:27px;height:27px;background: url(\'wimg/x.png\')"></div>'+
                    '<div>'+
                      '<div style="font-size:1px;float:left;width:8px;height:8px;background:url(\'wimg/clefttop.png\')"></div>'+
                      '<div style="font-size:1px;float:left;background:url(\'wimg/ctop.png\');height:8px;width:'+(size.width-16)+'px">'+

                      '</div>'+
                      '<div style="font-size:1px;float:left;width:8px;height:8px;background:url(\'wimg/crighttop.png\')"></div>'+
                     
                      '<div style="clear:left;float:left;width:8px;background:url(\'wimg/cleft.png\');height:'+(size.height-16)+'px"></div>'+
                      '<div style="float:left;background:#fff;height:'+(size.height-16)+'px;width:'+(size.width-16)+'px">'+
                        //TREŚĆ
                         '<div style="padding:10px;text-align:center;" id="bMessageBody">'+
                            this.text_ +
                         '</div>'+
                      '</div>'+
                      '<div style="float:left;width:8px;background:url(\'wimg/cright.png\');height:'+(size.height-16)+'px"></div>'+
                   
                      '<div style="font-size:1px;float:left;clear:left;width:8px;height:8px;background:url(\'wimg/cleftbottom.png\')"></div>'+
                      '<div style="font-size:1px;float:left;background:url(\'wimg/cbottom.png\');height:8px;width:'+(size.width-16)+'px"></div>'+
                      '<div style="font-size:1px;float:left;width:8px;height:8px;background:url(\'wimg/crightbottom.png\')"></div>'+
                    '</div>';
        div.innerHTML = html;
        div.style.zIndex="400";
        
        map.getContainer().appendChild(div);
        this.div_ = div;
        this.msg_ = document.getElementById('bMessageBody');
        Element.observe($('bX'),'click',this.clear_.bind(this));
        return div;
    }
    MsgControl.prototype.getDefaultPosition = function(){
        var
          size = Wiking.getMap().getSize(),
          dis = new GSize(370,110);
        return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(Math.round(size.width/2-dis.width/2),Math.round(size.height/2-dis.height/2)));
    }
    MsgControl.prototype.clear_ = function()
    {
        Wiking.widgets.BlackScreen.setZ(101);
        Wiking.getMap().removeControl(this);
    }
    MsgControl.prototype.setText = function(text)
    {
        this.text_=text;
        this.msg_.innerHTML=text;
    }
    MsgControl.prototype.showX = function()
    {
        $('bX').style.display='block';
    }    
    return MsgControl;    
})();

Wiking.widgets.Charts=Class.create(TMapStaticLayer,
{
    initialize:function($super,imei)
    {
        var width = document.body.getWidth() - (335 + 140 + 60);
        var height = document.body.getHeight() - (60 + 30);
        var options = {
                       'positioner' : new TLeftTopPositionStrategy(new TPoint(130,60)),
                       'style': {},
                       'clickable': true,
                       'size': new TSize(width,height)
                       };
        var html = '<div id="closeWykres" style="cursor:pointer;position:absolute;left:'+(width-17)+'px;top:-9px;width:27px;height:27px;background: url(\'wimg/x.png\')"></div>'+
               '<div>'+
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/clefttop.png\')"></div>'+
                 '<div style="float:left;background:url(\'wimg/ctop.png\');height:8px;width:'+(width-16)+'px"></div>'+
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/crighttop.png\')"></div>'+
                 
                 '<div style="clear:left;float:left;width:8px;background:url(\'wimg/cleft.png\');height:'+(height-16)+'px"></div>'+
                 '<div style="float:left;background:#fff;height:'+(height-16)+'px;width:'+(width-16)+'px">'+
                    //TREŚĆ
                    '<div style="padding:10px;">'+
                       '<p style="margin-top:0;border-bottom:1px solid #eee;padding-bottom:8px;font-size:14px;font-weight:bold;">Wykres prędkości</p>'+
                       '<div id="chartBody" style="width:'+(width-36)+'px;overflow-x:scroll;">'+
                       '</div>'+
                   '</div>'+
                 '</div>'+
                 '<div style="float:left;width:8px;background:url(\'wimg/cright.png\');height:'+(height-16)+'px"></div>'+
               
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/cleftbottom.png\')"></div>'+
                 '<div style="float:left;background:url(\'wimg/cbottom.png\');height:8px;width:'+(width-16)+'px"></div>'+
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/crightbottom.png\')"></div>'+
               '</div>';

        $super(options,html,Wiking.getMap());
        this.imei = imei;
        this.height = height;
        this.width = width;
        this.draw();
        $('closeWykres').observe('click',this.clear.bind(this)); // ;-)
        //TODO: reload przy zmianie danych
    },
    draw:function($super)
    {
        $super();
  
        var spd = Wiking.getObjectByImei(this.imei).getData()[2];
        var maxspd = spd.max();
        
        var width = spd.length*5;
        var multiplier = 5;
        
        if (width < (this.width-36))
        {
            width = this.width-36;
            multiplier = Math.round(width/spd.length);
        }
        
        var surface = new RysownikSurface(width,this.height-100);
        surface.attach($('chartBody'));
        var chart = new RysownikPath(surface);
        
        chart.setFill('solid',{'opacity':0});
        chart.setStroke({'color':'rgb(255,0,0)','width':'2','opacity':1});
        
        chart.moveTo(0,Math.round(spd[0]*350/maxspd));
        for(var i=1,l=spd.length;i<l;i++)
        {
            //spd[i] - x
            //maxspd - 150
            
            //odstep Math.round(i*(this.width-32)/l)
            // l - 400
            // i - x
            chart.lineTo(i*multiplier,Math.round(spd[i]*(this.height-100)/maxspd));
        }
    }
});
Wiking.widgets.Charts.show = function(imei)
{
    Wiking.getMap().clearByClass(Wiking.widgets.Charts);
    new Wiking.widgets.Charts(imei);
}



Wiking.widgets.Msg = Class.create(TMapStaticLayer,
{
      initialize:function($super)
      {
        var width = document.body.getWidth() - (335 + 140 + 60);
        var height = document.body.getHeight() - (60 + 30);
        var options = {
                       'positioner' : new TLeftTopPositionStrategy(new TPoint(130,60)),
                       'style': {},
                       'clickable': true,
                       'size': new TSize(width,height)
                       };
       var html ='<div id="closeMyMsg" style="cursor:pointer;position:absolute;left:'+(width-17)+'px;top:-9px;width:27px;height:27px;background: url(\'wimg/x.png\')"></div>'+
                 '<div>'+
                 '<div style="float:left;width:8px;height:39px;background:url(\'wimg/eclefttop.png\')"></div>'+
                   '<div style="float:left;background:url(\'wimg/ectop.png\');height:39px;width:'+(width-16)+'px">'+
                      '<p style="font-size:14px;font-weight:bold;margin-top:12px;margin-left:5px;">Wiadomości</p>'+
                   '</div>'+
                 '<div style="float:left;width:8px;height:39px;background:url(\'wimg/ecrighttop.png\')"></div>'+
                 
                 '<div style="clear:left;float:left;width:8px;background:url(\'wimg/cleft.png\');height:'+(height-46)+'px"></div>'+
                 '<div style="float:left;background:#fff;height:'+(height-46)+'px;width:'+(width-16)+'px">'+
                    //TREŚĆ
                   '<div style="padding:10px;">'+
                   '<p>Nie masz żadnych wiadomości.</p>'+
                   '</div>'+
                 '</div>'+
                 '<div style="float:left;width:8px;background:url(\'wimg/cright.png\');height:'+(height-46)+'px"></div>'+
               
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/cleftbottom.png\')"></div>'+
                 '<div style="float:left;background:url(\'wimg/cbottom.png\');height:8px;width:'+(width-16)+'px"></div>'+
                 '<div style="float:left;width:8px;height:8px;background:url(\'wimg/crightbottom.png\')"></div>'+
               '</div>';

        $super(options,html,Wiking.getMap());
        this.draw();
        Wiking.getMap().clearByClass(Wiking.widgets.MyAccount,Wiking.widgets.Help);
        $('closeMyMsg').observe('click',this.clear.bind(this)); // ;-)
   }   
});
Wiking.widgets.showMsg = function()
{
    Wiking.getMap().clearByClass(Wiking.widgets.Msg);
    new Wiking.widgets.Msg()
};

Wiking.widgets.showTryby = function(){
    var t = document.getElementById('trybymapy');
    t.style.display = (t.style.display == 'none' ? 'block' : 'none');
    if (!Wiking.widgets.showTryby.handler){      
        Wiking.widgets.showTryby.handler = GEvent.addDomListener(document.body,'click',function(){
            GEvent.removeListener(Wiking.widgets.showTryby.handler);
            Wiking.widgets.showTryby.handler = false;
            t.style.display='none'; 
            console.debug('done');
        });     
    }
}
Wiking.widgets.chooseMap = function(maptype){
    document.getElementById('trybymapy').style.display = 'none';
    Wiking.getMap().setMapType(maptype);
}
