function MfcWeb( ) {
window.open("http://15016.myersinternet.com/","MFCHomepage","width=800,height=600,top=0,toolbar=yes,status=yes,scrollbars=yes,resizable=yes");
}

try{
	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
}catch (e){
}

if (window.XMLHttpRequest) {
	var xmlhttp = new XMLHttpRequest();
}else if(window.ActiveXObject){
	var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}

curCno = "45";
curCit = "SOUTHEAST GEORGIA";
function requestCommunityCoordinates(){
	reqComUrl = "/cgi-bin/lansaweb?procfun+WSPPROC01+WSCOORD+prd+eng";
	reqComUrl += "+funcparms+Y30CNO(S0030):" + curCno + "+N11CIT(A0300):" + curCit.replace(/\s/g, "%20").replace("&amp;", "&");
	//alert(reqComUrl);
	if (xmlhttp) {
		try{
			xmlhttp.open("POST", reqComUrl, true);
			xmlhttp.onreadystatechange=reqComReadyStateChange;
			xmlhttp.send(null);
		}catch(e){
			alert("Error sending data");
		}
	}	
}

maxLat = 0
maxLon = 0;
minLat = 9999
minLon = -9999;
function reqComReadyStateChange(){
	//window.status += "x";
	if(xmlhttp.readyState == 4){
		markerArray = new Array();
		result = xmlhttp.responseText;
		coords = result.split("<COMMUNITY_COORDINATES>");
		coords2 = coords[1].split("</COMMUNITY_COORDINATES>");

		comCoords = coords2[0].split("~~");

		for(i=0; i<comCoords.length; i++){
			latLon = comCoords[i].split("|");
		//alert(latLon);
			theLon = latLon[0];
			theLat = latLon[1];
			townHome = latLon[2];

			theLon = parseFloat(theLon);;
			theLat = parseFloat(theLat);

			if(theLat > maxLat) maxLat = theLat;
			if(theLon < maxLon) maxLon = theLon;
			if(theLat < minLat) minLat = theLat;
			if(theLon > minLon) minLon = theLon;

			// Create our "tiny" marker icon -- will place later
			var icon = new GIcon();
			icon.iconSize = new GSize(12, 12);
			icon.iconAnchor = new GPoint(6, 20);
	
			if(townHome == "Y"){
				icon.image = "/webimg/IMAGES/redtriangle.gif";
			}else{
				icon.image = "/webimg/IMAGES/reddot.gif";
			}

			marker = new GMarker(new GLatLng(theLat, theLon), icon);
			markerArray.push(marker);
		}	

		makeMyMap(markerArray);
	}
}

function makeMyMap(markerArray){
	document.getElementById("mapImage").innerHTML=""; //clear map area

	//find the div that will contain the map.
	var map = new GMap2(document.getElementById("mapImage"));

	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GScaleControl());
	map.disableDoubleClickZoom();

	centerLat = (maxLat + minLat)/2.00000;
	centerLon = (maxLon + minLon)/2.00000;
	//alert(maxLat + " " + minLat + " " + maxLon + " " + minLon + " " + centerLat + " " + centerLon);
	map.setCenter(new GLatLng(parseFloat(centerLat), parseFloat(centerLon)), 8);
	map.savePosition();	
	for(i=0; i<markerArray.length-1; i++){
		map.addOverlay(markerArray[i]);
		GEvent.addListener(markerArray[i], 'click', function(){
			//add mouse onclick event for map markers here
		});
		GEvent.addListener(markerArray[i], 'mouseover', function(){
			//add mouse onmouseover event for map markers here
		});
		GEvent.addListener(map, "click", function(){
			window.location.href = "/cgi-bin/lansaweb?procfun+JC10WEB+JC11V81+PRD+ENG+FUNCPARMS+Y30CNO(S0030):45+N11CIT(A0300):SOUTHEAST GEORGIA+CCID(A0060):000024";
		});
	}
}

window.onload = requestCommunityCoordinates;


