window.onload = function () { window.scrollTo(0, 1); }

$(document).ready(function() {
  setInterval("loop()",3000);
  var now= new Date();
  var stamp = now.getTime();

  $.get('/otvia/vehicles_xml.pxp?time='+stamp+'', function(d){
      var count=0;
      $(d).find('item').each(function() {
           count +=1;
           var $busitem = $(this);
           var offtop = $busitem.find('spotlat').text();
           var offleft = $busitem.find('spotlong').text();
	   if (offtop) {
	   	$('#marker'+count).css("margin-top",offtop+"px");
	   	$('#marker'+count).css("margin-left",offleft+"px");
	   }
	  });
       });
   });

   function loop() {
       var now= new Date();
       var stamp = now.getTime();
       $.get('/otvia/vehicles_xml.pxp?time='+stamp+'', function(d){
            var count=0;
            $(d).find('item').each(function() {
               count +=1;
               var $busitem = $(this);
               var offtop = $busitem.find('spotlat').text();
               var offleft = $busitem.find('spotlong').text();
  	       if (offtop) {
		     $('#marker'+count).animate({ marginTop: offtop, marginLeft:offleft },750);
	       }
            });
         });
    }
