BProgress=function(){this._canvas=null;this.background="/html5/video/progress_background.png";this.l_item="/html5/video/progress_loaded_item.png";this.c_item="/html5/video/progress_current_time.png";this.progress=0;this.width=280;this.mode="loaded";this.ctx=function(){return this._canvas.getContext("2d")};this.createCompontent=function(){this._canvas=document.createElement("canvas");this._canvas.setAttribute("width",this.width);this._canvas.setAttribute("height",9);this._canvas.style.cursor="pointer";var b=new Image();b.src=this.background;var a=this.ctx();b.onload=function(){a.drawImage(b,0,0)};this._canvas.onmousemove=this._mousemove.bind(this);this._canvas.onmouseout=this._mouseout.bind(this);this._canvas.onclick=this._onclick.bind(this);return this._canvas};this.getDx=function(){return Element.viewportOffset(this.canvas())[0]};this.getDy=function(){return Element.viewportOffset(this.canvas())[1]};this._mousemove=function(c){var a=c.clientX-this.getDx();var d=c.clientY-this.getDy();var b=a/(this.width-2)*100;this.mousemove(a,d,b)};this._onclick=function(c){var a=c.clientX-this.getDx();var d=c.clientY-this.getDy();var b=a/(this.width-2)*100;this.onclick(b)};this.onclick=function(a){};this._mouseout=function(a){this.mouseout(a)};this.mouseout=function(a){};this.mousemove=function(a,c,b){};this.canvas=function(){return this._canvas};this.itemCount=function(){return Math.round(this.progress*this.percentLength())};this.percentLength=function(){return((this.width-2)/100)};this.showProgress=function(d){var b=new Image();if(this.mode=="loaded"){b.src=this.l_item}else{b.src=this.c_item}var a=this.ctx();var e=this;b.onload=function(){for(var c=d;c<e.itemCount();c++){a.drawImage(this,1+c,1)}}};this.clearRect=function(){this.ctx().clearRect(1,1,this.width-1,8)};this.clearCustomRect=function(b,a){this.ctx().clearRect(b*this.percentLength(),1,this.width-1,8)};this.setProgress=function(a){if(a==0){var b=new Image();b.src=this.background;this.ctx().drawImage(b,0,0);this.progress=a;this.clearRect()}else{var d=this.progress!=a;var c=(this.progress-1)*this.percentLength();this.progress=a;if(d){this.showProgress(0)}}}};BPlayer=function(){this.movies=[];this.container=null;this.current_video=0;this.video_width=0;this.video_height=0;this.player_width=0;this.player_height=0;this.controls_background="#325491";this.player_background="url(/html5/video/background.png)";this.title_height=30;this.play_btn="/html5/video/play.png";this.play_btn_active="/html5/video/play_active.png";this.play_btn_down="/html5/video/play_down.png";this.pause_btn="/html5/video/pause.png";this.pause_btn_active="/html5/video/pause_active.png";this.pause_btn_down="/html5/video/pause_down.png";this.stop_btn="/html5/video/stop.png";this.stop_btn_active="/html5/video/stop_active.png";this.stop_btn_down="/html5/video/stop_down.png";this.mute_btn_active="/html5/video/mute_active.png";this.mute_btn_down="/html5/video/mute_down.png";this.mute_btn="/html5/video/mute.png";this.mute_minus_btn_active="/html5/video/mute_minus_active.png";this.mute_minus_btn_down="/html5/video/mute_minus_down.png";this.mute_minus_btn="/html5/video/mute_minus.png";this.is_mute=false;this.is_paused=true;this._layout=null;if(!window.bplayer_ragister){window.bplayer_ragister=[this];this._index=0}else{this._index=window.bplayer_ragister.length;window.bplayer_ragister[this._index]=this}this.hide=function(){var a=this;this.video().style.display="none";jQuery(this.layout()).fadeOut(1000,function(){a.stop()})};this.isChrome=function(){return navigator.userAgent.indexOf("Chrome")>-1};this.getCloseBtn=function(){return"<div onclick='window.bplayer_ragister["+this._index+"].close();' style='cursor: pointer;float:right; color: yellow;'>Close [x]</div>"};this.showStatic=function(){try{this.tdTitle.innerHTML="<div style='float: left;'>"+this.getVideoTitle()+"</div>"+this.getCloseBtn();var d=this;var a="window.bplayer_ragister["+this._index+"].playAfterStop();";d.getTimeProgress().canvas().style.display="none";d.getProgress().canvas().style.display="none";jQuery(this.layout()).fadeIn(1500,function(){try{d.getTimeProgress().canvas().style.display="";d.getProgress().canvas().style.display="";d.getTimeProgress().canvas().style.position="absolute";d.getTimeProgress().canvas().clonePosition(d.getProgress().canvas());if(Prototype.Browser.Gecko){d.getTimeProgress().canvas().style.top=parseInt(d.getTimeProgress().canvas().style.top)-1+"px"}setTimeout(a,1000)}catch(c){console.log(c)}})}catch(b){console.error(b)}};this.show=function(){try{this.tdTitle.innerHTML="<div style='float: left;'>"+this.getVideoTitle()+"</div>"+this.getCloseBtn();this.layout().style.position="absolute";this.layout().clonePosition($("canvas_map"));var b=this;b.getTimeProgress().canvas().style.display="none";b.getProgress().canvas().style.display="none";jQuery(this.layout()).fadeIn(1000,function(){try{b.getProgress().canvas().style.display="";if(Prototype.Browser.Gecko){b.getTimeProgress().canvas().style.top=parseInt(b.getTimeProgress().canvas().style.top)-1+"px"}if(typeof HeaderImgCtrl!="undefined"){HeaderImgCtrl.DISABLED=false}}catch(c){console.log(c)}})}catch(a){console.error(a)}};this.close=function(){this.destroyAll()};this.getConteiner=function(){return $(this.container)};this.getVideoId=function(){return"bplayer_video_tag_"+this.current_video};this.getVideoSrc=function(){return this.movies[this.current_video].url};this.getVideoSrc2=function(){return this.movies[this.current_video].url2};this.getVideoSrc3=function(){return this.movies[this.current_video].url3};this.getVideoTitle=function(){return this.movies[this.current_video].title};this.getVideoElement=function(){return $(this.getVideoId())};this.video_is_loaded=false;this.video_loaded_progress=0;this.showProgress=function(b){if(this.video_is_loaded){return true}if(b.total){var a=b.loaded/b.total*100;this.getProgress().setProgress(a);this.updateCurrentTime()}else{var a=parseInt(((this.video().buffered.end(0)/this.video().duration)*100));this.getProgress().setProgress(a);this.updateCurrentTime()}this.vide_loaded_progress=a;if(Math.round(a)==100){this.video_is_loaded=true}};this.showCurrenTime=function(b){var a=this.video().currentTime/this.video().duration*100;this.getTimeProgress().setProgress(a);this.updateCurrentTime()};this.sources=[];this.createVideoTag=function(){if(this._video){return this._video}var b=document.createElement("video");b.setAttribute("width","100%");b.setAttribute("height","100%");b.setAttribute("id",this.getVideoId());b.setAttribute("autobuffer","true");var c=document.createElement("source");c.setAttribute("src",this.getVideoSrc());if(!this.isChrome()){b.appendChild(c);this.sources.push(c)}if(this.getVideoSrc3()){var a=document.createElement("source");a.setAttribute("src",this.getVideoSrc3());b.appendChild(a);this.sources.push(a)}b.addEventListener("timeupdate",this.showCurrenTime.bind(this),false);b.style.cursor="pointer";return this._video=b};this.videodoubleclick=function(){};this.videoclick=function(a){var b=this;this.playImg.src=b.is_paused?b.pause_btn_active:b.play_btn_active;b.is_paused=!b.is_paused;if(b.is_paused){b.pause()}else{b.play()}};this.video=function(){return this._video};this.layout=function(){return this._layout};this.mute=function(){this.video().volume=0;this.volumeComponent.setValue(0)};this.maxVolume=function(){this.video().volume=1;this.volumeComponent.setValue(100)};this.getProgress=function(){if(this.progress){return this.progress}else{this.progress=new BProgress();this.progress.createCompontent();return this.progress}};this.getTimeProgress=function(){if(this.time_progress){return this.time_progress}else{this.time_progress=new BProgress();this.time_progress.mode="currenttime";this.time_progress.createCompontent();this.time_progress.mousemove=this.progressmousemove.bind(this);this.time_progress.mouseout=this.progressmouseout.bind(this);this.time_progress.onclick=this.progressonclick.bind(this);return this.time_progress}};this.resetPosition=function(a){var b=a*this.video().duration/100;this.getTimeProgress().setProgress(a);this.getTimeProgress().clearCustomRect(a+1);this.video().currentTime=b;if(!this.is_paused){this.video().play()}};this.progressonclick=function(b){if(b<=this.getProgress().progress){var a=false;if(!this.is_paused){this.video().pause();a=true;setTimeout("window.bplayer_ragister["+this._index+"].resetPosition("+b+");",500)}else{this.resetPosition(b)}}};this.createToolTip=function(){var a=document.createElement("div");a.style.position="absolute";a.style.width="50px";a.style.fontSize="10px";document.body.appendChild(a);return a};this.getToolTip=function(){if(this.tool_tip){return this.tool_tip}else{return this.tool_tip=this.createToolTip()}};this.progressmouseout=function(a,c,b){this.getToolTip().style.display="none"};this.progressmousemove=function(a,e,c){var d=Math.round((c*this.video().duration)/100);d=this.secToMin(d);var b=this.getToolTip();b.innerHTML=d;b.style.display="inline";b.style.left=Element.cumulativeOffset(this._controls)[0]+80+a+"px";b.style.top=Element.cumulativeOffset(this._controls)[1]+10+"px"};this.updateCurrentTime=function(){this.tdCurrentTime.innerHTML=this.getCurrentTime()};this.volumechange=function(b){var a=b/100;if(a>1){a=1}if(a<0){a=0}this.video().volume=a;if(this.video().volume==0){this.is_mute=true;this.muteImg.src=this.mute_minus_btn_active}else{this.is_mute=false;this.muteImg.src=this.mute_btn_active}};this.createControlsLayout=function(){this.volumeComponent=new VolumeComponent();this.volumeComponent.value=100;this.volumeComponent.onchange=this.volumechange.bind(this);var n=document.createElement("table");var f=document.createElement("tbody");var i=document.createElement("tr");var e=document.createElement("td");e.setAttribute("colSpan",5);e.setAttribute("align","right");e.style.paddingRight="35px";e.style.fontSize="10px";e.innerHTML=this.getCurrentTime();this.tdCurrentTime=e;i.appendChild(e);var l=document.createElement("tr");var h=document.createElement("td");var d=document.createElement("img");this.playImg=d;d.src=this.play_btn;var k=this;d.style.cursor="pointer";d.onmouseover=function(){if(k.is_paused){this.src=k.play_btn_active}else{this.src=k.pause_btn_active}};d.onmouseout=function(){if(k.is_paused){this.src=k.play_btn}else{this.src=k.pause_btn}};d.onmousedown=function(){if(k.is_paused){this.src=k.play_btn_down}else{this.src=k.pause_btn_down}};d.onmouseup=function(){if(k.is_paused){this.src=k.play_btn_active}else{this.src=k.pause_btn_active}};d.onclick=function(){this.src=k.is_paused?k.pause_btn_active:k.play_btn_active;k.is_paused=!k.is_paused;if(k.is_paused){k.pause()}else{k.play()}};this.playImg=d;h.appendChild(d);var m=document.createElement("td");m.innerHTML='<img onclick="window.bplayer_ragister['+this._index+'].stop();" style="cursor: pointer;" onmouseup="this.src=\''+this.stop_btn_active+"';\" onmousedown=\"this.src='"+this.stop_btn_down+"';\" onmouseout=\"this.src='"+this.stop_btn+"';\" onmouseover=\"this.src='"+this.stop_btn_active+'\';" src="'+this.stop_btn+'" />';var j=document.createElement("td");var g=document.createElement("td");var b=document.createElement("td");b.setAttribute("width",100);b.setAttribute("align","right");this.volumeComponent.show(b);var a=document.createElement("img");a.src=this.mute_btn;var k=this;a.style.cursor="pointer";a.onmouseover=function(){if(!k.is_mute){this.src=k.mute_btn_active}else{this.src=k.mute_minus_btn_active}};a.onmouseout=function(){if(!k.is_mute){this.src=k.mute_btn}else{this.src=k.mute_minus_btn}};a.onmousedown=function(){if(!k.is_mute){this.src=k.mute_btn_down}else{this.src=k.mute_minus_btn_down}};a.onmouseup=function(){if(!k.is_mute){this.src=k.mute_btn_active}else{this.src=k.mute_minus_btn_active}};a.onclick=function(){this.src=k.is_mute?k.mute_btn_active:k.mute_minus_btn_active;k.is_mute=!k.is_mute;if(k.is_mute){k.mute()}else{k.maxVolume()}};this.muteImg=a;g.appendChild(a);l.appendChild(h);l.appendChild(m);l.appendChild(j);j.setAttribute("width","300");j.setAttribute("align","center");j.setAttribute("valign","top");j.appendChild(this.getProgress().canvas());j.appendChild(this.getTimeProgress().canvas());l.appendChild(g);l.appendChild(b);f.appendChild(i);f.appendChild(l);n.appendChild(f);return this._controls=n};this.getCurrentTime=function(){if(this.video().duration>=0){return this.secToMin(this.video().currentTime)+"/"+this.secToMin(this.video().duration)}else{return"&nbsp;"}};this.secToMin=function(c){var b=Math.round(c);var a=parseInt(b/60);if(a<10){a="0"+a}var d=b%60;if(d<10){d="0"+d}return a+":"+d};this.moveTo=function(a){this.video().currentTime=a};this.play=function(){this.video().play();this.is_stop=false};this.pause=function(){this.video().pause()};this.is_stop=true;this._stopEvent=function(){this.playImg.src=this.play_btn;this.is_stop=true;this.is_paused=true;this.getTimeProgress().setProgress(0)};this.stop=function(){if(!this.is_stop){this.reAppendVideo();this._stopEvent()}};this.createLayout=function(){var o=document.createElement("table");o.style.cursor="default";o.style.backgroundImage=this.player_background;o.style.backgroundRepeat="no-repeat";o.style.backgroundColor="rgb(50, 84, 145)";o.setAttribute("border","0");o.setAttribute("cellpadding","0");o.setAttribute("cellspacing","0");o.setAttribute("width",this.player_width);o.setAttribute("height",this.player_height);var e=document.createElement("tbody");var i=document.createElement("tr");var a=document.createElement("td");a.setAttribute("height",this.title_height);a.style.fontFamily="Tahoma";a.style.fontSize="18px";a.style.color="white";var j=document.createElement("td");var h=document.createElement("td");j.innerHTML=h.innerHTML="&nbsp;";j.setAttribute("width",100);h.setAttribute("width",110);i.appendChild(j);i.appendChild(a);i.appendChild(h);a.innerHTML="<div style='float: left;'>"+this.getVideoTitle()+"</div>"+this.getCloseBtn();var f=document.createElement("tr");var d=document.createElement("tr");this.imgPrev=document.createElement("img");this.imgPrev.src="/html5/video/prev.png";this.imgNext=document.createElement("img");this.imgNext.src="/html5/video/next.png";this.imgNext.style.cursor=this.imgPrev.style.cursor="pointer";var l=document.createElement("td");l.appendChild(this.imgPrev);var k=document.createElement("td");k.appendChild(this.createVideoTag());k.setAttribute("width",this.video_width);k.setAttribute("height",this.video_height-this.title_height);k.setAttribute("valign","top");this.tdVideo=k;this.tdTitle=a;this.imgNext.onclick=this.next.bind(this);this.imgPrev.onclick=this.prev.bind(this);var m=document.createElement("td");m.appendChild(this.imgNext);m.setAttribute("align","left");l.setAttribute("align","right");l.style.paddingRight="20px";m.style.paddingLeft="20px";var g=document.createElement("td");g.setAttribute("colSpan",3);g.style.background=this.controls_background;f.appendChild(l);f.appendChild(k);f.appendChild(m);g.setAttribute("align","center");g.setAttribute("valign","top");g.appendChild(this.createControlsLayout());d.appendChild(g);e.appendChild(i);e.appendChild(f);e.appendChild(d);o.appendChild(e);o.style.display="none";var n=this;var b="window.bplayer_ragister["+this._index+"].playAfterStop();";this.video().addEventListener("canplay",function(c){setTimeout(b,1000)},true);this.video().addEventListener("loadeddata",function(c){var c={loaded:100,total:100};n.showProgress(c)},false);return this._layout=o};this.init=function(){try{this.getConteiner().appendChild(this.createLayout())}catch(a){}};this.destroyVideo=function(){this.tdVideo.removeChild(this.video())};this.appendVideo=function(){this.tdVideo.appendChild(this.video())};this.reAppendVideo=function(){this.destroyVideo();delete this._video;this.createVideoTag();this.appendVideo()};this.next=function(){if(this.movies.length==1){if(this.next_video){location.href="/"+CanvasMap.getIslandName(this.permanent_active_island)+"/video/"+CanvasMap.converNameToUrl2(this.next_video)}return false}if(this.current_video==this.movies.length-1){this.current_video=0}else{this.current_video++}this.stop();var a="window.bplayer_ragister["+this._index+"].playAfterStop();";setTimeout(a,1000)};this.prev=function(){if(this.movies.length==1){if(this.prev_video){location.href="/"+CanvasMap.getIslandName(this.permanent_active_island)+"/video/"+CanvasMap.converNameToUrl2(this.prev_video)}return false}if(this.current_video==0){this.current_video=this.movies.length-1}else{this.current_video--}this.stop();var a="window.bplayer_ragister["+this._index+"].playAfterStop();";setTimeout(a,1000)};this.__ENDED__=false;this.destroyAll=function(b){try{this.__ENDED__=true;this.volumechange(0);this.pause();this._video.src="";for(var a=0;a<this.sources.length;a++){this.sources[a].setAttribute("src","")}this.video().load();jQuery(this.layout()).remove();if(typeof b=="function"){try{b()}catch(c){}}}catch(c){alert(c)}};this.end_callback=null;this.playAfterStop=function(){if(this.__ENDED__){return false}this.tdTitle.innerHTML="<div style='float: left;'>"+this.getVideoTitle()+"</div>"+this.getCloseBtn();this.video().addEventListener("timeupdate",this.showCurrenTime.bind(this),false);var a=this;this.video().addEventListener("ended",function(){a.destroyAll(a.end_callback)},false);this.video().setAttribute("oncontextmenu","return false;");var a=this;a.is_paused=false;this.playImg.src=a.pause_btn_active;fakeClick(function(){a.play()});this.getTimeProgress().canvas().style.display="";this.getTimeProgress().canvas().style.position="absolute";this.getTimeProgress().canvas().clonePosition(a.getProgress().canvas());a.getTimeProgress().canvas().style.display="";if(Prototype.Browser.Gecko){this.getTimeProgress().canvas().style.top=parseInt(this.getTimeProgress().canvas().style.top)-1+"px"}}};
