/* @param {Object} params The constructor params */
 
getPackageForName( "com.forddirect.presentation.widget.flvideoplayer" ).TestVid = function( el, jsInstance) {
	this.SWF_PATH = "/scripts/js/videoplayers/generic/flash/nextgenvideoplayer.swf"
	this.FLASHID="TestVid"
	this.widgetId = "" ;
	this.jsInstance = jsInstance;
	this.el = el;
	
	var oData = new Object;
	var oId = new Object

	/*
	* This function initializes the widget. 
	* @param {Object} initParams The object is as follows -
	*      {
	*         "widgetId":String                The id of the widget used for book-keeping
	*         "src":String                     The URL of the widget swf file
	*         "xVal":String                    The absolute x co-ordinate of the widget
	*         "yVal":String                    The absolute y co-ordinate of the widget
	*         "depth":String                   The depth of the widget
	*      }
	*/

	this.init = function( initParams, w, h ){
		if(typeof initParams == "undefined" ){
			initParams = "";
		}
		__flashFramework.loadFlashMovie( this.el, this.FLASHID , this.SWF_PATH , w , h , this.jsInstance , initParams);
	}

	this.onInitComplete = function(params){
		this.update();
	}

	/* @param {Object} oData */
	this.update = function(){
		oData = this.TheData
		
//		 DEBUG CODE Verification of Data object 
		//for (var i=0 ; i< oData.data.length ; i++){
		//	if (oData.data[i].id == oData.current){
		//		alert(oData.data[i].id + " " + oData.current  +  " " + oData.data[i].video);
		//	}
		//}
		__flashFramework.thisMovie(this.FLASHID)["eventHandler"]( "update", oData , "onUpdateComplete");
	}

	this.onUpdateComplete = function(params){
		alert("Whoo-hoo => onUpdateComplete deeplink:" + params[1].deeplink);
	}
	

	/* This function unloads the widget from the page and resets the widget data. */
	this.unload = function( ){
		//alert("unload");
		__flashFramework.thisMovie(this.FLASHID)["unloadWidget"](this.widgetId);
	}
	
	/* This function hides the UI widget keeping all the widget data intact. */
	this.hide = function( ){
		//alert("hide");
		__flashFramework.thisMovie(this.FLASHID)["eventHandler"]( "hide" ,firedData);
	}
	
	/* This function unhides the UI widget keeping all the widget data intact.*/
	this.unhide = function( ){
		//alert("unhide");
		__flashFramework.thisMovie(this.FLASHID)["eventHandler"]("unhide" ,firedData);
	}

	/* The Flash is listening for the last argument */

	this.launchVideo = function(oInput){
		if (oInput!=undefined){
			this.oId = oInput
		}
		
		try{
		__flashFramework.thisMovie(this.FLASHID)["eventHandler"]("launchVideo" ,this.oId , "onUpdateComplete");
		} catch(ee) {
			setTimeout(this.jsInstance  +".launchVideo()", 100)
		}
	}
	
	this.stopVideo = function(){
		var o = new Object();
		o.dummy = ""
		__flashFramework.thisMovie(this.FLASHID)["eventHandler"]("stopVideo", o, null)
	}
	
	/* JS Methods Fired from within Flash */
	this.onVideoStart= function(params){
		mVideoActivity(params[1].id, 0)
		//alert("onVideoStart " + params[0] + " " + params[1].id);
	}
	
	this.onVideoEnd = function(params){
		mVideoActivity(params[1].id, 1)
		//alert("onVideoEnd " + params[0] + " " + params[1].id )
	}
	
	this.onVideoLoaded = function(params){
		//alert("onVideoLoaded  "+  params[0] + " " + params[1].id);
	}
	
}