/*
 DMXzone Video Player
 version 1.0.1
 Author: George Petrov
 Copyright (c) 2011 DMXzone
*/
(function(g){var i={plugins:["Startbutton","Controlbar","Bufferingicon"],width:570,height:320,controls:true};g.fn.dmxHTML5VideoPlayer=function(e){function h(b,a){var c=a.getItemConfig("title",a.getItemIdx());c||(c="");return b.replace(/##index##/g,a.getItemIdx()).replace(/##nr##/g,a.getItemIdx()+1).replace(/##title##/g,c.replace(/'/g,"\\'").replace(/"/g,'\\"'.replace(/([\n\r\t])/g,"\\$1"))).replace(/##time##/g,m(a.getPosition())).replace(/##remaining##/g,m(a.getDuration()-a.getPosition())).replace(/##duration##/g,
m(a.getDuration())).replace(/##position##/g,p(a.getPosition(),a.getDuration())).replace(/##volume##/g,a.getVolume())}function p(b,a){return Math.round(100*b/a)||0}function m(b){var a={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""},c=new Date(b),j=c.getUTCHours();b=c.getUTCMinutes();c=c.getUTCSeconds();j=a.padHour&&j<10?"0"+j:j;b=a.padMin&&b<10?"0"+b:b;c=a.padSec&&c<10?"0"+c:c;return(a.showHour?j+a.sepHour:"")+(a.showMin?b+a.sepMin:
"")+(a.showSec?c+a.sepSec:"")}function q(){var b=jQuery('script[src*="ScriptLibrary/dmxHTML5VideoPlayer.js"]');if(b.length>0){b=b.eq(0).attr("src");var a=b.indexOf("dmxHTML5VideoPlayer.js");if(a!=-1)return b.substring(0,a)}return""}function o(b){b=String(b);b=jQuery('<a href="'+b+'" />');b=String(b[0].href);return String(b)}var k=/chrome/.test(navigator.userAgent.toLowerCase()),l=q(),d=l+"jarisplayer.swf";e=g.extend(i,e,{playerFlashMP4:d,playerFlashMP3:d,defaultPoster:l+"html5_video_player_poster_nobutton.jpg"});
o(l);for(var n=0;n<e.playlist.length;n++){d=e.playlist[n];for(var f=0;f<3;f++)if(d[f]&&d[f].src)d[f].src=o(d[f].src);if(d[0]&&d[0].src&&d[0].src.search(/\/vid\.ly\//)!=-1)if((f=d[0].src.replace(/\/$/,"").match(/\/vid\.ly\/(\w+)/))&&f.length>0){f=f[1];d[0]={src:"http://vidly.s3.amazonaws.com/"+f+"/mp4.mp4",type:"video/mp4"};d[1]={src:"http://vidly.s3.amazonaws.com/"+f+"/webm.webm",type:"video/webm"};d[2]={src:"http://vidly.s3.amazonaws.com/"+f+"/ogv.ogv",type:"video/ogg"}}if(k&&d[0]&&d[1]){f=d[1];
d[1]=d[0];d[0]=f}}if(e.volume&&e.volume>0)e.volume/=100;if(!e.poster)e.poster=l+"html5_video_player_poster_nobutton.jpg";e.currentItemPlaying=-1;playerModelYOUTUBE_MOBILE_APPLE=playerModelYOUTUBE_MOBILE_APPLE_DMX;k=projekktor(this.selector,e);g(this.selector).attr("id");k.addListener("state",function(b,a){if(a&&a.config){var c=document.getElementById(a._id);switch(b){case "PLAYING":a.config.currentItemPlaying==-1&&a._bubbleEvent("item",a.getItemIdx());a.config.currentItemPlaying=a.getItemIdx();if(a.config.onPlay)typeof a.config.onPlay==
"string"?(new Function(h(a.config.onPlay,a))).call(c):a.config.onPlay.call(a);break;case "PAUSED":if(a.config.onPause)typeof a.config.onPause=="string"?(new Function(h(a.config.onPause,a))).call(c):a.config.onPause.call(a);break;case "IDLE":if(a.config.onStop)typeof a.config.onStop=="string"?(new Function(h(a.config.onStop,a))).call(c):a.config.onStop.call(a);break}}});e.onUpdate&&k.addListener("time",function(b,a){if(a&&a.config){b=document.getElementById(a._id);if(a.config.onUpdate)typeof a.config.onUpdate==
"string"?(new Function(h(a.config.onUpdate,a))).call(b):a.config.onUpdate.call(a)}});if(e.onChange||e.onNext||e.onPrevious)k.addListener("item",function(b,a){if(a&&a.config){var c=document.getElementById(a._id);if(a.config.onChange)typeof a.config.onChange=="string"?(new Function(h(a.config.onChange,a))).call(c):a.config.onChange.call(a);if(a.config.onNext)if(a.config.currentItemPlaying!=null&&b>a.config.currentItemPlaying)typeof a.config.onNext=="string"?(new Function(h(a.config.onNext,a))).call(c):
a.config.onNext.call(a);if(a.config.onPrevious)if(a.config.currentItemPlaying!=null&&b<a.config.currentItemPlaying)typeof a.config.onPrevious=="string"?(new Function(h(a.config.onPrevious,a))).call(c):a.config.onPrevious.call(a)}});return this}})(jQuery);var playerModelYOUTUBE_MOBILE_APPLE_DMX=function(){};
jQuery(function(){playerModelYOUTUBE_MOBILE_APPLE_DMX.prototype={displayItem:function(g){if(this.elementReady!==true){this.applyMedia(this.controller.getMediaContainer().html(""));this.elementReady=true;this.waitTillReady(g)}},applyMedia:function(g){var i=this.media.file.replace(/^[^v]+v.(.{11}).*/,"$1");i='<iframe title="YouTube video player" scrolling="no" width="'+g.width()+'" height="'+g.height()+'" src="http://www.youtube.com/embed/'+i+'?controls=0" frameborder="0" allowfullscreen></iframe>';
g.html(i);this.elementReady=true},setFullscreen:function(){},_scaleVideo:function(){}}});

