var license = "72652e7265706c61742e636f6d-4d454e3457454220532e722e6c-1869f-132915f-7374616e64617264-0";
var key = "ABQIAAAAUFrppv2oMiwmfR8jhoAHFRQCecenUwhGiRVk6bsTp8zLS8a7BRQQ9NXNSf0cGXW3xhh7-hbVXQ6w9Q";

if (document.domain == "re.replat.com") {
  key = "ABQIAAAABC8SCe9lvkf858krcc4S7BSTs5ulkBctK4Mc8QwIgXsf9NhW4BRRXomzcDNmEkzNYeUJFc1mdXseVw";
} else if (document.domain == "re.replat-test.com") {
  key = "ABQIAAAABC8SCe9lvkf858krcc4S7BTZ3PfdOu3ajwZ3fRmOXxNECPDN1hT2PSyiMBeIuJhDPY2OJgVAbsTlxQ";
  license = "72652e7265706c61742d746573742e636f6d-4d454e3457454220532e722e6c-1869f-132915f-7374616e64617264-0";
}

document.write('<script src="http://maps.google.com/maps?file=api&v=2&key=' + key + '" type="text/javascript"></script>');

// gestiore della mappa
var _gcodemap = null;

// semaforo per la gestione delle request multiple
var _keystrokeCount = 0;

// contiene l'ultimo indirizzo ricercato su mappa
var _lastAddressSearch = "";

// dettagli indirizzo al momenot visibile su mappa
var _geoLocationOnMap = null;

// input per ricercare da un indirizzo
var geo_input = null;

// contenitore della risposta della ricerca di un indirizzo
var _suggest = null;

function setMapLang(lang1) {
  maplang=lang1;
}


/**
 * caricamento pagina
 */
function loadPage(ac_type) {

  // creazione della mappa
	_gcodemap = new GeoCoderMap("map", license);

	// Enables double click to zoom in and out (disabled by default). 
	_gcodemap.enableDoubleClickZoom();
	// Enables zooming using a mouse's scroll wheel. Note: scroll wheel zoom is disabled by default.
	_gcodemap.enableScrollWheelZoom();
	// Creates a control with buttons to pan in four directions, and zoom in and zoom out.
	_gcodemap.addSmallMapControl();
	// Creates a control with buttons to pan in four directions, and zoom in and zoom out, and a zoom slider.
	// _gcodemap.addLargeMapControl();
	// Creates a control with buttons to zoom in and zoom out.
	// _gcodemap.addSmallZoomControl();
	// Creates a control that displays the map scale.
	// _gcodemap.addScaleControl();
	// Creates a standard map type control for selecting and switching between supported map types via buttons.
	// _gcodemap.addMapTypeControl();
	// Creates a drop-down map type control for switching between supported map types.
	 _gcodemap.addMenuMapTypeControl();
	// Creates a "nested" map type control for selecting and switching between supported map types via buttons and nested checkboxes.
	// _gcodemap.addHierarchicalMapTypeControl();
	// Creates a collapsible overview mini-map in the corner of the main map for reference location and navigation (through dragging).
	//_gcodemap.addOverviewMapControl();
	
	// gestione suggest
  _suggest = document.getElementById("suggest");
	
	// gestione ricerca indirizzo
	geo_input = document.getElementById("geo_input");
	
	// eseguo la localizzazione ad ogni digitazione
  //q.onkeyup = q.onchange = function(event){updateAddress(event)};
  
  // eseguo la localizzazione solo alla fine
  //q.onblur = function(event){updateAddress(event)};

	// a questo punto la mappa e' visualizzata e
	// possiamo mostrare il form di inserimento indirizzo
	// geo_search e' l'id della tabella che lo racchiude

  if(ac_type!='search'){
    document.getElementById('geo_search').style.visibility='visible';
    document.getElementById('geo_search').style.display='inline';
  }

	if (ac_type=='mod') {updateAddress();}
	
}

//funzione per visualizzare la mappa nella view
function loadPageView(div_name) {
  // creazione della mappa
  _gcodemap = new GeoCoderMap(div_name, license);

  // Enables double click to zoom in and out (disabled by default).
  _gcodemap.enableDoubleClickZoom();
  // Enables zooming using a mouse's scroll wheel. Note: scroll wheel zoom is disabled by default.
  _gcodemap.enableScrollWheelZoom();
  // Creates a control with buttons to pan in four directions, and zoom in and zoom out.
  _gcodemap.addSmallMapControl();
  // Creates a control with buttons to pan in four directions, and zoom in and zoom out, and a zoom slider.
  // _gcodemap.addLargeMapControl();
  // Creates a control with buttons to zoom in and zoom out.
  // _gcodemap.addSmallZoomControl();
  // Creates a control that displays the map scale.
  // _gcodemap.addScaleControl();
  // Creates a standard map type control for selecting and switching between supported map types via buttons.
  // _gcodemap.addMapTypeControl();
  // Creates a drop-down map type control for switching between supported map types.
   _gcodemap.addMenuMapTypeControl();
  // Creates a "nested" map type control for selecting and switching between supported map types via buttons and nested checkboxes.
  // _gcodemap.addHierarchicalMapTypeControl();
  // Creates a collapsible overview mini-map in the corner of the main map for reference location and navigation (through dragging).
  _gcodemap.addOverviewMapControl();

  // gestione suggest
  _suggest = document.getElementById("suggest");

  var q_address=document.getElementById('complete_address').value;
  var q_lat=document.getElementById('map_lat').value;
  var q_lng=document.getElementById('map_lng').value;
  var show_pointer=document.getElementById('show_pointer').value;

  if(show_pointer==1){
    viewAddress(q_lat,q_lng);
  }else{
    var point=new GeoPoint(q_lat,q_lng);
    // ricerca indirizzo
    setCenter(point);  
  }
  
}

function setCenter(point){
  _gcodemap.setCenter(point,16);
}

function setCenterSearch(){

  var lng=document.getElementById('map_lng').value;
  var lat=document.getElementById('map_lat').value;
  var map_range=document.getElementById('map_range').value;  
  var point=new GeoPoint(lat,lng);
  var zoom=setLevelZoom(map_range);
  _gcodemap.setCenter(point,zoom);

}

function setLevelZoom(map_range) {
    
  if(map_range==0.25){
    var zoom=15;
  }else if(map_range==0.5){
    var zoom=14;
  }else if(map_range==1){
    var zoom=13;
  }else if(map_range==2){
    var zoom=12;
  }else if(map_range==3){
    var zoom=11;
  }else if(map_range==4){
    var zoom=10;
  }else if(map_range==5){
    var zoom=11;
  }else if(map_range==10){
    var zoom=10;
  }else if(map_range==15){
    var zoom=9;
  }else if(map_range==25){
    var zoom=8;
  }else if(map_range==40){
    var zoom=8;
  }else if(map_range==65){
    var zoom=7;
  }
  return zoom;
}

// gestione eliminazione contenuti su mappa
function reset() {
  geo_input.value = "";
  _suggest.innerHTML = "";
  document.getElementById('counter_gg1').innerHTML="";
  //document.getElementById('counter_gg2').innerHTML="";
  _gcodemap.clear();
}

/**
 * richiamato durante la digitazione dell'indirizzo da parte dell'utente.
 * @param event gestore dell'evento che ha prodotto la richiesta.
 */
function updateAddress(event,ac_ac) {

	// ignore tabs
	if (event && event.keyCode == 9) {
		return;
	}

    // wait two seconds, and if no more keys have been pressed, then update the address and map
	_keystrokeCount++;
	
	// gestione temporizzazione
	window.setTimeout(function(){updateAddressMap(_keystrokeCount,ac_ac)}, 500);

}

/**
 * ricerca l'indirizzo su mappa.
 * @param keyCount
 * @return
 */
function updateAddressMap(keyCount,ac_ac) {
	// only do the backend calls if it's been at least two seconds since the last key was pressed


	if (keyCount != _keystrokeCount) {
		return;
	}

	// evitiamo di effettuare richieste multiple
	var addressNormalize = geo_input.value.replace(/[^A-Za-z0-9]/g,"");
	if (_lastAddressSearch != addressNormalize && addressNormalize.length > 0) {
		_lastAddressSearch = addressNormalize;
		
		// ricerca indirizzo
		_gcodemap.searchAddress(geo_input.value, function(name, response) {
			// numero di risultati prodotti dalla ricerca
			var nFound = response.length;
	
			// mostriamo le opzioni
			_geoLocationOnMap = null;

			if (nFound > 0) {

				// recupero l'indirizzo al momento visibile su mappa
				_geoLocationOnMap = response[0];

        if (maplang!='es') {
          label_indirizzotrovato='indrizzo trovato';
        }else {
          label_indirizzotrovato='direccion encontrada';
        }

				// comunicazione messaggio utente
				var didyouHTML = "<br/><b>"+label_indirizzotrovato+"</b> '" + _geoLocationOnMap.getAddress() + "'<br/>";

				// risultati multipli
				if (nFound > 1) {
				  if (maplang!='es') {
            label_forse_cercavi='forse cercavi';
          }else {
            label_forse_cercavi='puede ser que buscaba';
          }

					didyouHTML += "<br/>"+label_forse_cercavi+":<br/>";
					
					// loop through the results
					for (var i = 0; i < nFound; i++) {
						var location = response[i];
						if(ac_ac=='ro_search'){
						  didyouHTML += "<div><a href=\"javascript:placeAddress('" + encodeURIComponent(location.getAddress().replace("'", "\\'")) + "');updateAddress();ro_pleaseWait();\">" + location.getAddress() + "</a></div>";
						}else{
              didyouHTML += "<div><a href=\"javascript:placeAddress('" + encodeURIComponent(location.getAddress().replace("'", "\\'")) + "');updateAddress();\">" + location.getAddress() + "</a></div>";
            }
					}
					
					didyouHTML += "<br/>";
				}
				
				// comunicazione messaggio utente
				_suggest.innerHTML = didyouHTML;

				//GETCOORDS//

				var point = _geoLocationOnMap.getPoint();
				
				// setto le coordinate
				var lng = point.lng();
				var lat = point.lat();
				document.getElementById('map_lng').value=lng;
				document.getElementById('map_lat').value=lat;
				
				//richiamo funzione di recupero dettagli
				parseAddressDetails();	
				//GETCOORDS//

				//la seguente funzione è presente in geo.xsl//
				get_geo_id();

				if (document.getElementById('map_range')) {
					drawCircle();
				}

			} else {
	       
	      if (maplang!='es') {
          label_impossibile_localita='impossibile riconoscere la localita';
        }else {
          label_impossibile_localita='imposible reconocer la localidad';
        }
				// comunicazione messaggio utente
				_suggest.innerHTML = "<br/><b>"+label_impossibile_localita+"</b> '" + name + "'<br/>";
				
			}
			
		});  //fine _gcodemap.searchAddress
	}  else { 

		//GETCOORDS//
		var point = _geoLocationOnMap.getPoint();
		
		// setto le coordinate
		var lng = point.lng();
		var lat = point.lat();
		document.getElementById('map_lng').value=lng;
		document.getElementById('map_lat').value=lat;
	
		//richiamo funzione di recupero dettagli
		parseAddressDetails();	
		//GETCOORDS//
	
		//la seguente funzione è presente in geo.xsl//
		get_geo_id();

		if (document.getElementById('map_range')) {
			drawCircle();
		}

	}  // fine else if lastaddress

}

/**
 * ricerca l'indirizzo specificato.
 */
function placeAddress(address) {
	geo_input.value = decodeURIComponent(address);
}

/**
 * disegna un cerchio su mappa
 */

function drawCircle() {

	if (_geoLocationOnMap) {
		var point = _geoLocationOnMap.getPoint();
		
		// oppure
		// var point = new GeoPoint(-122.083739, 37.423021);
		if (document.getElementById('map_range').options[document.getElementById('map_range').selectedIndex].value!='---') {		
			var radius = document.getElementById('map_range').options[document.getElementById('map_range').selectedIndex].value;
			var fillOpacity = 0.4;
			var lineOpacity = 0.7;
		} else{
			var fillOpacity = 0.0;
			var lineOpacity = 0.0;
		}
		var quality = 40;
		var lineColor = "#555555";
		var lineWidth = 1;

		var fillColor = "#ff9900";
		// disegno cerchio
		_gcodemap.drawCircle(point, radius, quality, lineColor, lineWidth, lineOpacity, fillColor, fillOpacity);

		//re_counter();

	} else {
/////		alert('non e\' stato definito un punto sulla mappa; controllare l\'indirizzo e cliccare su \'conferma\'');
	}
}


function re_counter() {
    var point = _geoLocationOnMap.getPoint();
    radius= document.getElementById('map_range').options[document.getElementById('map_range').selectedIndex].value;
    var lng = point.lng();
    var lat = point.lat();
    
    //conto immobili
		document.getElementById('counter_gg1').innerHTML="";
		counter(lng,lat,radius,1);
}


/**
 * conta gli elementi presenti in un dato range
 */
function counter(map_lng,map_lat,map_range,gg) {

	try {
	  
	  var url = 'index.php?ac=geo_counter&gg='+gg+'&map_lng='+map_lng+'&map_lat='+map_lat+'&map_range='+map_range;
	  
    new Ajax.Updater('counter_gg'+gg, url,{asynchronous:true, evalScripts:true});
		
	} catch(e) {
	
		alert(e.message);
		
	}
	
}


/**
 * recupera la localizzazione in formato JSON_xAL
 */
function parseAddressDetails() {
  
  var addressDetailsJSON_xAL = _geoLocationOnMap.getAddressDetails();
  
  var complete_address = _geoLocationOnMap.getAddress();
  document.getElementById('complete_address').value=complete_address;
  
  var accuracy = addressDetailsJSON_xAL.Accuracy;

  if (addressDetailsJSON_xAL.Country){
    var country = addressDetailsJSON_xAL.Country.CountryName;
    var country_code = addressDetailsJSON_xAL.Country.CountryNameCode;
  }else {
    var country = "";
    var country_code = "";
  }
  
  if (addressDetailsJSON_xAL.Country.AdministrativeArea){

    var region = addressDetailsJSON_xAL.Country.AdministrativeArea.AdministrativeAreaName;
    //province
    if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea){
      var province = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
        //town
        if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality){
          var town = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
          //address
          if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare){
            var address = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
          }else if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality){
          	if(addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare){
          		var address = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare.ThoroughfareName;
          	}else{
          	  var address = "";
          	}
          }else{
        	  var address = "";
          }
          //fine address
          //cap
          if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode) {
            var cap = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
          }else if (addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality){
        	if(addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.PostalCode){
        		var cap = addressDetailsJSON_xAL.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.PostalCode.PostalCodeNumber;
        	}else{
        		var cap = "";
        	}
          }else{
        	  var cap = "";
          }
          //fine cap
        }else{
          var town = "";
        }
        //fine town
    }else{
      var province = "";
      if(addressDetailsJSON_xAL.Country.AdministrativeArea.Locality){
        var town = addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.LocalityName;
        //address
          if (addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.Thoroughfare){
            var address = addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
          }else if (addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality){
          	if(addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality.Thoroughfare){
          		var address = addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality.Thoroughfare.ThoroughfareName;
          	}else{
          	  var address = "";
          	}
          }else{
        	  var address = "";
          }
          //fine address
          //cap
          if (addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.PostalCode) {
            var cap = addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber;
          }else if (addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality){
        	if(addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality.PostalCode){
        		var cap = addressDetailsJSON_xAL.Country.AdministrativeArea.Locality.DependentLocality.PostalCode.PostalCodeNumber;
        	}else{
        		var cap = "";
        	}
          }else{
        	  var cap = "";
          }
          //fine cap
      }else{
        var town = "";
      }
    }
    //fine province
  }else{
    var region = "";
      if (addressDetailsJSON_xAL.Country.SubAdministrativeArea){
        var province = addressDetailsJSON_xAL.Country.SubAdministrativeArea.SubAdministrativeAreaName;
        //town
        if (addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality){
          var town = addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.LocalityName;
          //address
          if (addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.Thoroughfare){
            var address = addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;
          }else if (addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality){
          	if(addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare){
          		var address = addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare.ThoroughfareName;
          	}else{
          	  var address = "";
          	}
          }else{
        	  var address = "";
          }
          //fine address
          //cap
          if (addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.PostalCode) {
            var cap = addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
          }else if (addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality){
        	if(addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality.PostalCode){
        		var cap = addressDetailsJSON_xAL.Country.SubAdministrativeArea.Locality.DependentLocality.PostalCode.PostalCodeNumber;
        	}else{
        		var cap = "";
        	}
          }else{
        	  var cap = "";
          }
          //fine cap
        }else{
          var town = "";
        }
        //fine town
      }else{
        var province = "";
          if (addressDetailsJSON_xAL.Country.Locality){
            var town = addressDetailsJSON_xAL.Country.Locality.LocalityName;
            //address
            if (addressDetailsJSON_xAL.Country.Locality.Thoroughfare){
              var address = addressDetailsJSON_xAL.Country.Locality.Thoroughfare.ThoroughfareName;
            }else if (addressDetailsJSON_xAL.Country.Locality.DependentLocality){
            	if(addressDetailsJSON_xAL.Country.Locality.DependentLocality.Thoroughfare){
            		var address = addressDetailsJSON_xAL.Country.Locality.DependentLocality.Thoroughfare.ThoroughfareName;
            	}else{
            	  var address = "";
            	}
            }else{
          	  var address = "";
            }
            //fine address
            //cap
            if (addressDetailsJSON_xAL.Country.Locality.PostalCode) {
              var cap = addressDetailsJSON_xAL.Country.Locality.PostalCode.PostalCodeNumber;
            }else if (addressDetailsJSON_xAL.Country.Locality.DependentLocality){
          	if(addressDetailsJSON_xAL.Country.Locality.DependentLocality.PostalCode){
          		var cap = addressDetailsJSON_xAL.Country.Locality.DependentLocality.PostalCode.PostalCodeNumber;
          	}else{
          		var cap = "";
          	}
            }else{
          	  var cap = "";
            }
            //fine cap
          }else{
            var town = "";
          }  //fine if locality
      }  // fine if subadministrativearea
    
  }   // fine id administrativearea

  document.getElementById('geo_country_name').value=country;
  document.getElementById('geo_country_code').value=country_code;
  document.getElementById('geo_region_name').value=region;
  document.getElementById('geo_province_name').value=province;
  document.getElementById('geo_town_name').value=town;
  document.getElementById('geo_address').value=address;
  document.getElementById('cap').value=cap;
}


//usata per geocodificare i nostri immobili... temporanea con geolocate.php//
function searchAddressFromData(id) {

	geo_input.value=eval('document.getElementById(\'complete_address_'+id+'\')').value;
  	
	_gcodemap.searchAddress(geo_input.value, function (name,response){
      
      // numero di risultati prodotti dalla ricerca
			var nFound = response.length;

			if (nFound > 0) {
			
				// recupero l'indirizzo al momento visibile su mappa
				_geoLocationOnMap = response[0];

				// comunicazione messaggio utente
				var geo = _geoLocationOnMap.getAddress();
				var point = _geoLocationOnMap.getPoint();
        
        eval('document.getElementById(\'new_complete_address_'+id+'\')').value=geo;
				eval('document.getElementById(\'lat_'+id+'\')').value=point.lat();
				eval('document.getElementById(\'lng_'+id+'\')').value=point.lng();

		document.getElementById('query').innerHTML=document.getElementById('query').innerHTML+
		'update re_re set map_lng='+point.lng()+',map_lat='+point.lat()+' where id='+id+';<br/>';
				
			}
			
  });
	
}


function searchAddressFromData_address_null(id) {

	geo_input.value=eval('document.getElementById(\'complete_address_'+id+'\')').value;
  	
	_gcodemap.searchAddress(geo_input.value, function (name,response){
      
      // numero di risultati prodotti dalla ricerca
			var nFound = response.length;

			if (nFound > 0) {
			
				// recupero l'indirizzo al momento visibile su mappa
				_geoLocationOnMap = response[0];

				// comunicazione messaggio utente
				var geo = _geoLocationOnMap.getAddress();
				var point = _geoLocationOnMap.getPoint();
        
        eval('document.getElementById(\'new_complete_address_'+id+'\')').value=geo;
				eval('document.getElementById(\'lat_'+id+'\')').value=point.lat();
				eval('document.getElementById(\'lng_'+id+'\')').value=point.lng();

		document.getElementById('query').innerHTML=document.getElementById('query').innerHTML+
		'update re_re set map_lng='+point.lng()+',map_lat='+point.lat()+' where (address is null or address=\'null\' or address =\'n/a\') and geo_town_id='+id+';<br/>';
				
			}
			
  });
	
}

// visualizzazione punto su mappa
function viewAddress(map_lat,map_lng,address) {

  // caricamento XML
	var xmlstring = '<?xml version="1.0"?>'+
    '<GeoCoderMap>'+
      '<Style id="orange">'+
    		'<Icon width="12" height="20">http:&#47;&#47;labs.google.com/ridefinder/images/mm_20_orange.png</Icon>'+
    		'<Shadow width="22" height="20">http:&#47;&#47;labs.google.com/ridefinder/images/mm_20_shadow.png</Shadow>'+
    	'</Style>'+
    	'<Point lat="'+map_lat+'" lng="'+map_lng+'">'+
    		'<Snippet>'+address+'</Snippet>'+
    		'<StyleRef>address</StyleRef>'+
    	'</Point>'+
    '</GeoCoderMap>';

  _gcodemap.loadXmlData(xmlstring,true);
  
}

function viewAddressFromXml() {
  
  // caricamento XML
  var xmlstring=document.getElementById('google_xml').value;

  _gcodemap.loadXmlData(xmlstring,true);
  
}