var map = "";
var mapLoadTO = null;
var defaultZoom = 14;

function mark_hood(idlist) {
	var strAreaList = "";
	var idarray = idlist.split(", ");
	for (var i=0; i<idarray.length; i++) {
		updateMap = updateMapNoFlash;
		document.getElementById(idarray[i]).click();
		updateMap = updateMapFlash;
		document.getElementById(idarray[i]).checked = true;
		strAreaList += (document.getElementById(idarray[i] + 'Lbl').innerHTML + ", ");
	}
	if (strAreaList.length > 0) {
		strAreaList = strAreaList.substring(0, strAreaList.length - 2);
	}
	document.getElementById('included-label').innerHTML = "Selected:";
	document.getElementById('included-area-list').innerHTML = strAreaList;
}

function unmark_hood(idlist) {
	var strAreaList = "";
	var idarray = idlist.split(", ");
	for (var i=0; i<idarray.length; i++) {
		updateMap = updateMapNoFlash;
		document.getElementById(idarray[i]).click();
		updateMap = updateMapFlash;
		document.getElementById(idarray[i]).checked = false;
		strAreaList += (document.getElementById(idarray[i] + 'Lbl').innerHTML + ", ");
	}
	if (strAreaList.length > 0) {
		strAreaList = strAreaList.substring(0, strAreaList.length - 2);
	}
	document.getElementById('included-label').innerHTML = "Removed:";
	document.getElementById('included-area-list').innerHTML = '<strike>' + strAreaList + '</strike>';
}

function updateMap(lat, lng, loc, checked) {
	try {
		map.setCenter(new GLatLng(lat, lng), defaultZoom);
	} catch(e) {
	
	}
	if (!checked) {
		window.document.map_chicago.SetVariable('msgUnmark', loc);
		unmark_hood(loc);
	} else {
		window.document.map_chicago.SetVariable('msgMark', loc);
		mark_hood(loc);
	}
}

function updateMapFlash(lat, lng, loc, checked) {
	try {
		map.setCenter(new GLatLng(lat, lng), defaultZoom);
	} catch(e) {
	
	}
	if (!checked) {
		window.document.map_chicago.SetVariable('msgUnmark', loc);
		unmark_hood(loc);
	} else {
		window.document.map_chicago.SetVariable('msgMark', loc);
		mark_hood(loc);
	}
}

function updateMapNoFlash(lat, lng, loc, checked) {
	try {
		map.setCenter(new GLatLng(lat, lng), defaultZoom);
	} catch(e) {
	
	}
}

function loadMap() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("vMap"));
		map.setCenter(new GLatLng(41.906602831015595, -87.67381668090821), defaultZoom);
		markMap();
	}
}

function markMap() {
	for (var j=0; j<document.frmCriteria.areaGuids.length; j++) {
		if (document.frmCriteria.areaGuids[j].checked) {
			document.frmCriteria.areaGuids[j].checked = false;
		}
	}
}
