
function updateAvatar(pField){
	if(pField){
		displayFreeze(true);
		$("comment_form").style.display = 'block' ;
		$("comment_form").innerHTML = '<iframe id="cropper_frame" src="popup/cropper/index.php?field=' + pField + '" frameborder="0"></iframe>' ;
	}
}

function updateMap(pField){
	if(pField){
		var city = window.parent.document.getElementById('ville').value ;
		var zip = window.parent.document.getElementById('cp').value ;
		var country = window.parent.document.getElementById('pays').value ;
		displayFreeze(true);
		$("comment_form").style.display = 'block' ;
		$("comment_form").innerHTML = '<iframe id="map_frame" src="popup/map/index.php?field=' + pField + '&city=' + city + '&zip=' + zip + '&country=' + country + '" frameborder="0"></iframe>' ;
	}
}

var map = null;
var geocoder = null;

function initialize() {
  if (GBrowserIsCompatible()) {
	geocoder = new GClientGeocoder();
	showAddress ();
  }
}

function showAddress() {
	var city = document.getElementById('ville').value ;
	var zip = document.getElementById('cp').value ;
	var country = document.getElementById('pays').options[document.getElementById('pays').selectedIndex].text ;
	if(city != '' && zip != '' && country != ''){
		var address = city + ' ' + zip + ' '  + country ;
		if (geocoder) {
		geocoder.getLatLng(
		  address,
		  function(point) {
			if (!point) {
				document.getElementById('coord_y').value = 0;
				document.getElementById('coord_x').value = 0;
			} else {
				document.getElementById('coord_y').value = point.y;
				document.getElementById('coord_x').value = point.x;
			}
		  }
		);
	  }
	}
}

window.onload = function (){initialize();}

