
    function initialize() {

      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
       GEvent.addListener(map, "load", getAddress);
        geocoder = new GClientGeocoder();
 

var baseIcon = new GIcon();
baseIcon.shadow = "http://www.mediameeting.it/meteo/images/shadow-arrow.png";
//baseIcon.iconSize = new GSize(20, 34);
baseIcon.iconSize = new GSize(22, 34);

baseIcon.shadowSize = new GSize(50, 30);
//baseIcon.shadowSize = new GSize(20, 34);

baseIcon.iconAnchor = new GPoint(10, 34);
//baseIcon.iconAnchor = new GPoint(30, 34);

baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);       

      
 icon = new GIcon(baseIcon);      
icon.image = "http://www.mediameeting.it/meteo/images/arrow.png";  

iconred = new GIcon(icon,"http://www.mediameeting.it/meteo/images/arrow-red.png"); 
//*********************************************************************************************************************
 
 
/*  
var publisher_id = 'pub-4445939314592851';
var adPos = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(1, 1)); // Set the anchor position and GSize offset to your desired values.    
var adsManagerOptions = { 
  maxAdsOnMap : 1, 
  style: 'adunit', 
  // The channel field is optional - replace this field with a channel number  
  // for Google AdSense tracking 
  channel: '6528546595'
  ,position: adPos 
}; 		
adsManager = new GAdsManager(map, publisher_id, adsManagerOptions); 
adsManager.enable();
*/  
        
 
      }
 
     geocoder.getLocations(address, addToMap);

}

    function getAddress(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress2);
      }else{
      geocoder.getLocations(point, showAddress2);

      }
      
    }



    function addToMap(response)
   {
      // Retrieve the object
      place = response.Placemark[0];

      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1],
                          place.Point.coordinates[0]);
                          
pointLat=place.Point.coordinates[1];
pointLong=place.Point.coordinates[0];

//alert(pointLat);
coord=pointLat+"_"+pointLong

      // Center the map on this point
      map.setCenter(point, 10);

      // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
      map.addOverlay(marker);

      // Add address information to marker
      marker.openInfoWindowHtml(place.address);
	 map.setUIToDefault();

   } 


    function showAddress2(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Status Code:" + response.Status.code);
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);

pointLat=place.Point.coordinates[1];
pointLong=place.Point.coordinates[0];
coord=pointLat+"_"+pointLong
                  
        marker = new GMarker(point);
        map.addOverlay(marker);
	        
dati(pointLat,pointLong);
      }
    }
   
 function myCallback( returnstring ){ 

xlayerbannerx="vicini";
testobanner=returnstring;
   if (document.layers)
      with (document.layers['vicini'].document) {
         open();
         write(testobanner);
         close(); }
   else if (document.getElementById)
     document.getElementById('vicini').innerHTML= testobanner;
      else xlayerbannerx.innerHTML= testobanner 
 }
 
 function arrow(lat,lng){
         var point2 = new GLatLng(lat,lng);
 	map.panTo(point2);         
         marker2 = new GMarker(point2, icon);
        map.addOverlay(marker2);       
 //alert(point2);
 polyline = new GPolyline([ 
  new GLatLng(pointLat,pointLong), 
  new GLatLng(lat,lng) 
], "#ff0000", 5); 
map.addOverlay(polyline);
 }
 
       function arrowhide() {

      map.removeOverlay(marker2);
      map.removeOverlay(polyline);
      map.panTo(new GLatLng(pointLat,pointLong));  
	//tooltip.style.visibility="hidden";

      }
	  
/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function dati(lat,lng) {
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'select-map2.php?lat='+lat+'&lng=' +lng);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){ 
var response = http.responseText;

strut=response;

myCallback( strut );
}
}
	  
