currentMarker=0;var map;pollDelay=60*1000;function load(){if(GBrowserIsCompatible()){resize();icons=new Array();icons.Clientdownload=new GIcon();icons.Clientdownload.image="/maps/res/dl.png";icons.Clientdownload.shadow="/maps/res/dl_shadow.png";icons.Clientdownload.iconSize=new GSize(12,20);icons.Clientdownload.shadowSize=new GSize(22,20);icons.Clientdownload.iconAnchor=new GPoint(6,20);icons.Clientdownload.infoWindowAnchor=new GPoint(5,1);icons.Skindownload=new GIcon(icons.Clientdownload);icons.Skindownload.image="/maps/res/skin.png";icons.Skindownload.shadow="/maps/res/skin_shadow.png";icons.Clientstart=new GIcon(icons.Clientdownload);icons.Clientstart.image="/maps/res/app.png";icons.Clientstart.shadow="/maps/res/app_shadow.png";icons.Clientstart.iconSize=new GSize(13,20);map=new GMap2(document.getElementById("map"));map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(330,2)));map.addControl(new GLargeMapControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(325,25)));map.setCenter(new GLatLng(30,-10),3);document.getElementById("visibleTime").innerHTML=visibleTime/1000/60;time=0;showQueue=new Array();removeQueue=new Array();tbody=document.getElementById("logbody");downloadCounterElement=document.getElementById("downloadCounter");getData();}}function getData(){var url="data"+(time==0?"":"?lastTime="+time);setTimeout("getData()",pollDelay);GDownloadUrl(url,function(data,responseCode){var xml=GXml.parse(data);var lastDownloads=xml.documentElement.getElementsByTagName("download");var currentTime=xml.documentElement.getElementsByTagName("timestamp")[0].getAttribute("time");if(lastDownloads.length>0){time=lastDownloads[0].getAttribute("time");}for(var i=lastDownloads.length-1;i>=0;--i){var d=lastDownloads[i];var downloadTime=d.getAttribute("time");if((currentTime-downloadTime)<visibleTime+pollDelay){var lat=d.getAttribute("lat");var lng=d.getAttribute("lng");if(lat!=null&&lng!=null){var location=d.getAttribute("location");var country=d.getAttribute("country");var type=d.getAttribute("type");var file=d.getAttribute("file");var html="";if(type=="Skindownload"){var previewId=d.getAttribute("previewId");html=(previewId!=null?'<img src="/static/icons/skin/id/'+previewId+'/type/MINI/" alt="" border="0" />':'<img src="/res/icons/skin_small.gif" />')+" "+file;}else{if(type=="Clientdownload"){var os=d.getAttribute("os");var version=d.getAttribute("version");html='<img src="/res/icons/os/'+os+'.gif"> jAlbum '+version+" "+file;}else{if(type=="Clientstart"){var os=d.getAttribute("os");var version=d.getAttribute("version");file="jAlbum "+version+" launched";html='<img src="/res/icons/os/'+os+'.gif"> '+file;d.setAttribute("file",file);}}}html+='<br /><table cellspacing="0" cellpadding="0" border="0"><tr><td>'+getFlag(country,24)+"</td><td>&nbsp;"+location+"</td></tr><table>";html='<span class="info">'+html+"</span>";var point=new GLatLng(parseFloat(lat)+(Math.random()-0.5)*0.5,parseFloat(lng)+(Math.random()-0.5)*0.8);var marker=new GMarker(point,icons[type]);download=new Object();download.marker=marker;download.html=html;download.download=d;showQueue.push(download);if((currentTime-downloadTime)<pollDelay){setTimeout("addMarker()",downloadTime-currentTime+pollDelay);}else{addMarker();}removeQueue.push(download);setTimeout("removeMarker()",downloadTime-currentTime+pollDelay+visibleTime);}}}document.getElementById("waiting").style.display="none";document.getElementById("main").style.visibility="visible";});}function addLog(d){var tr=document.createElement("tr");var td=document.createElement("td");var type=d.getAttribute("type");td.innerHTML=(type=="Clientdownload"||type=="Clientstart"?'<img src="/res/icons/os/'+d.getAttribute("os")+'.gif">':'<img src="/res/icons/skin_small.gif" height="16">');tr.appendChild(td);td=document.createElement("td");td.appendChild(document.createTextNode(d.getAttribute("file")));tr.appendChild(td);td=document.createElement("td");td.innerHTML=getFlag(d.getAttribute("country"),16);tr.appendChild(td);td=document.createElement("td");td.innerHTML=d.getAttribute("location");tr.appendChild(td);if(tbody.childNodes.length>0){tbody.insertBefore(tr,tbody.childNodes[0]);}else{tbody.appendChild(tr);}if(tbody.childNodes.length>10){tbody.removeChild(tbody.childNodes[10]);}}function addMarker(){var download=showQueue.shift();map.addOverlay(download.marker);download.marker.openInfoWindowHtml(download.html);addLog(download.download);updateDownloadCount();}function removeMarker(){var download=removeQueue.shift();map.removeOverlay(download.marker);updateDownloadCount();}function updateDownloadCount(){downloadCounterElement.innerHTML=(removeQueue.length-showQueue.length);}function getFlag(country,size){return'<img src="/res/icons/flags/'+size+"x"+size+"/flag_"+country.toLowerCase().replace(/ /g,"_")+'.png" width="'+size+'" height="'+size+'">';}function resize(){var height=(document.all?document.documentElement.clientHeight:window.innerHeight)+"px";document.getElementById("map").style.height=height;document.getElementById("waiting").style.height=height;}function debug(x){if(debug==1){var e=document.getElementById("debug");e.innerHTML=x+"<br>"+e.innerHTML;}}
