if (Garmin == undefined) var Garmin = {};
Garmin.FlashUtil = {

   /**
     * Adds a flash object to the page using the SWFObject library.  SWF's are loaded after the pageComplete 
     * event so we don't have to "activate" them.  And swfobject handles writing out the appropriate tags for
     * each browser and inserts the params appropriately.
     * 
     * @param {String} source URL to the swf file.  Relative to /trail/player2/
     * @param {Element} id where we're putting the swf on the page - content of the element will be replaced
     * @return {Element} that represents the swf, ready to be stored as an object to have methods called upon
     */
    addFlashObject: function(source, id, parameters) {
        //create flash object
        var swfId = id + "Swf";
        
        var so = new SWFObject(source, swfId, "100%", "100%", "9.0.0");
    	so.addParam("wmode", "transparent");
    	so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", true);
    	for(var index in parameters) {
    		so.addVariable(index, parameters[index]);
    	}
    	
    	
    	//so.addVariable("server", $F("server")); 
    	//so.addVariable("file_pk", $F("episodePkValues"));
    	
    	//if flash isn't installed, display the Get Flash picture instead
    	if( so.write(id) ){
    		//awesome
    	} else {
    		var installFlashLink = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
    		var installFlashText = "Install the <a href='" + installFlashLink + "' target='_new'>Flash Player</a> to view your activity charts.";
    		
    		$(id).innerHTML = installFlashText;
    	}
    	return Garmin.FlashUtil.getElement(swfId);
    },

    /**
     * Apparently document.getElementById doesn't work for Flash objects, so we need this
     * function to get the controller
     * 
     * @param {String} id dom id of the swf you want to retrieve
     * @return {Element} the flash controller element
     */
    getElement: function(id) {
        return (navigator.appName.indexOf("Microsoft") != -1) ? window[id] : document[id];
    }

};