jQuery(function($){"use strict";var
parent=$('.slider'),viewport=$('.slider-viewport',parent),itemWrap=$('.slider-elements',viewport),jumperWrap=$('.slider-jumpers',parent),items=itemWrap.children('li'),firstItem=items.eq(0),itemWidth=items.outerWidth(),scrollDuration=2000,scrollInterval=5000,interval=null,isSliding=false,position=0,slideTo=function(nextPosition,direction){var currentItem,nextItem,finalize=function(){tearDown(currentItem);currentItem.detach();viewport.scrollLeft(0);position=nextPosition;isSliding=false;};if(!isSliding){isSliding=true;jumperWrap.children('li.explicit-jumper').eq(nextPosition).addClass('active').siblings().removeClass('active');currentItem=items.eq(position);nextItem=items.eq(nextPosition);if(direction>0){nextItem.appendTo(itemWrap);viewport.scrollLeft(0);setup(nextItem);viewport.animate({scrollLeft:itemWidth},scrollDuration,finalize);}else if(direction<0){nextItem.prependTo(itemWrap);viewport.scrollLeft(itemWidth);setup(nextItem);viewport.animate({scrollLeft:0},scrollDuration,finalize);}}},slideToNext=function(){slideTo((position+1)%items.length,1);},slideToPrev=function(){slideTo((position-1)%items.length,-1);},start=function(){if(interval===null){interval=setInterval(slideToNext,scrollInterval+scrollDuration);}},stop=function(){if(interval!==null){clearInterval(interval);interval=null;}},setup=function(item){var videoItem=item.find('.slider-video'),videoId,videoPreviewImage,textItem=item.find('.slider-text');if(videoItem.length>0){videoId=parseInt(videoItem.data('video-id'),10);videoPreviewImage=videoItem.data('preview-image');$(document.createElement('div')).addClass('__CbUiPlayer').appendTo(videoItem);CbPlayerWindow.create(videoItem,{movie_id:videoId,image:videoPreviewImage,modal:false,config:'dsh'},'DshPlayerWindow',function(window){var element=$('.__CbUiPlayer');if(element.length>0){element.CbWidget().play(function(){stop();});}})}else if(textItem.length>0){textItem.each(function(){var $this=$(this),text=$.trim($('div, a',$this).html().replace(/\s*\<br ?\/?\>\s*/gi,"\n")),targetLineCount=text.split("\n").length;if(targetLineCount>1&&!$this.data('text-is-autosized')){$this.css('font-size',Math.round(parseInt($this.css('font-size'),10)/(targetLineCount*0.8))+'px');$this.data('text-is-autosized',true);}});}},tearDown=function(item){var videoItem=item.find('.slider-video');if(videoItem.length>0){videoItem.empty();}},createJumpers=function(){var i;$(document.createElement('li')).text('\u25c4').click(function(){slideToPrev();stop();}).appendTo(jumperWrap);for(i=0;i<items.length;i++)(function(i){var label=(i+1<10?'0':'')+(i+1);$(document.createElement('li')).text(label).click(function(){if(i!=position){slideTo(i,i>position?1:-1);}
stop();}).addClass(i==0?'active':'').addClass('explicit-jumper').appendTo(jumperWrap);}(i));$(document.createElement('li')).text('\u25ba').click(function(){slideToNext();stop();}).appendTo(jumperWrap);};items.not(firstItem).detach();setup(firstItem);viewport.scrollLeft(0);itemWrap.width(itemWidth*2);if(items.length>1){createJumpers();start();}});
window.createWindow=(function($,$window){var distanceFromTarget=30,distanceFromBorders=35,slideFadeDistance=10,showAnimationDuration=350,hideAnimationDuration=150,activeWindowCloser=null;return function(options){var $body=$('body'),windowElement,closeElement,contentElement,arrowElement,arrowPositionX,arrowPositionY,arrowDirection,windowWidth,windowHeight,windowPositionX,windowPositionY,targetOffset,targetPositionX,targetPositionY,targetWidth,targetHeight,close=function(){activeWindowCloser=null;if(!options.target){windowElement.fadeOut(hideAnimationDuration,function(){windowElement.remove();});}else{windowElement.animate({opacity:0.0,left:Math.round(arrowDirection==='left'?(windowPositionX+slideFadeDistance):(windowPositionX-slideFadeDistance))+'px'},hideAnimationDuration,function(){windowElement.remove();});}
options.onUnload();};if(activeWindowCloser!==null){activeWindowCloser();}
options=$.extend({target:null,arrowDirection:'auto',position:null,content:'',width:null,height:null,onLoad:$.noop,onUnload:$.noop},options||{});windowElement=$(document.createElement('div')).addClass('window');closeElement=$(document.createElement('a')).attr('href','#').addClass('window-close').appendTo(windowElement);contentElement=$(document.createElement('div')).addClass('window-content').appendTo(windowElement);contentElement.html(options.content);windowElement.appendTo($body);contentElement.width(options.width||contentElement.width());contentElement.height(options.height||contentElement.height());windowWidth=windowElement.outerWidth();windowHeight=windowElement.outerHeight();if(options.position){windowPositionX=options.position.x;windowPositionY=options.position.y;}else{if(options.target){targetOffset=options.target.offset();targetPositionX=targetOffset.left;targetPositionY=targetOffset.top;targetWidth=options.target.width();targetHeight=options.target.height();if(options.arrowDirection==='auto'){arrowDirection=targetPositionX-windowWidth-distanceFromTarget>0?'right':'left';}else{arrowDirection=options.arrowDirection;}
if(arrowDirection==='right'){windowPositionX=targetPositionX-windowWidth-distanceFromTarget;}else if(arrowDirection==='left'){windowPositionX=targetPositionX+targetWidth+distanceFromTarget;}
arrowElement=$(document.createElement('div')).addClass('window-arrow-'+arrowDirection).appendTo(windowElement);windowPositionY=Math.max(targetPositionY-windowHeight+arrowElement.height(),$window.scrollTop()+distanceFromBorders);if(arrowDirection==='right'){arrowPositionX=windowWidth;}else if(arrowDirection==='left'){arrowPositionX=-arrowElement.width();}
arrowPositionY=Math.floor(targetPositionY-windowPositionY+targetHeight/2-arrowElement.height()/2);if(arrowPositionY>=0&&arrowPositionY<=windowHeight-arrowElement.height()){arrowElement.css({top:Math.round(arrowPositionY)+'px',left:Math.round(arrowPositionX)+'px'});}else{arrowElement.remove();}}else{windowPositionX=$body.width()/2-windowWidth/2;windowPositionY=$window.scrollTop()+distanceFromBorders;}}
windowElement.css({top:Math.round(windowPositionY)+'px',left:Math.round(windowPositionX)+'px'});closeElement.click(function(e){e.preventDefault();close();});options.onLoad();if(!options.target){windowElement.hide().fadeIn(showAnimationDuration);}else{windowElement.css({opacity:0.0,left:Math.round(arrowDirection==='left'?(windowPositionX+slideFadeDistance):(windowPositionX-slideFadeDistance))+'px'}).animate({left:[Math.round(windowPositionX)+'px','easeOutQuart'],opacity:[1.0,'swing']},showAnimationDuration,function(){windowElement.css('opacity',1.0);});}
activeWindowCloser=close;};}(jQuery,jQuery(window)));
DshPlayerWindow=CbSimplePlayerWindow.extend({constructor:function(element,options){this.base(element,$.extend({config:'dsh',width:704,height:396,modal:true,layerColor:'#FFFFFF',layerOpacity:0.8,play_icon_width:60,play_icon_height:60},options||{}));if(this.insertElement){this.closeButton=$(document.createElement('div')).addClass('__CbUiFrameCloseButton').prependTo(this.element());this.autocenter();}},handleReady:function(options){this.base(options);if(this.closeButton){this.closeButton.click(jQuery.proxy(this.close,this));}}});
$(function(){"use strict";var
handleTicketsReserveForm=function(preselectedProductionId,preselectedEventId){var parent=$('.tickets-reserve .form'),fields=parent.find('[name]'),loader=$(document.createElement('div')).addClass('loader').width(parent.width()).height(parent.height()).css('opacity',0.9).appendTo(parent),productionField=fields.filter('[name="production"]'),productionFakeField=$(document.createElement('div')).addClass('fake-field').hide().insertAfter(productionField),locationField=fields.filter('[name="location"]'),locationFakeField=$(document.createElement('div')).addClass('fake-field').insertAfter(locationField),eventField=fields.filter('[name="event"]'),eventFakeField=$(document.createElement('div')).addClass('fake-field').hide().insertAfter(eventField),priceCategoryField=fields.filter('[name="price-category"]'),priceCategoryFakeField=$(document.createElement('div')).addClass('fake-field').hide().insertAfter(priceCategoryField),submit=parent.find('.submit'),formatPrice=function(price){if(price){if(price.indexOf(',00')===-1){price+=',00';}
return price.replace(',00',',\u2014')+' \u20AC';}
return'';};$.get(window.DOCUMENT_ROOT+'/ajax.php',{resource:'tickets_reserve_productions',environment:window.DSH_ENVIRONMENT},function(productions){var productionsById={},eventsById={};$.each(productions,function(index,production){var option=$(document.createElement('option')).val(production.id).text(production.title);if(preselectedProductionId&&production.id===preselectedProductionId){option.attr('selected','selected');}
productionsById[production.id]=production;$.each(production.events,function(index,event){eventsById[event.id]=event;});option.appendTo(productionField);});if(productionsById[preselectedProductionId]){productionField.hide();productionFakeField.text(productionsById[preselectedProductionId].title).show();}
productionField.unbind('change').change(function(){var productionId=productionField.find(':selected').val(),production=productionsById[productionId];eventField.empty();eventFakeField.text('');locationField.val(production.location);locationFakeField.text(production.location);$.each(production.events,function(index,event){var option=$(document.createElement('option')).val(event.id).text(event.date);if(preselectedEventId&&event.id===preselectedEventId){option.attr('selected','selected');}
option.appendTo(eventField);});if(production.events.length>1){eventField.show();eventFakeField.hide();}else{eventField.hide();eventFakeField.show().text(production.events[0].date);}
eventField.unbind('change').change(function(){var eventId=eventField.find(':selected').val();priceCategoryField.empty();priceCategoryFakeField.text('');$.each(eventsById[eventId].prices,function(index,price){$(document.createElement('option')).val(price).text(formatPrice(price)).appendTo(priceCategoryField);});if(eventsById[eventId].prices.length>1){priceCategoryField.show();priceCategoryFakeField.hide();}else{priceCategoryField.hide();priceCategoryFakeField.show().text(formatPrice(eventsById[eventId].prices[0]));}}).change();}).change();submit.unbind('click').click(function(e){var isFormValid=true,formData={};e.preventDefault();fields.removeClass('invalid').each(function(){var $this=$(this),fieldName=$this.attr('name'),fieldValue=$.trim($this.val()),isFieldValid=true;if($.inArray(fieldName,['amount','firstname','surname','phone'])!==-1&&fieldValue.length===0){isFieldValid=false;}
if($.inArray(fieldName,['email'])!==-1&&!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(fieldValue)){isFieldValid=false;}
if(!isFieldValid){$this.addClass('invalid');isFormValid=false;}else{if($this.filter('select').length>0){fieldValue=$this.find(':selected').text();}
formData[fieldName]=fieldValue;}});if(isFormValid){loader.show();$.post(window.DOCUMENT_ROOT+'/ajax.php',{resource:'reserve_tickets',fields:formData},function(response){loader.hide();if(response.message){alert(response.message);}},'json');}});loader.fadeOut(350);},'json');},handleSendAFriendForm=function(){var parent=$('.send-a-friend-form'),fields=parent.find('[name]'),loader=$(document.createElement('div')).addClass('loader').width(parent.width()).height(parent.height()).css('opacity',0.9).hide().appendTo(parent),messageField=fields.filter('[name="message"]'),submit=parent.find('.submit');submit.unbind('click').click(function(e){var isFormValid=true,formData={};e.preventDefault();fields.removeClass('invalid').each(function(){var $this=$(this),fieldName=$this.attr('name'),fieldValue=$.trim($this.val()),isFieldValid=true;if($.inArray(fieldName,['name','message'])!==-1&&fieldValue.length===0){isFieldValid=false;}
if($.inArray(fieldName,['email-from','email-to'])!==-1&&!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(fieldValue)){isFieldValid=false;}
if(!isFieldValid){$this.addClass('invalid');isFormValid=false;}else{formData[fieldName]=fieldValue;}});if(isFormValid){loader.show();$.post(window.DOCUMENT_ROOT+'/ajax.php',{resource:'send_a_friend',fields:formData},function(response){loader.hide();if(response.message){alert(response.message);}},'json');}});messageField.text(window.location.href);},handlePressDownloadRequestForm=function(){var parent=$('.press-download-request-form'),fields=parent.find('[name]'),loader=$(document.createElement('div')).addClass('loader').width(parent.width()).height(parent.height()).css('opacity',0.9).hide().appendTo(parent),mediumField=fields.filter('[name="medium"]'),submit=parent.find('.submit');submit.unbind('click').click(function(e){var isFormValid=true,formData={};e.preventDefault();fields.removeClass('invalid').each(function(){var $this=$(this),fieldName=$this.attr('name'),fieldValue=$.trim($this.val()),isFieldValid=true;if($.inArray(fieldName,['name','medium','medium-id'])!==-1&&fieldValue.length===0){isFieldValid=false;}
if($.inArray(fieldName,['email'])!==-1&&!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(fieldValue)){isFieldValid=false;}
if(!isFieldValid){$this.addClass('invalid');isFormValid=false;}else{formData[fieldName]=fieldValue;}});if(isFormValid){loader.show();$.post(window.DOCUMENT_ROOT+'/ajax.php',{resource:'press_download_request',fields:formData},function(response){loader.hide();if(response.message){alert(response.message);}},'json');}});};if($('.tickets-reserve').length>0){handleTicketsReserveForm();}
$('.mdb-image img').hover(function(){$(this).siblings('.tooltip').show();},function(){$(this).siblings('.tooltip').hide();}).mousemove(function(event){$(this).siblings('.tooltip').css({'left':(event.layerX||event.offsetX)-$(this).siblings('.tooltip').outerWidth()/2,'top':(event.layerY||event.offsetY)-$(this).siblings('.tooltip').outerHeight()-5});});$('.popup').click(function(){window.open(this.href);return false;});$('.performance h2').each(function(){var $this=$(this),text=$.trim($('a',$this).html().replace(/\s*\<br ?\/?\>\s*/gi,"\n")),targetLineCount=text.split("\n").length;if(targetLineCount>1){$this.css('font-size',Math.round(parseInt($this.css('font-size'),10)/(targetLineCount*1.16))+'px');}});Shadowbox.init({overlayColor:'#FFFFFF',overlayOpacity:0.8,counterType:'skip'});$('a.reserve-tickets').each(function(){var $this=$(this),isOpen=false;$this.click(function(e){var showSeatingPlan=!!$this.data('show-seating-plan');e.preventDefault();$this.blur();if(!isOpen){isOpen=true;$.get(window.DOCUMENT_ROOT+'/ajax.php',{'resource':'tickets_reserve_form','show_seating_plan':showSeatingPlan,'show_extra_description':!showSeatingPlan},function(template){createWindow({target:showSeatingPlan?null:$this,width:showSeatingPlan?990:350,onUnload:function(){isOpen=false;},content:template});handleTicketsReserveForm($this.data('preselected-production-id'),$this.data('preselected-event-id'));},'json');}});});$('a.send-a-friend').each(function(){var $this=$(this),isOpen=false;$this.click(function(e){e.preventDefault();$this.blur();if(!isOpen){isOpen=true;$.get(window.DOCUMENT_ROOT+'/ajax.php?resource=send_a_friend_form',function(template){createWindow({target:$this,width:450,onUnload:function(){isOpen=false;},content:template});handleSendAFriendForm();},'json');}});});$('.subscriberInfoButton').click(function(e){var content=$(this).data('infoboxcontent');createWindow({target:$(this),width:350,content:content});});$('.layer-player').each(function(){var self=$(this),videoId=parseInt(self.data('video-id'),10),previewImage=self.data('preview-image');if(!self.is('img')){$(document.createElement('div')).addClass('play-icon').appendTo(self);}
self.click(function(){CbPlayerWindow.create(null,{image:previewImage,movie_id:videoId,config:'dsh'},'DshPlayerWindow');});});$('.download-tm-file').each(function(){var $this=$(this),isOpen=false,fileId=$this.data('file-id');$this.click(function(e){e.preventDefault();$this.blur();if(!isOpen){isOpen=true;$.get(window.DOCUMENT_ROOT+'/ajax.php',{resource:'press_download_request_form',id:fileId},function(template){createWindow({target:$this,width:350,onUnload:function(){isOpen=false},content:template});handlePressDownloadRequestForm();},'json');}});});(function(){var fragmentPattern=/#(.+)$/;$('a').click(function(e){var matches=fragmentPattern.exec(this.href),target;if(matches){target=$(document.getElementById(matches[1]));if(target.length>0&&(target.hasClass('anchor-target')||target.is('body'))){$('html, body').animate({scrollTop:target.position().top+'px'},500);}}});}());var showElements=34;var hideMe=[];$('.calendar li:first-child').hide().click(function(){$('.calendar li').show();for(var i=0;i<hideMe.length;i++){hideMe[i].hide();}
$(this).hide();$('.calendar li:last-child').show();return false;});$('.calendar li:last-child').hide().click(function(){$('.calendar li.month').eq(1).prevAll().hide();$('.calendar li.month').eq(1).nextAll().show();$(this).hide();$('.calendar li:first-child').show();return false;});if($('.calendar li.month').length>1){for(var i=showElements;i<$('.calendar li').length;i++){if($('.calendar li').eq(i).prev().attr('class')!='month'||i>showElements){$('.calendar li').eq(i).hide();hideMe.push($('.calendar li').eq(i));}}
$('.calendar li:last-child').show();}});$(window).load(function(){if(window.location.hash!=''){window.scroll(0,$(window.location.hash).get(0).offsetTop);}});

