// ********************************************
// **        Flashmaps DB Mapper 1.1         **
// **      JavaScript Custom Functions       **
// ********************************************
// ** Feel free to make any changes you need **
// **      to fit your requirements.         **
// ********************************************
// **      (c)2006 Flashmaps Geospatial      **
// **        http://www.flashmaps.com        **
// ********************************************


// ********************************************
// **  Functions called from the map, events **
// ********************************************

// The visitor placed the mouse over a POI
function fmCustomPOIOnRollOver(fmPOIID) {}

// The visitor moved the mouse out of a POI
function fmCustomPOIOnRollOut(fmPOIID) {}

// The visitor clicked on a POI
function fmCustomPOIOnRelease(fmPOIID) {
    fmCustomPOIUnhighlight(fmPOIID);
}

// The map is ready to receive commands
function fmCustomMapIsReady() {}

function loadSecondaryData()
{
	if(fmMapIsReady())
	{	
		//stop the loop
		window.clearInterval(appStartInterval);
		
		//do initial load

		//load the flow data
		fmGeometryUnload();
		if (mapPageType == "admin")
		{
			fmGeometryLoad("/flashmaps/fmDBMMap/info/flow_admin.aspx");
		} else {
			fmGeometryLoad("/flashmaps/fmDBMMap/info/flow.aspx");
		}

		//load the cookie data
		if(window.loadCookieData)
		{
			loadCookieData("1");
		}

		//kick off the periodic POI reload
		window.setInterval("reloadPOIs();",180000);
		//window.setInterval("reloadPOIs();",30000);

	}
}

// A set of POIs has been loaded
function fmCustomPOIURLLoaded(strPOIsURL, iPOIsNumber) {}

function reloadPOIs()
{
	//reset the pois
	fmPOIRemoveAll();
	if (mapPageType == "main")
	{
		fmPOILoadURL("info/pois.aspx");
	} else if (mapPageType == "mini") {
		fmPOILoadURL("info/pois_mini.aspx");
	} else {
		fmPOILoadURL("info/pois_admin.aspx");
	}

	//reset the flow
	fmGeometryUnload();
	if (mapPageType == "admin")
	{
		fmGeometryLoad("/flashmaps/fmDBMMap/info/flow_admin.aspx");
	} else {
		fmGeometryLoad("/flashmaps/fmDBMMap/info/flow.aspx");
	}

	//now kick off an interval to check for when the POI has been loaded.
	if (mapPageType == "main")
	{
		//only do this on the main map page.
		poisLoadedInterval = window.setInterval("refreshPOIState()",100);
	}
}

function refreshPOIState()
{
	if(fmPOIsHaveBeenLoaded())
	{
		window.clearInterval(poisLoadedInterval);
		fmMapObj1.resetPOIState();
	}
}

// ********************************************
// **  Functions to send commands to the map **
// ********************************************

// Highlight a POI
function fmCustomPOIHighlight(fmPOIID, strMethod) {
	// Highlight a POI inside the map
	fmPOIHighlight(fmPOIID, strMethod);
}

// Unhighlight a POI
function fmCustomPOIUnhighlight(fmPOIID) {
	// Unhighlight a POI inside the map
	if (fmPOIsHaveBeenLoaded()) {
		fmMapObj1.SetVariable("_root." + fmMcPath + "map_mc.fromOutsidePOIID", fmPOIID);
		fmMapObj1.SetVariable("_root." + fmMcPath + "map_mc.fromOutsideAction", "unhighlightPOI"); 
		fmMapObj1.TCallLabel("_root." + fmMcPath + "map_mc.fromOutside_mc", "doAction");
	}
}

// Highlight and focus on a POI
function fmCustomPOIHighlightAndFocusOn(fmPOIID, strMapScale, strMethod)
{
	// Focus and highlight on a POI inside the map
	//alert("Reached: fmCustomPOIHighlightAndFocusOn(fmPOIID, strMapScale, strMethod)");
	// fmPOIHighlightAndFocusOn(fmPOIID, strMapScale, strMethod);
}
