var map;
var markerIcon
var bounds = null;
var mainMarker=null;
var eventData="";
var directoryData="";

function init(showBlock)
{   
    initMap();
    
}
function resolvePostCode()
{
    var mapFrame = window.frames["googleMapFrame"];
    if (mapFrame) {
	    var el = document.getElementById("postcode");
		mapFrame.document.getElementById("postcode").value = el.value;
		el.value = "checking...";
		mapFrame.resolvePostCode(resolvedPostCode);
	}
}

function resolvedPostCode(obj)
{
	var mapFrame = window.frames["googleMapFrame"];
    if (mapFrame) {
		var el1 = document.getElementById("postcode").value="";	    
		mapFrame.resolvedPostCode(obj);
	}
}
 
function memberLookup()
{
    var value = document.getElementById("nameLookUp").value;
    if (value != "") {
		setLongLat();
		var lng = document.getElementById("homeLong").value;
		var lat = document.getElementById("homeLat").value;
		if (lng == "-1" && lat == "-1")
			alert("You must set a location on the map first");
		else {    
			new ajax.Loader("local/ajax/getMember.php","name="+value+"&lat="+lat+"&lng="+lng,memberLookupResponse);
	    }
    }
}

function memberLookupResponse(HTMLResponse)
{
    if (HTMLResponse !== false) {
        var parent = document.getElementById("members");
        var obj = document.createElement("DIV");
        obj.innerHTML=HTMLResponse;
        parent.appendChild(obj);
    }
    
}

function setLongLat()
{
    var lat = -1;
    var lng = -1;
    var mapFrame = window.frames["googleMapFrame"];
    if (mapFrame) {
        mapFrame.setLongLat();
        document.getElementById('homeLat').value = mapFrame.document.getElementById('homeLat').value;
        document.getElementById('homeLong').value = mapFrame.document.getElementById('homeLong').value;
    }
}

