// (c)2007-2008 Media General Inc.

if(typeof nebulaplayer=='undefined')nebulaplayer=new Object();nebulaplayer.Nebula=function(elemId){this.initialized=false;this.enabled=true;this.ready=false;this.__listeners=[];this.muted=false;this.playing=false;this.paused=false;this.instance=nebulaplayer.manager.addPlayer(this);this.duration=0;this.time=0;this.element=document.getElementById(elemId);this.element.className="NebulaContainer";this.nVideoCell=document.createElement('div');this.nVideoCell.id="video_"+this.instance;this.element.appendChild(this.nVideoCell);this.nVideoCell.className="videoPlayer";this.htmlLayer=document.createElement('div');this.htmlLayer.id="layer_"+this.instance;this.element.insertBefore(this.htmlLayer,this.nVideoCell);this.htmlLayer.className="videoHtmlLayer";setTimeout(this.delegate(this,this.drawSWF),800);};nebulaplayer.Nebula.prototype={drawSWF:function(event){if(!this.ready){this.ready=true;try{var swf=new SWFObject('http://media.mgnetwork.com/mgvp/nebula.swf',this.instance,"100%","100%","9","#000000");if(!swf.installedVer.versionIsValid(swf.getAttribute('version'))){this.dispatchEvent({target:this,type:nebulaplayer.event.BAD_VERSION});}
swf.addParam('allowScriptAccess','always');swf.addParam('wmode','transparent');swf.addVariable('id',this.instance);swf.write(this.nVideoCell);}catch(err){this.element.innerHTML="<pre>An error has occured.<br />"+err+"</pre>";}}},dispatchQueue:function(queueObj,eventObj){var queueName="__q_"+eventObj.type;var queue=queueObj[queueName];if(queue!=undefined){var i;for(i in queue){var o=queue[i];var oType=typeof(o);o.apply(queueObj,[eventObj]);}}},delegate:function(obj,func){var f=function(){var target=arguments.callee.target;var func0=arguments.callee.func;return func0.apply(target,arguments);};f.target=obj;f.func=func;return f;},addEventListener:function(eventType,callback){var queueName="__q_"+eventType;if(this[queueName]==undefined){this[queueName]=new Array();}
this[queueName].push(callback);},dispatchEvent:function(eventObj){if(eventObj.target==undefined)eventObj.target=this;this.dispatchQueue(this,eventObj);},play:function(flvSrc){if(this.initialized){if(this.enabled){if(flvSrc!=''&&flvSrc!=null){this.getInstance()[this.instance+"_play"](flvSrc);}else{throw Error('Unrecognized video source.');}}}else{throw new Error('#200 Nebula player is not ready.');}},pause:function(){if(this.initialized){if(this.enabled){if(this.playing){this.getInstance()[this.instance+"_pause"]();}else{throw new Error('Unable to fulfill pause request; no video playing.');}}}else{throw new Error('#200 Nebula player is not ready.');}},stop:function(){if(this.initialized){if(this.enabled){if(this.playing){this.getInstance()[this.instance+"_stop"]();this.playing=false;}else{throw new Error('Unable to fulfill stop request; no video playing.');}}}else{throw new Error('#200 Nebula player is not ready.');}},seek:function(offset){if(this.initialized){if(this.enabled){if(this.playing){this.getInstance()[this.instance+"_seek"](offset);}else{throw new Error('Unable to fulfill seek request; no video playing.');}}}else{throw new Error('#200 Nebula player is not ready.');}},mute:function(){if(this.initialized){this.getInstance()[this.instance+"_mute"]();this.muted=!this.muted;}else{throw new Error('#200 Nebula player is not ready.');}},getVolume:function(){if(this.initialized){return this.getInstance()[this.instance+"_getVolume"]();}else{throw new Error('#200 Nebula player is not ready.');}},setVolume:function(lvl){if(this.initialized){this.getInstance()[this.instance+"_setVolume"](lvl);}else{throw new Error('#200 Nebula player is not ready.');}},getInstance:function(){if(navigator.appName.indexOf("Microsoft")!=-1){return window[this.instance];}else{return document[this.instance];}}};nebulaplayer.event={ADVANCE:'advance',BUFFER:'buffer',COMPLETE:'complete',CONNECT:'connect',ENABLE:'enable',FAILURE:'failure',LOAD:'load',MUTE:'mute',PAUSE:'pause',PLAY:'play',STOP:'stop',STREAM_ERROR:'streamError',SUCCESS:'success',BAD_VERSION:'badVersion'};nebulaplayer.manager={__players:[],addPlayer:function(plyr){var ranNum=new Date().getTime();ranNum=ranNum.toString().substr(-5);var nLen=nebulaplayer.manager.__players.push(plyr);var nName="$"+ranNum+"_nebulaInstance_"+nLen;return nName;},delegateEvent:function(target,eventType,additionalInfo){var i=0;var key,player;for(i;i<nebulaplayer.manager.__players.length;i++){player=nebulaplayer.manager.__players[i];if(player.instance==target){if(typeof(additionalInfo)!="undefined"){for(key in additionalInfo){player[key]=additionalInfo[key];}}
player.dispatchEvent({target:player,type:eventType});break;}}}};