google.load("maps","2.x");var map;var lineWeight=3;var lineColor="#ff0000";var lineOpacity=0.5;var gPositions=new Array();var gMarker;var gCurrent;var gUitzichtKml;var gWisentGebiedKml;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(!gWisentGebiedKml.hasLoaded()){setTimeout(getPositions,500);return}var url="http://"+location.hostname+"/wisenten/cgi/wisenten.cgi";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);var bounds=gWisentGebiedKml.getDefaultBounds();var checkedPositions=new Array();var first=1;for(var i=0;i<gPositions.length;i++){var point=new GLatLng(gPositions[i].Lat,gPositions[i].Long);if(bounds.containsLatLng(point)){var icon=first?{icon:gCurrent}:{icon:gMarker};gPositions[i].Marker=createMarker(point,icon,getInfo(gPositions[i]));checkedPositions[checkedPositions.length]=gPositions[i];first=0}}gPositions=checkedPositions;var h=force?parseInt(s.getValue()*(48/100)):-1;showPositions(h)}else{alert("Kan actuele posities niet ophalen.")}})}function showPositions(a){map.clearOverlays();map.addOverlay(gWisentGebiedKml);map.addOverlay(gUitzichtKml);if(gPositions&&gPositions.length){map.addOverlay(gPositions[0].Marker);var e=a||0;var c=parseInt(((new Date()).getTime()-(e*3600000))/1000);if(gPositions.length>1){for(var d=0;d<gPositions.length-1;d++){if(a==-1||gPositions[d+1].Time>c){var b=new GPolyline([new GLatLng(gPositions[d].Lat,gPositions[d].Long),new GLatLng(gPositions[d+1].Lat,gPositions[d+1].Long)],lineColor,lineWeight,lineOpacity);map.addOverlay(b);map.addOverlay(gPositions[d+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 initialize(){if(fullscreen){var a=document.getElementById("positie_map");a.style.position="absolute";a.style.left="0";a.style.top="0";a.style.width=screen.width+"px";a.style.height=screen.height+"px";document.body.style.overflow="hidden";setInterval("getPositions(1)",1000*60*5)}s.setValue(101);gUitzichtKml=new GGeoXml("http://"+location.hostname+"/css/wisenten/uitzichtpunt.kml");gWisentGebiedKml=new GGeoXml("http://"+location.hostname+"/css/wisenten/wisentgebied.kml");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();gMarker=new GIcon(G_DEFAULT_ICON);gMarker.iconAnchor=new GPoint(5,5);gMarker.iconSize=new GSize(10,10);gMarker.shadowSize=new GSize(10,10);gMarker.image="http://"+location.hostname+"/css/wisenten/gfx/marker.png";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";getPositions();initDone=1;if(/\?rt/.test(location.href)){document.getElementById("update").style.display="block"}}google.setOnLoadCallback(initialize);