/**
 * XZFlashController 1.0: Flash communication with Javascript - The 'core.xml.JavscriptControl' class must be implemented in Flash application
 * Author : 404.fr
 */

if (typeof fr == "undefined") var fr = {};
if (typeof fr.xzone == "undefined") fr.xzone = {};
if (typeof fr.xzone.flash == "undefined") fr.xzone.flash = {};
   
/**
 * Class XZFlashController
 */
fr.xzone.flash.XZFlashController = {
	get : function(objId){ return new fr.xzone.flash.XZFlashControllerObject(objId); },
	_receiveEventFromFlash : function(objId, evt){  }
}

fr.xzone.flash.XZFlashControllerObject = function(objId) {
	this.objectID = objId;
	
	this.flashPlayer = null;
	if(document && document.getElementById) this.flashPlayer = document.getElementById(objId);
	else if(document) this.flashPlayer = document[objId];
	
	this._dispatchEventToFlash = function(evt, option){
		if (this.flashPlayer != null && this.flashPlayer.externalEvent != null && typeof(this.flashPlayer.externalEvent) == 'function')
			this.flashPlayer.externalEvent(evt, option);
	}
	
	/* Integrated methods examples */
	this.version = function(){ this._dispatchEventToFlash("version", null); }
	this.blur = function(){ this._dispatchEventToFlash("blur", null); }
	//this.play = function(){ this._dispatchEventToFlash("play", null); }
	//this.volume = function(_volume){ this._dispatchEventToFlash("volume", _volume); }
}

XZFlashController = fr.xzone.flash.XZFlashController;
