
			   var map;
			   
			    // array to hold copies of the markers 
      var gmarkers = [];
      var marker = [];
	  var i;
	  var mm;
 


 
 
var zoomLevel = 16;

 function createMarker() {
   var point = new GLatLng(46.01167245,8.95568132);
   // Create a lettered icon for this point using our icon class
         var iconcustom=new GIcon();
        //  iconcustom.image = "http://www.rocoma.it/immagini_sys/map/marker_34_pointer_3.gif";
		 iconcustom.image = "img/headquarters1.png";
		 iconcustom.shadow = "img/shadow-headquarters1.png";
           //iconcustom. = "http://www.google.com/mapfiles/shadow50.png";
           iconcustom.iconSize = new GSize(32, 40);
           iconcustom.shadowSize = new GSize(53, 40);
           iconcustom.iconAnchor = new GPoint(16, 20);
           iconcustom.infoWindowAnchor = new GPoint(16, 20);

          // Set up our GMarkerOptions object
          //markerOptions = { icon:iconcustom };
          var marker = new GMarker(point, iconcustom);

         GEvent.addListener(marker, "mouseover", function() {
 marker.openInfoWindowHtml('<span class="font_02"><b>ZONAPROTETTA</b><br>via Bagutti, 2<br>CH 6900 LUGANO<br>T 091 923 80 40</span><br><br><form action="http://maps.google.com/maps" method="get" target="_blank"><span class="font_01">Inserisci il tuo indirizzo: <br>(es via Brentani, 3, 6900, Lugano)<br>' +'<input type="text" size="40" maxlength="40" name="saddr" id="saddr" value="" /><br></font>' +'<input value="calcola percorso" type="submit"/>' +'<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + '"/></form>');
 //  map.setCenter(point,zoomLevel,G_NORMAL_MAP); 

});
          return marker;
        }

           //var marker = new GMarker(point, iconcustom);
           //var marker = new PdMarker(point, iconcustom, Name);
          // var marker = new PdMarker(point, iconcustom,'ro', {draggable: true} );
//var marker = new GMarker(point, iconcustom);
 // function to repond to clicks and open info window
  function myclick(i) {
     gmarkers[i].openInfoWindowHtml(gmarkers[i].my_html);
     }
     
 function crea(){
  //  check to see if browser can run google API
  //  Bypassed for now
  if (GBrowserIsCompatible()) {

 
 

 // display the map, with some controls to set the initial location
    map = new GMap2(document.getElementById("map"));

   var centerPoint = new GLatLng(46.01288,8.95611);
var  point = new GLatLng(46.01288,8.95611);	

 
  
   _mPreferMetric=true;
map.hideControls();

////'mouseover' listener shows controls

GEvent.addListener(map, "mouseover", function(){
map.showControls();
});

////'mouseout' listener hides controls

GEvent.addListener(map, "mouseout", function(){
map.hideControls(); 
});
   map.addControl(new GSmallMapControl());
//    map.addControl(new GMapTypeControl()); 
    map.addControl(new GScaleControl());
//    map.addMapType(G_NORMAL_MAP);
  //  map.addMapType(G_SATELLITE_MAP);
 //   map.addMapType(G_HYBRID_MAP);
    
 map.enableContinuousZoom();
		map.enableDoubleClickZoom();
		map.enableScrollWheelZoom();
     
   map.setCenter(centerPoint,zoomLevel,G_NORMAL_MAP);  

      // Create the magnifier
    // var magControl = new GxMagnifierControl();
    // map.addControl(magControl);
    // var mag = magControl.GxMagnifierControl;
    
  //   add a map overview
    var ovcontrol = new GOverviewMapControl(new GSize(150,150));
    map.addControl(ovcontrol);
	 GEvent.addDomListener(map.getContainer(), "DOMMouseScroll", wheelevent);
map.getContainer().onmousewheel = wheelevent; 



 

  }
   

  else {
     alert("Sorry, the Google Maps API is not compatible with this browser");
  }    
  //setTimeout('prendi();',200);
  map.addOverlay(createMarker());
//  var point = new GLatLng(45.81556,8.83069);
//addMarkerP(point);
//var point = new GLatLng(45.81581,8.83254);
//addMarkerP(point);
//var point = new GLatLng(45.81514,8.82879);
//addMarkerP(point);
//var point = new GLatLng(45.81533,8.83150);
//addMarkerB(point, '<b>Autobus Urbano</b><br>Linea/e: <b>A</b> - <b>E</b><br><a href="http://www.sila.it" target="_blank">Orari</a>');
//var point = new GLatLng(45.81654,8.83266);
//addMarkerB(point, '<b>Autobus Urbano</b><br>Linea/e: <b>A</b> - <b>B</b>- <b>E</b>- <b>G</b>- <b>P</b><br><a href="http://www.sila.it" target="_blank">Orari</a>');
//var point = new GLatLng(45.81637,8.83295);
//addMarkerT(point, '<b>Ferrovie dello stato</b><br><a href="http://www.trenitalia.it" target="_blank">Orari</a>');
//var point = new GLatLng(45.81830,8.83332);
//addMarkerT(point, '<b>Ferrovie Nord Milano</b><br><a href="http://www.ferrovienord.it" target="_blank">Orari</a>');
//
//var point = new GLatLng(45.831994,8.833694);
//addMarkerF(point, '<B>FARMACIA: </B>All\'Ippodromo<br>Via Butti, 4-ang.V.Valganna<br>0332-239280<br>Chiusura: martedì pomeriggio'); 
//
//var point = new GLatLng(45.837039,8.795456);
//addMarkerF(point,'<B>FARMACIA: </B>Avigno<br>Via Saffi, 162<br>0332-225218<br>Chiusura: lunedì mattino e sabato pomeriggio'); 
//
//var point = new GLatLng(45.817352,8.827442);
//addMarkerF(point, '<B>FARMACIA: </B>Badò<br>Corso Aldo Moro, 13<br>0332-281567<br>Chiusura: lunedì'); 
//
//var point = new GLatLng(45.822849,8.834158);
//addMarkerF(point,'<B>FARMACIA: </B>Biumo<br>P.za XXVI Maggio, 4<br>0332-284362<br>Chiusura: sabato pomeriggio' ); 
//
//var point = new GLatLng(45.792387,8.850466);
//addMarkerF(point,'<B>FARMACIA: </B>Bizzozero<br>Via Adriatico, 5<br>0332-262360<br>Chiusura: venerdì mattino' ); 
//
//var point = new GLatLng(45.810967,8.799344);
//addMarkerF(point,'<B>FARMACIA: </B>Bobbiate<br>Via Daverio, 152<br>0332-310057<br>Chiusura: sabato' ); 
//
//var point = new GLatLng(45.811754,8.833267);
//addMarkerF(point,'<B>FARMACIA: </B>Bosto<br>Via S.Imerio, 23<br>0332-235134<br>Chiusura: giovedì mattino' ); 
//
//var point = new GLatLng(45.822295,8.818468);
//addMarkerF(point, '<B>FARMACIA: </B>Brunella<br>Via Salvo d\'Acquisto, 2<br>0332-289300<br>Chiusura: giovedì pomeriggio'); 
//
//var point = new GLatLng(45.81752,8.81446);
//addMarkerF(point, '<B>FARMACIA: </B>Casbeno<br>Via Monastero Vecchio, 45<br>0332-313132<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.818775,8.826289);
//addMarkerF(point, '<B>FARMACIA: </B>Centrale<br>Corso Matteotti, 48<br>0332-280370<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.820303,8.832588);
//addMarkerF(point, '<B>FARMACIA: </B>Gagliardelli<br>V.le Milano, 25<br>0332-288112<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.814866,8.835039);
//addMarkerF(point,'<B>FARMACIA: </B>Giubiano<br>P.za Biroldi, 20<br>0332-235021<br>Chiusura: lunedì mattino' ); 
//
//var point = new GLatLng(45.777258,8.770054);
//addMarkerF(point,'<B>FARMACIA: </B>Mandelli<br>Via Volta, 2<br>0332-283482<br>Chiusura: sabato'); 
//
//var point = new GLatLng(45.829014,8.799748);
//addMarkerF(point, '<B>FARMACIA: </B>Masnago<br>Via Caracciolo, 23<br>0332-225367<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.808461,8.836815);
//addMarkerF(point, '<B>FARMACIA: </B>Ospedale<br>V.le Borri, 28<br>0332-812101<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.843879,8.806326);
//addMarkerF(point, '<B>FARMACIA: </B>S.Ambrogio<br>Via Ausonio, 2<br>0332-227021<br>Chiusura: martedì mattino'); 
//
//var point = new GLatLng(45.830033,8.85126);
//addMarkerF(point, '<B>FARMACIA: </B>S.Fermo<br>Via Pergine, 5<br>0332-331302<br>Chiusura: sabato'); 
//
//var point = new GLatLng(45.801724,8.842568);
//addMarkerF(point, '<B>FARMACIA: </B>S.Maria<br>V.le Borri, 125<br>0332-263673<br>Chiusura: sabato pomeriggio'); 
//
//var point = new GLatLng(45.820145,8.826476);
//addMarkerF(point,'<B>FARMACIA: </B>Sociale<br>P.za Carducci, 2<br>0332-283463<br>Chiusura: lunedì mattino' ); 
//
//var point = new GLatLng(45.824732,8.846022);
//addMarkerF(point, '<B>FARMACIA: </B>Valle Olona<br>Via Dalmazia, 61<br>0332-331247<br>Chiusura: lunedì mattino'); 
//
//var point = new GLatLng(45.819478,8.842045);
//addMarkerF(point, '<B>FARMACIA: </B>V.le Belforte<br>V.le Belforte, 69/D<br>0332-334368<br>Chiusura: lunedì mattino'); 
//
//var point = new GLatLng(45.800401,8.8337);
//addMarkerF(point, '<B>FARMACIA: </B>V.le Europa<br>Via Gasparotto, 66<br>0332-286191<br>Chiusura: lunedì mattino' ); 


}

 

function wheelevent(e)
{
//if(document.getElementById("prevent").checked){
if (!e){
e = window.event
}
if (e.preventDefault){
e.preventDefault()
}
e.returnValue = false;
//}
}
  // functions to open direction forms
   function tohere(i) {
      gmarkers[i].openInfoWindowHtml(gmarkers[i].to_html );
      }   
   function fromhere(i) {
      gmarkers[i].openInfoWindowHtml(gmarkers[i].from_html );
      }   
	

function prendi() {
	
	rc=alert(point);


          // create variable based on starting map position
         var point = new GLatLng(46.01288,8.95611);
var marker1 = new GMarker(point, iconcustom);
 GEvent.addListener(marker1, "mouseover", function() {
 marker1.openInfoWindowHtml('<span class="font_02"><b>Multi Medica Varese Srl</b><br>via Piave, 9<br>21100 - Varese Italy<br>Tel: +39 0332 287257 - Fax:+39 0332 287257</span><br><form action="http://maps.google.com/maps" method="get" target="_blank"><span class="font_01">Inserisci il tuo indirizzo: (es via verdi, 1, 20100, milano)<br>' +'<input type="text" size="40" maxlength="40" name="saddr" id="saddr" value="" /><br></font>' +'<input value="calcola percorso" type="submit"/>' +'<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + '"/></form>');
});
map.addOverlay(marker1);
 
     
	//	}
	// }
     // request.send(null);




 //chiusura sql          
 }
 

 

function addMarkerP(point) {
    var icon = new GIcon();
    icon.image = "img/posteggio2.png";
    icon.shadow = "img/shadow-quadrato.png";
    icon.iconSize = new GSize(30.0, 32.0);
    icon.shadowSize = new GSize(47.0, 32.0);
    icon.iconAnchor = new GPoint(15.0, 16.0);
    icon.infoWindowAnchor = new GPoint(15.0, 16.0);
        
    map.addOverlay(new GMarker(point, icon));
 //   map.setCenter(point,zoomLevel,G_NORMAL_MAP); 

}

function addMarkerB(point, testo) {
    var icon = new GIcon();
    icon.image = "img/bus.png";
    icon.shadow = "img/shadow-quadrato.png";
    icon.iconSize = new GSize(30.0, 32.0);
    icon.shadowSize = new GSize(47.0, 32.0);
    icon.iconAnchor = new GPoint(15.0, 16.0);
    icon.infoWindowAnchor = new GPoint(15.0, 16.0);
   var   marker= new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowHtml(testo);
 map.setCenter(point,zoomLevel,G_NORMAL_MAP); 

									 });
	map.addOverlay(marker)	;
	return marker;
}
function addMarkerT(point, testo) {
    var icon = new GIcon();
    icon.image = "img/treno.png";
    icon.shadow = "img/shadow-quadrato.png";
    icon.iconSize = new GSize(30.0, 32.0);
    icon.shadowSize = new GSize(47.0, 32.0);
    icon.iconAnchor = new GPoint(15.0, 16.0);
    icon.infoWindowAnchor = new GPoint(15.0, 16.0);
        
 var   marker= new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowHtml(testo);
  map.setCenter(point,zoomLevel,G_NORMAL_MAP); 
		 });
//GEvent.addListener(marker, "mouseout", function() {
//marker.closeInfoWindow();
//		});	
	map.addOverlay(marker)	;
	return marker;
}

function addMarkerF(point, testo) {
    var icon = new GIcon();
    icon.image = "img/farmacia.png";
    icon.shadow = "img/shadow-farmacia.png";
    icon.iconSize = new GSize(30.0, 32.0);
    icon.shadowSize = new GSize(47.0, 32.0);
    icon.iconAnchor = new GPoint(15.0, 16.0);
    icon.infoWindowAnchor = new GPoint(15.0, 16.0);
        
 var   marker= new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowHtml(testo);
  map.setCenter(point,zoomLevel,G_NORMAL_MAP); 
		 });
//GEvent.addListener(marker, "mouseout", function() {
//marker.closeInfoWindow();
//		});	
	map.addOverlay(marker)	;
	return marker;
}
function addMarkerF_Turno(point, testo) {
    var icon = new GIcon();
    icon.image = "img/farmacia_t.png";
    icon.shadow = "img/shadow-farmacia.png";
    icon.iconSize = new GSize(30.0, 32.0);
    icon.shadowSize = new GSize(47.0, 32.0);
    icon.iconAnchor = new GPoint(15.0, 16.0);
    icon.infoWindowAnchor = new GPoint(15.0, 16.0);
        
 var   marker= new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowHtml(testo);
  map.setCenter(point,zoomLevel,G_NORMAL_MAP); 
		 });
//GEvent.addListener(marker, "mouseout", function() {
//marker.closeInfoWindow();
//		});	
	map.addOverlay(marker)	;
	return marker;
}

var address;
var indirizzi= new Array('Via Butti, 4','Via Saffi, 162','Corso Aldo Moro, 13','Piazza 26 Maggio, 4','Via Adriatico, 5','Via Daverio, 152','Via S.Imerio, 23','Via Salvo d\'Acquisto, 2','Via Monastero Vecchio, 45','Corso Matteotti, 48','V.le Milano, 25','P.za Biroldi, 20','Via Volta, 2','Via Caracciolo, 23','V.le Borri, 28','Via Ausonio, 2','Via Pergine, 5','V.le Borri, 125','P.za Carducci, 2','Via Dalmazia, 61','V.le Belforte, 69/D','Via Gasparotto, 66');
var testa;
function AddMarkerFromAddress() {
	
//rc=alert(window.map);
var Nazione='Italia';
for(var i=0; i<parseInt(indirizzi.length);i++){
	//pausecomp(400);
 window.address= indirizzi[i]+', 21100, VARESE, italia';

 testa=indirizzi[i];
var geocoder = new GClientGeocoder();
geocoder.getLatLng(address,function(point) {
		if (!point) {
//alert(window.address + "\nNON TROVATO !!!");
document.getElementById('scrivi').innerHTML =document.getElementById('scrivi').innerHTML + window.address +'NON TROVATO !!!<br>';
		} else {
//var marker = new GMarker(point);
//alert(point.x+','+point.y+'<br>');
document.getElementById('scrivi').innerHTML =document.getElementById('scrivi').innerHTML + window.address +'<br>var point = new GLatLng('+point.y+','+point.x+');<br>addMarkerB(point,  ); <br>';
//GEvent.addListener(marker, "click", function() {
//marker.openInfoWindowHtml(fumetto);
//});

//map.addOverlay(marker);
//rc=alert(point.lat());
//document.getElementById("lat").value=point.lat();
//document.getElementById("lng").value=point.lng();
// map.panTo(new GLatLng(point.lat(),point.lng()));
		}
	});
rc=alert(address);
}
}
function pausecomp(millis) 
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); } 
while(curDate-date < millis);
return;
} 

var xlongitudine = '';
var ylatitudine = '';
var indirizzi2='';
    function SendQuery(query)
    {
            query = escape(query);
            var xmlDoc = getXMLHttpRequestInstance();
            xmlDoc.open("GET" , "selezioni/aj_operazioni.asp?sql=" + escape(query), true);
            xmlDoc.send("");
    }

    function addresstopoint(ragsoc,address) {
	//	alert(address);
        var geocoder = new GClientGeocoder();
                                geocoder.getLatLng(address,function(point){
								window.indirizzi2=window.indirizzi2+address+'<br>';
                                try {
                                    xlongitudine = point.x; 
									ylatitudine = point.y;
									//alert(ragsoc);
                                    SendQuery("update farmacie set lang='" + xlongitudine + "', lat='" + ylatitudine + "' where ragsoc='" + ragsoc+"'");
                                } catch(e) {
                                xlongitudine = "0";
                                ylatitudine = "0";
                                SendQuery("update farmacie set lang='" + xlongitudine + "', lat='" + ylatitudine + "' where ragsoc='" + ragsoc+"'");
                }
                            }
                                );
    }

    function getXMLHttpRequestInstance() {
        var xmlhttp;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {

            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                xmlhttp = false;
            }
        }
    return xmlhttp;
}

function GetXMLList()
{
        var xmlDoc = getXMLHttpRequestInstance();
        xmlDoc.open("GET" , "selezioni/aj_farmaciegeo.asp", false);
        xmlDoc.send("");
		//alert(xmlDoc.responseXML);
                var x = xmlDoc.responseXML.getElementsByTagName("row");
				//alert(x.lenght);
                for (i=0;i<x.length;i++)//
                    {
						//alert(x[i].value);
                    var ragsoc;
                    var indirizzo;
                    var cap;
                    var citta;
                    var nazione;

//ragsoc=x[i].childNodes[1].firstChild.nodeValue;
//alert(ragsoc);


                    try {ragsoc=x[i].childNodes[1].firstChild.nodeValue;;} catch (e) {ragsoc = ''}
                    try {indirizzo=xmlDoc.responseXML.getElementsByTagName("indirizzo")[i].firstChild.nodeValue;} catch (e) {indirizzo = ''}
                    try {cap=xmlDoc.responseXML.getElementsByTagName("cap")[i].firstChild.nodeValue;} catch (e) {cap = ''}
                    try {citta=xmlDoc.responseXML.getElementsByTagName("citta")[i].firstChild.nodeValue;} catch (e) {citta = ''}
                    try {nazione=xmlDoc.responseXML.getElementsByTagName("nazione")[i].firstChild.nodeValue;} catch (e) {nazione = ''}
             //       try {addresstopoint(id, indirizzo + ',' + cap + ',' + citta + ',' + nazione);} catch (e) {}
				 try {addresstopoint(escape(ragsoc),indirizzo + ", "+cap+ ", "  + citta + ", " + nazione);} catch (e) {}
                 }
// document.write(window.indirizzi2);

}

function farmacie(){
	
	  var xmlDoc = getXMLHttpRequestInstance();
        xmlDoc.open("GET" , "selezioni/aj_farmacie.asp", false);
        xmlDoc.send("");
		//alert(xmlDoc.responseXML);
          var x = xmlDoc.responseXML.getElementsByTagName("row");
	for (i=0;i<x.length;i++)//
                    {
			var ragsoc;
			var indirizzo;
			var telefono;
			var chiusura;
			var turno;
			var lat;
			var lang;
	   		try {ragsoc=x[i].childNodes[1].firstChild.nodeValue;;} catch (e) {ragsoc = ''}
	        try {indirizzo=xmlDoc.responseXML.getElementsByTagName("indirizzo")[i].firstChild.nodeValue;} catch (e) {indirizzo = ''}
			 try {telefono=xmlDoc.responseXML.getElementsByTagName("telefono")[i].firstChild.nodeValue;} catch (e) {telefono = ''}
			  try {chiusura=xmlDoc.responseXML.getElementsByTagName("chiusura")[i].firstChild.nodeValue;} catch (e) {chiusura = ''}
			   try {turno=xmlDoc.responseXML.getElementsByTagName("turno")[i].firstChild.nodeValue;} catch (e) {turno = ''}
			try {lat=xmlDoc.responseXML.getElementsByTagName("lat")[i].firstChild.nodeValue;} catch (e) {lat = ''}
			try {lang=xmlDoc.responseXML.getElementsByTagName("lang")[i].firstChild.nodeValue;} catch (e) {lang = ''}
			lat=parseFloat(lat);
			lang=parseFloat(lang);
			var point = new GLatLng(lat,lang);
		var testo='<b>Farmacia:</b> '+ragsoc+'<br>'+indirizzo+'<br>Tel:'+telefono+'<br>Chiusura: '+chiusura;
		if (turno!=''){
			try {addMarkerF_Turno(point, testo)} catch (e) {}
		}
		 else {
			try {addMarkerF(point, testo)} catch (e) {}	 
		 }
					}
}
var nlat,nlang
function sposta(nlat,nlang){
	map.setZoom(13)
	//var z= map.getZoom()
//	if(z>16){
//	map.zoomOut();
//	map.zoomOut();
//	}
	nlat=parseFloat(nlat);
	nlang=parseFloat(nlang);
	//window.setTimeout(function() {
          map.panTo(new GLatLng(nlat, nlang));
      //  }, 1000);
}
