// JavaScript Document
/*
* This will load the video with the corresponding settings
* the setup is :
* give the divisions where the player will be installed a class of "videoplayer"
* inside that division there should be a tag "<settings /> with all the settings inside
* possible settings: autoplay="(true or false)" pause="(true or false)" controls="(true or false)" width="(number only)" height="(number only)" image="(path to image)" source="(path to video)"
*/
/*
*	Script created Maurix Suarez
*	http://orangepixel.us and http://goconvergence.com
*	you can use this script for free, but do not remove this notice
*	This script has been release under the GNU/GPL 2011
*/
// JavaScript Document
/*
*	script created by MAURIX SUAREZ 
*	released under the GNU/MIT licence
*	orangepixel@live.com
*	feel free to use this script, but do not remove this notice.
*/
//var userCustomImageURL = 'user_files\/videos\/video_posters\/';

//var defaultBgImageURL = 'user_files\/videos\/video_posters\/video_placeholder1.jpg';


//catch the url strings

$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

var allVars = $.getUrlVars();
var getStringAutoplay = $.getUrlVar('autoplay');



var userCustomImageURL = '';

var defaultBgImageURL = '\/static\/js\/video_play\/player\/video_play.png';

$(document).ready(function(){
	
	$('settings').hide();
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentName = deviceAgent.match(/(iphone|ipod|blackberry|ipad)/);
	//initialize the count for the ids
	var a = 0;
	
	//set the type to write the proper html
	if (agentName){
		var deviceType = 'mobile';
	}else{
		var deviceType = 'computer';
	}
	
	//check all div tag that have the class "video player"
	$('.videoplayer').each(function(){
		
		//conter
		a++;
		
		//add uniqueid
		$('.videoplayer').attr("id",function(arr){
			return "videoholder" + arr;
		});
		
		//get the settings for the video (s)
		var getAutoplay = $.trim($('settings',this).attr('autoplay'));
		var getWidth = $.trim($('settings', this).attr('width'));
		var getHeight = $.trim($('settings',this).attr('height'));
		var getControls = $.trim($('settings',this).attr('controls'));
		var getPause = $.trim($('settings',this).attr('pause'));
		var getImage = $.trim($('settings',this).attr('image'));
		var getSource =$.trim($('settings',this).attr('source'));
		var getOverlay = $.trim($('settings',this).attr('rel'));
		var getID = $.trim($('settings',this).attr('id'));
		
		//check versus the possible answers
		var checkArr = ['true','yes'];
		
		//set the class of overlays (if any)
		var overlay;
		if ($.inArray(getOverlay,checkArr) !== -1 && getOverlay !== '' && getOverlay !== 'rel' && getOverlay !== 'false'){
			//$(this).addClass('hideoverlay');
			overlay = 'true';
		}
		//check for errors or malformed html or no source attribute
		if (getSource === 'undefined' || $('settings').length == 0 || getSource == ''){
		
			//clear the tags
			//var deleteID = '#'+this.id;
			$(this).remove();
			$('settings').remove();

		}
		
	
		//remove the base url (if any)
		var baseURL = document.URL.split('/');
		var cleanURL = 'http://'+baseURL[2]+'/';
		var rawSource1 = getSource.replace(cleanURL,' ');
		
		var currentFolder = location.pathname.split('/');
		//currentFolder = currentFolder[1];
		//solve the bug of recognizing the localhost
		
		//var clearLocalHost = 'http://localhost/';
		//rawSource = getSource.replace(clearLocalHost,' ');
		rawSource2 = rawSource1.replace(currentFolder[1]+'/','');
		//rawSource2 = rawSource2.replace('/','');
		var source = $.trim(rawSource2);
		
		//check the autoplay varibales
		if ($.inArray(getAutoplay,checkArr) !== -1 && getAutoplay !== ''){
			var autoplay = 'true';
		}else{
			var autoplay = 'false';
		}
		
		var width = getWidth;
		var height = getHeight;
		var image;
		if (getImage !== '' && getImage !== 'image' && getImage !== 'undefined'){
			image = userCustomImageURL+getImage;
		}else{
			image = '';	
		}
		
		if (getControls === '' || getControls === 'controls' || getControls === 'undefined'){
			var showControls = 'true';
		}else{
			var showControls = 'false';	
		}
		
		
		var disablePause = getPause;
		
		//initialize the variable and write the html
		//all tags are dependant of the type of device
		var videoTAG;
		
		//prepare the link to open the popup
		if(overlay){
			
			//set the rel attribute 
			var cleanID = getID.replace('.mp4',' ');					
			cleanID = cleanID.replace(/ /g,'');
			setThisREL = '.'+cleanID;
			setThisRELID = 'open_'+this.id;
			setThisRELIDRef = '#'+setThisRELID;
			$(setThisREL).attr('rel','#'+this.id);
			$(setThisREL).attr('id',setThisRELID);
			
			//hide the element
			$(this).addClass("hideoverlay");
			$(this).addClass("setsize"+a);
			$('<style type=\'text/css\'> .setsize'+a+'{width:'+width+'px; height:'+height+'px;} <\/style>').appendTo('head');	
		}
		
		//set the html according to the device
		if(deviceType == 'mobile'){
				
				
				if(overlay){

					$(setThisREL).attr('href',source);
					
				}else{
					if(agentName[0] == 'blackberry'){
						//set an image if user has not specified one
						if (image === '' || image === 'image' || image === 'undefined'){
							image = defaultBgImageURL;
						}
						videoTAG = '<a class="fallback_link" href="'+source+'" style="background:#000 url('+image+') center no-repeat; display:block; width:'+width+'px; height:'+height+'px; overflow:hidden;">';
						videoTAG += '<\/a>';
					
					}else{
						
						if(a > 0){
							if (image === '' || image === 'image' || image === 'undefined'){
								image = defaultBgImageURL;
							}
							videoTAG = '<a class="fallback_link" href="'+source+'" style="background:#000 url('+image+') center no-repeat; display:block; width:'+width+'px; height:'+height+'px; overflow:hidden;">';
							videoTAG += '<\/a>';
						}else{
							if (image === '' || image === 'image' || image === 'undefined'){
								image = '';
							}
							videoTAG = '<div class="video-js-box">';
							videoTAG += '<video class="video-js" width="'+width+'" controls preload height="'+height+'" poster="'+image+'" >';
							videoTAG += '<source src="'+source+'" type="video\/mp4;" \/>';
							videoTAG += '<\/video>';
							videoTAG += '<\/div>';
						}
					}
				}
				
		}else{	
				if(overlay){
					
						//add the html
						videoTAG = '<a  class="'+this.id+'" href="'+source+'" style="width:'+width+'px; height:'+height+'px;">&nbsp;</a>';
						videoTAG += '<script type="text\/javascript">';
						videoTAG += '$(document).ready(function(){';
						videoTAG += '$("'+setThisRELIDRef+'[rel]").overlay({';
						//set the effect type											  
						videoTAG += 'effect: \'apple\',';
						
						//set the mask (bg)
						videoTAG += 'mask: {';
						videoTAG += 'color: \'#fff\',';
						videoTAG += 'loadSpeed: 200,';
						videoTAG += 'opacity: 0.9';
						videoTAG += '},';
						//find and install the video player
						videoTAG += 'onLoad: function(content) {';
						videoTAG += 'this.getOverlay().find("a.'+this.id+'").flowplayer(0).load();';
						videoTAG += '},';
						videoTAG += 'onClose: function(content) {';
						videoTAG += '$f().unload();';
						videoTAG += '}';
						//close the overlay function											  
						videoTAG += '});';
						videoTAG += '$("a.'+this.id+'").flowplayer("\/static\/js\/video_play\/player\/flowplayer-3.2.7.swf");';
						//close the main tag function
						videoTAG += '});';
						videoTAG += '<\/script>';
					
								 
				}else{
					
					videoTAG = '<a id="player'+a+'" href="'+source+'" style="background:#000; display:block; width:'+width+'px; height:'+height+'px; overflow:hidden; margin:0px; vertical-align:middle; text-align:center; ">';
					if(image){
					
						//insert the image for the splash
						//it only works in computers / not mobiles
						videoTAG += '<img src="'+image+'" alt="'+source+'" \/>';
						
						autoplay = 'true';
					}else{
						
						if(autoplay == 'false'){
							videoTAG += '<span style="background:url('+defaultBgImageURL+') center no-repeat #000; display:block; width:'+width+'px; height:'+height+'px;" >';
							videoTAG += '<\/span>';
							autoplay = 'true';
						}
					}
					
					videoTAG += '<\/a>';
					videoTAG += '<script type="text\/javascript">';
					//embed the video player
					videoTAG += '$f("player'+a+'",{src: "\/static\/js\/video_play\/player\/flowplayer-3.2.7.swf", wmode:"transparent"},{';
					
					//disable the pause
					if (disablePause == 'false'){
						videoTAG += 'onBeforePause: function () {';
						videoTAG += 'return false;';
						videoTAG += '},';
					}
					
					//screen settings
					videoTAG += 'screen:{';
					videoTAG += 'bottom: 0';
					videoTAG += '},';
					
					//control bar settings

					videoTAG += 'plugins: {';
					if (showControls == 'false'){
						videoTAG += 'controls:null';
					}else{
						videoTAG += 'controls: {';
						videoTAG += 'url: \'\/static\/js\/video_play\/player\/flowplayer.controls-3.2.5.swf\',';
							
						videoTAG += 'backgroundColor: "transparent",';
						videoTAG += 'backgroundGradient: "none",';
						videoTAG += 'sliderColor: \'#FFFFFF\',';
						videoTAG += 'sliderBorder: \'1px solid rgba(160,160,160,0.7)\',';
						videoTAG += 'volumeSliderColor: \'#FFFFFF\',';
						videoTAG += 'volumeBorder: \'1px solid rgba(160,160,160,0.7)\',';
			
						videoTAG += 'timeColor: \'#ffffff\',';
						videoTAG += 'durationColor: \'#535353\',';
			
						videoTAG += 'tooltipColor: \'rgba(255, 255, 255, 0.7)\',';
						videoTAG += 'tooltipTextColor: \'#000000\'';
						videoTAG += '}';
					}
					
					videoTAG += '},';
			
					//clip settings
					videoTAG += 'clip: {';
					videoTAG += 'autoPlay:'+autoplay+',';
					videoTAG += 'autoBuffering: true';
					videoTAG += '}';
					
					//close the main flowplayer tag
					videoTAG += '});';
					
					
					videoTAG += '<\/script>';
				}
	
		}
		
		/*$(this).attr("id",function(arr){
			return "videoholder" + arr;
		});*/
		
		//send the html video output
		$(this).append(videoTAG);
		
		//after loading the settings clear the html settings
		$('settings',this).remove();
		
	 });
	//setup the VideoJS for mobile devices
	VideoJS.setupAllWhenReady();
	
 });


/* ***************************** */
/*LOAD THE JS LIBRARY*/
/* ***************************** */
(function(window,undefined){var document=window.document;(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz})?/\b_super\b/ :/.*/;this.JRClass=function(){};JRClass.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret}})(name,prop[name]):prop[name]}function JRClass(){if(!initializing&&this.init)this.init.apply(this,arguments)}JRClass.prototype=prototype;JRClass.constructor=JRClass;JRClass.extend=arguments.callee;return JRClass}})();var VideoJS=JRClass.extend({init:function(element,setOptions){if(typeof element=='string'){this.video=document.getElementById(element)}else{this.video=element}this.video.player=this;this.values={};this.elements={};this.options={autoplay:false,preload:true,useBuiltInControls:false,controlsBelow:false,controlsAtStart:false,controlsHiding:true,defaultVolume:0.85,playerFallbackOrder:["html5","flash","links"],flashPlayer:"htmlObject",flashPlayerVersion:false};if(typeof VideoJS.options=="object"){_V_.merge(this.options,VideoJS.options)}if(typeof setOptions=="object"){_V_.merge(this.options,setOptions)}if(this.getPreloadAttribute()!==undefined){this.options.preload=this.getPreloadAttribute()}if(this.getAutoplayAttribute()!==undefined){this.options.autoplay=this.getAutoplayAttribute()}this.box=this.video.parentNode;this.linksFallback=this.getLinksFallback();this.hideLinksFallback();this.each(this.options.playerFallbackOrder,function(playerType){if(this[playerType+"Supported"]()){this[playerType+"Init"]();return true}});this.activateElement(this,"player");this.activateElement(this.box,"box")},behaviors:{},newBehavior:function(name,activate,functions){this.behaviors[name]=activate;this.extend(functions)},activateElement:function(element,behavior){if(typeof element=="string"){element=document.getElementById(element)}this.behaviors[behavior].call(this,element)},errors:[],warnings:[],warning:function(warning){this.warnings.push(warning);this.log(warning)},history:[],log:function(event){if(!event){return}if(typeof event=="string"){event={type:event}}if(event.type){this.history.push(event.type)}if(this.history.length>=50){this.history.shift()}try{console.log(event.type)}catch(e){try{opera.postError(event.type)}catch(e){}}},setLocalStorage:function(key,value){if(!localStorage){return}try{localStorage[key]=value}catch(e){if(e.code==22||e.code==1014){this.warning(VideoJS.warnings.localStorageFull)}}},getPreloadAttribute:function(){if(typeof this.video.hasAttribute=="function"&&this.video.hasAttribute("preload")){var preload=this.video.getAttribute("preload");if(preload===""||preload==="true"){return"auto"}if(preload==="false"){return"none"}return preload}},getAutoplayAttribute:function(){if(typeof this.video.hasAttribute=="function"&&this.video.hasAttribute("autoplay")){var autoplay=this.video.getAttribute("autoplay");if(autoplay==="false"){return false}return true}},bufferedPercent:function(){return(this.duration())?this.buffered()[1]/this.duration():0},each:function(arr,fn){if(!arr||arr.length===0){return}for(var i=0,j=arr.length;i<j;i++){if(fn.call(this,arr[i],i)){break}}},extend:function(obj){for(var attrname in obj){if(obj.hasOwnProperty(attrname)){this[attrname]=obj[attrname]}}}});VideoJS.player=VideoJS.prototype;VideoJS.player.extend({flashSupported:function(){if(!this.flashElement){this.flashElement=this.getFlashElement()}if(this.flashElement&&this.flashPlayerVersionSupported()){return true}else{return false}},flashInit:function(){this.replaceWithFlash();this.element=this.flashElement;this.video.src="";var flashPlayerType=VideoJS.flashPlayers[this.options.flashPlayer];this.extend(VideoJS.flashPlayers[this.options.flashPlayer].api);(flashPlayerType.init.context(this))()},getFlashElement:function(){var children=this.video.children;for(var i=0,j=children.length;i<j;i++){if(children[i].className=="vjs-flash-fallback"){return children[i]}}},replaceWithFlash:function(){if(this.flashElement){this.box.insertBefore(this.flashElement,this.video);this.video.style.display="none"}},flashPlayerVersionSupported:function(){var playerVersion=(this.options.flashPlayerVersion)?this.options.flashPlayerVersion:VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion;return VideoJS.getFlashVersion()>=playerVersion}});VideoJS.flashPlayers={};VideoJS.flashPlayers.htmlObject={flashPlayerVersion:9,init:function(){return true},api:{width:function(width){if(width!==undefined){this.element.width=width;this.box.style.width=width+"px";this.triggerResizeListeners();return this}return this.element.width},height:function(height){if(height!==undefined){this.element.height=height;this.box.style.height=height+"px";this.triggerResizeListeners();return this}return this.element.height}}};VideoJS.player.extend({linksSupported:function(){return true},linksInit:function(){this.showLinksFallback();this.element=this.video},getLinksFallback:function(){return this.box.getElementsByTagName("P")[0]},hideLinksFallback:function(){if(this.linksFallback){this.linksFallback.style.display="none"}},showLinksFallback:function(){if(this.linksFallback){this.linksFallback.style.display="block"}}});VideoJS.merge=function(obj1,obj2,safe){for(var attrname in obj2){if(obj2.hasOwnProperty(attrname)&&(!safe||!obj1.hasOwnProperty(attrname))){obj1[attrname]=obj2[attrname]}}return obj1};VideoJS.extend=function(obj){this.merge(this,obj,true)};VideoJS.extend({setupAllWhenReady:function(options){VideoJS.options=options;VideoJS.DOMReady(VideoJS.setup)},DOMReady:function(fn){VideoJS.addToDOMReady(fn)},setup:function(videos,options){var returnSingular=false,playerList=[],videoElement;if(!videos||videos=="All"){videos=VideoJS.getVideoJSTags()}else if(typeof videos!='object'||videos.nodeType==1){videos=[videos];returnSingular=true}for(var i=0;i<videos.length;i++){if(typeof videos[i]=='string'){videoElement=document.getElementById(videos[i])}else{videoElement=videos[i]}playerList.push(new VideoJS(videoElement,options))}return(returnSingular)?playerList[0]:playerList},getVideoJSTags:function(){var videoTags=document.getElementsByTagName("video"),videoJSTags=[],videoTag;for(var i=0,j=videoTags.length;i<j;i++){videoTag=videoTags[i];if(videoTag.className.indexOf("video-js")!=-1){videoJSTags.push(videoTag)}}return videoJSTags},browserSupportsVideo:function(){if(typeof VideoJS.videoSupport!="undefined"){return VideoJS.videoSupport}VideoJS.videoSupport=!!document.createElement('video').canPlayType;return VideoJS.videoSupport},getFlashVersion:function(){if(typeof VideoJS.flashVersion!="undefined"){return VideoJS.flashVersion}var version=0,desc;if(typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]=="object"){desc=navigator.plugins["Shockwave Flash"].description;if(desc&&!(typeof navigator.mimeTypes!="undefined"&&navigator.mimeTypes["application/x-shockwave-flash"]&&!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)){version=parseInt(desc.match(/^.*\s+([^\s]+)\.[^\s]+\s+[^\s]+$/)[1],10)}}else if(typeof window.ActiveXObject!="undefined"){try{var testObject=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(testObject){version=parseInt(testObject.GetVariable("$version").match(/^[^\s]+\s(\d+)/)[1],10)}}catch(e){}}VideoJS.flashVersion=version;return VideoJS.flashVersion},isIE:function(){return!+"\v1"},isIPad:function(){return navigator.userAgent.match(/iPad/i)!==null},isIPhone:function(){return navigator.userAgent.match(/iPhone/i)!==null},isIOS:function(){return VideoJS.isIPhone()||VideoJS.isIPad()},iOSVersion:function(){var match=navigator.userAgent.match(/OS (\d+)_/i);if(match&&match[1]){return match[1]}},isAndroid:function(){return navigator.userAgent.match(/Android/i)!==null},androidVersion:function(){var match=navigator.userAgent.match(/Android (\d+)\./i);if(match&&match[1]){return match[1]}},warnings:{videoNotReady:"Video is not ready yet (try playing the video first).",localStorageFull:"Local Storage is Full"}});if(VideoJS.isIE()){document.createElement("video")}window.VideoJS=window._V_=VideoJS;VideoJS.player.extend({html5Supported:function(){if(VideoJS.browserSupportsVideo()&&this.canPlaySource()){return true}else{return false}},html5Init:function(){this.element=this.video;this.fixPreloading();this.supportProgressEvents();this.volume((localStorage&&localStorage.volume)||this.options.defaultVolume);if(VideoJS.isIOS()){this.options.useBuiltInControls=true;this.iOSInterface()}else if(VideoJS.isAndroid()){this.options.useBuiltInControls=true;this.androidInterface()}if(!this.options.useBuiltInControls){this.video.controls=false;if(this.options.controlsBelow){_V_.addClass(this.box,"vjs-controls-below")}this.activateElement(this.video,"playToggle");this.buildStylesCheckDiv();this.buildAndActivatePoster();this.buildBigPlayButton();this.buildAndActivateSpinner();this.buildAndActivateControlBar();this.loadInterface();this.getSubtitles()}},canPlaySource:function(){if(this.canPlaySourceResult){return this.canPlaySourceResult}var children=this.video.children;for(var i=0,j=children.length;i<j;i++){if(children[i].tagName.toUpperCase()=="SOURCE"){var canPlay=this.video.canPlayType(children[i].type)||this.canPlayExt(children[i].src);if(canPlay=="probably"||canPlay=="maybe"){this.firstPlayableSource=children[i];this.canPlaySourceResult=true;return true}}}this.canPlaySourceResult=false;return false},canPlayExt:function(src){if(!src){return""}var match=src.match(/\.([^\.]+)$/);if(match&&match[1]){var ext=match[1].toLowerCase();if(VideoJS.isAndroid()){if(ext=="mp4"||ext=="m4v"){return"maybe"}}else if(VideoJS.isIOS()){if(ext=="m3u8"){return"maybe"}}}return""},forceTheSource:function(){this.video.src=this.firstPlayableSource.src;this.video.load()},fixPreloading:function(){if(typeof this.video.hasAttribute=="function"&&this.video.hasAttribute("preload")&&this.video.preload!="none"){this.video.autobuffer=true}else{this.video.autobuffer=false;this.video.preload="none"}},supportProgressEvents:function(e){_V_.addListener(this.video,'progress',this.playerOnVideoProgress.context(this))},playerOnVideoProgress:function(event){this.setBufferedFromProgress(event)},setBufferedFromProgress:function(event){if(event.total>0){var newBufferEnd=(event.loaded/event.total)*this.duration();if(newBufferEnd>this.values.bufferEnd){this.values.bufferEnd=newBufferEnd}}},iOSInterface:function(){if(VideoJS.iOSVersion()<4){this.forceTheSource()}if(VideoJS.isIPad()){this.buildAndActivateSpinner()}},androidInterface:function(){this.forceTheSource();_V_.addListener(this.video,"click",function(){this.play()});this.buildBigPlayButton();_V_.addListener(this.bigPlayButton,"click",function(){this.play()}.context(this));this.positionBox();this.showBigPlayButtons()},loadInterface:function(){if(!this.stylesHaveLoaded()){if(!this.positionRetries){this.positionRetries=1}if(this.positionRetries++<100){setTimeout(this.loadInterface.context(this),10);return}}this.hideStylesCheckDiv();this.showPoster();if(this.video.paused!==false){this.showBigPlayButtons()}if(this.options.controlsAtStart){this.showControlBars()}this.positionAll()},buildAndActivateControlBar:function(){this.controls=_V_.createElement("div",{className:"vjs-controls"});this.box.appendChild(this.controls);this.activateElement(this.controls,"controlBar");this.activateElement(this.controls,"mouseOverVideoReporter");this.playControl=_V_.createElement("div",{className:"vjs-play-control",innerHTML:"<span></span>"});this.controls.appendChild(this.playControl);this.activateElement(this.playControl,"playToggle");this.progressControl=_V_.createElement("div",{className:"vjs-progress-control"});this.controls.appendChild(this.progressControl);this.progressHolder=_V_.createElement("div",{className:"vjs-progress-holder"});this.progressControl.appendChild(this.progressHolder);this.activateElement(this.progressHolder,"currentTimeScrubber");this.loadProgressBar=_V_.createElement("div",{className:"vjs-load-progress"});this.progressHolder.appendChild(this.loadProgressBar);this.activateElement(this.loadProgressBar,"loadProgressBar");this.playProgressBar=_V_.createElement("div",{className:"vjs-play-progress"});this.progressHolder.appendChild(this.playProgressBar);this.activateElement(this.playProgressBar,"playProgressBar");this.timeControl=_V_.createElement("div",{className:"vjs-time-control"});this.controls.appendChild(this.timeControl);this.currentTimeDisplay=_V_.createElement("span",{className:"vjs-current-time-display",innerHTML:"00:00"});this.timeControl.appendChild(this.currentTimeDisplay);this.activateElement(this.currentTimeDisplay,"currentTimeDisplay");this.timeSeparator=_V_.createElement("span",{innerHTML:" / "});this.timeControl.appendChild(this.timeSeparator);this.durationDisplay=_V_.createElement("span",{className:"vjs-duration-display",innerHTML:"00:00"});this.timeControl.appendChild(this.durationDisplay);this.activateElement(this.durationDisplay,"durationDisplay");this.volumeControl=_V_.createElement("div",{className:"vjs-volume-control",innerHTML:"<div><span></span><span></span><span></span><span></span><span></span><span></span></div>"});this.controls.appendChild(this.volumeControl);this.activateElement(this.volumeControl,"volumeScrubber");this.volumeDisplay=this.volumeControl.children[0];this.activateElement(this.volumeDisplay,"volumeDisplay");this.fullscreenControl=_V_.createElement("div",{className:"vjs-fullscreen-control",innerHTML:"<div><span></span><span></span><span></span><span></span></div>"});this.controls.appendChild(this.fullscreenControl);this.activateElement(this.fullscreenControl,"fullscreenToggle")},buildAndActivatePoster:function(){this.updatePosterSource();if(this.video.poster){this.poster=document.createElement("img");this.box.appendChild(this.poster);this.poster.src=this.video.poster;this.poster.className="vjs-poster";this.activateElement(this.poster,"poster")}else{this.poster=false}},buildBigPlayButton:function(){this.bigPlayButton=_V_.createElement("div",{className:"vjs-big-play-button",innerHTML:"<span></span>"});this.box.appendChild(this.bigPlayButton);this.activateElement(this.bigPlayButton,"bigPlayButton")},buildAndActivateSpinner:function(){this.spinner=_V_.createElement("div",{className:"vjs-spinner",innerHTML:"<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>"})},buildStylesCheckDiv:function(){this.stylesCheckDiv=_V_.createElement("div",{className:"vjs-styles-check"});this.stylesCheckDiv.style.position="absolute";this.box.appendChild(this.stylesCheckDiv)},hideStylesCheckDiv:function(){this.stylesCheckDiv.style.display="none"},stylesHaveLoaded:function(){if(this.stylesCheckDiv.offsetHeight!=5){return false}else{return true}},positionAll:function(){this.positionBox();this.positionControlBars();this.positionPoster()},positionBox:function(){if(this.videoIsFullScreen){this.box.style.width="";this.element.style.height="";if(this.options.controlsBelow){this.box.style.height="";this.element.style.height=(this.box.offsetHeight-this.controls.offsetHeight)+"px"}}else{this.box.style.width=this.width()+"px";this.element.style.height=this.height()+"px";if(this.options.controlsBelow){this.element.style.height=""}}},getSubtitles:function(){var tracks=this.video.getElementsByTagName("TRACK");for(var i=0,j=tracks.length;i<j;i++){if(tracks[i].getAttribute("kind")=="subtitles"&&tracks[i].getAttribute("src")){this.subtitlesSource=tracks[i].getAttribute("src");this.loadSubtitles();this.buildSubtitles()}}},loadSubtitles:function(){_V_.get(this.subtitlesSource,this.parseSubtitles.context(this))},parseSubtitles:function(subText){var lines=subText.split("\n"),line="",subtitle,time,text;this.subtitles=[];this.currentSubtitle=false;this.lastSubtitleIndex=0;for(var i=0;i<lines.length;i++){line=_V_.trim(lines[i]);if(line){subtitle={id:line,index:this.subtitles.length};line=_V_.trim(lines[++i]);time=line.split(" --> ");subtitle.start=this.parseSubtitleTime(time[0]);subtitle.end=this.parseSubtitleTime(time[1]);text=[];for(var j=i;j<lines.length;j++){line=_V_.trim(lines[++i]);if(!line){break}text.push(line)}subtitle.text=text.join('<br/>');this.subtitles.push(subtitle)}}},parseSubtitleTime:function(timeText){var parts=timeText.split(':'),time=0;time+=parseFloat(parts[0])*60*60;time+=parseFloat(parts[1])*60;var seconds=parts[2].split(/\.|,/);time+=parseFloat(seconds[0]);ms=parseFloat(seconds[1]);if(ms){time+=ms/1000}return time},buildSubtitles:function(){this.subtitlesDisplay=_V_.createElement("div",{className:'vjs-subtitles'});this.box.appendChild(this.subtitlesDisplay);this.activateElement(this.subtitlesDisplay,"subtitlesDisplay")},addVideoListener:function(type,fn){_V_.addListener(this.video,type,fn.rEvtContext(this))},play:function(){this.video.play();return this},onPlay:function(fn){this.addVideoListener("play",fn);return this},pause:function(){this.video.pause();return this},onPause:function(fn){this.addVideoListener("pause",fn);return this},paused:function(){return this.video.paused},currentTime:function(seconds){if(seconds!==undefined){try{this.video.currentTime=seconds}catch(e){this.warning(VideoJS.warnings.videoNotReady)}this.values.currentTime=seconds;return this}return this.video.currentTime},onCurrentTimeUpdate:function(fn){this.currentTimeListeners.push(fn)},duration:function(){return this.video.duration},buffered:function(){if(this.values.bufferStart===undefined){this.values.bufferStart=0;this.values.bufferEnd=0}if(this.video.buffered&&this.video.buffered.length>0){var newEnd=this.video.buffered.end(0);if(newEnd>this.values.bufferEnd){this.values.bufferEnd=newEnd}}return[this.values.bufferStart,this.values.bufferEnd]},volume:function(percentAsDecimal){if(percentAsDecimal!==undefined){this.values.volume=Math.max(0,Math.min(1,parseFloat(percentAsDecimal)));this.video.volume=this.values.volume;this.setLocalStorage("volume",this.values.volume);return this}if(this.values.volume){return this.values.volume}return this.video.volume},onVolumeChange:function(fn){_V_.addListener(this.video,'volumechange',fn.rEvtContext(this))},width:function(width){if(width!==undefined){this.video.width=width;this.box.style.width=width+"px";this.triggerResizeListeners();return this}return this.video.offsetWidth},height:function(height){if(height!==undefined){this.video.height=height;this.box.style.height=height+"px";this.triggerResizeListeners();return this}return this.video.offsetHeight},supportsFullScreen:function(){if(typeof this.video.webkitEnterFullScreen=='function'){if(!navigator.userAgent.match("Chrome")&&!navigator.userAgent.match("Mac OS X 10.5")){return true}}return false},html5EnterNativeFullScreen:function(){try{this.video.webkitEnterFullScreen()}catch(e){if(e.code==11){this.warning(VideoJS.warnings.videoNotReady)}}return this},enterFullScreen:function(){if(this.supportsFullScreen()){this.html5EnterNativeFullScreen()}else{this.enterFullWindow()}},exitFullScreen:function(){if(this.supportsFullScreen()){}else{this.exitFullWindow()}},enterFullWindow:function(){this.videoIsFullScreen=true;this.docOrigOverflow=document.documentElement.style.overflow;_V_.addListener(document,"keydown",this.fullscreenOnEscKey.rEvtContext(this));_V_.addListener(window,"resize",this.fullscreenOnWindowResize.rEvtContext(this));document.documentElement.style.overflow='hidden';_V_.addClass(this.box,"vjs-fullscreen");this.positionAll()},exitFullWindow:function(){this.videoIsFullScreen=false;document.removeEventListener("keydown",this.fullscreenOnEscKey,false);window.removeEventListener("resize",this.fullscreenOnWindowResize,false);document.documentElement.style.overflow=this.docOrigOverflow;_V_.removeClass(this.box,"vjs-fullscreen");this.positionAll()},onError:function(fn){this.addVideoListener("error",fn);return this},onEnded:function(fn){this.addVideoListener("ended",fn);return this}});VideoJS.player.newBehavior("player",function(player){this.onError(this.playerOnVideoError);this.onPlay(this.playerOnVideoPlay);this.onPlay(this.trackCurrentTime);this.onPause(this.playerOnVideoPause);this.onPause(this.stopTrackingCurrentTime);this.onEnded(this.playerOnVideoEnded);this.trackBuffered();this.onBufferedUpdate(this.isBufferFull)},{playerOnVideoError:function(event){this.log(event);this.log(this.video.error)},playerOnVideoPlay:function(event){this.hasPlayed=true},playerOnVideoPause:function(event){},playerOnVideoEnded:function(event){this.currentTime(0);this.pause()},trackBuffered:function(){this.bufferedInterval=setInterval(this.triggerBufferedListeners.context(this),500)},stopTrackingBuffered:function(){clearInterval(this.bufferedInterval)},bufferedListeners:[],onBufferedUpdate:function(fn){this.bufferedListeners.push(fn)},triggerBufferedListeners:function(){this.isBufferFull();this.each(this.bufferedListeners,function(listener){(listener.context(this))()})},isBufferFull:function(){if(this.bufferedPercent()==1){this.stopTrackingBuffered()}},trackCurrentTime:function(){if(this.currentTimeInterval){clearInterval(this.currentTimeInterval)}this.currentTimeInterval=setInterval(this.triggerCurrentTimeListeners.context(this),100);this.trackingCurrentTime=true},stopTrackingCurrentTime:function(){clearInterval(this.currentTimeInterval);this.trackingCurrentTime=false},currentTimeListeners:[],triggerCurrentTimeListeners:function(late,newTime){this.each(this.currentTimeListeners,function(listener){(listener.context(this))(newTime||this.currentTime())})},resizeListeners:[],onResize:function(fn){this.resizeListeners.push(fn)},triggerResizeListeners:function(){this.each(this.resizeListeners,function(listener){(listener.context(this))()})}});VideoJS.player.newBehavior("mouseOverVideoReporter",function(element){_V_.addListener(element,"mousemove",this.mouseOverVideoReporterOnMouseMove.context(this));_V_.addListener(element,"mouseout",this.mouseOverVideoReporterOnMouseOut.context(this))},{mouseOverVideoReporterOnMouseMove:function(){this.showControlBars();clearInterval(this.mouseMoveTimeout);this.mouseMoveTimeout=setTimeout(this.hideControlBars.context(this),4000)},mouseOverVideoReporterOnMouseOut:function(event){var parent=event.relatedTarget;while(parent&&parent!==this.box){parent=parent.parentNode}if(parent!==this.box){this.hideControlBars()}}});VideoJS.player.newBehavior("box",function(element){this.positionBox();_V_.addClass(element,"vjs-paused");this.activateElement(element,"mouseOverVideoReporter");this.onPlay(this.boxOnVideoPlay);this.onPause(this.boxOnVideoPause)},{boxOnVideoPlay:function(){_V_.removeClass(this.box,"vjs-paused");_V_.addClass(this.box,"vjs-playing")},boxOnVideoPause:function(){_V_.removeClass(this.box,"vjs-playing");_V_.addClass(this.box,"vjs-paused")}});VideoJS.player.newBehavior("poster",function(element){this.activateElement(element,"mouseOverVideoReporter");this.activateElement(element,"playButton");this.onPlay(this.hidePoster);this.onEnded(this.showPoster);this.onResize(this.positionPoster)},{showPoster:function(){if(!this.poster){return}this.poster.style.display="block";this.positionPoster()},positionPoster:function(){if(!this.poster||this.poster.style.display=='none'){return}this.poster.style.height=this.height()+"px";this.poster.style.width=this.width()+"px"},hidePoster:function(){if(!this.poster){return}this.poster.style.display="none"},updatePosterSource:function(){if(!this.video.poster){var images=this.video.getElementsByTagName("img");if(images.length>0){this.video.poster=images[0].src}}}});VideoJS.player.newBehavior("controlBar",function(element){if(!this.controlBars){this.controlBars=[];this.onResize(this.positionControlBars)}this.controlBars.push(element);_V_.addListener(element,"mousemove",this.onControlBarsMouseMove.context(this));_V_.addListener(element,"mouseout",this.onControlBarsMouseOut.context(this))},{showControlBars:function(){if(!this.options.controlsAtStart&&!this.hasPlayed){return}this.each(this.controlBars,function(bar){bar.style.display="block"})},positionControlBars:function(){this.updatePlayProgressBars();this.updateLoadProgressBars()},hideControlBars:function(){if(this.options.controlsHiding&&!this.mouseIsOverControls){this.each(this.controlBars,function(bar){bar.style.display="none"})}},onControlBarsMouseMove:function(){this.mouseIsOverControls=true},onControlBarsMouseOut:function(event){this.mouseIsOverControls=false}});VideoJS.player.newBehavior("playToggle",function(element){if(!this.elements.playToggles){this.elements.playToggles=[];this.onPlay(this.playTogglesOnPlay);this.onPause(this.playTogglesOnPause)}this.elements.playToggles.push(element);_V_.addListener(element,"click",this.onPlayToggleClick.context(this))},{onPlayToggleClick:function(event){if(this.paused()){this.play()}else{this.pause()}},playTogglesOnPlay:function(event){this.each(this.elements.playToggles,function(toggle){_V_.removeClass(toggle,"vjs-paused");_V_.addClass(toggle,"vjs-playing")})},playTogglesOnPause:function(event){this.each(this.elements.playToggles,function(toggle){_V_.removeClass(toggle,"vjs-playing");_V_.addClass(toggle,"vjs-paused")})}});VideoJS.player.newBehavior("playButton",function(element){_V_.addListener(element,"click",this.onPlayButtonClick.context(this))},{onPlayButtonClick:function(event){this.play()}});VideoJS.player.newBehavior("pauseButton",function(element){_V_.addListener(element,"click",this.onPauseButtonClick.context(this))},{onPauseButtonClick:function(event){this.pause()}});VideoJS.player.newBehavior("playProgressBar",function(element){if(!this.playProgressBars){this.playProgressBars=[];this.onCurrentTimeUpdate(this.updatePlayProgressBars)}this.playProgressBars.push(element)},{updatePlayProgressBars:function(newTime){var progress=(newTime!==undefined)?newTime/this.duration():this.currentTime()/this.duration();if(isNaN(progress)){progress=0}this.each(this.playProgressBars,function(bar){if(bar.style){bar.style.width=_V_.round(progress*100,2)+"%"}})}});VideoJS.player.newBehavior("loadProgressBar",function(element){if(!this.loadProgressBars){this.loadProgressBars=[]}this.loadProgressBars.push(element);this.onBufferedUpdate(this.updateLoadProgressBars)},{updateLoadProgressBars:function(){this.each(this.loadProgressBars,function(bar){if(bar.style){bar.style.width=_V_.round(this.bufferedPercent()*100,2)+"%"}})}});VideoJS.player.newBehavior("currentTimeDisplay",function(element){if(!this.currentTimeDisplays){this.currentTimeDisplays=[];this.onCurrentTimeUpdate(this.updateCurrentTimeDisplays)}this.currentTimeDisplays.push(element)},{updateCurrentTimeDisplays:function(newTime){if(!this.currentTimeDisplays){return}var time=(newTime)?newTime:this.currentTime();this.each(this.currentTimeDisplays,function(dis){dis.innerHTML=_V_.formatTime(time)})}});VideoJS.player.newBehavior("durationDisplay",function(element){if(!this.durationDisplays){this.durationDisplays=[];this.onCurrentTimeUpdate(this.updateDurationDisplays)}this.durationDisplays.push(element)},{updateDurationDisplays:function(){if(!this.durationDisplays){return}this.each(this.durationDisplays,function(dis){if(this.duration()){dis.innerHTML=_V_.formatTime(this.duration())}})}});VideoJS.player.newBehavior("currentTimeScrubber",function(element){_V_.addListener(element,"mousedown",this.onCurrentTimeScrubberMouseDown.rEvtContext(this))},{onCurrentTimeScrubberMouseDown:function(event,scrubber){event.preventDefault();this.currentScrubber=scrubber;this.stopTrackingCurrentTime();this.videoWasPlaying=!this.paused();this.pause();_V_.blockTextSelection();this.setCurrentTimeWithScrubber(event);_V_.addListener(document,"mousemove",this.onCurrentTimeScrubberMouseMove.rEvtContext(this));_V_.addListener(document,"mouseup",this.onCurrentTimeScrubberMouseUp.rEvtContext(this))},onCurrentTimeScrubberMouseMove:function(event){this.setCurrentTimeWithScrubber(event)},onCurrentTimeScrubberMouseUp:function(event){_V_.unblockTextSelection();document.removeEventListener("mousemove",this.onCurrentTimeScrubberMouseMove,false);document.removeEventListener("mouseup",this.onCurrentTimeScrubberMouseUp,false);if(this.videoWasPlaying){this.play();this.trackCurrentTime()}},setCurrentTimeWithScrubber:function(event){var newProgress=_V_.getRelativePosition(event.pageX,this.currentScrubber);var newTime=newProgress*this.duration();this.triggerCurrentTimeListeners(0,newTime);if(newTime==this.duration()){newTime=newTime-0.1}this.currentTime(newTime)}});VideoJS.player.newBehavior("volumeDisplay",function(element){if(!this.volumeDisplays){this.volumeDisplays=[];this.onVolumeChange(this.updateVolumeDisplays)}this.volumeDisplays.push(element);this.updateVolumeDisplay(element)},{updateVolumeDisplays:function(){if(!this.volumeDisplays){return}this.each(this.volumeDisplays,function(dis){this.updateVolumeDisplay(dis)})},updateVolumeDisplay:function(display){var volNum=Math.ceil(this.volume()*6);this.each(display.children,function(child,num){if(num<volNum){_V_.addClass(child,"vjs-volume-level-on")}else{_V_.removeClass(child,"vjs-volume-level-on")}})}});VideoJS.player.newBehavior("volumeScrubber",function(element){_V_.addListener(element,"mousedown",this.onVolumeScrubberMouseDown.rEvtContext(this))},{onVolumeScrubberMouseDown:function(event,scrubber){_V_.blockTextSelection();this.currentScrubber=scrubber;this.setVolumeWithScrubber(event);_V_.addListener(document,"mousemove",this.onVolumeScrubberMouseMove.rEvtContext(this));_V_.addListener(document,"mouseup",this.onVolumeScrubberMouseUp.rEvtContext(this))},onVolumeScrubberMouseMove:function(event){this.setVolumeWithScrubber(event)},onVolumeScrubberMouseUp:function(event){this.setVolumeWithScrubber(event);_V_.unblockTextSelection();document.removeEventListener("mousemove",this.onVolumeScrubberMouseMove,false);document.removeEventListener("mouseup",this.onVolumeScrubberMouseUp,false)},setVolumeWithScrubber:function(event){var newVol=_V_.getRelativePosition(event.pageX,this.currentScrubber);this.volume(newVol)}});VideoJS.player.newBehavior("fullscreenToggle",function(element){_V_.addListener(element,"click",this.onFullscreenToggleClick.context(this))},{onFullscreenToggleClick:function(event){if(!this.videoIsFullScreen){this.enterFullScreen()}else{this.exitFullScreen()}},fullscreenOnWindowResize:function(event){this.positionControlBars()},fullscreenOnEscKey:function(event){if(event.keyCode==27){this.exitFullScreen()}}});VideoJS.player.newBehavior("bigPlayButton",function(element){if(!this.elements.bigPlayButtons){this.elements.bigPlayButtons=[];this.onPlay(this.bigPlayButtonsOnPlay);this.onEnded(this.bigPlayButtonsOnEnded)}this.elements.bigPlayButtons.push(element);this.activateElement(element,"playButton")},{bigPlayButtonsOnPlay:function(event){this.hideBigPlayButtons()},bigPlayButtonsOnEnded:function(event){this.showBigPlayButtons()},showBigPlayButtons:function(){this.each(this.elements.bigPlayButtons,function(element){element.style.display="block"})},hideBigPlayButtons:function(){this.each(this.elements.bigPlayButtons,function(element){element.style.display="none"})}});VideoJS.player.newBehavior("spinner",function(element){if(!this.spinners){this.spinners=[];_V_.addListener(this.video,"loadeddata",this.spinnersOnVideoLoadedData.context(this));_V_.addListener(this.video,"loadstart",this.spinnersOnVideoLoadStart.context(this));_V_.addListener(this.video,"seeking",this.spinnersOnVideoSeeking.context(this));_V_.addListener(this.video,"seeked",this.spinnersOnVideoSeeked.context(this));_V_.addListener(this.video,"canplay",this.spinnersOnVideoCanPlay.context(this));_V_.addListener(this.video,"canplaythrough",this.spinnersOnVideoCanPlayThrough.context(this));_V_.addListener(this.video,"waiting",this.spinnersOnVideoWaiting.context(this));_V_.addListener(this.video,"stalled",this.spinnersOnVideoStalled.context(this));_V_.addListener(this.video,"suspend",this.spinnersOnVideoSuspend.context(this));_V_.addListener(this.video,"playing",this.spinnersOnVideoPlaying.context(this));_V_.addListener(this.video,"timeupdate",this.spinnersOnVideoTimeUpdate.context(this))}this.spinners.push(element)},{showSpinners:function(){this.each(this.spinners,function(spinner){spinner.style.display="block"});clearInterval(this.spinnerInterval);this.spinnerInterval=setInterval(this.rotateSpinners.context(this),100)},hideSpinners:function(){this.each(this.spinners,function(spinner){spinner.style.display="none"});clearInterval(this.spinnerInterval)},spinnersRotated:0,rotateSpinners:function(){this.each(this.spinners,function(spinner){spinner.style.WebkitTransform='scale(0.5) rotate('+this.spinnersRotated+'deg)';spinner.style.MozTransform='scale(0.5) rotate('+this.spinnersRotated+'deg)'});if(this.spinnersRotated==360){this.spinnersRotated=0}this.spinnersRotated+=45},spinnersOnVideoLoadedData:function(event){this.hideSpinners()},spinnersOnVideoLoadStart:function(event){this.showSpinners()},spinnersOnVideoSeeking:function(event){},spinnersOnVideoSeeked:function(event){},spinnersOnVideoCanPlay:function(event){},spinnersOnVideoCanPlayThrough:function(event){this.hideSpinners()},spinnersOnVideoWaiting:function(event){this.showSpinners()},spinnersOnVideoStalled:function(event){},spinnersOnVideoSuspend:function(event){},spinnersOnVideoPlaying:function(event){this.hideSpinners()},spinnersOnVideoTimeUpdate:function(event){if(this.spinner.style.display=="block"){this.hideSpinners()}}});VideoJS.player.newBehavior("subtitlesDisplay",function(element){if(!this.subtitleDisplays){this.subtitleDisplays=[];this.onCurrentTimeUpdate(this.subtitleDisplaysOnVideoTimeUpdate);this.onEnded(function(){this.lastSubtitleIndex=0}.context(this))}this.subtitleDisplays.push(element)},{subtitleDisplaysOnVideoTimeUpdate:function(time){if(this.subtitles){if(!this.currentSubtitle||this.currentSubtitle.start>=time||this.currentSubtitle.end<time){var newSubIndex=false,reverse=(this.subtitles[this.lastSubtitleIndex].start>time),i=this.lastSubtitleIndex-(reverse)?1:0;while(true){if(reverse){if(i<0||this.subtitles[i].end<time){break}if(this.subtitles[i].start<time){newSubIndex=i;break}i--}else{if(i>=this.subtitles.length||this.subtitles[i].start>time){break}if(this.subtitles[i].end>time){newSubIndex=i;break}i++}}if(newSubIndex!==false){this.currentSubtitle=this.subtitles[newSubIndex];this.lastSubtitleIndex=newSubIndex;this.updateSubtitleDisplays(this.currentSubtitle.text)}else if(this.currentSubtitle){this.currentSubtitle=false;this.updateSubtitleDisplays("")}}}},updateSubtitleDisplays:function(val){this.each(this.subtitleDisplays,function(disp){disp.innerHTML=val})}});VideoJS.extend({addClass:function(element,classToAdd){if((" "+element.className+" ").indexOf(" "+classToAdd+" ")==-1){element.className=element.className===""?classToAdd:element.className+" "+classToAdd}},removeClass:function(element,classToRemove){if(element.className.indexOf(classToRemove)==-1){return}var classNames=element.className.split(/\s+/);classNames.splice(classNames.lastIndexOf(classToRemove),1);element.className=classNames.join(" ")},createElement:function(tagName,attributes){return this.merge(document.createElement(tagName),attributes)},blockTextSelection:function(){document.body.focus();document.onselectstart=function(){return false}},unblockTextSelection:function(){document.onselectstart=function(){return true}},formatTime:function(secs){var seconds=Math.round(secs);var minutes=Math.floor(seconds/60);minutes=(minutes>=10)?minutes:"0"+minutes;seconds=Math.floor(seconds%60);seconds=(seconds>=10)?seconds:"0"+seconds;return minutes+":"+seconds},getRelativePosition:function(x,relativeElement){return Math.max(0,Math.min(1,(x-this.findPosX(relativeElement))/relativeElement.offsetWidth))},findPosX:function(obj){var curleft=obj.offsetLeft;while(obj=obj.offsetParent){curleft+=obj.offsetLeft}return curleft},getComputedStyleValue:function(element,style){return window.getComputedStyle(element,null).getPropertyValue(style)},round:function(num,dec){if(!dec){dec=0}return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec)},addListener:function(element,type,handler){if(element.addEventListener){element.addEventListener(type,handler,false)}else if(element.attachEvent){element.attachEvent("on"+type,handler)}},removeListener:function(element,type,handler){if(element.removeEventListener){element.removeEventListener(type,handler,false)}else if(element.attachEvent){element.detachEvent("on"+type,handler)}},get:function(url,onSuccess){if(typeof XMLHttpRequest=="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(f){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(g){}throw new Error("This browser does not support XMLHttpRequest.")}}var request=new XMLHttpRequest();request.open("GET",url);request.onreadystatechange=function(){if(request.readyState==4&&request.status==200){onSuccess(request.responseText)}}.context(this);request.send()},trim:function(string){return string.toString().replace(/^\s+/,"").replace(/\s+$/,"")},bindDOMReady:function(){if(document.readyState==="complete"){return VideoJS.onDOMReady()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",VideoJS.DOMContentLoaded,false);window.addEventListener("load",VideoJS.onDOMReady,false)}else if(document.attachEvent){document.attachEvent("onreadystatechange",VideoJS.DOMContentLoaded);window.attachEvent("onload",VideoJS.onDOMReady)}},DOMContentLoaded:function(){if(document.addEventListener){document.removeEventListener("DOMContentLoaded",VideoJS.DOMContentLoaded,false);VideoJS.onDOMReady()}else if(document.attachEvent){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",VideoJS.DOMContentLoaded);VideoJS.onDOMReady()}}},DOMReadyList:[],addToDOMReady:function(fn){if(VideoJS.DOMIsReady){fn.call(document)}else{VideoJS.DOMReadyList.push(fn)}},DOMIsReady:false,onDOMReady:function(){if(VideoJS.DOMIsReady){return}if(!document.body){return setTimeout(VideoJS.onDOMReady,13)}VideoJS.DOMIsReady=true;if(VideoJS.DOMReadyList){for(var i=0;i<VideoJS.DOMReadyList.length;i++){VideoJS.DOMReadyList[i].call(document)}VideoJS.DOMReadyList=null}}});VideoJS.bindDOMReady();Function.prototype.context=function(obj){var method=this,temp=function(){return method.apply(obj,arguments)};return temp};Function.prototype.evtContext=function(obj){var method=this,temp=function(){var origContext=this;return method.call(obj,arguments[0],origContext)};return temp};Function.prototype.rEvtContext=function(obj,funcParent){if(this.hasContext===true){return this}if(!funcParent){funcParent=obj}for(var attrname in funcParent){if(funcParent[attrname]==this){funcParent[attrname]=this.evtContext(obj);funcParent[attrname].hasContext=true;return funcParent[attrname]}}return this.evtContext(obj)};if(window.jQuery){(function($){$.fn.VideoJS=function(options){this.each(function(){VideoJS.setup(this,options)});return this};$.fn.player=function(){return this[0].player}})(jQuery)}window.VideoJS=window._V_=VideoJS})(window);

/* ***************************** */
/*LOAD THE FLOWPLAYER*/
/* ***************************** */

(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.4";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){w.setPlaylist([H]);return w},getIndex:function(){return p},_swfHeight:function(){return v.clientHeight}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=w._swfHeight();m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;t.playerId=E;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var I=0;m(t.playlist,function(){var K=this;if(typeof K=="object"&&K.length){K={url:""+K}}m(t.clip,function(L,M){if(M!==undefined&&K[L]===undefined&&typeof M!="function"){K[L]=M}});t.playlist[I]=K;K=new h(K,I,w);F.push(K);I++});m(t,function(K,L){if(typeof L=="function"){if(s[K]){s[K](L)}else{j(x,K,L)}delete t[K]}});m(t.plugins,function(K,L){if(L){y[K]=new l(K,L,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function J(L){var K=w.hasiPadSupport&&w.hasiPadSupport();if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(F[0].url)&&!K){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(L)}function H(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",J,false)}else{if(q.attachEvent){q.attachEvent("onclick",J)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(H,0)}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}q=z;B()}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var m,f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(o){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=m&&m.GetVariable("$version")}catch(n){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");f=m&&m.GetVariable("$version")}catch(l){}}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.4"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();

