if(typeof jQuery=="undefined"){throw"Gypsy Player requires jQuery!"}$GP={debug:false,players:[],error:function(a){if(typeof console!="undefined"){console.log(a)}else{if(this.debug){alert(a)}}throw ("Gypsy")},trace:function(c,b){if(this.debug&&typeof console!="undefined"){console.log(c,b||"")}},events:{},registerPlayer:function(a){a.enabled=a._detect();this.players.push(a)},unregisterPlayer:function(b){var a=this.players.length;while(a--){if(this.players[a]&&this.players[a].name==b){delete this.players[a]}}},getStreamType:function(b){var c=b.indexOf("?"),b=(c>-1)?b.substring(0,c):b,a=/.+\.([^.]+)$/.exec(b)||[];return a[1]||"unknown"},url:{silverlight:"digomePlayer/digomePlayer.xap",flash:"digomePlayer/digomePlayer.swf"},IE:(jQuery.browser.msie),_detect:function(f,d){if(navigator.plugins&&navigator.plugins.length){for(var b=0,a=navigator.plugins.length;b<a;++b){if(navigator.plugins[b].name.indexOf(f)>-1){return true}}}else{try{return Boolean(new ActiveXObject(d))}catch(c){}}return false},nextID:function(){var a="gp_"+this.i++;this.ID=a;return a},ID:null,i:0,getGypsy:function(a){a=a||this.ID;return $("#"+a)[0].gypsy},readyPlayers:function(){if(!$GP.readyPlayersInterval){return $GP.readyPlayersInterval=setInterval($GP.readyPlayers,300)}if($GP.readyPlayersStack.length){$.each($GP.readyPlayersStack,function(b,a){var f=$("#"+a+":visible");if(!f.length){return}var d=f[0],g=$("embed",f)[0],c=f[0].gypsy;if(c.plugin._isReady.apply(d)){c.runtime=d}else{if(c.plugin._isReady.apply(g)){c.runtime=g}else{return}}if($.isFunction(c.plugin.onStart)){c.plugin.onStart.call(c.runtime,c)}$GP.events.onReady.call(c.runtime,c);c.config.onReady.call(c.runtime,c);if(c.config.autoPlay){c.cmd("play")}$GP.readyPlayersStack.splice(b,1)})}else{clearInterval($GP.readyPlayersInterval);$GP.readyPlayersInterval=0}},readyPlayersStack:[],readyPlayersInterval:0};(function(b){b.fn.gypsy=function(d){return this.each(function(){var f=b.extend({width:"720",height:"480",onReady:function(i){},autoPlay:false,playerParams:{},url:b(this).attr("src")||b(this).attr("href")||"",forceExtension:false},d),h=(f.forceExtension)?f.forceExtension:$GP.getStreamType(f.url);var g=false,e="";b.each($GP.players,function(j,l){if(b.inArray(h.toLowerCase(),l.ext)>-1){if(!g||(!g.enabled&&l.enabled)||l.priority>g.priority){g=l}e+='&nbsp; * <a href="'+l.url+'">'+l.name+"</a> <br />"}});if(g.enabled){return a(this,g,f)}e=(e!="")?"Your browser does not support viewing ."+h+" files. <br /> Please install one of the following to play these files &raquo; <br />"+e:"Unsupported Video Type ("+h+")";$GP.ID=false})};function a(l,n,f){var m=$GP.nextID();if(n._beforeEmbed){n._beforeEmbed()}var d={width:f.width,height:f.height},g=b.extend({},n._params,f.playerParams),j="";n.setStream.call(g,f.url);for(var o in g){j+=c({name:"param",attr:{name:o,value:g[o]}})}var h=c({name:"object",attr:b.extend({id:m},n._obj,d),child:[j,($GP.IE||!n._embed)?{}:{name:"embed",attr:b.extend({name:m},n._embed,d,g)}]});var i={ID:m,plugin:n,config:f,runtime:false,cmd:function(){var e=b.makeArray(arguments),s=e.shift();$GP.trace("cmd: "+s,e);if(!this.runtime){return false}try{if(b.isFunction($GP.events["before"+s])){if(!$GP.events["before"+s].apply(this.runtime,e)){return false}}var r=this.plugin.API[s],q=(b.isFunction(r))?r.apply(this.runtime,e):this.runtime[r]();return(b.isFunction($GP.events["after"+s]))?$GP.events["after"+s].apply(this.runtime,e):q}catch(p){$GP.error('error executing "'+s+'" -> '+p)}}};if($GP.IE){b(l)[0].innerHTML=h}else{b(l).html(h)}b("#"+m)[0].gypsy=i;if(n._afterEmbed){n._afterEmbed()}$GP.readyPlayersStack.push(m);$GP.readyPlayers()}function c(g){if(typeof(g.name)=="undefined"){return""}var f="<"+g.name,h="";if(g.attr){for(k in g.attr){f=f+" "+k+'="'+g.attr[k]+'"'}}if(g.child){if(typeof(g.child)=="string"){g.child=[g.child]}for(var d=0;d<g.child.length;d++){h+=(typeof(g.child[d])=="object")?c(g.child[d]):g.child[d]}}return(g.selfClose)?f+"/>":f+">"+h+"</"+g.name+">"}})(jQuery);$GP.registerPlayer({name:"Adobe Flash Player",url:"http://www.adobe.com/products/flashplayer/",ext:["flash","flv","mp3","mp4","f4v","m4v","mov"],priority:50,_obj:{classid:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},_embed:{type:"application/x-shockwave-flash"},_detect:function(){return $GP._detect("Shockwave Flash","ShockwaveFlash.ShockwaveFlash.7")},_params:{allowScriptAccess:"always",allowFullScreen:true,bgcolor:"#000000",wmode:"Opaque"},setStream:function(a){this.FlashVars="videoURL="+a+"&id="+this.id},onStart:function(a){this.addCallback("onPlay","$GP.flashHandler");this.addCallback("onPause","$GP.flashHandler");this.addCallback("onFinish","$GP.flashHandler");this.addCallback("onWait","$GP.flashHandler");this.addCallback("onError","$GP.flashHandler")},_beforeEmbed:function(){this._params.src=$GP.url.flash;this._params.id=$GP.ID},_afterEmbed:function(){},_isReady:function(){try{return(this.isReady()&&this.getVersion())}catch(a){}return false},API:{play:"playStream",stop:"stopStream",pause:"pauseStream",getVolume:"getVolume",setVolume:function(a){this.setVolume(a)},fullscreen:false,mute:function(){this.setVolume(0)},unmute:function(){this.setVolume(100)},getProgress:"getProgress",setProgress:function(a){this.setProgress(a)},getBuffer:"getBuffer",getReceived:"getReceived",getStream:"getStream",setStream:function(a,b){this.setStream(a);if(b||this.isStreamPlaying()){this.playStream()}},isPlaying:"isStreamPlaying"}});$GP.flashHandler=function(b,a,c){c=c||null;if(typeof($GP.events[b])!="undefined"){$GP.events[b]($GP.getGypsy(a),c)}};(function($){$GP.DP={mySkin:{},registerSkin:function(path){path=path||"digomePlayer/skin";if(path.charAt(path.length-1)!="/"){path+="/"}var skin={path:path};this.skins.push(skin);$("head").append('<link rel="stylesheet" href="'+path+'dpSkin.css" type="text/css" />');$.ajax({url:path+"dpSkin.html",success:function(html){skin.markup=html},error:function(){skin.fail=true}});$.get(path+"dpSkin.js",null,function(js){eval(js);$.extend(skin,$GP.DP.skinTemplate,DigomePlayerSkin)},"text");this.lastSkin=skin},load:function(selector,skinName){if(!this.lastSkin){$GP.error("No Registered Skins")}var skin=this.lastSkin;var i=0;(function onSkinReady(){if(i++>60){$GP.error('Timeout registering "'+((skinName)?skinName:skin.path)+'" Skin.')}if(skin.fail){$GP.error('Error Loading "'+((skinName)?skinName:skin.path)+'" Skin.')}if(skinName&&skinName!=skin.name){skin={};var x=$GP.DP.skins,y=x.length;while(y--){if(x[y].name==skinName){skin=x[y];break}}}if(!skin.name||!skin.markup){return setTimeout(onSkinReady,333)}$(selector).each(function(i){var d="{}",m=/({.*})/.exec(this.className);if(m){d=m[1]}if(d.indexOf("{")<0){d="{"+d+"}"}d=eval("("+d+")");var o=$.extend({url:this.href,playerParams:{},timeout:"Unable to load Video. Please try again."},d);var mySkin=$.extend({gypsy:null,config:o},skin);mySkin.draw(this);if(!mySkin.movie||mySkin.movie.length<1){$GP.error("Skin did not declare valid movie element(s).")}mySkin.movie.gypsy(o);if($GP.ID){$GP.DP.mySkin[$GP.ID]=mySkin}if(o.tab){mySkin.tabAdd(o.url,o.tab,S)}$(this).remove()})})()},skins:[],lastSkin:false,skinTemplate:{draw:function(e){$(e).after(skin.markup)},onDraw:function(){},addComponent:function(type,selector,alt){alt=alt||false;var gypsy=this.gypsy,e=(typeof(selector)=="string")?$(selector,this.xml):$(selector);if(e.length<1){$GP.error('Unable to register Skin Component "'+type+', invalid selector."')}e.each(function(){this._gypsy=gypsy});switch(type){case"control":e.each(function(){$(this).click(function(){var cmd=$(this).attr("name");if($GP.events[cmd+"Click"]&&!$GP.events[cmd+"Click"](this._gypsy)){return}this._gypsy.cmd(cmd)})[0]._gypsy=gypsy}).bind("mouseenter mouseleave",function(e){$(this)[((e.type=="mouseenter")?"add":"remove")+"Class"]("dpHover")});if(alt){alt=(typeof(alt)=="string")?$(alt,this.xml):$(this.xml);alt.mousemove(function(){var S=this._gypsy.skin;(S._cc)?clearTimeout(S._cc):S.showControls();S._cc=setTimeout(function(){S.hideControls();S._cc=false},1200)})[0]._gypsy=gypsy}break;case"timeline":this.makeSliderControl("timeline",e,{slideTo:function(i){this.handle.width(i+"%")},onSlide:function(i){this.gypsy.cmd("pause");if(i>100){i=100}this.handle.width(i+"%")},afterSlide:function(i){this.set(i);this.gypsy.cmd("play")},set:function(i){if(i>100){i=100}this.gypsy.cmd("setProgress",i)},onPoll:function(){var p=(this.gypsy.cmd("getProgress"));if(p>=100){p=100;this.stop()}this.handle.width(p+"%")}});break;case"progress":this.makeSliderControl("progress",e,{onPoll:function(){var p=(this.gypsy.cmd("getReceived"));if(p>=100){p=100;this.stop()}this.handle.width(p+"%")}},true);break;case"volume":this.makeSliderControl("volume",e,{bar:(alt)?$(alt,this.xml):false,set:function(i){if(i>100){i=100}var handleWith=this.handle.width(),l=(this.bounds.width-handleWith)*i/100;this.bar.width(i+"%");this.handle.css("left",l+"px");this.gypsy.cmd("setVolume",i);if(i===0&&this.gypsy.skin.onMute){this.gypsy.skin.onMute()}else{if(this.gypsy.skin.onUnmute){this.gypsy.skin.onUnmute()}}}});break;case"mute":e.click(function(){var vol=this._gypsy.cmd("getVolume");if(vol>0){this._vol=vol;this._gypsy.skin.volume.set(0)}else{this._gypsy.skin.volume.set(this._vol||50)}});break;case"posterPlay":e.click(function(){this._gypsy.cmd("play")});this.posterPlay={e:e,hide:function(){this.e.fadeOut()},show:function(){this.e.fadeIn()}};break}},makeSliderControl:function(name,handle,object,notClickable){var me=this[name]=$.extend({gypsy:this.gypsy,handle:handle,box:handle.parent(),bar:null,bounds:null,slideTo:function(i){this.set(i)},onSlide:function(i){this.set(i)},afterSlide:function(i){this.set(i)},set:function(i){},reset:function(){this.handle.width(0);this.stop()},onPoll:function(){},start:function(){var me=this;if(!this.pollInterval){this.pollInterval=setInterval(function(){me.onPoll()},400)}},stop:function(){clearInterval(this.pollInterval);this.pollInterval=null},pollInterval:null},object);if(notClickable){return}this[name].box.mousedown(function(z){var slide=function(e){var i=(e.clientX<me.bounds.left)?0:((e.clientX>me.bounds.right)?100:(100*(e.clientX-me.bounds.left)/me.bounds.width));me.slideTo(i)};$(document).mousemove(slide).one("mouseup",function(e){$(document).unbind("mousemove",slide);me.afterSlide(100*(e.clientX-me.bounds.left)/me.bounds.width)});me.onSlide(100*(z.clientX-me.bounds.left)/me.bounds.width)})},calculateBounds:function(){$GP.trace("calculateBounds");var skin=this;$.each(["volume","timeline"],function(i,v){var e=skin[v];if(e){var b=e.box.offset();b.right=b.left+e.box.width();b.width=b.right-b.left;e.bounds=b}});if(skin.volume&&$(skin.volume.handle).is(":visible")){skin.volume.set(skin.gypsy.cmd("getVolume")||0)}},tabAdd:function(){},tabDel:function(){},tabClick:function(){},onPlay:function(){},onPause:function(){},showStatus:function(msg){},hideStatus:function(){},reset:function(poster){poster=poster||false;if(this.timeline){this.timeline.reset()}if(this.progress){this.progress.reset()}if(poster){if(this.posterPlay){this.posterPlay.show()}}}}};$.extend($GP.events,{onPlay:function(h){var i=0,stream=h.cmd("getStream");h._p=true;(function onPlaying(){if(!h._p){return}if(i++>30){h.cmd("pause");return h.skin.showStatus(h.skin.config.timeout)}if(!h.cmd("isPlaying")){if(i%10==0){h.cmd("play")}return setTimeout(onPlaying,333)}if(!h.skin.buffering){h.skin.hideStatus()}if(h.skin.timeline){h.skin.timeline.start()}if(h.skin.progress){h.skin.progress.start()}if(h.skin.posterPlay){h.skin.posterPlay.hide()}h.skin.onPlay()})()},onPause:function(h){h._p=false;if(h.skin.timeline){h.skin.timeline.stop()}h.skin.onPause()},onWait:function(h){if(h.skin.buffering){return}h.skin.buffering=true;(function pollBuffer(){var b=h.cmd("getBuffer");if(b<100){h.skin.showStatus("Buffering ("+b+"%)");return setTimeout(pollBuffer,800)}h.skin.hideStatus();h.skin.buffering=false})()},onError:function(h,msg){h._p=false;if(h.skin.timeline){h.skin.timeline=false}return h.skin.showStatus(msg)},onFinish:function(h){h._p=false;h.skin.onPause();h.skin.reset(true)},onReady:function(h){if(!h.skin){h.skin=$GP.DP.mySkin[h.ID];h.skin.gypsy=h;h.skin.onDraw()}if(h.plugin.name=="Image Player"){h.skin.hideControls()}else{h.skin.showControls()}if(h.skin.posterPlay&&h.plugin.name!="Image Player"){h.skin.posterPlay.show()}},fullscreenClick:function(gypsy){if(gypsy.plugin.API.fullscreen){return true}gypsy.skin.fullscreen(true);return false},onChange:function(h){h.skin.reset()}})})(jQuery);DigomePlayer=$GP.DP;
