
window.addEvent('domready',function(){function setSelectedToggle(popups,toggles,selectedToggle){toggles.each(function(tog,i){if(tog===selectedToggle&&!tog.hasClass('selected')){tog.addClass('selected');popups[i].setStyle('display','block');popups[i].slide('in');}else{popups[i].slide('out');tog.removeClass('selected');}});}
function buildStringEmbed(newWidth,newHeight){return'<object><embed src="'+this.playerUrl+'" width="'+newWidth+'" height="'+newHeight+'" allowfullscreen="true" allowscriptaccess="always" flashvars="video='+this.idVideo+'"></embed></object>';}
function calculateHeightFromWidth(width){var ratio=420/560;return parseInt(width*ratio,10);}
jwplayer("videoplayer").setup({width:width,height:(parseInt(this.real_height,10)+35),controlbar:"bottom",levels:[{file:this.videoURL}],modes:[{type:"html5"},{type:"flash",src:"/flash/extern/cinochePlayer/player.swf"},{type:'download'}],skin:"/flash/extern/cinochePlayer/skins/cinoche/cinoche.xml",stretching:"uniform",events:{onError:function(event){},onReady:function(event){jwplayer('videoplayer').play(true);}}});var videoSharePopup=$('videoSharePopup');var videoFormatPopup=$('videoFormatPopup');var videoDownloadPopup=$('videoDownloadPopup');var videoSocialPopup=$('videoSocialPopup');var videoShareToggle=$('videoShare');var videoFormatToggle=$('videoFormat');var videoDownloadToggle=$('videoDownload');var videoSocialToggle=$('videoSocial');var popups=[videoSharePopup,videoFormatPopup,videoDownloadPopup,videoSocialPopup];var toggles=[videoShareToggle,videoFormatToggle,videoDownloadToggle,videoSocialToggle];popups.each(function(el){el.slide('hide');});var formatButtons=$$('.videoFormatButton');if(formatButtons.length>1){videoFormatToggle.show();videoDownloadToggle.show();}
toggles.each(function(el){el.addEvent('click',function(){setSelectedToggle(popups,toggles,el);});});formatButtons.addEvent('click',function(evt){evt.stop();formatButtons.removeClass('selected');this.addClass('selected');videoFormatToggle.set('class',this.get('data-video-format'));setSelectedToggle(popups,toggles,null);jwplayer('videoplayer').load({file:this.get('href')}).play(true);return false;});if((/iPad/i).test(navigator.userAgent)){$$('.videoFormat-high').hide();}
$$('.videoDownloadButton').addEvent('click',function(){setSelectedToggle(popups,toggles,null);});$$('#copyLinkShare').addEvent('click',function(el){var texttocopy=$('copyLinkShareValue').get('value');var clipboard=new ClipBoard();clipboard.save(texttocopy);});$$('#copyEmbedShare').addEvent('click',function(el){var texttocopy=$('copyEmbedShareValue').get('value');var clipboard=new ClipBoard();clipboard.save(texttocopy);});$$('#copyEmbedSizeValue').addEvent('keyup',function(el){if(parseInt($$('#copyEmbedSizeValue').get('value'),10)>=300&&parseInt($$('#copyEmbedSizeValue').get('value'),10)<=560){var newWidth=parseInt($$('#copyEmbedSizeValue').get('value'),10);var newHeight=calculateHeightFromWidth(newWidth);var embedString=buildStringEmbed(newWidth,newHeight);$$('#copyEmbedShareValue').set('value',embedString);$$('#copyEmbedSizeShareHeight').set('text',newHeight);}});});
