// check if the map is saved before the
// page is unloaded.
function getFlashMovie(movieName)
{
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function checkMapSave()
{
	var saved = getFlashMovie("editor").isMapSaved();
	
	if(!saved)
	{
		if(confirm("Are you sure you wish to abandon this clever composition of cartography?\n\nPress [OK] to save your changes or [CANCEL] to continue."))
		{
			getFlashMovie("editor").saveMap();
		}
	}
}

window.onbeforeunload = checkMapSave;