FAVideo=function(divName,videoPath,width,height,options){this.DEFAULT_SWF_PATH="FAVideo";this.DEFAULT_SKIN_PATH="skins/ClearOverAll.swf";this.DEFAULT_WIDTH=320;this.DEFAULT_HEIGHT=240;this.ERROR_DIV_NOT_FOUND="The specified DIV element was not found.";this.id=FAVideoManagerInstance.addPlayer(this);this.rendered=false;this.inited=false;this.divName=divName;this.name="FAVideo_"+divName;this.videoPath=videoPath;this.width=(width>0)?width:this.DEFAULT_WIDTH;this.height=(height>0)?height:this.DEFAULT_HEIGHT;this.player=null;this.initProperties();this.setOptions(options);this.createPlayer();this.render();}
FAVideo.prototype.play=function(videoPath,totalTime){this.autoPlay=true;if(totalTime!=null){this.setTotalTime(totalTime);}
if(videoPath!=null){this.videoPath=videoPath;}
if(this.videoPath==null&&!this.firstLoad){this.dispatchEvent({type:"error",error:"FAVideo::play - No videoPath has been set."});return;}
if(videoPath==null&&this.firstLoad&&!this.autoLoad){videoPath=this.videoPath;}
this.firstLoad=false;this.callMethod("playVideo",videoPath,totalTime);}
FAVideo.prototype.load=function(videoPath){if(videoPath!=null){this.videoPath=videoPath;}
if(this.videoPath==null){this.dispatchEvent({type:"error",error:"FAVideo::loadVideo - No videoPath has been set."});return;}
this.firstLoad=false;this.autoPlay=false;this.callMethod("loadVideo",this.videoPath);}
FAVideo.prototype.pause=function(pauseState){this.callMethod("pause",pauseState);}
FAVideo.prototype.stop=function(){this.callMethod("stop");}
FAVideo.prototype.seek=function(seconds){this.callMethod("seek",seconds);}
FAVideo.prototype.setSize=function(width,height){this.width=width;this.height=height;this.container.style.width=this.width+"px";this.container.style.height=this.height+"px";this.callMethod("setSize",this.width,this.height);}
FAVideo.prototype.addEventListener=function(eventType,object,functionRef){if(this.listeners==null){this.listeners={};}
if(this.listeners[eventType]==null){this.listeners[eventType]=[];}else{this.removeEventListener(eventType,object,functionRef);}
this.listeners[eventType].push({target:object,func:functionRef});}
FAVideo.prototype.removeEventListener=function(eventType,object,functionRef){for(var i=0;i<this.listeners[eventType].length;i++){var listener=this.listeners[eventType][i];if(listener.target==object&&listener.func==functionRef){this.listeners[eventType].splice(i,1);break;}}}
FAVideo.prototype.getVolume=function(){return this.volume;}
FAVideo.prototype.setVolume=function(value){this.setProperty("volume",value);}
FAVideo.prototype.getAutoPlay=function(){return this.autoPlay;}
FAVideo.prototype.setAutoPlay=function(value){this.setProperty("autoPlay",value);}
FAVideo.prototype.getClickToTogglePlay=function(){return this.clickToTogglePlay;}
FAVideo.prototype.setClickToTogglePlay=function(value){this.setProperty("clickToTogglePlay",value);}
FAVideo.prototype.getAutoLoad=function(){return this.autoLoad;}
FAVideo.prototype.setAutoLoad=function(value){this.setProperty("autoLoad",value);}
FAVideo.prototype.getSkinAutoHide=function(){return this.skinAutoHide;}
FAVideo.prototype.setSkinAutoHide=function(value){this.setProperty("skinAutoHide",value);}
FAVideo.prototype.getSkinVisible=function(){return this.skinVisible;}
FAVideo.prototype.setSkinVisible=function(value){this.setProperty("skinVisible",value);}
FAVideo.prototype.getPlayheadTime=function(){return this.playheadTime;}
FAVideo.prototype.setPlayheadTime=function(value){this.setProperty("playheadTime",value);}
FAVideo.prototype.getTotalTime=function(){return this.totalTime;}
FAVideo.prototype.setTotalTime=function(value){this.setProperty("totalTime",value);}
FAVideo.prototype.getBufferTime=function(){return this.bufferTime;}
FAVideo.prototype.setBufferTime=function(value){this.setProperty("bufferTime",value);}
FAVideo.prototype.getVideoScaleMode=function(){return this.videoScaleMode;}
FAVideo.prototype.setVideoScaleMode=function(value){this.setProperty("videoScaleMode",value);}
FAVideo.prototype.getVideoAlign=function(){return this.videoAlign;}
FAVideo.prototype.setVideoAlign=function(value){this.setProperty("videoAlign",value);}
FAVideo.prototype.getPlayheadUpdateInterval=function(){return this.playheadUpdateInterval;}
FAVideo.prototype.setPlayheadUpdateInterval=function(value){this.setProperty("playheadUpdateInterval",value);}
FAVideo.prototype.getPreviewImagePath=function(){return this.previewImagePath;}
FAVideo.prototype.setPreviewImagePath=function(value){this.setProperty("previewImagePath",value);}
FAVideo.prototype.getThemeColor=function(){return this.themeColor;}
FAVideo.prototype.setThemeColor=function(value){this.setProperty("themeColor",value);}
FAVideo.prototype.getSkinPath=function(){return this.skinPath;}
FAVideo.prototype.setSkinPath=function(value){this.setProperty("skinPath",value);}
FAVideo.prototype.update=function(props){for(var n in props){this[n]=props[n];}
props.type="change";this.dispatchEvent(props);}
FAVideo.prototype.event=function(eventName,evtObj){switch(eventName){case"progress":this.bytesLoaded=evtObj.bytesLoaded;this.bytesTotal=evtObj.bytesTotal;this.dispatchEvent({type:"progress",bytesLoaded:this.bytesLoaded,bytesTotal:this.bytesTotal});break;case"playheadUpdate":this.playheadTime=evtObj.playheadTime;this.totalTime=evtObj.totalTime;this.dispatchEvent({type:"playheadUpdate",playheadTime:this.playheadTime,totalTime:this.totalTime});break;case"stateChange":this.state=evtObj.state;this.dispatchEvent({type:"stateChange",state:this.state});break;case"change":this.dispatchEvent({type:"change"});break;case"complete":this.dispatchEvent({type:"complete"});break;case"ready":this.dispatchEvent({type:"ready"});break;case"metaData":this.dispatchEvent({type:"metaData",infoObject:evtObj});break;case"cuePoint":this.dispatchEvent({type:"cuePoint",infoObject:evtObj});break;case"init":this.inited=true;this.callMethod("setSize",this.width,this.height);this.invalidateProperty("clickToTogglePlay","skinVisible","skinAutoHide","autoPlay","autoLoad","volume","bufferTime","videoScaleMode","videoAlign","playheadUpdateInterval","skinPath","previewImagePath");this.validateNow();this.makeDelayCalls();if(this.autoPlay){this.play(this.videoPath);}else if(this.autoLoad){this.load(this.videoPath);}
this.dispatchEvent({type:"init"});break;}}
FAVideo.prototype.render=function(){var div=this.getElement(this.divName);if(div==null){return;}
this.pluginError=false;div.innerHTML=this.content;this.player=this.getElement(this.name);this.container=this.getElement(this.name+"_Container");this.rendered=true;}
FAVideo.prototype.setOptions=function(options){if(options==null){return;}
var hash=["volume","skinAutoHide","skinVisible","autoPlay","clickToTogglePlay","autoLoad","playHeadTime","totalTime","bufferTime","videoScaleMode","videoAlign","playheadUpdateInterval","skinPath","previewImagePath"];for(var i=0;i<hash.length;i++){var prop=hash[i];if(options[prop]==null){continue;}
this.setProperty(prop,options[prop]);}}
FAVideo.prototype.initProperties=function(){this.delayCalls=[];this.videoWidth=0;this.videoHeight=0;this.totalTime=0;this.bytesLoaded=0;this.bytesTotal=0;this.state=null;this.volume=50;this.clickToTogglePlay=true;this.autoPlay=true;this.autoLoad=true;this.skinAutoHide=false;this.skinVisible=true;this.skinPath=this.DEFAULT_SKIN_PATH;this.playheadTime=null;this.bufferTime=0.1;this.videoScaleMode="maintainAspectRatio";this.videoAlign="center";this.playheadUpdateInterval=1000;this.previewImagePath=null;this.themeColor=null
this.firstLoad=true;this.pluginError=false;}
FAVideo.prototype.createPlayer=function(){this.requiredMajorVersion=8;this.requiredMinorVersion=0;this.requiredRevision=0;this.content="";var flash="";var hasProductInstall=DetectFlashVer(6,0,65);var hasRequestedVersion=DetectFlashVer(this.requiredMajorVersion,this.requiredMinorVersion,this.requiredRevision);if(hasProductInstall&&!hasRequestedVersion){var MMPlayerType=(isIE==true)?"ActiveX":"PlugIn";var MMredirectURL=window.location;document.title=document.title.slice(0,47)+" - Flash Player Installation";var MMdoctitle=document.title;flash=this.AC_FL_RunContent("src","playerProductInstall","FlashVars","MMredirectURL="+MMredirectURL+"&MMplayerType="+MMPlayerType+"&MMdoctitle="+MMdoctitle+"","width","100%","height","100%","align","middle","id",this.name,"quality","high","bgcolor","#000000","name",this.name,"allowScriptAccess","always","type","application/x-shockwave-flash","pluginspage","http://www.adobe.com/go/getflashplayer");}else if(hasRequestedVersion){flash=this.AC_FL_RunContent("src",this.DEFAULT_SWF_PATH,"width","100%","height","100%","align","middle","id",this.name,"quality","high","bgcolor","#000000","allowFullScreen","true","name",this.name,"flashvars","playerID="+this.id+"&initialVideoPath="+this.videoPath,"allowScriptAccess","always","type","application/x-shockwave-flash","pluginspage","http://www.adobe.com/go/getflashplayer","menu","true");}else{flash="<tt>To view this Video, you need <br>the latest version of the free<br><a href=http://www.adobe.com/go/getflash target=_blank>Adobe Flash Player</a>.</tt>";this.pluginError=true;}
this.content="<div id='"+this.name+"_Container"+"' class='FAVideo' style='width:"+this.width+"px;height:"+this.height+"px;'>"+flash+"</div>";return this.content;}
FAVideo.prototype.getElement=function(id){var elem;if(navigator.appName.indexOf("Microsoft")!=-1){return window[id]}else{if(document[id]){elem=document[id];}else{elem=document.getElementById(id);}
return elem;}}
FAVideo.prototype.invalidateProperty=function(){if(this.invalidProperties==null){this.invalidProperties={};}
for(var i=0;i<arguments.length;i++){this.invalidProperties[arguments[i]]=true;}
if(this.validateInterval==null&&this.inited){var _this=this;this.validateInterval=setTimeout(function(){_this.validateNow();},100);}}
FAVideo.prototype.validateNow=function(){this.validateInterval=null;var props={};for(var n in this.invalidProperties){props[n]=this[n];}
this.invalidProperties={};this.player.callMethod("update",props);}
FAVideo.prototype.callMethod=function(param1,param2,param3){if(this.inited){this.player.callMethod(param1,param2,param3);}else{this.delayCalls.push(arguments);}}
FAVideo.prototype.makeDelayCalls=function(){for(var i=0;i<this.delayCalls.length;i++){this.callMethod.apply(this,this.delayCalls[i]);}}
FAVideo.prototype.setProperty=function(property,value){this[property]=value;if(this.inited){this.invalidateProperty(property);}}
FAVideo.prototype.dispatchEvent=function(eventObj){if(this.listeners==null){return;}
var type=eventObj.type;var items=this.listeners[type];if(items==null){return;}
for(var i=0;i<items.length;i++){var item=items[i];item.func.apply(item.target,[eventObj]);}}
FAVideo.prototype.AC_Generateobj=function(objAttrs,params,embedAttrs){var str='';if(isIE&&isWin&&!isOpera){str+='<object ';for(var i in objAttrs){str+=i+'="'+objAttrs[i]+'" ';}
str+='>';for(var i in params){str+='<param name="'+i+'" value="'+params[i]+'" /> ';}
str+='</object>';}else{str+='<embed ';for(var i in embedAttrs){str+=i+'="'+embedAttrs[i]+'" ';}
str+='> </embed>';}
return str;}
FAVideo.prototype.AC_FL_RunContent=function(){var ret=AC_GetArgs(arguments,".swf","movie","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000","application/x-shockwave-flash");return this.AC_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs);}
FAVideoManager=function(){hash={};uniqueID=1;}
FAVideoManager.prototype.addPlayer=function(player){hash[++uniqueID]=player;return uniqueID;}
FAVideoManager.prototype.getPlayer=function(id){return hash[id];}
FAVideoManager.prototype.callMethod=function(id,methodName){var player=FAVideoManagerInstance.getPlayer(id);if(player==null){alert("Player with id: "+id+" not found");}
if(player[methodName]==null){alert("Method "+methodName+" Not found");}
var args=new Array();for(var i=2;i<arguments.length;i++){args.push(arguments[i]);}
player[methodName].apply(player,args);}
if(FAVideoManagerInstance==null){var FAVideoManagerInstance=new FAVideoManager();}

