// JavaScript Document

var map;

function initGMaps() {
	try
	{
		if (GBrowserIsCompatible()) {
			map = new GMap2(document.getElementById( "map" ));
			//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
			geocoder = new GClientGeocoder();
			showAddress( "Via Isonzo 14, 40033 Casalecchio di Reno (BO)", "BODY'S FAIRY<br /> Via Isonzo 14, 40033 Casalecchio di Reno (BO) <br />tel. 051 592569" );
		}
	}
	catch ( e )
	{
	}
}

function terminateGMaps() {
	try
	{
		GUnload();
	}
	catch ( e )
	{
	}
}

function ddlRegioniSimplyCenter_Changed( ddlRegioniSimplyCenter )
{
	//alert( "ddlRegioniSimplyCenter_Changed: " + ddlRegioniSimplyCenter.selectedIndex );
	//alert( "ddlRegioniSimplyCenter_Changed: " + ddlRegioniSimplyCenter.options[ ddlRegioniSimplyCenter.selectedIndex ].value );
	
	var strSimplyCenterCode = ddlRegioniSimplyCenter.options[ ddlRegioniSimplyCenter.selectedIndex ].value;
	var strIndirizzo = "";
	var strMarkerText = "";
	
	switch ( strSimplyCenterCode )
	{
		case "BO":
			strIndirizzo = "Via Isonzo 14, 40033 Casalecchio di Reno (BO)";
			strMarkerText = "BODY'S FAIRY<br /> Via Isonzo 14, 40033 Casalecchio di Reno (BO) <br />tel. 051 592569";
			break;
		case "FE":
			strIndirizzo = "Via Bologna, 500 44100 (FE)";
			strMarkerText = "TANNING & WELLNESS<br /> Via Bologna, 500 44100 (FE) <br />tel. 0532 977683";
			break;
		case "VR":
			strIndirizzo = "Via Peschiera 37017 Lazise (VR)";
			strMarkerText = "AQUAMARINA<br /> Via Ca Praleor, 1 – Lazise (VR) <br />tel.  045 6470229";
			break;
		case "PT":
			strIndirizzo = "Via Ugo Foscolo, 27 – Montecatini Terme (PT)";
			strMarkerText = "BAYA DEL SOL<br /> Via Ugo Foscolo, 27 – Montecatini Terme (PT) <br />tel.  0572 910480";
			break;
		case "AN":
			strIndirizzo = "Via Provinciale Sant’Angelo, 117 – Senigallia (AN)";
			strMarkerText = "CLUB 2000 BEAUTY<br /> Via Provinciale Sant’Angelo, 117 – Senigallia (AN) <br />tel.  338 1737617";
			break;
		case "RO":
			strIndirizzo = "Viale Porta Adige 45/G – (RO)";
			strMarkerText = "NEW BODY MAN<br /> Viale Porta Adige 45/G – (RO) <br />tel. 0425 30224";
			break;
		case "PU":
			strIndirizzo = "Via Canale Albani, 5 – Fano (PU)";
			strMarkerText = "POSEIDON<br /> Via Canale Albani, 5 – Fano (PU) <br />tel.  0721 865162";
			break;
		case "TR":
			strIndirizzo = "Strada di Cesure, 20/22 – (TR)";
			strMarkerText = "RAGGIO DI SOLE<br /> Strada di Cesure, 20/22 – (TR) <br />tel.  0744 283342";
			break;
		case "TR_SOLECOCCOLE":
			strIndirizzo = "Via Bartocci 10/18 – (TR)";
			strMarkerText = "SOLECOCCOLE<br /> Via Bartocci 10/18 – (TR) <br />tel. 0744 800946";
			break;
		case "PD":
			strIndirizzo = "Via Regia, 69 – Vigonza (PD)";
			strMarkerText = "SUNLINE<br /> Via Regia, 69 – Busa di Vigonza (PD) <br />tel.  049 626132";
			break;
		case "PU_TINTARELLA":
			strIndirizzo = "Via Litoranea, 218/A – Marotta (PU)";
			strMarkerText = "TINTARELLA<br /> Via Litoranea, 218/A – Marotta (PU) <br />tel.  0721 961309";
			break;
	}
	
	//alert( "Indirizzo: " + strIndirizzo );
	showAddress( strIndirizzo, strMarkerText );
	//showMarker( "
}

function showAddress( strIndirizzo, strMarkerText )
{
	try
	{
		if (geocoder) {
			geocoder.getLatLng(
				strIndirizzo,
				function(point) {
					if (!point) {
						alert( "Indirizzo " + strIndirizzo + " non trovato...");
					} else {
						//alert( "map: " + map );
						//alert( "map.setCenter: " + map.setCenter );
						map.setCenter(point, 13);
						var marker = new GMarker(point);
						map.addOverlay(marker);
						//marker.openInfoWindowHtml(address);
						
		
						GEvent.addListener( marker,"click",	function()	
															{
																//map.setCenter(point, 15);
																
																if ( strMarkerText != "" )
																{
																	/*if (tab == 1)
																	{
													 					var msg_ar = msg.split("###");
													 					var tit_ar = tit.split("###");
													 					var infoTabs = new Array();
																	 	
													 					for (var i=0; i<msg_ar.length; i++)
													 					{
																			infoTabs[i] = new GInfoWindowTab(tit_ar[i], msg_ar[i]);
																		}

																		marker.openInfoWindowTabsHtml(infoTabs);
																	}
																	
																	else
																	{*/
																		marker.openInfoWindowHtml( strMarkerText );
																		//map.setCenter( point, 13 );
																	//}
																}
															}
						);
						
						
						
					}
				}
			);
		}
	}
	catch ( e )
	{
	}
}


function openPopPrivacy()
{
	window.open( 'popPrivacy.htm','popPrivacy','scrollbars=no,width=600,height=128' );
}







function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

