$(gmailInitialize);

function gmailInitialize() {
	if ( document.getElementById("geoName").value ) {
		map = new GMap2(document.getElementById("gmap"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMenuMapTypeControl(true, false));
		map.addMapType(G_PHYSICAL_MAP);

		gGeo = new GClientGeocoder();
		searchPoint()
	} else {
		document.getElementById("gmap").style.display = "none";
		document.getElementById("gmap").style.width   = "0px";
		document.getElementById("gmap").style.height  = "0px";
	}
}

function searchPoint() {
	var address = document.getElementById("geoName").value;
	gGeo.getLatLng( address, checkGeo );
}

function checkGeo( point ) {
	if ( point ) {
		document.getElementById("gmap").style.display = "block";
		document.getElementById("gmap").style.width   = "450px";
		document.getElementById("gmap").style.height  = "320px";
		
		map.setCenter( point, 15 );
		var marker = new GMarker( point );

		map.addOverlay( marker );
		GEvent.addListener(marker, "mouseover", function() { marker.openInfoWindowHtml(
			document.getElementById("nodeName").value )
			 });
	} else {
		document.getElementById("gmap").style.display = "none";
		document.getElementById("gmap").style.width   = "0px";
		document.getElementById("gmap").style.height  = "0px";
	}
}
