function MapaAnim(L,P){this.q=L;this.B=new GLatLng(-11.609193,-52.470703);this.d=16;this.n="#0000FF";this.j=null;this.N=null;this.arrCorredores=new Array();this.t=0;this.velocidade=100;this.o=0;if(GBrowserIsCompatible()){this.S=new GMap2(document.getElementById(P));this.S.addControl(new GMapTypeControl());this.S.addControl(new GSmallMapControl());this.S.addControl(new GScaleControl());this.S.setCenter(this.B,this.d);}this.g='/ondepraticar/imagens/icones';this.carregarRota=function(data){if(data){var Q=GXml.parse(data);var V=Q.documentElement.getElementsByTagName("rota");if(V[0]!=null){var u=V[0].getAttribute("codigo");var levels=V[0].getAttribute("levels");var l=new GPolyline.fromEncoded({color:this.n,weight:5,points:u,levels:levels,zoomFactor:2,numLevels:18,opacity:0.8});if(l){this.S.addOverlay(l);this.S.setCenter(l.getBounds().getCenter(),this.S.getBoundsZoomLevel(l.getBounds()));this.o=l.getLength();this.E();}}}};this.E=function(){R=document.getElementById('dist');R.innerHTML=(this.o/1000).toFixed(2);};this.carregarCaminho=function(data){if(data){this.N=eval(data);}};this.criarCorredor=function(F,K,x,w){this.arrCorredores.push(new z(this.S,this.N,F,K,this.g+w+'/'+x+'.png'));return this.arrCorredores.length-1;};this.onTimer=function(){var D=false;var M=true;for(var C=0;C<this.arrCorredores.length;C++){M=this.arrCorredores[C].t(this.t);D=D||M;}this.t+=this.velocidade;if(!D){this.t=0;this.pause();}this.onProgress();};this.onProgress=function(){};this.play=function(Z){clearInterval(this.j);this.j=setInterval(this.q+".onTimer()",Z);};this.stop=function(){clearInterval(this.j);this.t=0;for(var C=0;C<this.arrCorredores.length;C++){M=this.arrCorredores[C].t(this.t);}};this.clear=function(){clearInterval(this.j);this.t=0;for(var C=0;C<this.arrCorredores.length;C++){this.S.removeOverlay(this.arrCorredores[C].tMarker);}this.arrCorredores=new Array();};this.remover=function(T){clearInterval(this.j);this.t=0;this.S.removeOverlay(this.arrCorredores[T].tMarker);};this.pause=function(){clearInterval(this.j);};this.getTime=function(){var A=new Date(1970,0,1,0,0,0,0,0);A.setSeconds(Math.round(this.t/50));return A.toTimeString().substring(0,8);};}function z(S,arrCaminho,F,K,x){this.m=function(S,r,F,x){var f=new GIcon();f.image=x;f.iconSize=new GSize(35,28);f.iconAnchor=new GPoint(12,14);f.infoWindowAnchor=new GPoint(1,1);var tMarker=new GMarker(r,{icon:f,draggable:false,clickable:false,title:F});S.addOverlay(tMarker);return tMarker;};this.t=function(a){var H=Math.round(a*this.velocidade);if(H<this.arrCaminho.length){var O=new GLatLng(this.arrCaminho[H]['lat'],this.arrCaminho[H]['lon']);this.tMarker.setLatLng(O);return true;}else{var O=new GLatLng(this.arrCaminho[this.arrCaminho.length-1]['lat'],this.arrCaminho[this.arrCaminho.length-1]['lon']);this.tMarker.setLatLng(O);return false;}};this.F=F;this.K=K;this.arrCaminho=arrCaminho;this.velocidade=this.arrCaminho.length/(this.K*50);this.tMarker=this.m(S,new GLatLng(this.arrCaminho[0]['lat'],this.arrCaminho[0]['lon']),F,x);};
