
var fi=fi||{};fi.component=fi.component||{};fi.component.VideoPlayer=function($context){var VIDEO_PLAYER_SWF="/static/flash/videoplayer.swf";if(fi.STATIC){VIDEO_PLAYER_SWF="/"+VIDEO_PLAYER_SWF;};var VIDEO_PLAYER_CONFIG_JSON='{}';var VIDEO_PLAYER_DICTIONARY_JSON='{}';var api={};var $context=$context;var $container=$(".video-container",$context);var doAutoplay=false;var videoReady=false;var GUID="video-"+Math.floor(Math.random()*999999);var videoID=$context.data("video");var videoWidth=parseInt($context.width(),10)||620;var videoHeight=parseInt($context.height(),10)||350;$container.width(videoWidth);$container.height(videoHeight);$container.attr("id",GUID);api.init=function(){$('a',$container).bind("click",function(event){doAutoplay=true;api.embedFlash();return false;});};api.embedFlash=function(){videoReady=false;var flashvars={data_config:encodeURIComponent(VIDEO_PLAYER_CONFIG_JSON),data_dictionary:encodeURIComponent(VIDEO_PLAYER_DICTIONARY_JSON),data_dynamic:encodeURIComponent('{}'),data_static:encodeURIComponent("{}"),callbackReady:"fi.common.ComponentLoader.findInstanceById('"+this.id+"').videoReady"};var params={wmode:"opaque",bgcolor:"#FFFFFF",allowfullscreen:"true",allowscriptaccess:"always"};var attributes={id:GUID,name:GUID};swfobject.embedSWF(VIDEO_PLAYER_SWF,GUID,videoWidth,videoHeight,"9","expressinstall.swf",flashvars,params,attributes);};api.play=function(__videoID,__autoplay){if(typeof(__autoplay)==="undefined"){__autoplay=false;}
if(!videoReady){videoID=__videoID;doAutoplay=__autoplay;api.embedFlash();return;}
api.callFlashMethod(GUID,"videoPlayback",{VideoType:0,VideoId:__videoID,AutoPlay:__autoplay});};api.callFlashMethod=function(swfID,methodName,params){var swfObj=document.getElementById(swfID);if(swfObj){try{swfObj[methodName](params);}catch(e){}}};api.videoReady=function(){videoReady=true;if(videoID&&videoID.length>0){api.play(videoID,doAutoplay);videoReady=false;}};return api;};fi.common.ComponentLoader.register("video-player",fi.component.VideoPlayer);
