




/* Version: 1318003614 */


View.YoutubePlayerView=Class.create(View,{main:function(strPlayerWrapperId)
{this.Object=$(strPlayerWrapperId);this.Object.Player=this.Object.down('#ytapiplayer');this.Object.ListeWrapper=this.Object.down('ol');this.Object.Liste=this.Object.down('ol').childElements();}});var YoutubePlayer=Class.create(Module,{View:'View.YoutubePlayerView',blnAutoPlay:false,intIndexId:null,arrPlaylist:[],main:function($super,strPlayerWrapperId,blnAutoPlay,options)
{if(blnAutoPlay)
{this.blnAutoPlay=true;}
$super(strPlayerWrapperId);this.options={width:300,height:168,playItem:0,playSecond:0};Object.extend(this.options,options||{});this.initPlaylist();this.initPlayer(this.View.Liste[this.options.playItem],this.options.playItem,this.options.playSecond);},initPlaylist:function()
{for(var i=0;this.View.Liste.length>i;i++)
{this.arrPlaylist[i]=this.View.Liste[i].readAttribute('data-youtubeid');}},initPlayer:function(listElement,intLiedIndex)
{if(!this.blnAutoPlay)
{listElement.addClassName('play');}
else
{listElement.addClassName('pause');}
var divSwf=Builder.node('div');divSwf.identify();this.View.Player.update(divSwf);var params={allowScriptAccess:'always',allowFullScreen:true};var atts={id:'myytplayer'};var strUrl='http://www.youtube.com/e/'+this.arrPlaylist[intLiedIndex]+'?enablejsapi=1&playerapiid=ytplayer';if(this.blnAutoPlay)
{strUrl=strUrl+'&autoplay=1';}
if(this.options.playSecond>0)
{strUrl=strUrl+'&start='+this.options.playSecond;}
swfobject.embedSWF(strUrl,divSwf.id,this.options.width,this.options.height,'8',null,null,params,atts);this.intIndexId=intLiedIndex;},playVideo:function(clickElement,intLiedIndex)
{if(clickElement.hasClassName('pause'))
{this.pause();}
else
{if(this.intIndexId==intLiedIndex)
{this.play();}
else
{this.View.ListeWrapper.scrollTop=(this.View.ListeWrapper.getHeight()-this.View.Liste[intLiedIndex].offsetTop-this.View.Liste[intLiedIndex].getHeight())*-1;this.loadVideo(intLiedIndex);}}},loadVideo:function(intLiedIndex)
{this.intIndexId=intLiedIndex;$('myytplayer').loadVideoById(this.arrPlaylist[intLiedIndex]);},play:function()
{$('myytplayer').playVideo();},pause:function()
{$('myytplayer').pauseVideo();},stop:function()
{$('myytplayer').stopVideo();},getCurrentTime:function()
{return $('myytplayer').getCurrentTime();},youtubePlayerReady:function()
{if(this.blnAutoPlay)
{this.play();}
$('myytplayer').addEventListener('onStateChange','objYoutubePlayer.stateChange');$('myytplayer').addEventListener('onError','objYoutubePlayer.error');},stateChange:function(intStateChange)
{switch(intStateChange)
{case 0:if(this.intIndexId==this.View.Liste.length-1)
{this.playVideo(this.View.Liste[0],0);}
else
{this.playVideo(this.View.Liste[this.intIndexId+1],this.intIndexId+1);}
break;case 1:this.View.Liste[this.intIndexId].up().select('li.play').each(function(e){e.removeClassName('play');e.removeClassName('pause');});this.View.Liste[this.intIndexId].addClassName('pause');this.View.Liste[this.intIndexId].addClassName('play');break;case 2:this.View.Liste[this.intIndexId].removeClassName('pause');break;}},error:function(intErrorCode)
{switch(intErrorCode)
{case 101:new Ajax.Request('/YoutubeVideoNotAvailable?video_id='+this.View.Liste[this.intIndexId].readAttribute('data-videoId')+'&youtube_id='+this.arrPlaylist[this.intIndexId]+'&check'+strCheck);this.View.Liste[this.intIndexId].remove();this.initPlaylist();this.playVideo(this.View.Liste[this.intIndexId],this.intIndexId);break;}},setListeners:function()
{document.observe('youtubePlayer:playerReady',this.youtubePlayerReady.bind(this));},removeListeners:function()
{document.stopObserving('youtubePlayer:playerReady',this.youtubePlayerReady.bind(this));}});View.YoutubePlayerEditView=Class.create(View,{main:function(strPlayerWrapperId)
{this.Object=$(strPlayerWrapperId);this.Object.Suche={};this.Object.Suche.Input=this.Object.down('input');this.Object.Suche.Container=this.Object.down('.suchContainer');this.Object.Playlist=this.Object.down('ol.sortierung');this.Object.Playlist.handles=this.Object.Playlist.getElementsByClassName('titel');}});var YoutubePlayerEdit=Class.create(Module,{View:'View.YoutubePlayerEditView',intUserId:null,strVorschauId:null,main:function($super,strPlayerWrapperId,intUserId)
{this.intUserId=intUserId;$super(strPlayerWrapperId);this.View.Playlist.identify();this.createSort();this.createTypingUpdater();},createTypingUpdater:function()
{new Ajax.TypingUpdater(this.View.Suche.Input,'/YoutubePlayerSearchVideo',this.View.Suche.Container,{minChars:3});},addVideo:function(clickElement,strYoutubeId)
{Sortable.destroy(this.View.Playlist.id);var objHinzufuegen=Builder.node('div',{className:'positive hinzugefuegt',style:'display: none;'},'wird hinzugefügt...');new Ajax.RequestUpdater('/YoutubePlayerAddEntry?user_id='+this.intUserId+'&youtube_id='+strYoutubeId+'&check='+strCheck,this.View.Playlist.id,'/YoutubePlaylist?sortierung=1&blnInlineLoad=1','',{onLoading:function()
{clickElement.up(1).insert(objHinzufuegen);objHinzufuegen.appear();}.bind(this),onComplete:function()
{this.createSort();objHinzufuegen.update('hinzugefügt');objHinzufuegen.fade({delay:4})}.bind(this)});delete objHinzufuegen;},playVideo:function(clickElement,strYoutubeId)
{$$('.youtubePlayerPreview').each(function(e){e.remove();});$(clickElement).identify();if(this.strVorschauId&&$(this.strVorschauId))
{$(this.strVorschauId).up().removeClassName('play');clickElement.up().removeClassName('stop');}
if(this.strVorschauId==clickElement.id)
{this.strVorschauId=null;return;}
var divWrapper=Builder.node('div',{style:'top: -84px; left: -318px; position: absolute; width: 300px; height: 168px; z-index: 2; display: none;',className:'youtubePlayerPreview'});var divSwf=Builder.node('div');var divArrow=Builder.node('div',{className:'arrow'});var divDelete=Builder.node('div',{className:'delete',onclick:'this.up(1).down(".play").triggerEvent("click");'});divSwf.identify();divWrapper.appendChild(divSwf);divWrapper.appendChild(divArrow);divWrapper.appendChild(divDelete);clickElement.up().insert(divWrapper);divWrapper.appear({duration:0.3});var params={allowScriptAccess:'always'};var atts={id:'inlineYoutubePlayer'};swfobject.embedSWF('http://www.youtube.com/e/'+strYoutubeId+'?enablejsapi=1&playerapiid=ytplayer&autoplay=1&controls=0',divSwf.id,'300','168','8',null,null,params,atts);clickElement.up().addClassName('play');this.strVorschauId=clickElement.id;clickElement.up().addClassName('stop');},createSort:function()
{Sortable.create(this.View.Playlist.id,{handles:this.View.Playlist.handles,onUpdate:function(){new Ajax.Request('/YoutubeChangeOrder?user_id='+this.intUserId,{method:'post',parameters:{data:Sortable.serialize(this.View.Playlist.id)}});}.bind(this)});},_switchInfotext:function(Elem,Mode)
{if($F(Elem)!=''||Mode=='f')
{Elem.removeClassName('infoText');}
else
{Elem.addClassName('infoText');}},setListeners:function()
{this.View.Suche.Input.observe('focus',this._switchInfotext.bind(this,this.View.Suche.Input,'f'));this.View.Suche.Input.observe('blur',this._switchInfotext.bind(this,this.View.Suche.Input,'b'));},removeListeners:function()
{this.View.Suche.Input.stopObserving('focus',this._switchInfotext.bind(this,this.View.Suche.Input,'f'));this.View.Suche.Input.stopObserving('blur',this._switchInfotext.bind(this,this.View.Suche.Input,'b'));}});





