a=document.createElement('DIV')
a.setAttribute('id','container')
document.body.appendChild(a)
$('container').style.width=(myX-40)+'px';$('container').style.height=(myY-50)+'px';a=document.createElement('DIV')
a.setAttribute('id','map')
$('container').appendChild(a)
$('map').style.width=(Element.getDimensions('container').width-155)+'px';$('map').style.height=(Element.getDimensions('container').height-100)+'px';var map=new GMap2(document.getElementById("map"));setHome()
map.addControl(new GScaleControl());map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.addMapType(G_SATELLITE_3D_MAP)
a=document.createElement('DIV')
a.setAttribute('id','logo')
document.body.appendChild(a)
a=document.createElement('DIV')
a.setAttribute('id','loadingWindow')
$('container').appendChild(a)
$('loadingWindow').className='loadingWindow'
$('loadingWindow').innerHTML='loading...'
$('loadingWindow').style.left=(myX/2-150)+'px'
$('loadingWindow').style.top=myY/2+'px'
drawTools();function drawTc(){buildASC()}
function buildASC(){for(x=0;x<19;x++)showAddress2(x)}
function buildComunali(){for(x=19;x<44;x++)showAddress2(x)}
function showAddress(address){geocoder=new GClientGeocoder();geocoder.getLatLng(address,function(point){if(!point){alert(address+" non riesco a trovarlo!");}else{var marker=new GMarker(point);map.addOverlay(marker);GEvent.addListener(marker,"mouseover",function(){toolTip(1,x,marker);});GEvent.addListener(marker,"mouseout",function(){removeToolTip(x);});}});}
function showAddress2(x){point=new GLatLng(tc[x]['y'],tc[x]['x']);var icon=new GIcon();if(x<19)
icon.image=nowPlaying(x);else icon.image="img/verde.png";icon.iconSize=new GSize(16,28);icon.shadowSize=new GSize(16,28);icon.iconAnchor=new GPoint(6,20);icon.infoWindowAnchor=new GPoint(5,1);var marker=new GMarker(point,icon);map.addOverlay(marker);GEvent.addListener(marker,"mouseover",function(){toolTip(1,x,marker);});GEvent.addListener(marker,"mouseout",function(){removeToolTip(x);});GEvent.addListener(marker,"click",function(){permaToolTip(marker,x);});}
function toolTip(mode,x,marker){a=document.createElement('DIV')
a.setAttribute('id','pop'+x)
map.getPane(G_MAP_FLOAT_PANE).appendChild(a)
iH='<p>'+tc[x]['name']+'</p>';imgIcon=nowPlaying(x);if(imgIcon=='img/arancio_C.png')iH+='<p>'+nextEvent.getDate()+'/'+(nextEvent.getMonth()+1)+': maschile C</p>';if(imgIcon=='img/arancio_BA.png')iH+='<p>'+nextEvent.getDate()+'/'+(nextEvent.getMonth()+1)+': masch. B femm. A</p>';if(imgIcon=='img/arancio_AB.png')iH+='<p>'+nextEvent.getDate()+'/'+(nextEvent.getMonth()+1)+': masch. A femm. B</p>';if(imgIcon=='img/arancio_M.png')iH+='<p>'+nextEvent.getDate()+'/'+(nextEvent.getMonth()+1)+': misto A e B</p>';if(imgIcon=='img/arancio_J.png')iH+='<p>'+nextEvent.getDate()+'/'+(nextEvent.getMonth()+1)+': juniores A e B</p>';$('pop'+x).className='pop'
document.getElementById('pop'+x).style.position='absolute'
document.getElementById('pop'+x).style.left=(map.fromLatLngToDivPixel(marker.getPoint()).x+10)+'px'
document.getElementById('pop'+x).style.top=(map.fromLatLngToDivPixel(marker.getPoint()).y-10)+'px'
document.getElementById('pop'+x).innerHTML=iH;}
function removeToolTip(x){a=document.getElementById('pop'+x);map.getPane(G_MAP_FLOAT_PANE).removeChild(a)}
function lookAdr(){showAddress3($('adr').value)}
function addScript(url){var script=document.createElement('script');script.type='text/javascript';script.id='lnk_aprs';script.src=url;document.getElementsByTagName('head')[0].appendChild(script);}
function addPoint(){alert('E\' stato aggiunto un punto al centro della mappa; serve come segnaposto per ricordare un luogo.\nSi puo\' spostare con il mouse')
point=map.getCenter();var icon=new GIcon();icon.image="img/home.gif";icon.shadow="img/homeshadow.png";icon.iconSize=new GSize(29,25);icon.shadowSize=new GSize(41,36);icon.iconAnchor=new GPoint(6,20);icon.infoWindowAnchor=new GPoint(5,1);id_marker=new GMarker(point,{icon:icon,draggable:true});map.addOverlay(id_marker);GEvent.addListener(id_marker,"click",function(){permaToolTip('home');});GEvent.addListener(id_marker,"dragend",function(){});}
function getCenter(){alert(map.getCenter())}
function print_r(theObj){if(theObj.constructor==Array||theObj.constructor==Object){document.write("<ul>")
for(var p in theObj){if(theObj[p].constructor==Array||theObj[p].constructor==Object){document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");document.write("<ul>")
print_r(theObj[p]);document.write("</ul>")}else{document.write("<li>["+p+"] => "+theObj[p]+"</li>");}}
document.write("</ul>")}}
function drawTools(){for(x=0;x<tools.length;x++){}
var newDiv=document.createElement('div')
newDiv.setAttribute('id','check')
$('container').appendChild(newDiv)
$('check').style.left=(Element.getDimensions('container').width-105)+'px'
$('check').style.width='100px'
$('check').className='toolcheck'
$('check').style.top=(50)+'px'
$('check').innerHTML+='<br><input type=button onClick=getAPRS() id=checkWeather value=\'get APRS\'>'
$('check').innerHTML+='<br><input type=checkbox  id=onlymeteo checked=on>meteo only'
$('check').innerHTML+='<br><input type=input size=3 id=lastxhours value=24> hours'}
function setHome(){map.setCenter(new GLatLng(45.069,7.742),10);}
function setOfData(){map.clearOverlays()
if($('checkASC').checked==true)buildASC();if($('checkComunali').checked==true)buildComunali();}
function loading(how,message){if(how=='on'){$('loadingWindow').style.display='block'
if(message)$('loadingWindow').innerHTML=message}
if(how=='off')$('loadingWindow').style.display='none'}
function weather(){getAPRS();showAPRS();}
