Cobalt.Website.Media.ProfessionalFlashVideoPlayer = function(sandbox)
{
    var _options;

    return {
        init : function(videoData)
        {
            _options = {
                swfUrl : videoData.url,
                contentDomId : videoData.clientElementId,
                sourceID : videoData.sourceID,
                width: videoData.width || "500",
                height: videoData.height || "375",
                videoFlashVersion: "8",
                expressInstallSwfUrl : null,
                flashVars: {"autoStart":videoData.autoPlay},
                params: {
                    quality: "high",
                    scale: "exactfit",
                    wmode: "transparent",
                    bgcolor: "#FFFFFF"
                },
                attributes: null,
                callback: null
            };
        },

        play:function(startMovie)
        {
            if (startMovie)
            {
                _options.flashVars.autoStart = true;
            }

            var WheelsTVPlayer = Cobalt.Website.Media.WheelsTVPlayer();
            WheelsTVPlayer.initVars( _options);
            WheelsTVPlayer.play();
        },

        destroy:function()
        {
            
        }

    };
};
Cobalt.Website.Media.WheelsTVPlayer = function(){
	
	return {
		initVars: function(options){
			this.options = options;
			this.params= [];
			this.params['bgcolor']=options.params.bgcolor;
			this.params['width']=options.width;
			this.params['height']=options.height;
			this.params['playerID']=this.getPlayerId();
			this.params['videoID']=options.sourceID;
			this.params['wmode']=options.params.wmode;
			this.params['playerKey']=this.getPlayerKey();
			this.params['isVid']=true;
			this.params['dynamicStreaming']=true;
			this.params['autoStart']=options.flashVars.autoStart;
			this.params['playerContainer']=options.contentDomId;
		},
		getPlayerId : function(){
			return "1126033613001";
		},
		getPlayerKey : function(){
			return "AQ~~,AAAAAC3mmL4~,c1Sr2lzKCfCo7LQ7PIWPD6RMHDR5OKxN";
		},
		getPlayerClass : function(){
			return "BrightcoveExperience";
		},
		play: function(){
			if(typeof(brightcove)=="undefined"){
				var oThis = this;
				jQuery.ajax({
					cache: false
				,   url: this.options.swfUrl
				,   success: function(){ 
						oThis.embedPlayerObject();
						brightcove.createExperiences();
					}
				,   dataType: 'script'
			});
			}else{
				this.embedPlayerObject();
				brightcove.createExperiences();
			}
		},
	    embedPlayerObject : function(){
	    	var playerObject = "<object class=\""+this.getPlayerClass()+"\">";
			var params = this.params;
			for (var key in params) {
				playerObject += "<param name=\"" + key + "\" value=\"" + params[key] + "\" />";
			}
			playerObject += "</object>";
			document.getElementById(params["playerContainer"]).innerHTML=playerObject;
	    }
	}
}
