
/* - jquery.primacontrolflowplayer.min.js - */
// http://www.pienelleparasta.fi/portal_javascripts/jquery.primacontrolflowplayer.min.js?original=1
(function(e){var d,f,c,g,a,b={};a=function(h){var i;if(b.seekto){i=b.seekto}else{e.each(h.attr("class").split(/\s/),function(j,k){if(k.indexOf("seekto_")===0){i=k.substring(7);return false}})}i=parseInt(i,10);if(isNaN(i)||i<1){i=0}return i};d=function(){this.name="YouTube"};d.prototype.accepts=function(h){return(/www.youtube.com/).test(h)};d.prototype.embed=function(i,k){var j=i.attr("href").match(/(?:[\\?&]v=([^&#]*))|(?:\/v\/([^&#]*))/i),l=j[1]||j[2],h,m=a(i);if(l!==null){h="http://www.youtube.com/v/"+l;if(i.hasClass("autoplay")){h=h+"&autoplay=1"}if(m>0){h=h+"&start="+m}i.flashembed(e.extend({},k.flashembed,{src:h}))}};f=function(h){this.name="GoogleVideo";this.parameters=e.extend({fs:"true",hl:"fi"},h||{})};f.prototype.accepts=function(h){return(/video.google.com/).test(h)};f.prototype.embed=function(i,j){var m=i.attr("href").match(/docid=([\-0-9]+)/i)[1],l=e.extend({},this.parameters),h,k=a(i);if(m){l.docId=m;if(i.hasClass("autoplay")){l.autoPlay="true"}if(k>0){l.initialTime=k}h="http://video.google.com/googleplayer.swf?"+e.param(l);i.flashembed(e.extend({},j.flashembed,{src:h}))}};c=function(h){this.name="Vimeo";this.parameters=e.extend({server:"vimeo.com",show_title:1,show_byline:1,show_portrait:0,fullscreen:1},h||{})};c.prototype.accepts=function(h){return(/vimeo.com/).test(h)};c.prototype.embed=function(i,k){var j=i.attr("href").match(/(?:vimeo.com\/([0-9]+))|(?:clip_id=([0-9]+))/i),m=j[1]||j[2],l=e.extend({},this.parameters),h;if(m){l.clip_id=m;if(i.hasClass("autoplay")){l.autoplay=1}h="http://vimeo.com/moogaloop.swf?"+e.param(l);i.flashembed(e.extend({},k.flashembed,{src:h}))}};g=function(){this.name="FlowPlayer"};g.prototype.accepts=function(h){return true};g.prototype.embed=function(h,l){var k=h.attr("href"),m=e.extend({},l.flashembed,{src:this.flowplayerUrl(l)}),j,i,o,n;if(h.hasClass("flowplayerCustomConfig")){e.getJSON(this.relativeUrl("/@@flowplayer-config.js"),{url:k,width:h.width(),height:h.height()},function(p){h.width(p.player_dimensions.width).height(p.player_dimensions.height);h.flowplayer(p.player||m,e.extend({key:l.flowplayer_key},p.clips))})}else{j={key:l.flowplayer_key,plugins:{controls:{url:this.resourceUrl(l,"flowplayer.controls-3.2.5.swf"),autoHide:h.hasClass("hidecontrols")?"always":"never",stop:h.hasClass("stopbutton")}},clip:{autoPlay:h.hasClass("autoplay"),autoBuffering:h.hasClass("autobuffer"),live:h.hasClass("live")}};if(h.hasClass("fit")){j.clip.scaling="fit"}n=parseInt(h.height(),10);if(!h.hasClass("hidecontrols")){j.screen={height:n,top:0};h.height(n+24)}if(this.hasExtension(k,[".mp3"])){j.plugins.controls.fullscreen=false;j.plugins.controls.height=30;j.plugins.controls.audio={url:this.resourceUrl(l,"flowplayer.audio-3.2.2.swf")};h.height(j.plugins.controls.height)}if(this.isRTMP(k)){j.clip.provider="rtmp";j.plugins.rtmp={url:this.resourceUrl(l,"flowplayer.rtmp-3.2.3.swf")};o=a(h);if(o>0){j.clip.onStart=function(p){if(!h.data("primacontrol.flowplayer.seek")){h.data("primacontrol.flowplayer.seek",true);this.seek(o)}}}i=this.parseRTMPUrl(k);if(this.isAkamai(k)&&i.video!==null){j.clip.url=i.url+"/"+i.video}else{if(this.hasExtension(i.video,[".mp4",".mp3",".f4v"])){i.video=this.mediaPrefix(i.video)}if(this.hasExtension(i.video,[".flv",".mp3"])){i.video=i.video.substring(0,i.video.lastIndexOf("."))}j.clip.url=i.video;j.plugins.rtmp.netConnectionUrl=i.url}}if(this.isAkamai(k)){j.plugins.akamai={url:this.resourceUrl(l,"flowplayer.akamai-3.2.0.swf")}}h.flowplayer(m,j)}};g.prototype.hasExtension=function(h,j){var k=false,i;h=e.trim(h);e.each(j,function(l,m){i=h.match(m+"$");if(i&&i[0]===m){k=true;return false}});return k};g.prototype.mediaPrefix=function(h){var i=h.substring(h.lastIndexOf(".")+1,h.length).toLowerCase();if(i==="f4v"){i="mp4"}return i+":"+h};g.prototype.isAkamai=function(h){return(/\.edgefcs\.net/).test(h)};g.prototype.isRTMP=function(h){return(/^rtmp(.?):\/\//).test(h)};g.prototype.parseRTMPUrl=function(h){var i=h.lastIndexOf(":");if(i>5){return{url:h.substring(0,i),video:h.substring(i+1,h.length)}}else{return{url:h,video:null}}};g.prototype.resourceUrl=function(h,i){return h.portal_url+"/"+i};g.prototype.flowplayerUrl=function(h){return this.resourceUrl(h,e.trim(h.flowplayer_key).length>0?"flowplayer.commercial-3.2.7.swf":"flowplayer-3.2.7.swf")};g.prototype.relativeUrl=function(i){var h=window.location.href.substring(0,window.location.href.length-window.location.search.length);if(h[h.length-1]==="/"){h=h.substring(0,h.length-1)}return h+i};e.fn.extend({primacontrolflowplayer:function(j){var i=e.extend({},e.fn.primacontrolflowplayer.defaults,j||{}),h=false;if(e.url){e.extend(b,{autoplay:!!e.url.param("autoplay"),seekto:e.url.param("seekto")})}h=e.grep(this,function(l,k){return b.autoplay||e(l).hasClass("autoplay")}).length>1;return e(this).each(function(){var k=e(this);e.each(e.fn.primacontrolflowplayer.providers,function(l,m){if(m.accepts(k.attr("href"))){k.addClass("flowplayerdefault").css({display:"block"});if(b.autoplay){k.addClass("autoplay")}if(h){k.removeClass("autoplay")}if(k.children("img").length===0){k.empty()}else{k.prepend(e('<img class="playbutton" />').attr({src:i.portal_url+"/play_large.png"})).addClass("autoplay")}k.click(function(n){n.preventDefault()});m.embed(k,i);return false}})})}});e.fn.primacontrolflowplayer.provider_factory={YouTubeProvider:d,GoogleVideoProvider:f,VimeoProvider:c,FlowPlayerProvider:g};e.fn.primacontrolflowplayer.providers=[new d(),new f(),new c(),new g()];e.fn.primacontrolflowplayer.defaults={flashembed:{version:[9,115],allowfullscreen:"true",allowscriptaccess:"always",wmode:"opaque"},flowplayer_key:"",portal_url:""}}(jQuery));

