﻿/*
'Autore:			Talesco Giovanni
'Descrizione: Funzioni di gestione della ricerca spaziale
*/


//Start - Funzioni UTILITY ***************************************************************************************
function verificaPresInvio(e)
//Verifica pressione del tasto invio
{
	//Determino tipo browser
	browserUtente = navigator.userAgent.toUpperCase();
	//alert(browserUtente);
	
	//Memorizzo il codice del tasto premuto
	if (browserUtente.indexOf("MSIE") >= 0)
  {	//1
   	CodiceTasto = window.event.keyCode;
  }	//1
  
  if (browserUtente.indexOf("MOZILLA") >= 0)
  {	//1
  	//alert("MOZILLA");
  	CodiceTasto = e.keyCode;
  }	//1
  //alert(CodiceTasto);

  //Eseguo l'operazione in base al tasto premuto
  if (CodiceTasto==13)
{	//1
		//Direttiva da inserire nel tag in cui si vuole gestire la pressione del tasto invio
		//onkeypress="javascript:verificaPresInvio(event);"
		
		Gestistisci_AvviaRicercaSpaziale();
	}	//1

}
//End - Funzioni UTILITY ***************************************************************************************


//Start - Funzioni INVIO RICHIESTA LISTA POI EFFETTIVI **********************************************************************
function FormattaAmpiezzaBuffer(objControllo)
//Riformatta il valore della textbox secondo le specifiche desiderate
{
	//In questo modo è possibile specificare un numero decimale sia con la virgola sia col punto.
	//Il software in automatico riformatterà la stringa inserita
	objControllo.value = objControllo.value.replace(",",".");
	
	return objControllo.value;
}

function FormattaLatLon(objControllo)
//Riformatta il valore della textbox secondo le specifiche desiderate
{
	//In questo modo è possibile specificare un numero decimale sia con la virgola sia col punto.
	//Il software in automatico riformatterà la stringa inserita
	objControllo.value = objControllo.value.replace(",",".");
	
	return objControllo.value;
}

function AggiornaOggettoBuffer()
//Aggiorna l'oggetto buffer sia dal punto di vista del valore che grafico
{
	//Buffer	
	AmpiezzaBuffer = document.getElementById("SelectAmpiezzaBuffer").value;
	
	//Percorso
	if (document.getElementById("SelectTipoBuffer_T").checked == true)
		TipoBuffer = "T";
	else
		TipoBuffer = "S";
	
	if (document.getElementById("SelectTipoPercorso_A").checked == true)
		TipoPercorso = "A";		
	else
		TipoPercorso = "P";	
		
	//Controllo formato distanza buffer
	if (IsBufferValue(AmpiezzaBuffer,TipoBuffer,TipoPercorso) == true)
	{	//1
		
		//Aggiorno il disegno del buffer e dello slider corrispondente
		ValoreSlider = CalcolaAmpiezzaSlider(parseFloat(AmpiezzaBuffer));
		document.getElementById("CampoValoreSlider").value = ValoreSlider;
		resize_buffer(ValoreSlider);
		
	}	//1
	else
	{	//1
		alert(strFormatoBuffer);
	}	//1
	
	return true;
}


function GestisciOnChangeAmpiezzaBuffer(objControllo)
//Gestione del cambio manuale del valore della textbox del buffer
{
	//Start - Formattazione ----------------------------
	//Formatto il dato inserito nella taxtbox del Buffer
	ValoreBuffer = FormattaAmpiezzaBuffer(objControllo);
	//End - Formattazione ------------------------------
	
	
	//Start - Aggiornamento oggetto buffer-------------
	AggiornaOggettoBuffer();
	//End - Aggiornamento oggetto buffer---------------
		
}

function GestisciOnChangeLatLon(objControllo)
{
	var RetVal;
	RetVal = false;
	
	
	//Start - Validazione dati -----------------------------------------
	lat = FormattaLatLon(document.getElementById("lat_ricspaziale"));
	lon = FormattaLatLon(document.getElementById("lon_ricspaziale"));
	
	//Conversione in gradi
	strGradLat = Convert_DecToGrad(lat);
	strGradLon = Convert_DecToGrad(lon);
	InserisciInGrad(strGradLat,strGradLon);
	
	//Controllo Presenza coordinate
	if ((lat != "") && (lon != ""))
	{	//0
		
		//Controllo formato e range delle coodinate del punto di partenza
		if (IsLatLong(lat,lon) == true)
		{	//1
			 
			 RetVal = true;
							
		}	//1
		else
		{	//1
			alert(strFormatoCoordinate + " " + strRangeLatLong);
		}	//1
		
				
	}	//0
	else
	{	//0
		alert(strCoordinate);
	}	//0
	//End - Validazione dati ----------------------------------------------
	
	
	
	//Start - Aggiornamento posizione buffer sulla mappa ------------------
	if (RetVal == true)
	{		//0
		
		//Conversione in UTM
		XGeo_RS=parseFloat(lon);
		YGeo_RS=parseFloat(lat);
		XUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[0];
		YUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[1];
		
		AggiornaPosizioneBuffer(XUtm_RS,YUtm_RS);
    
     
	}		//0
	//End - Aggiornamento posizione buffer sulla mappa ---------------------
	
}

function GestisciOnChangeLatLonGradi(objControllo)
{
	var RetVal;
	RetVal = false;
	
	
	//Start - Validazione dati -----------------------------------------
	LatG = document.getElementById("lat_g").value;
	LatP = document.getElementById("lat_p").value;
	LatS = document.getElementById("lat_s").value;
	
	LonG = document.getElementById("lon_g").value;
	LonP = document.getElementById("lon_p").value;
	LonS = document.getElementById("lon_s").value;
	
	//Conversione
	strDecLat = Convert_GradToDec(LatG,LatP,LatS).replace(",",".");
	strDecLon = Convert_GradToDec(LonG,LonP,LonS).replace(",",".");
		
	//Scrivi nelle texbox dei decimali
	InserisciInDec(strDecLat,strDecLon);
	
	
	//Controllo Presenza coordinate
	if ((LatG + LatP + LatS != "") && (LonG + LonP + LonS != ""))
	{	//0
				
				
		//Controllo formato e range delle coodinate del punto in GRADI
		if ((strDecLat != "") && (strDecLon != ""))
		{	//1
									
			//Controllo formato e range delle coodinate del punto in DECIMALE
			if (IsLatLong(strDecLat,strDecLon) == true)
			{	//2
				 
				 RetVal = true;
								
			}	//2
			else
			{	//2
				alert(strFormatoCoordinate + " " + strRangeLatLong);
			}	//2
			
			
		}	//1
		else
		{	//1
			alert(strFormatoCoordinate + " " + strRangeLatLong);
		}	//1
	
				
	}	//0
	else
	{	//0
		alert(strCoordinate);
	}	//0
	//End - Validazione dati ----------------------------------------------
	
	
	//Start - Aggiornamento posizione buffer sulla mappa ------------------
	if (RetVal == true)
	{		//0
		
		//Conversione in UTM
		XGeo_RS=parseFloat(strDecLon);
		YGeo_RS=parseFloat(strDecLat);
		XUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[0];
		YUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[1];
		
		AggiornaPosizioneBuffer(XUtm_RS,YUtm_RS);
		
	}		//0
		
}


function Convert_DecToGrad(Dec)
//input: stringa decimale lat lon
//output: stringa in grad lat lon formattata g|p|s
//Se errore o input vuoto allora strGrad ritornata = ""
{
	strGrad = "";
	
	try
	{//0
		
		//Controllo presenza input
		if (Dec != "")
		{	//1
			
			valDec = parseFloat(Dec);		//Valore decimale
			
			if (valDec >= 0)						//Segno (In realtà non utilizzato in questa applicazione)
			{
				segno = 1;
			}
			else
			{
				segno = -1;
			}
			
			valG = Math.floor(valDec);	//Gradi
			
			aux = (valDec - valG)*60;
			
			valP = Math.floor(aux);			//Primi
			
			aux = (aux - valP)*60;
			
			valS = Math.floor(aux);			//Secondi
			
			strGrad = String(valG) + "|" + String(valP) + "|" + String(valS);
			
		}	//1

	}
	catch(e)	
	{
	}
	finally
	{
		return strGrad;
	}
	
}


function Convert_GradToDec(g,p,s)
//input: g,p,s stringa
//output: decimale in stringa
//Se errore o input vuoto allora strDecimale  ritornata = ""
{
	strDec = "";
	Dec = 0;
	
	try
	{//0
		
		//Controllo presenza input
		if ((g + p + s) != "")
		{	//1
			
			//Start - inizializzazione valori
			if (g == "")
				{
					valg = 0;
				}
			else
				{
					valg = parseInt(g);
				}
				
			if (p == "")
				{
					valp = 0;
				}
			else
				{
					valp = parseInt(p);
				}
				
			if (s == "")
				{
					vals = 0;
				}
			else
				{
					vals = parseInt(s);
				}	
			//End - inizializzazione valori
			
			
			//Conversione in Decimale
			Dec = valg + valp/60 + vals/3600;
			
			//Conversione in stringa
			strDec = String(Dec);
		}	//1

	}
	catch(e)	
	{
	}
	finally
	{
		return strDec;
	}
	
}

function InserisciInDec(strDecLat,strDecLon)
//Scrive i lat lon nella texbox decimale
//Input: stringa che rappresenta il lat lon in decimale
{
	if (strDecLat != "")
	{
		document.getElementById("lat_ricspaziale").value = arrotonda(strDecLat,4);
	}
	else
	{
		document.getElementById("lat_ricspaziale").value = "";
	}	
	
	if (strDecLon)
	{
		document.getElementById("lon_ricspaziale").value = arrotonda(strDecLon,4);
	}
	else
	{
		document.getElementById("lon_ricspaziale").value = "";
	}	
	
}

function InserisciInGrad(strGradLat,strGradLon)
//Scrive i lat lon nella texbox in gradi
//Input: stringa che rappresenta il lat lon in gradi
{
	//alert("strGradLat: " + strGradLat + " - " + "strGradLon: " + strGradLon);
	
	//LAT
	if (strGradLat != "")
	{
		//Estraggo le singole componenti Lat
		arrayLat = strGradLat.split("|");
		
		//Setto textbox LAT
		document.getElementById("lat_g").value = arrayLat[0];
		document.getElementById("lat_p").value = arrayLat[1];
		document.getElementById("lat_s").value = arrayLat[2];
	}
	else
	{
		//Setto textbox LAT
		document.getElementById("lat_g").value = "";
		document.getElementById("lat_p").value = "";
		document.getElementById("lat_s").value = "";
	}
	
	//LON
	if (strGradLon != "")
	{
		//Estraggo le singole componenti Lon
		arrayLon = strGradLon.split("|");
		
		//Setto textbox LON
		document.getElementById("lon_g").value = arrayLon[0];
		document.getElementById("lon_p").value = arrayLon[1];
		document.getElementById("lon_s").value = arrayLon[2];
	}
	else
	{
		//Setto textbox LON
		document.getElementById("lon_g").value = "";
		document.getElementById("lon_p").value = "";
		document.getElementById("lon_s").value = "";
	}
	
}

function AggiornaPosizioneBuffer(x,y)
//x,y centro buffer in formato UTM
{
	//Aggiornamento buffer
	if (map.getLayerIndex(pointLayer)!=-1 )
	{		//1
		
   	if ( map.layers[map.getLayerIndex(pointLayer)].features.length>0)
   	{		//2
   		map.layers[map.getLayerIndex(pointLayer)].features[0].geometry.x = x;
   		map.layers[map.getLayerIndex(pointLayer)].features[0].geometry.y = y;
   		
   		map.layers[map.getLayerIndex(pointLayer)].drawFeature(map.layers[map.getLayerIndex(pointLayer)].features[0]);
   	}
   	else if (map.layers[map.getLayerIndex(pointLayer)].features.length==0)
   	{	//2
   		geometry_point=new OpenLayers.Geometry.Point(x,y);
    	feature_point = new OpenLayers.Feature.Vector(geometry_point);
   		map.layers[map.getLayerIndex(pointLayer)].addFeatures([feature_point]);
   		map.layers[map.getLayerIndex(pointLayer)].drawFeature(feature_point);	
   	}	//2
   	
 		//Aggiornamento marker
		indice_marker=map.getLayerIndex(markers_buffer);
		map.layers[indice_marker].clearMarkers();
		coord_buffer=new OpenLayers.LonLat(x,y)
		marker_buf = new OpenLayers.Marker(coord_buffer,icon_buffer);
		map.layers[indice_marker].addMarker(marker_buf);

   	
  }		//1
  
  return true;
}


function Gestistisci_ResettaRicercaSpaziale()
//Procedura di reset dei campi della ricerca spaziale
{
	//Servizio
		//Tema
		ObjControlloTema = document.getElementById("TemaRicercaProx");
		ObjControlloTema.selectedIndex = 0;
	
	
	//Punto di partenza
		//Coordinate
		InserisciInDec("","");
				
		document.getElementById("lat_ricspaziale_geo").value = "";
		document.getElementById("lon_ricspaziale_geo").value = "";
		
		InserisciInGrad("","");
				
		
		
		//Marker del buffer
		try
		{
			objFeatureMarker = map.getLayerIndex(markers_buffer);
			
			//Se l'oggetto esiste allora lo distruggo
			if (objFeatureMarker != -1)
			{
				map.layers[objFeatureMarker].clearMarkers();	
			}
		}
		catch(e){}
	
	
	//Ampiezza buffer
	resize_buffer(0);
	document.getElementById("UnitaMisuraAmpiezzaBuffer").value = UM_S;

	
	//Tipo distanza e tipo percorso
	document.getElementById("SelectTipoBuffer_S").checked = true;
	document.getElementById("SelectTipoBuffer_T").checked = false;
	
	document.getElementById("SelectTipoPercorso_A").checked = true;
	document.getElementById("SelectTipoPercorso_P").checked = false;
	
	document.getElementById("RigaTipoPercorso").style.display = "none";
	
		
	//Eliminazione del buffer
	destroy_buffer();
	
}


function Gestistisci_AvviaRicercaSpaziale()
//Gestione richesta di ricerca spaziale
{
	
	var RetVal;
	var idTema, TitoloTema;
	var AmpiezzaBuffer, TipoBuffer, TipoPercorso;
	var lat_ricspaziale, lon_ricspaziale;
	
	
	RetVal = false;
	
	//Start - Determinazione parametri di ricerca
	//Lat Long
	lat_ricspaziale = document.getElementById("lat_ricspaziale").value;
	lon_ricspaziale = document.getElementById("lon_ricspaziale").value;
	
	
	
	//Tema
	ObjControlloTema = document.getElementById("TemaRicercaProx");		//Prima dell'approvazione la combo di riferimento era (tema)
	idTema_RS = ObjControlloTema.value;;
	NomeTema_RS = ObjControlloTema.options[ObjControlloTema.selectedIndex].text;
		
		
	//Buffer	
	AmpiezzaBuffer = document.getElementById("SelectAmpiezzaBuffer").value;
	
	//Percorso
	if (document.getElementById("SelectTipoBuffer_T").checked == true)
		TipoBuffer = "T";
	else
		TipoBuffer = "S";
	
	if (document.getElementById("SelectTipoPercorso_A").checked == true)
		TipoPercorso = "A";		
	else
		TipoPercorso = "P";		
	//End - Determinazione parametri di ricerca
	
				
	//Start - Validazione dati ---------------------------------------
	//Controllo Presenza coordinate
	if ((lat_ricspaziale != "") && (lon_ricspaziale != ""))
	{	//0
		
		//Controllo formato e range delle coodinate del punto di partenza
		if (IsLatLong(lat_ricspaziale,lon_ricspaziale) == true)
		{	//1
			 
			 //Conversione in UTM
			 XGeo_RS=parseFloat(lon_ricspaziale);
  		 YGeo_RS=parseFloat(lat_ricspaziale);
			 XUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[0];
			 YUtm_RS=(LL2UTM(YGeo_RS,XGeo_RS,33))[1];
			
			//Controllo presenza distanza buffer
			if (AmpiezzaBuffer != "")
			{	//2
				
				//Controllo formato distanza buffer
				if (IsBufferValue(AmpiezzaBuffer,TipoBuffer,TipoPercorso) == true)
				{	//3
					
					//Controllo presenza tematismo
					if (parseInt(idTema_RS) != 0)
					{		//4
						
						//Controllo tematismo selezionato
						if (TematismoAmmesso(idTema_RS) == true)
						{		//5
							RetVal = true;
						}		//5
						else
						{		//5
							alert(strTematismoSelezionato);
						}		//5
						
					}		//4
					else
					{		//4
						alert(strTematismo);
					}		//4
					
				}	//3
				else
				{	//3
					alert(strFormatoBuffer);
				}	//3
				
			}	//2
			else
			{	//2
				alert(strAmpiezzaBuffer);

			}	//2
			
			
		}	//1
		else
		{	//1
			alert(strFormatoCoordinate + " " + strRangeLatLong);
		}	//1
		
				
	}	//0
	else
	{	//0
		alert(strCoordinate);
	}	//0
	//End - Validazione dati -------------------------------------
	
	
	
	//Start - Esecuzine in base all'esito della validazione -------
	//Se la validazione è andata a buon fine allora potrò avviare effettivamente la RicercaSpaziale
	if (RetVal == true)
	{
		AvviaRicercaSpaziale(AmpiezzaBuffer,TipoBuffer,TipoPercorso,lat_ricspaziale,lon_ricspaziale,XUtm_RS,YUtm_RS,idTema_RS,NomeTema_RS);
	}
	//End - Esecuzine in base all'esito della validazione ---------
	
	return RetVal;
}
	

function IsLatLong(strLat,strLong)
//Verifica formato coordinate
//Si assume che le stringhe non siano vuote
//Se il parametro rispetta i requisiti allora TRUE altruimensi FALSE
{
	var RetVal;
		
	RetVal = false;

	//alert("strLat: " + strLat + " - " + "strLong: " + strLong);
			
	//Controllo che si tratti di numeri
	if ((!isNaN(strLat)) && (!isNaN(strLong)))
	{	
			
			//Controllo range
			if ((parseFloat(strLat) >= minLat) && (parseFloat(strLat) <= maxLat) && (parseFloat(strLong) >= minLong) && (parseFloat(strLong) <= maxLong))
			{
				RetVal = true;
			}
	}	
	
	return RetVal;	
}


function IsBufferValue(strAmpiezzaBuffer,TipoBuffer,TipoPercorso)
//Verifica formato dell'ampiezza del buffer
//Si assume che la stringa non sia vuota
//Se il parametro rispetta i requisiti allora TRUE altruimensi FALSE
{
	var RetVal;
	var Range;
			
	RetVal = false;
	
	
	//Controllo che si tratti di numeri
	if (!isNaN(strAmpiezzaBuffer))
	{	
		
			//Determino range
			if (TipoBuffer == "S")
			{
				Range = rangeSpaziale;
			}
			else
			{
				if (TipoPercorso == "A")
					Range = rangeTemporale_A;
				else
					Range = rangeTemporale_P;
					
			}
			
			//Controllo appartenenza al range
			if ((parseFloat(strAmpiezzaBuffer) > 0) && (parseFloat(strAmpiezzaBuffer) <= Range))
			{
				RetVal = true;
			}
			
	}	
	
	return RetVal;	
}

function TematismoAmmesso(idTema_RS)
//Controllo tematismo selezionato
{
	
	if ((idTema_RS != -1) && (idTema_RS != 20) && idTema_RS.indexOf(",") == -1)
	{
		return true;
	}
	else
	{
		return false;
	}
	
}



function AvviaRicercaSpaziale(AmpiezzaBuffer,TipoBuffer,TipoPercorso,lat_ricspaziale,lon_ricspaziale,XUtm_RS,YUtm_RS,idTema_RS,NomeTema_RS)
//Prepara la chiamata alla pagina di script lato server per la ricerca spaziale effettiva
//Si assume che la validazione dei dati sia stata già fatta

{
	PrefissoURL = "./RicercaSpaziale/ListaIdRSS.asp"
	
	//Start - Creo querystring --------------------
 	QueryString = "?AmpiezzaBuffer=" + AmpiezzaBuffer + "&TipoBuffer=" + TipoBuffer + "&TipoPercorso=" + TipoPercorso;
 	QueryString = QueryString + "&lat_ricspaziale=" + lat_ricspaziale + "&lon_ricspaziale=" + lon_ricspaziale;
 	QueryString = QueryString + "&XUtm_RS=" + XUtm_RS + "&YUtm_RS=" + YUtm_RS;
 	QueryString = QueryString + "&VelocitaMediaAuto=" + VelocitaMediaAuto + "&VelocitaMediaPiedi=" + VelocitaMediaPiedi;
 	QueryString = QueryString + "&idTema_RS=" + idTema_RS + "&NomeTema_RS=" + NomeTema_RS;
 	//End - Creo querystring ----------------------
	
	//alert(PrefissoURL + QueryString);
	
	document.getElementById("iframeRisultatoRicercaSpaziale").src = PrefissoURL + QueryString;	
	
}


function AccettaSelectTipoBuffer(objControllo)
{
	//alert(objControllo.id);
		
	if (objControllo.id == "SelectTipoBuffer_T")
	{		//1
		
		//Accendo la riga di selezione tipo percorso
		document.getElementById("RigaTipoPercorso").style.display = "";
		
	}		//1
	else
	{		//1
		
		//Spengo la riga di selezione tipo percorso
		document.getElementById("RigaTipoPercorso").style.display = "none";
		document.getElementById("UnitaMisuraAmpiezzaBuffer").value = UM_S;
		
	}		//1
	
		
	CambiaUnitaMisura();
	
	//CalcolaAmpiezzaBuffer(parseFloat(document.getElementById("CampoValoreSlider").value));
}


function AccettaSelectTipoPercorso(objControllo)
{
	//alert(objControllo.id);
	
	CambiaUnitaMisura();
	
	//CalcolaAmpiezzaBuffer(parseFloat(document.getElementById("CampoValoreSlider").value));
		
}


function CambiaUnitaMisura()
{
	var UM = "";
	
	//Determino l'unità di misura
	if (document.getElementById("SelectTipoBuffer_S").checked == true)
	{	//1
		UM = UM_S;				//temporale Spaziale
	}	//1
	else
	{	//1
		
		if (document.getElementById("SelectTipoPercorso_A").checked == true)
		{	//2
			UM = UM_T_A;		//Temporale Auto
		}	//2
		else
		{	//2
			UM = UM_T_P;		//Temporale a Piedi
		}	//2
		
	}	//1
	
	//Visualizzo l'unità di misura
	document.getElementById("UnitaMisuraAmpiezzaBuffer").value = UM;
	
	return true;
}


function CalcolaAmpiezzaBuffer(ValoreSlider)
//Calcola e visualizza l'ampiezza del buffer in funzione dei parametri di ricerca e del valore dello slider[0,1]
//In [metri] per ricerca spaziale
//In [secondi] per ricerca temporale
{
	
	if (document.getElementById("SelectTipoBuffer_S").checked == true)
	{
		AmpiezzaCalcolata = ValoreSlider*rangeSpaziale;		//Spaziale
		
	}	
	else
	{	
		if (document.getElementById("SelectTipoPercorso_A").checked == true)
			AmpiezzaCalcolata = ValoreSlider*rangeTemporale_A;		//Temporale Auto
		else
			AmpiezzaCalcolata = ValoreSlider*rangeTemporale_P;		//Temporale Piedi
		
	}
	
	//Arrotondamento alla secoda cifra decimale
	AmpiezzaCalcolata = arrotonda(AmpiezzaCalcolata,2);
	
	document.getElementById("SelectAmpiezzaBuffer").value = AmpiezzaCalcolata;

}

function CalcolaAmpiezzaSlider(ValoreBuffer)
//Calcola l'ampiezza dello Slider[0,1] in funzione del buffer specificato

{
	ValoreSlider = 0
	
	if (document.getElementById("SelectTipoBuffer_S").checked == true)
	{
		ValoreSlider = ValoreBuffer/rangeSpaziale;		//Spaziale
		
	}	
	else
	{	
		if (document.getElementById("SelectTipoPercorso_A").checked == true)
			ValoreSlider = ValoreBuffer/rangeTemporale_A;		//Temporale Auto
		else
			ValoreSlider = ValoreBuffer/rangeTemporale_P;		//Temporale Piedi
		
	}
	return ValoreSlider;
	
}

function VisualizzaPOI(idTema_RS,idAttrattori_RS)
{
	//alert("VisualizzaPOI");
	//alert("idTema_RS: " + idTema_RS + " " + "idAttrattori_RS: " + idAttrattori_RS)
	//MC 28-03-08
	id_tematismo=""
	SwitchBGOffAll()
	crea_query(idTema_RS,idAttrattori_RS)
	
}
//End - Funzioni INVIO RICHIESTA LISTA POI EFFETTIVI *******************************************************************


//Start - Funzioni Geocoding ****************************************************************************************
function AvviaGeocodingRicercaSpaziale(x,y)
{
	PrefissoURL = "./RicercaSpaziale/Geocode.asp"
	
	//Start - Creo querystring --------------------
 	QueryString = "?x=" + x + "&y=" + y;
 	//End - Creo querystring ----------------------
	
	//alert(PrefissoURL + QueryString);
	
	document.getElementById("iframeRisultatoRicercaSpaziale").src = PrefissoURL + QueryString;
}

function InserisciRisultatoGeocode(citta,indirizzo,civico)
//Scrive nel documento html le informazioni ottenute con il geocode
{
	//alert(citta + " - " + indirizzo + " - " + civico);
	
	document.getElementById("Citta").value = citta;
	document.getElementById("Indirizzo_cerca").value = indirizzo;
	document.getElementById("Civico").value = civico;

}
//End - Funzioni Geocoding ******************************************************************************************