
// this effectively replaces fscommand, RBGISClient.swf will call this function like an event handler
function flashEvent(event, args) {
  // just to test that it works...
  /*if (event=="Map load") {
    alert(event + " : " + args);
  } else { 
    window.status = event + " : " + args;
  }*/
  
  var p;
  
  if (event == "Map mousemove") {
    SetMapLatLon(parseFloat(args.split(",")[1]), parseFloat(args.split(",")[0]));
  }
  else if (event == "Map load") {
    SetBBox(args);
	SetMapScale(args);
	SetZoomIndex();
	SetShowPoint();
  }
  else if (event == "Map save") {
    ShowSaveMap(args);
  }
  else if (event == "Map topography") {
    Topography(args);
  }
  else if (event == "Map placenames") {
    Placenames(args);
  }
  else if (event == "Map resize") {
    MapWidth = args.split(",")[0]
  }
  else if (event == "Map querybox") {
    //alert(args);
    //flashMovie('GISClient').PointFeature();
    
    clearTimeout(ShowPointTimeout);

    PopupInfo('info.aspx?bbox=' + args);
  }
  else if (event == "Map query") {
    //alert(args);
    
    clearTimeout(ShowPointTimeout);

    p = args.split("&")
    flashMovie('GISClient').PointFeature(parseFloat(p[0].substr(2)),parseFloat(p[1].substr(2)));
    
    if (p.length>2) {
        layer = p[2].substr(6);
        id = p[3].substr(3);
    }
    else
    {
        layer = "";
        id = "";
    }
    
    PopupInfo('info.aspx?x=' + p[0].substr(2) + '&y=' + p[1].substr(2) + '&mapwidth=' + MapWidth.toString() + '&layer=' + layer + '&id=' + id);
  }
  else if (event == "Symbol press") {
    clearTimeout(ShowPointTimeout);
  
    p = args.split("&")
    flashMovie('GISClient').PointFeature(parseFloat(p[0].substr(2)),parseFloat(p[1].substr(2)))
    
    var layer = "";
    
    if ($get("hdnWMS").value == "RGWSST" || 
            $get("hdnWMS").value == "RGWSSTANOMALY" || 
            $get("hdnWMS").value == "RGWHOTSPOT" || 
            $get("hdnWMS").value == "RGWDHW")
    {
        if ($get("hdnLayers").value.indexOf("DHW") >= 0)
        {
            layer = "DHW";
        }
        else if ($get("hdnLayers").value.indexOf("HOTSPOT") >= 0)
        {
            layer = "HOTSPOT";
        }
        else if ($get("hdnLayers").value.indexOf("SSTANOMALY") >= 0)
        {
            layer = "SSTANOMALY";
        }
        else if ($get("hdnLayers").value.indexOf("SST2") >= 0)
        {
            layer = "SST2";
        }
        else if ($get("hdnLayers").value.indexOf("SSTMAX") >= 0)
        {
            layer = "SSTMAX";
        }
    }
    
    PopupInfo('info.aspx?x=' + p[0].substr(2) + '&y=' + p[1].substr(2) + '&mapwidth=' + MapWidth.toString() + '&layer=' + layer + '&id=' + p[p.length-1].substr(4));
    //flashMovie('GISClient').Load();
  }
  else {
    //window.status = event + " : " + args
  }
}


// use this to access the flash movie so you can call it's external functions
function flashMovie(movieName)
{
    return $get(movieName);
    
    /*if (navigator.appName.indexOf("Microsoft") != -1)
    {
        return document[movieName];
    }
    else
    {
        return document[movieName];
    }*/
}