<!--

function cambiaImmagine(origine,cambiaDa,cambiaA){
  if(cambiaDa==undefined){
		cambiaDa = "min";
	}
	if(cambiaA==undefined){
		cambiaA = "max";
	}
	var orig =  document.getElementById(origine);
	var origAlt = orig.alt
	var origTitle = orig.title
	var newOrig = orig.src.replace('/'+ cambiaDa +'/','/'+ cambiaA +'/')
	var dest = document.getElementById("Dett_image");
	var oldDest = dest.src.replace('/'+ cambiaA +'/','/'+ cambiaDa +'/')
	
	var oldAlt = dest.alt
	var oldTitle = dest.title
	dest.src = newOrig;
	dest.alt = origAlt;
	dest.title = origTitle;
	orig.src = oldDest;
	orig.alt = oldAlt;
	orig.title = oldTitle;

	//var elem = document.getElementsByClassName('image')
	//for (i=0;i<elem.length;i++){
	//	if (elem[i].id==id){
	//		elem[i].style.background='url(css/img/bgimgsel.gif)';
	//	}else{
	//		elem[i].style.background='url(css/img/bgimg.gif)';
	//	}
	//}
}

function RichiediInformazioni(qualeDiv,ilForm,qualePagina){
	$(qualeDiv).innerHTML = '<div style="padding-top:6px;padding-bottom:3px;margin:auto;text-align:center;"><img src="/css/img/indicator.gif" alt="" width="16" height="16" border="0" align="absmiddle"></div>';
	$(qualeDiv).show();
	new Ajax.Updater(qualeDiv, qualePagina , {
														asynchronous:true,
														evalScripts:true,
														encoding:'UTF-8',
														parameters:Form.serialize(ilForm)
														}
					);
	return false;
}

function loadhref(qualeDiv,qualePagina){
	//$(qualeDiv).hide();
	new Ajax.Updater(qualeDiv, qualePagina ,
						{
							asynchronous:true,
							evalScripts:true,
							encoding:'UTF-8',
							onComplete:function(){
														new Effect.Appear(qualeDiv,{duration:0.4,from:0,to:1.0})
							}
						}
					);
}


function slideShow(attuale,successivo){
	if(attuale>0){
		clearTimeout(timerID);
	}
	if($('div_'+successivo)!=null){
		$('div_'+successivo).remove();
	}
	var newDiv = new Element('div',{'id':'div_'+successivo,'style':'display:none;','class':'contSlide'})
	new Ajax.Updater('div_'+successivo, '/loadslide.asp?id='+successivo , {
																asynchronous:true,
																evalScripts:true
																}
							);
	$('postIt').appendChild(newDiv)
	if(attuale>0){
		new Effect.Fade('div_'+attuale,{ from: 1.0, to: 0.5, duration: 0.8 })
	}
	new Effect.Appear('div_'+successivo,{duration:0.8,from:0.5,to:1.0});
	//var newDiv = $('div_'+successivo);
	//new setTimeout(newDiv.show(),3000);
}

var noReload=false
var timeReload=0
function createMarker(point,icona,messaggio,myTitle) {
	var marker = new GMarker(point,{title:myTitle,icon:icona});
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(messaggio);
		noReload=true
	});
	return marker;
}

function load2(coordInizLat,coordInizLon,comune,zoom,wherefunct) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		//map.enableScrollWheelZoom()
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		//default visualizzazione mappa
		//map.setMapType(G_SATELLITE_MAP);
		var icon = new GIcon();
		icon.image = "http://www.centri3a.itx/css/img/sociomap.png";
		icon.iconSize = new GSize(93, 85);
		icon.iconAnchor = new GPoint(64, 74);
		icon.infoWindowAnchor = new GPoint(64, 74);
		if (coordInizLat!=undefined && coordInizLon!=undefined ) {
			if (wherefunct>0) {
				map.setCenter(new GLatLng(coordInizLat,coordInizLon), zoom);
			} else {
				map.setCenter(new GLatLng(coordInizLat,coordInizLon), 5);
			}
		} else {
			map.setCenter(new GLatLng(42.042726,12.392578), 6);
		}
		var myMarkers=new Array()
		GEvent.addListener(map,"moveend",function() {
				ricaricaMappa(map,comune,wherefunct)
			}
		)
		GEvent.addListener(map,"zoomend",function() {
				ricaricaMappa(map,comune,wherefunct)
			}
		)
		clearTimeout(timeReload)
		timeReload=setTimeout(function () {ricaricaMappa(map,comune,wherefunct)},400)
	}
}

function ricaricaMappa(map,local,condiz) {
	if (!noReload) {
		GDownloadUrl("../js/xmlLocator.asp?local="+local+"&t="+condiz, function(data, responseCode) {
			map.clearOverlays()
			myZoom=map.getZoom()
			responseCode=200
			if(responseCode == 200) {
				var myMarkers=new Array()
				var xml = GXml.parse(data);
				//alert(data);
				var markers = xml.documentElement.getElementsByTagName("marker");
				if (markers.length>0) {
					for (var i = 0; i < markers.length; i++) {
						 var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
								                              parseFloat(markers[i].getAttribute("lng")));
				 		k=0;
						myMarkers[i]=new Array()
						myMarkers[i]["coord"]=point
						myMarkers[i]["visib"]=false
						gruppa=false
						if (!gruppa) {
							var NomeLoc = markers[i].getAttribute("nome")
							myMarkers[i]["htmlPage"]='<div style="font-size:13px;font-weight:bold;"><a href="http://www.centri3a.itx/centri3a/elenco/6/'+markers[i].getAttribute("nome")+'.html?idr='+markers[i].getAttribute("regione")+'&ids='+markers[i].getAttribute("id")+'" style="color:#2d5578;">'+markers[i].getAttribute("nome")+'</a></div>'
							myMarkers[i]["htmlPage"]+='<div style="margin:3px 0 1px 0;font-size:11px;color:#6b6b6b;">'+ markers[i].getAttribute("indirizzo")+''+ markers[i].getAttribute("localita")+'</div>'
							myMarkers[i]["htmlPage"]+='<div style="margin:1px 0 1px 0;font-size:11px;color:#6b6b6b;"><span style="color:#2d5578;">Tel:</span> '+ markers[i].getAttribute("telefono")+'</div>'
							myMarkers[i]["htmlPage"]+='<div style="margin:1px 0 1px 0;font-size:11px;color:#6b6b6b;"><span style="color:#2d5578;">Fax:</span> '+ markers[i].getAttribute("fax")+'</div>'
							myMarkers[i]["punto"]=point
							myMarkers[i]["nome"]=NomeLoc
							myMarkers[i]["visib"]=true
						}
					}
					for (i=0;i<myMarkers.length;i++) {
						if (myMarkers[i]["visib"] ) {
							var icon = new GIcon();
							if (condiz>0) {
								icon.image = "http://www.centri3a.it/css/img/sedemap.png";
								icon.iconSize = new GSize(93, 85);
								icon.iconAnchor = new GPoint(64, 74);
								icon.infoWindowAnchor = new GPoint(64, 74);
							} else {
							  icon.image = "http://www.centri3a.it/css/img/Centro3A.png";
								icon.iconSize = new GSize(20, 20);
								icon.iconAnchor = new GPoint(14, 15);
								icon.infoWindowAnchor = new GPoint(14, 15);
							}
							myHTMLPAGE='<div class="gmapStyle" style="overflow:auto;width: 280px;height:80px;">'
							myHTMLPAGE+=myMarkers[i]["htmlPage"]
							myHTMLPAGE+='</div>'
								map.addOverlay(createMarker(myMarkers[i]["punto"],icon,myHTMLPAGE,'Scheda socio: '+myMarkers[i]["nome"]));
							}
						}
						noReload=false
				} else {
					alert("Nessuna risultato per questa ricerca");
				}
			} else if(responseCode == -1) {
				alert("Data request timed out. Please try later.");
			} else {
				alert("Request resulted in error. Check XML file is retrievable.");
			}
		});
	}
	noReload=false
}

function caricaLocalita(nome,numcond) {
	noReload=false
	var geocoder = new GClientGeocoder();
	if (nome.length>0) {
			geocoder.getLatLng(nome,
			function (point) {
				if (point!=undefined) {
					load2(point.lat(),point.lng(),nome,8,numcond)
				} else {
					alert("Valore della ricerca non valido");
				}
			}
		)
	} else {
		alert("Valore della ricerca non valido");
	}
}


function Information(divve){
	if($(divve).style.display!='none') {
		new Effect.Fade(divve, { duration: 1 });
	} else {
		new Effect.Appear(divve, { duration: 1 });
	}
}

function inviaCommento() {
	var myURL="/inc/invia.asp"
	new Ajax.Updater("emailChange",  myURL, {
								asynchronous:true,
								evalScripts:true,
								parameters:Form.serialize('emailForm')
							}
	);
}
	
function caricaPhotogallery(gallery,pag,tipo){
		new Ajax.Updater('Photogallery', "/_inc/photogallery.asp?id="+gallery+"&t="+tipo+"&p="+pag,
				{
					asynchronous:true,
					evalScripts:true,
					encoding:'UTF-8'
				}
		);
}
function overimg(id){
	$('contimgphoto_'+id).style.background="url(/css/img/bgphotosel.png)";
	$('bgimgphoto_'+id).style.background="url(/css/img/1t.gif)";
}
function outimg(id){
	$('contimgphoto_'+id).style.background="url(/css/img/bgphoto.png)";
	$('bgimgphoto_'+id).style.background="url(/css/img/bgphotoUp.png)";
}
function viewImage(id,tipo){
	if($('contElem').style.display=='none') {
		$('contElem').show();
		$('imagedett').show();
	}
	
	var elem = document.getElementsByClassName('photoelem')
	for (i=0;i<elem.length;i++){
		elem[i].removeClassName('photoelem_sel');
		if (elem[i].id==id){
			elem[i].addClassName('photoelem_sel');
		}
	}
	
	var elem = document.getElementsByClassName('images')
	for (i=0;i<elem.length;i++){
		elem[i].removeClassName('images_sel');
		if (elem[i].id==id){
			elem[i].addClassName('images_sel');
		}
	}
	//$('contimgphoto_'+id).style.background="url(/css/img/bgphotosel.png)";
	//$('bgimgphoto_'+id).style.background="url(/css/img/1t.gif)";
	new Ajax.Updater('imagedett', "/_inc/loadimage.asp?id="+id+"&t="+tipo , {
														asynchronous:true,
														evalScripts:true,
														encoding:'UTF-8'
														}
					);
	return false;
}

//-->
