function centerMap(ville) {
	//var map = new GMap2(document.getElementById('map'));
	lat= VillesInfos[ville]['lat'];
	lng= VillesInfos[ville]['lng'];
	zoom= VillesInfos[ville]['zoom'];
	//hasQuartiers=VillesInfos[ville]['hasQuartiers'];
	var point = new GLatLng(lat, lng);
    map.setCenter(point, zoom);
	ajax_submit(ville,false);
}

function centerMapQuartier(ville,quartier) {
	//var map = new GMap2(document.getElementById('map'));
	lat= QuartiersInfos[quartier]['lat'];
	lng= QuartiersInfos[quartier]['lng'];
	zoom= QuartiersInfos[quartier]['zoom'];
	var point = new GLatLng(lat, lng);
    map.setCenter(point, zoom);
	ajax_submit(ville,quartier);
}


function centerMapPt(lng,lat,address) {
	var point = new GLatLng(lat, lng);
    map.setCenter(point, 14);
	myclick(address,lng,lat,'tt_address');
}

function showStreetView(lng,lat) {
	var point = new GLatLng(lat,lng);
	var html='<div id="fond_lightbox"><div id="lightsv"><a href="#" onclick="javascript:closeStreetView();return false;" class="fermer">fermer</a><div id="sv"></div></div></div>';
	var myPano;
	  svOptions = { latlng:point };
	document.getElementById('light').innerHTML = html;
	document.getElementById('light').style.display = 'block';	
	  document.getElementById('fond_lightbox').style.display = 'block';
	  myPano = new GStreetviewPanorama(document.getElementById("sv"), svOptions);
}

function closeStreetView() {
	document.getElementById('fond_lightbox').style.display = 'none';
	document.getElementById('light').innerHTML ='';
	document.getElementById('light').style.display = 'none';
}

function checkCategories() {
tx_rggooglemap_pi1processCat(xajax.getFormValues('xajax_cat'));
clearCat();
}

function ajax_submit(ville,quartier){
		document.getElementById('wait_loading').style.display = 'block';
		document.getElementById('tx_icsstarvillesselect_pi1_ptsvente').style.display = 'none';
		var xhr_object = null; 
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
				xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		}
		if (quartier!=false)
		xhr_object.open("POST", "index.php?eID=ics_starvillesselect&tx_icsstarvillesselect_pi1[ville]="+ville+"&tx_icsstarvillesselect_pi1[quartier]="+quartier);
		else
		xhr_object.open("POST", "index.php?eID=ics_starvillesselect&tx_icsstarvillesselect_pi1[ville]="+ville);
		xhr_object.onreadystatechange = function()
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				/*if(strpos(xhr_object.responseText,"headerLocation"))
				{
					var resultat = xhr_object.responseText.match(/<(\w+)((?:\s+\w+(?:\s*=\s*(?:"[\s\S]*?"|\'[\s\S]*?\'|[^\'">\s]+))?)+\s*|\s*)>([\s\S]*?)<\/\1>/gi);
					var re2 = resultat[0].replace("<div class=\"tx-icsstarvilleselect-pi1\">", "");
					re2 = re2.replace("<headerLocation>", "");
					re2 = re2.replace("</headerLocation>", "");
					re2 = re2.replace("</div>", "");
					re2 = trim(re2);
					document.location=re2;
				}
				else*/
				
					document.getElementById('tx_icsstarvillesselect_pi1_ptsvente').innerHTML = xhr_object.responseText;
					document.getElementById('tx_icsstarvillesselect_pi1_ptsvente').style.display = 'block';
					document.getElementById('wait_loading').style.display = 'none';
								
			}
		};

		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		xhr_object.send();
	return false;
}

