/**************************************************************************************************
BSD LicenseThe BSD License (http://www.opensource.org/licenses/bsd-license.php) specifies the terms andconditions of use for FAVideo:Copyright (c) 2007. Adobe Systems Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permittedprovided that the following conditions are met:¥ Redistributions of source code must retain the above copyright notice, this list of conditionsand the following disclaimer.¥ Redistributions in binary form must reproduce the above copyright notice, this list ofconditions and the following disclaimer in the documentation and/or other materials provided with the distribution.¥ Neither the name of Adobe Systems Incorporated nor the names of its contributors may be usedto endorse or promote products derived from this software without specific prior writtenpermission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIESOF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
For more information and updates for FAVideo, please visit:
http://www.adobe.com/go/FAVideo/
**************************************************************************************************/
/* ----------------------------------------------------
 * FAVideo system *
 * This system provide a simple method for embedding and controlling Flash video through Javascript.
 *
 * Dependencies:
 * - Requires AC_RunActiveContent.js
 *----------------------------------------------------- */
/* ----------------------------------------------------
 * FAVideo
 *
 * FAVideo represents a video player instance on the page. It allows you to instantiate, control,
 * and listen to events from a Flash video player through Javascript.
 *----------------------------------------------------- */MOKEVideo=function(divName,videoPath,bgColor,liveSite,width,height,options){liveSite=(liveSite)?liveSite:"";this.DEFAULT_SWF_PATH=liveSite+"flash/FAVideo";this.DEFAULT_SKIN_PATH=liveSite+"skins/ClearOverCustom.swf";this.DEFAULT_FOLDER=liveSite;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.bgColor=(bgColor!="undefined")?bgColor:"000000";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();};MOKEVideo.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);};MOKEVideo.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);};MOKEVideo.prototype.pause=function(pauseState){this.callMethod("pause",pauseState);};MOKEVideo.prototype.stop=function(){this.callMethod("stop");};MOKEVideo.prototype.seek=function(seconds){this.callMethod("seek",seconds);};MOKEVideo.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);};MOKEVideo.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});};MOKEVideo.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;}}};MOKEVideo.prototype.getVolume=function(){return this.volume;};MOKEVideo.prototype.setVolume=function(value){this.setProperty("volume",value);};MOKEVideo.prototype.getAutoPlay=function(){return this.autoPlay;};MOKEVideo.prototype.setAutoPlay=function(value){this.setProperty("autoPlay",value);};MOKEVideo.prototype.getClickToTogglePlay=function(){return this.clickToTogglePlay;};MOKEVideo.prototype.setClickToTogglePlay=function(value){this.setProperty("clickToTogglePlay",value);};MOKEVideo.prototype.getAutoLoad=function(){return this.autoLoad;};MOKEVideo.prototype.setAutoLoad=function(value){this.setProperty("autoLoad",value);};MOKEVideo.prototype.getSkinAutoHide=function(){return this.skinAutoHide;};MOKEVideo.prototype.setSkinAutoHide=function(value){this.setProperty("skinAutoHide",value);};MOKEVideo.prototype.getSkinVisible=function(){return this.skinVisible;};MOKEVideo.prototype.setSkinVisible=function(value){this.setProperty("skinVisible",value);};MOKEVideo.prototype.getPlayheadTime=function(){return this.playheadTime;};MOKEVideo.prototype.setPlayheadTime=function(value){this.setProperty("playheadTime",value);};MOKEVideo.prototype.getTotalTime=function(){return this.totalTime;};MOKEVideo.prototype.setTotalTime=function(value){this.setProperty("totalTime",value);};MOKEVideo.prototype.getBufferTime=function(){return this.bufferTime;};MOKEVideo.prototype.setBufferTime=function(value){this.setProperty("bufferTime",value);};MOKEVideo.prototype.getVideoScaleMode=function(){return this.videoScaleMode;};MOKEVideo.prototype.setVideoScaleMode=function(value){this.setProperty("videoScaleMode",value);};MOKEVideo.prototype.getVideoAlign=function(){return this.videoAlign;};MOKEVideo.prototype.setVideoAlign=function(value){this.setProperty("videoAlign",value);};MOKEVideo.prototype.getPlayheadUpdateInterval=function(){return this.playheadUpdateInterval;};MOKEVideo.prototype.setPlayheadUpdateInterval=function(value){this.setProperty("playheadUpdateInterval",value);};MOKEVideo.prototype.getPreviewImagePath=function(){return this.previewImagePath;};MOKEVideo.prototype.setPreviewImagePath=function(value){this.setProperty("previewImagePath",value);};MOKEVideo.prototype.getThemeColor=function(){return this.themeColor;};MOKEVideo.prototype.setThemeColor=function(value){this.setProperty("themeColor",value);};MOKEVideo.prototype.getSkinPath=function(){return this.skinPath;};MOKEVideo.prototype.setSkinPath=function(value){this.setProperty("skinPath",value);};MOKEVideo.prototype.getSkinVisible=function(){return this.skinVisible;};MOKEVideo.prototype.setSkinVisible=function(value){this.setProperty("skinVisible",value);};MOKEVideo.prototype.update=function(props){for(var n in props){this[n]=props[n];}props.type="change";this.dispatchEvent(props);};MOKEVideo.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.startNextVideo();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;}};MOKEVideo.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;};MOKEVideo.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]);}};MOKEVideo.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=false;this.skinPath=this.DEFAULT_SKIN_PATH;this.playheadTime=null;this.bufferTime=0.1;this.videoScaleMode="maintainAspectRatio";this.videoAlign="center";this.playheadUpdateInterval=1000;this.previewImagePath=this.DEFAULT_FOLDER+"images/playVideo.png";this.themeColor=null;this.firstLoad=true;this.pluginError=false;};MOKEVideo.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","#"+this.bgColor,"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","wmode","opaque","bgcolor","#"+this.bgColor,"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="This content requires the <a href=http://www.adobe.com/go/getflash/>Adobe Flash Player</a>.";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;};MOKEVideo.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;}};MOKEVideo.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);}};MOKEVideo.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);};MOKEVideo.prototype.callMethod=function(param1,param2,param3){if(this.inited){this.player.callMethod(param1,param2,param3);}else{this.delayCalls.push(arguments);}};MOKEVideo.prototype.makeDelayCalls=function(){for(var i=0;i<this.delayCalls.length;i++){this.callMethod.apply(this,this.delayCalls[i]);}};MOKEVideo.prototype.setProperty=function(property,value){this[property]=value;if(this.inited){this.invalidateProperty(property);}};MOKEVideo.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]);}};MOKEVideo.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;};MOKEVideo.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);};MOKEVideo.prototype.startNextVideo=function(){this.callMethod("setPreviewVisible");};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();}