google.load("maps","2.x");var map;var lineWeight=3;var lineColor=["#ff0000","#5CFE2C","#C6005B","#2C5CFE","#FF5BC6","#5CC690","#FEFE01"];var lineOpacity=0.5;var gPositions=[];var gMarker=[];var gCurrent;var gIcons=[];var gTransmitters=[];var gKML=[];var initDone=0;var debug=/\?debug/.test(location.href);var fullscreen=/\?fs/.test(location.href);if(fullscreen){document.getElementById("slider-1").style.display="none"}var s=new Slider(document.getElementById("slider-1"),document.getElementById("slider-input-1"));s.setValue(100);var tid;s.onchange=function(){if(!initDone){return}var a=parseInt(s.getValue()*(48/100));document.getElementById("sliderhours").innerText=a;if(tid){clearTimeout(tid)}tid=setTimeout(function(){showPositions(a)},500)};function getPositions(force){if(gKML.length&&!gKML[0].hasLoaded()){setTimeout(getPositions,500);return}var url="http://"+location.hostname+"/wisenten/cgi/wisenten.cgi?transmitters="+gTransmitters.join(",");if(force){var unique=(new Date()).getTime()%1000000000;url+=";forced=1;unique="+unique}new xcmsAJAX(url,function(httpRequest){if(httpRequest.status==200){eval(httpRequest.responseText);gPositions.pop();if(gPositions.length){var bounds=gKML.length?gKML[0].getDefaultBounds():null;var boundingBox=[];for(var j=0;j<gPositions.length;j++){var checkedPositions=new Array();var first=1;for(var i=0;i<gPositions[j].length;i++){var point=new GLatLng(gPositions[j][i].Lat,gPositions[j][i].Long);if(!bounds||bounds.containsLatLng(point)){boundingBox.push(point);var icon=first?{icon:(gIcons[j]||gCurrent)}:{icon:gMarker[j]};gPositions[j][i].Marker=createMarker(point,icon,getInfo(gPositions[j][i]));checkedPositions[checkedPositions.length]=gPositions[j][i];first=0}}gPositions[j]=checkedPositions}var h=force?parseInt(s.getValue()*(48/100)):-1;showPositions(h);if(bounds){centerAndZoomMap(map,bounds)}else{if(boundingBox.length){var poly=new GPolyline(boundingBox);centerAndZoomMap(map,poly.getBounds())}}}}else{alert("Kan actuele posities niet ophalen.")}})}function showPositions(a){map.clearOverlays();for(var e=0;e<gKML.length;e++){map.addOverlay(gKML[e])}if(gPositions){var f=a||0;var d=parseInt(((new Date()).getTime()-(f*3600000))/1000);for(var c=0;c<gPositions.length;c++){if(gPositions[c].length){map.addOverlay(gPositions[c][0].Marker);for(var e=0;e<gPositions[c].length-1;e++){if(a==-1||gPositions[c][e+1].Time>d){var b=new GPolyline([new GLatLng(gPositions[c][e].Lat,gPositions[c][e].Long),new GLatLng(gPositions[c][e+1].Lat,gPositions[c][e+1].Long)],lineColor[c],lineWeight,lineOpacity);map.addOverlay(b);map.addOverlay(gPositions[c][e+1].Marker)}}}}}}function getInfo(j){var d=new Date();d.setTime(j.Time*1000);var b=new Date();var f=b.getYear();var g=b.getMonth();var n=b.getDate();var k=(Date.UTC(f,g,n,0,0,0))/86400000;var i=d.getYear();var a=d.getMonth();var e=d.getDate();var l=(Date.UTC(i,a,e,0,0,0))/86400000;var o=k-l;var m="dagen";if(o>730){o=Math.floor(o/365);m="jaren"}else{if(o>60){o=Math.floor(o/30);m="maanden"}else{if(o>14){o=Math.floor(o/7);m="weken"}}}if(o==0){m="Vandaag"}else{if(o==1){m="Gisteren"}else{m=o+" "+m+" geleden"}}var h=d.getMinutes();if(h<10){h="0"+h}var c="Breedtegraad: "+j.Lat+"<br>Lengtegraad: "+j.Long+"<br>Tijdstip: "+m+" om "+d.getHours()+":"+h;return c}function createMarker(a,c,d){var b=new GMarker(a,c);GEvent.addListener(b,"click",function(){b.openInfoWindowHtml(d)});return b}function centerAndZoomMap(b,a){gCenter=getCenter(a);gZoomLevel=b.getBoundsZoomLevel(a);var c="-1";if(c!=""){if(/^[+-]/.test(c)){gZoomLevel+=parseInt(c)}else{gZoomLevel=parseInt(c)}}if(gZoomLevel>15){gZoomLevel=15}b.setCenter(gCenter,gZoomLevel)}function getCenter(a){var d=a.getNorthEast();var h=a.getSouthWest();var g=d.lat();var i=d.lng();var e=h.lat();var f=h.lng();var b=((g-e)/2)+e;var c=(((-1*f)-(-1*i))/2)+f;return new GLatLng(b,c)}function initialize(){if(fullscreen){var b=document.getElementById("positie_map");b.style.position="absolute";b.style.left="0";b.style.top="0";b.style.width=screen.width+"px";b.style.height=screen.height+"px";document.body.style.overflow="hidden";setInterval("getPositions(1)",1000*60*5)}s.setValue(101);for(var c=0;c<gKML.length;c++){gKML[c]=new GGeoXml("http://"+location.hostname+"/"+gKML[c])}map=new google.maps.Map2(document.getElementById("positie_map"));map.setCenter(new google.maps.LatLng(52.387413,4.573013),14,G_HYBRID_MAP);if(!fullscreen){map.addControl(new GSmallMapControl())}if(!fullscreen){map.addControl(new GMapTypeControl())}map.enableDoubleClickZoom();for(var c=0;c<7;c++){var a=new GIcon(G_DEFAULT_ICON);a.iconAnchor=new GPoint(5,5);a.iconSize=new GSize(10,10);a.shadowSize=new GSize(10,10);a.image="http://"+location.hostname+"/css/wisenten/gfx/marker"+c+".png";gMarker.push(a)}gCurrent=new GIcon(G_DEFAULT_ICON);gCurrent.iconAnchor=new GPoint(5,5);gCurrent.iconSize=new GSize(28,32);gCurrent.shadowSize=new GSize(28,32);gCurrent.image="http://"+location.hostname+"/css/wisenten/gfx/current.png";for(var c=0;c<gIcons.length;c++){if(gIcons[c]){var d=new GIcon(G_DEFAULT_ICON);d.iconAnchor=new GPoint(5,5);d.iconSize=new GSize(28,32);d.shadowSize=new GSize(28,32);d.image=(/^\w+:/.test(gIcons[c])?gIcons[c]:"http://"+location.hostname+"/"+gIcons[c]);gIcons[c]=d}else{gIcons[c]=gCurrent}}getPositions();initDone=1;if(/\?rt/.test(location.href)){document.getElementById("update").style.display="block"}}google.setOnLoadCallback(initialize);
