function trim(str) 
{
  return str.replace(/^\s+|\s+$/g, '');
}


function avvio() {
	// calcolo le dimensioni dello schermo
	var larghezza = 0, altezza = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		larghezza = window.innerWidth;
		altezza = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		larghezza = document.documentElement.clientWidth;
		altezza = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		larghezza = document.body.clientWidth;
		altezza = document.body.clientHeight;
	}
}
function blocca(id) {
	if ( document.getElementById(id) ) {
		if (document.getElementById(id).style.display == 'block') {
			document.getElementById(id).style.display = 'none';
			} else {
	document.getElementById(id).style.display = 'block';
	}
	}
}
function nascondi(id){
	if ( document.getElementById(id) ) {
	document.getElementById(id).style.display = 'none';
	}
}
function visualizza(id){
	if ( document.getElementById(id) ) {
	document.getElementById(id).style.display = 'block';
	}
}
function mostra(id){
	if ( document.getElementById(id) ) {
	document.getElementById(id).style.display = '';
	}
}
function vai(id){
	location.href = id;
}
function settavalore(formmoduloid,id,nuovovalore){
	eval("document."+formmoduloid+"."+id+".value='"+nuovovalore+"'");
}
function settavaloredahtml(formmoduloid,id,nuovovalore){
	valoredaprendere = document.getElementById(nuovovalore).innerHTML 
	valoredaprendere = valoredaprendere.replace(/\'/g,"'");
	valoredaprendere = valoredaprendere.replace(/\"/g,"");
	eval("document."+formmoduloid+"."+id+".value='"+valoredaprendere+"'");
}
function settavalorehtml(id,nuovovalore){
	document.getElementById(id).innerHTML = nuovovalore;
}
function cambia(formmodulo,modulo,formmoduloid,id) {
	var nuovovalore;
	eval("nuovovalore=document."+formmodulo+"."+modulo+".value");
	
	nuovovalore = nuovovalore.replace(/\n/g,"<br>");
	//nuovovalore = nuovovalore.replace(/\r/g,"<br>");
	if (formmoduloid == '') {
		if (document.getElementById(id)) {
		document.getElementById(id).innerHTML = nuovovalore;
		}
	} else {
		eval("document."+formmoduloid+"."+id+".value='"+nuovovalore+"'");
	}
}

function daivisibilita(id){
	document.getElementById(id).style.visibility = "visible";
}

function settaposizione(divdaspostare,divperposizione,destrasinistra) {
	//window.alert (document.getElementById(divperposizione).offsetRight)
	if (destrasinistra == 0) {
		document.getElementById(divdaspostare).style.left = document.getElementById(divperposizione).offsetLeft + "px"
	} else {
		//document.getElementById(divdaspostare).style.left = (document.getElementById(divperposizione).offsetLeft+document.getElementById(divperposizione).offsetWidth-document.getElementById(divdaspostare).offsetWidth)+"px";
		document.getElementById(divdaspostare).style.left = (document.getElementById(divperposizione).offsetLeft+document.getElementById(divperposizione).offsetWidth)-435+"px";
	}
	document.getElementById(divdaspostare).style.visibility = "visible";
	document.getElementById(divdaspostare).style.display = "none";
}

function colora(id) {
	var theParagraph = document.getElementById('menutestata')
	for (x=1; theParagraph.childNodes[x]; x++ ) {
		document.getElementById(theParagraph.childNodes[x].id).style.background = ""
		document.getElementById(theParagraph.childNodes[x].id).style.color = "#666666"
		theParagraphb = document.getElementById(theParagraph.childNodes[x].id)
		for( var k = 0; k < theParagraphb.attributes.length; k++ ) {
			//window.alert(theParagraphb.childNodes[0].nodeName.toLowerCase())
			theParagraphb.childNodes[0].setAttribute('class','nonselezionato');
		}
		
	}
	if (document.getElementById(id)) {
	document.getElementById(id).style.background = "url(/layout/sfondo_menu.png) repeat";
	document.getElementById(id).childNodes[0].setAttribute('class','selezionato');
	}
}


function mondo(id) {
	document.getElementById('globe').style.background = "url(/layout/continenti.png) 0 -" + 209*id + "px no-repeat";
}

function mostratabella(id)
	{
	var nuovatabella = document.getElementById(id).innerHTML
	//nuovatabella = nuovatabella.replace("tabelladatism", "tabelladatibig")
	nuovatabella = "<table border='0' cellspacing='0' cellpadding='0' width='100%' height='100%' valign='center' align='center'><tr><td align='center'><table id='tabellagrande' class='tabelladatibig' border='0' cellspacing='0' cellpadding='0'>" + nuovatabella + "</table></td></tr></table>"
	document.getElementById('tabschermointero').innerHTML = nuovatabella
	visualizza('tabschermointero')
	}

function chiamafotovideo(fotoovideo,url,titolo,testo,id2) {
	if (document.formimmagine) {
		if (document.formimmagine.id2) {
		document.formimmagine.id2.value = id2
		}
	}
	if (document.formvideo) {
		if (document.formvideo.id2) {
		document.formvideo.id2.value = id2
		}
	}
	if (document.getElementById('contenitorefilmato')) {
	if (fotoovideo == 1) {
		valoreinner = "<img src='/img/big/"+url+"' alt='"+titolo+"' title='"+titolo+"' width='440' height='324'/>"
		if (document.getElementById('eliminafoto')) {
			document.getElementById('eliminafoto').innerHTML = "<a href='?gar=7"+id2+"'>elimina foto</a>"
			}
		if (document.getElementById('cambioimmagine')) {
			visualizza('cambioimmagine')
			}
		if (document.getElementById('cambiovideo')) {
			nascondi('cambiovideo')
			}
		} else {
		valoreinner = "<object width='440' height='264'><param name='movie' value='http://www.youtube.com/v/"+url+"?fs=1&amp;hl=it_IT&amp;rel=0&amp;autoplay=1&amp;loop=1&amp;autohide=1'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/"+url+"?fs=1&amp;hl=it_IT&amp;rel=0&amp;autoplay=1&amp;loop=1&amp;autohide=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='440' height='264' background='transparent'></embed></object><div class='spiegazione'><u id='titolovideo'>"+titolo+"</u><br><span id='testovideo'>"+testo+"</span></div>"
		if (document.getElementById('eliminafoto')) {
			document.getElementById('eliminafoto').innerHTML = "<a href='?gar=8"+id2+"'>elimina video</a>"
			}
		if (document.getElementById('cambioimmagine')) {
			nascondi('cambioimmagine')
			document.formvideo.titolovideomodulo.value = titolo
			}
		if (document.getElementById('cambiovideo')) {
			visualizza('cambiovideo')
			document.formvideo.testovideomodulo.value = testo
			}
	}
	document.getElementById('contenitorefilmato').innerHTML = valoreinner;
	}
}

function controllaobbligo(nomeblocco,valore,regexp) {
	if (document.getElementById(nomeblocco)) {
	document.getElementById(nomeblocco).style.color = "#000000"
	document.getElementById(nomeblocco).style.border = "1px solid #7F9DB9"
	}
	if (document.getElementById('span'+nomeblocco)) {
	document.getElementById('span'+nomeblocco).style.display = "none";
	}
	regexpemail = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+/
	regexpusr = /^([1-zA-Z0-1_.\-\s]{6,32})/
	regexpsms = /^([+]39)?((38[{8,9}|0])|(34[{6-9}|0])|(39[{2-3}|0])|(37[{7-9}|0])|(36[6|8|0])|(33[{3-9}|0])|(32[{8,9}]))([\d]{6,7})$/ //sms italia
	regexpsitoweb = /^(http\:\/\/|www.)+[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}/
	regexpnome = /^[a-zA-Zàèéìòù]+(([\'\,\.\- ][a-zA-Zàèéìòù ])?[a-zA-Zàèéìòù]*)*$/
	regexpskype = /^([1-zA-Z0-1_.\-\s]{6,32})/
	regexptelefono = /^([+|])?([1-9]*\-?\ ?\/?[0-9\.\-\ \/]*)$/
	regexpcapitaliano = /^(V-|I-)?[0-9]{5}$/
	regexpcodfiscita = /^[A-Za-z]{6}[0-9LMNPQRSTUV]{2}[A-Za-z]{1}[0-9LMNPQRSTUV]{2}[A-Za-z]{1}[0-9LMNPQRSTUV]{3}[A -Za-z]{1}$/
	regexpcampoobbligatorio = /.{1,100}/
	regexpdatanascita = /^\d{1,2}[-\/\.]\d{1,2}[-\/\.]\d{2,4}$/
	
	espressione = eval(regexp)
	if (!espressione.test(valore)) {
		if (document.getElementById(nomeblocco)) {
		document.getElementById(nomeblocco).style.color = "#ff0000"
		document.getElementById(nomeblocco).style.border = "1px solid #ff0000"
		}
		if (document.getElementById('span'+nomeblocco)) {
		document.getElementById('span'+nomeblocco).style.color = "#000000"
		document.getElementById('span'+nomeblocco).style.display = "block";
		}
		return true;
	} else {
		return false;
	}
}


function startControllomessaggio(campidacontrollare,campidachecked,campiemail) {
	//campidacontrollare = "ragsoc|nome|cognome|stato|settore|funzione|oggettomessaggio|messaggio"
	//campidachecked = "accettoprivacy"
	//campiemail = "email"
	if (campidacontrollare != "" && campidacontrollare != undefined ) {
		var tuttiicampi = campidacontrollare.split("|");
		errore = 0;
		for (i=0; i < tuttiicampi.length; i++) {
			document.getElementById(tuttiicampi[i]).style.color = "#000000"
			document.getElementById(tuttiicampi[i]).style.border = "1px solid #7F9DB9"
			if (document.getElementById(tuttiicampi[i]).value == "") {
				errore = errore+1
				document.getElementById(tuttiicampi[i]).style.border = "1px solid #ff0000"
				document.getElementById(tuttiicampi[i]).style.color = "#ff0000"
				//erroreparlante = erroreparlante + "cognome mancante\r"
			}
		}
	}
	if (campidachecked != "" && campidachecked != undefined ) {
		var tuttiicampib = campidachecked.split("|");
		for (i=0; i < tuttiicampib.length; i++) {
			document.getElementById(tuttiicampib[i]).style.color = "#000000"
			document.getElementById(tuttiicampib[i]).style.border = "1px solid #7F9DB9"
			if(document.getElementById(tuttiicampib[i]).checked) {
				
			} else {
				errore = errore+1
				//window.alert(tuttiicampib[i]);
				document.getElementById(tuttiicampib[i]).style.border = "1px solid #ff0000"
			}
		}
	}
	if (campiemail != "" && campiemail != undefined ) {
		var tuttiicampic = campiemail.split("|");
		for (i=0; i < tuttiicampic.length; i++) {
			document.getElementById(tuttiicampic[i]).style.color = "#000000"
			document.getElementById(tuttiicampic[i]).style.border = "1px solid #7F9DB9"
			if (document.getElementById(tuttiicampic[i]).value == "") {
				errore = errore+1
				document.getElementById(tuttiicampic[i]).style.border = "1px solid #ff0000"
				document.getElementById(tuttiicampic[i]).style.color = "#ff0000"
				//erroreparlante = erroreparlante + "cognome mancante\r"
			} else if (controllaobbligo(document.getElementById(tuttiicampic[i]).value,document.getElementById(tuttiicampic[i]).value,'regexpemail')) {
				errore = errore+1
				document.getElementById(tuttiicampic[i]).style.border = "1px solid #ff0000"
				document.getElementById(tuttiicampic[i]).style.color = "#ff0000"
				//erroreparlante = erroreparlante + "cognome mancante\r"
			} 
		}
	}
	//errore = 1
	if (errore > 0) {
		//window.alert("errore finale:" + errore)
		//ripristiniamo i valori default
		
		//window.alert(1)
		//return true;
		return false;
	} else {
		//window.alert("errore finale:" + errore)
		nascondi('bottoneinvio');
		//document.getElementById('spancheckboxe').innerHTML = '<img src="/layout/ajax-loader.gif"> <b>Stiamo controllando ed inviando i dati... siete pregati di attendere</b>' ;
		//return true;
		//window.alert(2)
		return true;
	}
}

//posizione mouse
function handleEvento(oEvent) {
	   mousex = oEvent.screenX;
	   mousey = oEvent.screenY;
	   mousexb = oEvent.pageX;
	   mouseyb = oEvent.pageY;

	  // window.alert(mousex+"px")
	   //window.alert(document.getElementById('supercontenitorescroll').offsetWidth)
	   //window.alert(document.getElementById('supercontenitorescroll').offsetLeft)
	  
	   
	   larghezzadiunterzo = parseInt(document.getElementById('supercontenitorescroll').offsetWidth/3)
	   massimaxbottonesinistra = document.getElementById('supercontenitorescroll').offsetLeft*1+larghezzadiunterzo*1
	   minimaxbottonedestra = document.getElementById('supercontenitorescroll').offsetLeft*1+document.getElementById('supercontenitorescroll').offsetWidth*1-larghezzadiunterzo*1
		
		if (massimaxbottonesinistra > mousex) { //allora siamo nel primo terzo di quadrante
	   //		sposta(0,'',1)
		} else if ( minimaxbottonedestra < mousex ) {
		//   sposta(0,'',-1)
		}
   }
   
function calcolaspostamentomassimo() {
	numerobox = document.getElementById('numerobox').value;
	marginedestrosupercontenitorescroll = document.getElementById('supercontenitorescroll').offsetWidth+document.getElementById('supercontenitorescroll').offsetLeft
	eval("posizioneultimodiv = document.getElementById('box"+numerobox+"').offsetLeft");
	eval("larghezzaultimodiv= document.getElementById('box"+numerobox+"').offsetWidth");
	marginedestroultimafoto = posizioneultimodiv+larghezzaultimodiv
	document.getElementById('spostamentomassimo').value = marginedestroultimafoto-marginedestrosupercontenitorescroll
	}
   
//per scroller
function sposta(tipo,divchevaazero,azione) { //azione = 0 allora ho un target azione = 1 avanti azione = 2 indietro
	// IE7 e IE6 tiene a memoria la posizione originale quidni non possiamo fare movimentazione ma facciamo salto secco
	versionebrowser = navigator.appVersion;
	if ((versionebrowser.indexOf("MSIE 6") > 0) || (versionebrowser.indexOf("MSIE 7") > 0))  {
		noscrollare = 1 } else {
		noscrollare = 0
		}
	//window.alert (noscrollare);
	if ( document.getElementById(divchevaazero) ) {
		document.getElementById(divchevaazero).style.display = 'block';
	}
	var numerobox;
	numerobox = document.getElementById('numerobox').value;
	eval("posizioneprimodiv = document.getElementById('box0').offsetLeft");
	eval("posizioneultimodiv = document.getElementById('box"+numerobox+"').offsetLeft");
	eval("larghezzaultimodiv= document.getElementById('box"+numerobox+"').offsetWidth");
	eval("larghezzatotale = document.getElementById('supercontenitorescroll').offsetWidth");
	
	if ( document.getElementById('spostamentomassimo').value < 1 ) {
		javascript: sposta(1,'',0)
		//window.alert('stop')
	}
	larghezzadivs = 0
	for (i=0; i<=numerobox; i=i+1) {
		eval("larghezzadivs= larghezzadivs+document.getElementById('box"+i+"').offsetWidth");
	}
	if (tipo == 0 ) {
		if (azione == 0 ) {
			eval("posizione = document.getElementById('"+divchevaazero+"').offsetLeft");
			if (posizione < 10 &&  posizione > -10 ) {
				if (noscrollare == 0) {
				posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft-posizione
				document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
				} else {
					document.getElementById('contenitorescroll').style.marginLeft = "0px";
					}
				//clearTimeOut();
			} else if ( posizione > 0 )  {
				if (noscrollare == 0) {
				posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft-10
				document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
				clearTimeout(document.getElementById('valoretempo').value);
				g = setTimeout("sposta(0,'"+divchevaazero+"',0)",1) //un millisecondo*/
				document.getElementById('valoretempo').value = g;
				} else {
					//posizionecontenitore = document.getElementById('contenitore').offsetLeft-posizione
					document.getElementById('contenitorescroll').style.marginLeft = -posizione+"px";
				//window.alert(posizione + " maggiore di 0")
					}
				
			} else if ( posizione < 0 )  {
				posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft+10
				document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
				clearTimeout(document.getElementById('valoretempo').value);
				g = setTimeout("sposta(0,'"+divchevaazero+"',0)",1) //un millisecondo*/
				document.getElementById('valoretempo').value = g;
				//window.alert(posizione + " minore di 0")
		 	}
		} else {
			if (posizioneprimodiv < 1 &&  posizioneprimodiv > -1 && azione < 0 && noscrollare == 0 ) { // in caso di ie7 lo scrolll sarà continuo anche a sinistra
				posizione = document.getElementById('box0').offsetLeft;
				posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft-posizione
				document.getElementById('spostamentomassimo').value = document.getElementById('spostamentomassimo').value*1+azione
				document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
				g = 0;
//			} else if (posizioneultimodiv+larghezzaultimodiv < larghezzatotale && azione > 0) {
//				posizionecontenitore = larghezzatotale-larghezzadivs
//				document.getElementById('contenitore').style.marginLeft = posizionecontenitore+"px";
//				g = 0;
//window.alert('m')
			} else {
				posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft-azione
				document.getElementById('spostamentomassimo').value = document.getElementById('spostamentomassimo').value*1-azione
				document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
				clearTimeout(document.getElementById('valoretempo').value);
				g = setTimeout("sposta(0,'',"+azione+")",1) //un millisecondo*/
				document.getElementById('valoretempo').value = g;
				//window.alert('g')
			}
		}
	} else {
		 posizionecontenitore = document.getElementById('contenitorescroll').offsetLeft-0
		 document.getElementById('contenitorescroll').style.marginLeft = posizionecontenitore+"px";
		 clearTimeout(document.getElementById('valoretempo').value);
		 document.getElementById('valoretempo').value = g;
	}
}


function recenterMap() {
	var qs = "";
	var zoom = 0;
	if ($F("address_name") != "") {
		qs += $F("address_name") + " ";
	}
	if ($F("address_number") != "" && $F("address_number") != 0) {
		qs += $F("address_number") + " ";
	}
	if ($F("zipcode") != "") {
		qs += $F("zipcode") + " ";
	}
	if ($F("country_code") != "") {
		var countryCode = null;
		switch($F("country_code")) {
			case "jp":
				countryCode = "Japan";
				break;
			default:
				countryCode = $F("country_code");
		}
		qs += countryCode + " ";
	}
	if ($F("country_code") != "") {
		zoom = 4;
	}
	if ($F("zipcode") != "") {
		zoom = 13;
	}
	if ($F("address_name") != "" || ($F("address_number") != "" && $F("address_number") != 0)) {
		zoom = 16;
	}
	geocoder.getLatLng(qs, function(point) {
		if (point) {
			map.setCenter(point, zoom);
			marker.setPoint(point);
			var pointNew = point.toString();
			var preLatlongNew=pointNew.split(", ");
			var latitudeNew=preLatlongNew[0].split("(");
			latitude=latitudeNew[1];
			var longitudeNew=preLatlongNew[1].split(")");
			longitude=longitudeNew[0];
			$("latitude").value = latitude;
			$("longitude").value = longitude;
		}
	});
}

//questa funzione serve per la centratura della mappa
function mappacentrabile(id,livellozoom,lat,lon) {
	document.getElementById("xgoogle").value = lat;
	document.getElementById("ygoogle").value = lon;
		// create map and add controls
	var map = new GMap2(document.getElementById(id));
	map.addControl(new GLargeMapControl());        
	map.addControl(new GMapTypeControl());
	
	// set centre point of map
	var centrePoint = new GLatLng(lat, lon);
	map.setCenter(centrePoint, livellozoom);	
	
	// add a draggable marker
	var marker = new GMarker(centrePoint, {draggable: true});
	map.addOverlay(marker);
	
	// add a drag listener to the map
	GEvent.addListener(marker, "dragend", function() {
		var point = marker.getPoint();
		map.panTo(point);
		document.getElementById("xgoogle").value = point.lat();
		document.getElementById("ygoogle").value = point.lng();
    });
}

function cercaluogo(){
	///window.alert(document.getElementById('nomecomune').value);
	//location.href = "/ajax/puntivendita/index.asp?nomecomune="+document.getElementById('nomecomune').value;
	
	indirizzo = document.getElementById('indirizzo').value
	indirizzo = indirizzo.replace(/ /g, "mirko")
	citta = document.getElementById('citta').value
	citta = citta.replace(/ /g, "mirko")
	cap = document.getElementById('cap').value
	provincia = document.getElementById('provincia').value
	provincia = provincia.replace(/ /g, "mirko")
	stato = document.getElementById('stato').value
	//window.alert(indirizzo)
//	window.alert(citta)
//	window.alert(cap)
//	window.alert(provincia)
//	window.alert(stato)

	if (citta != "" && citta != undefined) {
		//window.alert(quanti)
		//window.alert(id2carrello)
		if(window.XMLHttpRequest)
			{
			   richiestaricerca = new XMLHttpRequest();
			}
			else if(window.ActiveXObject)
			{
			   richiestaricerca = new ActiveXObject("Microsoft.XMLHTTP");
			}
			richiestaricerca.open("POST", "/ajax/centramappa/index.asp", true);
			richiestaricerca.onreadystatechange = function() 
			{
				if(richiestaricerca.readyState == 4)
				{	
					if(richiestaricerca.status == 200)
					{
						rispostaricerca = richiestaricerca.responseText
						//window.alert(rispostaricerca)
						var mySplitResultb = rispostaricerca.split("|||");
						//elencofornitori = mySplitResultb[0];
						//valori = mySplitResultb[1];
						lat = mySplitResultb[0];
						lon = mySplitResultb[1];
						//zoommappa = parseInt(mySplitResultb[4]);
						zoommappa = 12
						//document.getElementById('elencodistributori').innerHTML = elencofornitori

						mappacentrabile('mappalatoedit',zoommappa,lat,lon);
					}
				}
			}
			richiestaricerca.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			richiestaricerca.send("indirizzo="+indirizzo+"&citta="+citta+"&cap="+cap+"&provincia="+provincia+"&stato="+stato);
	}
}

function test() {
	//showRecenterMap ('mappamultipla',45,38,15);
	mappacentrabile('mappalatoedit',14,45.4011185,8.9702627)
}

function mappamultipla(id,livellozoom,lat,lon,localizzazioni) {
	  	//localizzazioni = "Bondi Beach|55.7315032|12.3382982###DINGBRO LTD - Ayr|55.475425|-4.5985545###Cronulla Beach|-34.028249|151.157507###Manly Beach|-33.80010128657071|151.28747820854187###Baden - Jensen a/s|53.6398062|-1.7830555"
		//window.alert(livellozoom);
		//window.alert(lat);
		//window.alert(lon);
		//window.alert(localizzazioni);
		splittalocalizzazioni = localizzazioni.split("###");	
	
		var map = new google.maps.Map(document.getElementById(id), {
		  zoom: livellozoom,
		  center: new google.maps.LatLng(lat, lon),
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		});
	
		var infowindow = new google.maps.InfoWindow();
	
		var marker, i;
	
		for (i = 0; i < splittalocalizzazioni.length; i++) {  
			localizzazione = splittalocalizzazioni[i]
			splittalocalizzazione = localizzazione.split("|");
		    marker = new google.maps.Marker({
			position: new google.maps.LatLng(splittalocalizzazione[1], splittalocalizzazione[2]),
			map: map
		  });
	
		  google.maps.event.addListener(marker, 'click', (function(marker, i) {
			return function() {
			  localizzazioneb = splittalocalizzazioni[i]
			  splittalocalizzazioneb = localizzazioneb.split("|");
			  infowindow.setContent(splittalocalizzazioneb[0]);
			  infowindow.open(map, marker);
			}
		  })(marker, i));
		}
	
		
	  }

function inviaricerca(){
	///window.alert(document.getElementById('nomecomune').value);
	//location.href = "/ajax/puntivendita/index.asp?nomecomune="+document.getElementById('nomecomune').value;
	
	nomecomune = document.getElementById('nomecomune').value
	nomecomune = nomecomune.replace(/ /g, "mirko")
	statoen = document.getElementById('statoen').value
	distanza = document.getElementById('distanza').value
	tipologia = document.getElementById('tipologia').value
	limite = document.getElementById('limite').value
	linkbase = document.getElementById('linkbase').value
	testocerca = document.getElementById('testocerca').value
	parolacitta = document.getElementById('parolacitta').value
	parolasettore = document.getElementById('parolasettore').value
	settore = document.getElementById('settore').value
	lingua = document.getElementById('lingua').value

	if (nomecomune != "" && nomecomune != undefined) {
		//window.alert(quanti)
		//window.alert(id2carrello)
		if(window.XMLHttpRequest)
			{
			   richiestaricerca = new XMLHttpRequest();
			}
			else if(window.ActiveXObject)
			{
			   richiestaricerca = new ActiveXObject("Microsoft.XMLHTTP");
			}
			richiestaricerca.open("POST", "/ajax/puntivendita/index.asp", true);
			richiestaricerca.onreadystatechange = function() 
			{
				if(richiestaricerca.readyState == 4)
				{	
					if(richiestaricerca.status == 200)
					{
						rispostaricerca = richiestaricerca.responseText
						var mySplitResultb = rispostaricerca.split("|||");
						elencofornitori = mySplitResultb[0];
						valori = mySplitResultb[1];
						lat = mySplitResultb[2];
						lon = mySplitResultb[3];
						zoommappa = parseInt(mySplitResultb[4]);

						document.getElementById('elencodistributori').innerHTML = elencofornitori
						//zoommappa = 10;
						//lat = 55.7315032
						//lon = 12.3382982
						//valori = elencopermappa
						//window.alert (zoommappa)
						//window.alert (lat)
						//window.alert (lon)
						//window.alert (valori)
						mappamultipla('mappalato',zoommappa,lat,lon,valori);
					}
				}
			}
			richiestaricerca.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			richiestaricerca.send("statoen="+statoen+"&nomecomune="+nomecomune+"&distanza="+distanza+"&tipologia="+tipologia+"&limite="+limite+"&linkbase="+linkbase+"&testocerca="+testocerca+"&parolacitta="+parolacitta+"&parolasettore="+parolasettore+"&settore="+settore+"&lingua="+lingua);
	}
}


////apre in target_blankl
////apertura link balnk sennza target
/*
addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
*/
function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}

/*
Create the new window
*/
function openInNewWindow() {
	// Change "_blank" to something like "newWindow" to load all links in the same new window
    var newWindow = window.open(this.getAttribute('href'), '_blank');
    newWindow.focus();
    return false;
}

/*
Add the openInNewWindow function to the onclick event of links with a class name of "new-window"
*/
function getNewWindowLinks() {
	// Check that the browser is DOM compliant
	if (document.getElementById && document.createElement && document.appendChild) {
		// Change this to the text you want to use to alert the user that a new window will be opened
		//var strNewWindowAlert = "" //" (opens in a new window)";
		var strNewWindowAlert = "";
		// Find all links
		var links = document.getElementsByTagName('a');
		var objWarningText;
		var strWarningText;
		var link;
		for (var i = 0; i < links.length; i++) {
			link = links[i];
			// Find all links with a class name of "non-html"
			if (/\btargetblank\b/.exec(link.className)) {
				// Create an em element containing the new window warning text and insert it after the link text
				objWarningText = document.createElement("em");
				strWarningText = document.createTextNode(strNewWindowAlert);
				objWarningText.appendChild(strWarningText);
				link.appendChild(objWarningText);
				link.onclick = openInNewWindow;
			}
		}
		objWarningText = null;
	}
}

addEvent(window, 'load', getNewWindowLinks);////fine apre target blank//////////////

function scambio(id) {
	if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
		else if (document.getElementById(id).style.display == '')
		{
		document.getElementById(id).style.display = 'block';
		}
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
	}
}

function regolacontenitoremuseo(id) {
	larghezzamonitor = document.documentElement.clientWidth;
	larghezzacontenitore = larghezzamonitor - 164;
	document.getElementById(id).style.width = larghezzacontenitore + "px"
}


