/**
* ASSEMBLED FILE.
* timestamp:  2019-01-02 03:54:52
* cache:      not cached
*/
/*
// Infinite Scroll jQuery plugin
// copyright Paul Irish, licensed GPL & MIT
// version 1.5.100504
// home and docs: http://www.infinite-scroll.com
*/
(function(A){A.fn.infinitescroll=function(R,O){function E(){if(B.debug){window.console&&console.log.call(console,arguments)}}function H(T){for(var S in T){if(S.indexOf&&S.indexOf("Selector")>-1&&A(T[S]).length===0){E("Your "+S+" found no elements.");return false}return true}}function N(S){S.match(C)?S.match(C)[2]:S;if(S.match(/^(.*?)\b2\b(.*?$)/)){S=S.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(S.match(/^(.*?)2(.*?$)/)){if(S.match(/^(.*?page=)2(\/.*|$)/)){S=S.match(/^(.*?page=)2(\/.*|$)/).slice(1);return S}E("Trying backup next selector parse technique. Treacherous waters here, matey.");S=S.match(/^(.*?)2(.*?$)/).slice(1)}else{if(S.match(/^(.*?page=)1(\/.*|$)/)){S=S.match(/^(.*?page=)1(\/.*|$)/).slice(1);return S}E("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");K.isInvalidPage=true}}return S}function L(){return B.localMode?(A(K.container)[0].scrollHeight&&A(K.container)[0].scrollHeight):A(document).height()}function F(){var S=0+L()-(B.localMode?A(K.container).scrollTop():(A(K.container).scrollTop()||A(K.container.ownerDocument.body).scrollTop()))-A(B.localMode?K.container:window).height();E("math:",S,K.pixelsFromNavToBottom);return(S-B.bufferPx<K.pixelsFromNavToBottom)}function M(){K.loadingMsg.find("img").hide().parent().find("div").html(B.donetext).animate({opacity:1},2000).fadeOut("normal");B.errorCallback()}function D(){if(K.isDuringAjax||K.isInvalidPage||K.isDone){return }if(!F(B,K)){return }A(document).trigger("retrieve.infscr")}function G(){K.isDuringAjax=true;K.loadingMsg.appendTo(B.contentSelector).show();A(B.navSelector).hide();K.currPage++;E("heading into ajax",Q);J=A(B.contentSelector).is("table")?A("<tbody/>"):A("<div/>");P=document.createDocumentFragment();J.load(Q.join(K.currPage)+" "+B.itemSelector,null,I)}function I(){if(K.isDone){M();return false}else{var T=J.children().get();if(T.length==0){return A.event.trigger("ajaxError",[{status:404}])}while(J[0].firstChild){P.appendChild(J[0].firstChild)}A(B.contentSelector)[0].appendChild(P);K.loadingMsg.fadeOut("normal");if(B.animate){var S=A(window).scrollTop()+A("#infscr-loading").height()+B.extraScrollPx+"px";A("html,body").animate({scrollTop:S},800,function(){K.isDuringAjax=false})}O.call(A(B.contentSelector)[0],T);if(!B.animate){K.isDuringAjax=false}}}A.browser.ie6=A.browser.msie&&A.browser.version<7;var B=A.extend({},A.infinitescroll.defaults,R),K=A.infinitescroll,J,P;O=O||function(){};if(!H(B)){return false}K.container=B.localMode?this:document.documentElement;B.contentSelector=B.contentSelector||this;var C=/(.*?\/\/).*?(\/.*)/,Q=A(B.nextSelector).attr("href");if(!Q){E("Navigation selector not found");return }Q=N(Q);if(B.localMode){A(K.container)[0].scrollTop=0}K.pixelsFromNavToBottom=L()+(K.container==document.documentElement?0:A(K.container).offset().top)-A(B.navSelector).offset().top;K.loadingMsg=A('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="'+B.loadingImg+'" /><div>'+B.loadingText+"</div></div>");(new Image()).src=B.loadingImg;A(document).ajaxError(function(T,U,S){E("Page not found. Self-destructing...");if(U.status==404){M();K.isDone=true;A(B.localMode?this:window).unbind("scroll.infscr")}});A(B.localMode?this:window).bind("scroll.infscr",D).trigger("scroll.infscr");A(document).bind("retrieve.infscr",G);return this};A.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,localMode:false,bufferPx:40,errorCallback:function(){}},loadingImg:undefined,loadingMsg:undefined,container:undefined,currPage:1,currDOMChunk:null,isDuringAjax:false,isInvalidPage:false,isDone:false}})(jQuery);;(function($) {
var COPY_VALUES = [
'fontFamily',
'fontSize',
'fontStyle',
'fontWeight',
'letterSpacing',
'lineHeight',
'paddingBottom',
'paddingLeft',
'paddingRight',
'paddingTop',
'textAlign',
'textDecoration',
'textIndent',
'textStroke',
'WebkitTextStroke',
'textTransform',
'verticalAlign',
'verticalAlign',
'whiteSpace',
'width',
'wordSpacing'
];
var SHRINK_FACTOR       = 0.95;
var LINEHEIGHT_PADDING  = 0.025;
var FONT_SIZE_THRESHOLD = 14;
var CONTAINER_ID        = 'shrink-to-fit-measure-container';
var BODY_FONT_SIZE 		= parseFloat($('body').css('font-size'));
$.fn.shrinkToFit = function(options) {
var settings = $.extend( {
'vcenter' : false
}, options);
var measureContainer = $('<div id="' + CONTAINER_ID + '"></div>')
.css({
position: 'absolute',
height: 'auto',
top: 0,
left: '-6174px'
})
.appendTo('body')
;
var chainableObject = this.each(function() {
var element = $(this);
// reset custom styles already set by shrinkToFit (or another function)
this.style.fontSize   = '';
this.style.lineHeight = '';
// copy css from original element to measure container
$.each(COPY_VALUES, function(index, value) {
// element.css('lineHeight') on ie9 returns the em value instead of the computed px value				
if (!/px/.test(element.css(value)) && value == 'lineHeight' && element.css(value) !== 'normal'){
measureContainer.css(value, element.css(value) * BODY_FONT_SIZE);
return;
}
measureContainer.css(value, element.css(value))
});
// set values 
$(measureContainer).html(element.html());
var fontSize   = parseInt(measureContainer.css('fontSize'), 10);
var lineHeight = parseInt(measureContainer.css('lineHeight'), 10);
// shrink height by whole text
var height = element.height();
while (measureContainer.height() > height) {
fontSize   *= SHRINK_FACTOR;
lineHeight *= (SHRINK_FACTOR+LINEHEIGHT_PADDING);
measureContainer.css('fontSize',   fontSize + 'px');
measureContainer.css('lineHeight', lineHeight + 'px');
if (fontSize < FONT_SIZE_THRESHOLD) { // to prevent infinite loops
break;
}
}
// shrink width by longest word
measureContainer.contents().filter(function() {
return this.nodeType === 3;
}).each(function() {
// replace text node by longest word
this.nodeValue = this.nodeValue.split(/\s+/).sort(function(one, other) { return one.length < other.length; })[0];
});
measureContainer.css('width', 'auto');
var width = element.width();
while (measureContainer.width() > width) {
fontSize *= SHRINK_FACTOR;
lineHeight *= (SHRINK_FACTOR+LINEHEIGHT_PADDING);
measureContainer.css('fontSize',   fontSize + 'px');
measureContainer.css('lineHeight', lineHeight + 'px');
if (fontSize < FONT_SIZE_THRESHOLD) { // to prevent infinite loops
break;
}
}
// set font size and line height
var newCss = {
fontSize:   fontSize + 'px',
lineHeight: lineHeight + 'px'
};
element.css(newCss);
});
$('body').remove('#' + CONTAINER_ID);
return chainableObject;
};
}(jQuery));
;/*!
* jQuery Cookie Plugin v1.3
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2011, Klaus Hartl
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function ($, document, undefined) {
var pluses = /\+/g;
function raw(s) {
return s;
}
function decoded(s) {
return decodeURIComponent(s.replace(pluses, ' '));
}
var config = $.cookie = function (key, value, options) {
// write
if (value !== undefined) {
options = $.extend({}, config.defaults, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = config.json ? JSON.stringify(value) : String(value);
return (document.cookie = [
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path    ? '; path=' + options.path : '',
options.domain  ? '; domain=' + options.domain : '',
options.secure  ? '; secure' : ''
].join(''));
}
// read
var decode = config.raw ? raw : decoded;
var cookies = document.cookie.split('; ');
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
if (decode(parts.shift()) === key) {
var cookie = decode(parts.join('='));
return config.json ? JSON.parse(cookie) : cookie;
}
}
return null;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) !== null) {
$.cookie(key, null, options);
return true;
}
return false;
};
})(jQuery, document);
;// see http://paulgueller.com/2011/04/26/parse-the-querystring-with-jquery/
jQuery.extend({
parseQuerystring: function(qs) {
var nvpair = {};
var qs = qs || window.location.search.replace('?', '');
if (qs) {
var pairs = qs.split('&');
$.each(pairs, function(i, v){
var pair = v.split('=');
nvpair[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
});
}
return nvpair;
}
});
;(function( $ ) {
$.fn.minislide = function(opts) {
var htmlData, wrapper, width, index, prevArrow, nexArrow, info, that, innerClass, url, hideTimeout;
switch (opts.type) {
case 'tweet':
innerClass = '.info';
break;
case 'instagram':
innerClass = '.thumb';
break;
case 'project':
innerClass = 'img.attachment-square-large, .youtube';
break;
}
that      = this;
index     = 0;
width     = opts.type == 'tweet' && !isMobile() ? 640 : 312;
url       = opts.type == 'tweet' ? '/sv/?rox=1&method=getAdditionalFrontPageTweets' : '?rox=1&method=getAdditionalFrontPageInstagrams';
info      = this.find(innerClass).not('.youtube-image');
nextArrow = this.find('.next');
prevArrow = this.find('.prev');
$(this).find('.info').addClass('visible');
$(this).find('.nav').addClass('visible');
// If we only have one image in slider, hide arrows
if ((info.length == 1 || info.length == 0) && opts.type == 'project') {
nextArrow.hide();
prevArrow.hide();
return;
};
if (info.length > 0) {
info.wrapAll('<div class="minislide-wrapper"><div class="minislide" /></div>');
wrapper = info.parent();
var top, left;		
switch(opts.type) {
case 'tweet':
top = info.position().top + 25;
left = 0;
break;
case 'instagram':
top = info.position().top + 4;
left = 2;
break;
case 'project':
top = info.position().top;
left =  0;
break;
}
var w = opts.type == 'tweet' ? '100%' : 312; 
var h = isMobile() ? 312 : info.outerHeight();
top = isMobile() && opts.type == 'tweet' ? 0 : top; 
wrapper.css({'height': h, 'width': width});
wrapper.parent().css({'height': '100%', 'width': w, 'top': top, 'left': left});
var getData = function (callback) {
// Load tweets or instagrams, fire callback if we already have data.
if (htmlData !== undefined || opts.type == 'project') {
wrapper.css({'width': $(innerClass, wrapper).not('.youtube-image').length * width})
callback(htmlData);
return;
}
$.ajax({url: url}).done(function (data) {
htmlData = data;
wrapper.append(data);
wrapper.css({'width': $(innerClass, wrapper).not('.youtube-image').length * width});
if (opts.type == 'instagram') {
wrapper.find('img')[1].onload = function () {
callback();
};
} else {
callback();
}
});
};
var slideLeft = function () {
index--;
index = index < 0 ? $(innerClass, wrapper).not('.youtube-image').length-1 : index;
//if (isMobile()) {
//	wrapper.css({'transform': 'translate3d('+(-(index*width))+'px,0,0)'});
//} else {
wrapper.animate({'left': -(index*width)}, {duration: 200});
//}
};
var slideRight = function () {
index++;
index = index > $(innerClass, wrapper).not('.youtube-image').length -1 ? 0 : index;
//if (isMobile()) {
//	wrapper.css({'transform': 'translate3d('+(-(index*width))+'px,0,0)'});
//} else {
wrapper.animate({'left': -(index*width)}, {duration: 200});
//}
};
var slide = function (e) {
if (isMobile()) {
//e.stopPropagation();
clearTimeout(hideTimeout);
$(this).find('.info').addClass('visible');
$(this).find('.nav').addClass('visible');
}
e.preventDefault();
var direction = $(this).attr('class');
var goLeft    = direction == 'prev';
var goRight   = direction == 'next';
goLeft  = isMobile() && e.type == 'swiperight' ? true : goLeft;
goRight = isMobile() && e.type == 'swipeleft' ? true : goRight;  
getData(function(data){
if (goLeft) {
slideLeft();	
}
if (goRight) {
slideRight();
}
if (opts.type == 'instagram') {
hideTimeout = setTimeout(hide, 5000);
} 
that.find('.nav .count span').text(index+1);
that.find('.info strong').text($($(innerClass, wrapper).get(index)).attr('data-author-id'));
});
};
var getVideo = function (e) {
var isYoutube = $(e.target).is('.youtube');
var url       = isYoutube ? $(e.target).attr('data-youtubeurl') : $(e.target).parent().attr('data-youtubeurl');
var youtube   = isYoutube ? $(e.target) : $(e.target).parent();
if (url !== undefined) {
youtube.addClass('playing');
youtube.find('img').remove();
youtube.append('<object type="application/x-shockwave-flash" class="youtube-video" data="'+url+'&autoplay=1"><param name="movie" value="'+url+'&autoplay=1" /> \
<param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /></object>');
}
};
$('.youtube', wrapper).on('click', getVideo);
// Mobile events
if (isMobile()) {
var hammer = Hammer(this, {
drag: false,
swipe_velocity: 0.1
});
Hammer(nextArrow).on('tap', slide);
Hammer(prevArrow).on('tap', slide);
hammer.on('swipeleft', slide);
hammer.on('swiperight', slide);
if (opts.type.match(/instagram|tweet/)) {
// Open instagram url on tap
hammer.on('tap', function (e) {
//console.log(e.target);
if ($(e.target).attr('class').match(/prev|next/)) {
return;
}
e.preventDefault();
if (opts.type == 'instagram') {
$(this).find('.info').addClass('visible');
$(this).find('.nav').addClass('visible');
window.location = $($('.thumb', this).get(index)).find('a').attr('href');
}
if (opts.type == 'tweet') {
window.location = $($('.info', this).get(index)).find('a.reply').attr('href');
}
});
}
} else {
nextArrow.on('click', slide); // Right
prevArrow.on('click', slide); // Left
}
function hide() {
if (isMobile() && opts.type == 'instagram') {
clearTimeout(hideTimeout);
/*$(that).find('.info').removeClass('visible');
$(that).find('.nav').removeClass('visible');*/
}
}
}
};
})( jQuery );
;hideTimeline();
// getComputedStyle polyfill for ie7
if (!window.getComputedStyle) {
window.getComputedStyle = function (el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
}
return this;
}
}
$(window).load(function () {
$('#cover article h2, .gridview h2').shrinkToFit();
});
$(document).ready(function () {
function updateDisqusCommentCount() {
var newsLoaded = $('div#newslist').find('div.post');
var disqusLoaded = $('div#disqus_thread');
if (disqusLoaded.length > 0) {
if (newsLoaded.length > 0) {
var type = 'news';
var firstClass = $('div.type-post').attr('class').split(' ')[0];
id = firstClass.split('-')[1];
} else {
var type = $('div.item').attr('data-type');
var id = $('div.item').attr('data-id');
}
var method = 'updateDisqusCommentCount';
$.ajax('?rox=1&method=' + method + '&id=' + id +'&type=' + type).done(function(response){
if (response != null) {
$('div.social a.comments').text(response);
}
});
}
}
updateDisqusCommentCount();
// open external links in a new window. These links must be marked with the rel attribute.
$('a[rel=external]').click(function () {
window.open(this.href);
return false;
});
$('a.share').on('click', function (e) {
e.preventDefault();
share($(this));
});
// set javascript variable to media query
$(window).resize(function() {
window.MEDIAQUERY_ID = !$.browser.msie && window.getComputedStyle(document.head, null).getPropertyValue('font-family').replace(/^_+/, '');
// special rule Instagram mobile
if (isMobile()) {
$('body').addClass('mobile');
$('#cover article.type-instagram').removeClass('size-small').addClass('size-large');
} else {
$('body').removeClass('mobile');
$('#cover article.type-instagram').removeClass('size-large').addClass('size-small');
}
hideTimeline();
}).resize();
// close popup on clicking outside
$(document).click(function(e) {
var langSelector = $('#langsel:visible');
if (langSelector.length && !$(e.target).is('a#js_langtoggle')) {
langSelector.slideUp(200);
}
var seasonInfopop = $('#seasoninfo:visible');
if (seasonInfopop.length && !$(e.target).is('#season-infobutton')) {
seasonInfopop.slideUp(200);
}
var gridPopup = $('#cover article.active-popup');
if (gridPopup.length) {
if ($(e.target).closest(gridPopup).length == 0) {
closePopup();
}
}
var sharePopup = $('body > .share-popup');
if (sharePopup.length && !$(e.target).is('a.share')) {
if ($(e.target).closest(sharePopup).length == 0)  {
sharePopup.slideUp(100, function () {
$(this).remove();
});
}
}
});
// Toggle comments area (mobile)
$("#togglecomments").click(function(){
$('#commentarea').slideToggle(function() {
$('#togglecomments a').text(
$(this).is(':visible') ? "Hide comments" : "Show comments"
);
});
return false;
});
// iOS + Android specific
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
if (ua.indexOf('iphone') > -1 || isAndroid) {
window.addEventListener('load', function() {
   setTimeout(scrollTo, 0, 0, 1);
}, false);
}
$(".totop a").click(function() {
$("html, body").animate({ scrollTop: 0 }, "easeinout");
return false;
});
// Language selector
if (isMobile()) {
$('#js_langtoggle').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$('#langsel').slideDown(200);
});
} else {
$('#js_langtoggle').on('mouseover', function() {
$('#langsel').slideDown(200);
});
$('#langsel').on('mouseleave', function () {
$('#langsel').slideUp(200);
});
}
// Calendar info
$('#season-infobutton').click(function(){
$('#seasoninfo').slideToggle(200);
});
// Start grid
var MODE_REPOSITION = 'reposition';
var MODE_SCALE      = 'scale';
var match = $('body').attr('class').match(/\bmode-(\w+)\b/);
var DESIGN_MODE;
if (match) {
DESIGN_MODE = match[1];
}
$('#cover article').hover(
function() {$(this).addClass('hover'); },
function() {$(this).removeClass('hover'); }
);
$('#cover article > *').click(function(e) {
var article = $(this).closest('article');
var matches = article.attr('class').match(/type-(\w+)/);
var type    = matches ? matches[1] : undefined;
e.stopPropagation();
closePopup();
if (type == 'link' || type == 'feature' || type == 'content' || type == 'push' || type == 'highlight') {
return true;
}
e.preventDefault();
if (article.is('.more')) {
showMore();
} else if (!article.is('.active-popup')) {
if (isMobile()) {
if (type =='event' || type == 'news' || type == 'project') {
location.href = article.find('a.moreinfo').attr('href');
}
} else if (type != 'emptybox') {
tilePopup(article);
}
}
});
if (DESIGN_MODE == MODE_REPOSITION) {
$('article.type-event .thumb img, article.type-instagram .thumb img').hoverImageShift({
offsetX: 10,
offsetY: 10,
hoverHandle: function(obj) {
return obj.parent().prev().is('.dim') ? obj.parent().prev() : obj;
}
});
}
$("#cover").click(function(e) {
if ($(e.target).closest('.dim').length) {
e.preventDefault();
closePopup();
}
if ($(e.target).closest('article.active-popup').length) {
return;
}
e.preventDefault();
closePopup();
});
$(document).keyup(function(e) {
switch(e.keyCode) {
case 27:
case 88:
closePopup();
break;
default:
// console.log(e.keyCode);
}
});
// toggle listview/gridview
$('ul.viewoptions .gridview').click(function(e) {
setViewOption(e, 'gridview');
});
$('ul.viewoptions .listview').click(function(e) {
setViewOption(e, 'listview');
});
var setViewOption = function(e, viewType) {
$.cookie('viewtype', viewType, { expires: 30, path: '/' });
var onFavoritePage = $('#calendar.favorites').length > 0 || $('#projects.favorites').length > 0;
if (onFavoritePage) {
return;
}
e.preventDefault();
$('ul.viewoptions a').removeClass('active');
$('ul.viewoptions li.' + viewType + ' a').addClass('active');
$('body.page-template-page-events-php #calendar, body.page-template-page-project-php #projects, #news')
.removeClass('listview')
.removeClass('gridview')
.addClass(viewType)
;
if (viewType == 'listview'){
$('.listview h2').removeAttr('style');
} else {
setTimeout(function () {
$('.gridview h2').shrinkToFit();
}, 200);
}
};
// image click opens event/project in overview pages
$('body.page-template-page-events-php #calendar img, body.page-template-page-project-php #projects img').live('click', function() {
location.href = $(this).parent().find('a.moreinfo').attr('href');
});
// whole box in gridview as a link
$('section.gridview li').live('click', function() {
var url = $(this).find('a.moreinfo').attr('href');
location.href = url;
});
// Handles tap on calendar beacuse hammer.js doesn't support .live()
var touches = {timestamp: 0};
$('#calendar-overview td a').live('touchstart touchend', function (e) {
if (e.type == 'touchstart') {
touches.timestamp = e.timestamp;
}
if (e.type == 'touchend') {
if (e.timestamp < touches.timestamp + 20) {
touches.timestamp = 0;
$(this).click();
}
}
});
// calendar: hijack calendar links and append anchor
$('#calendar-overview td a').live('click', function (e) {
e.preventDefault();
if ($(e.target).parent().parent().is('.inactive')) {
return;
}
window.location.href = ($(this).attr('href') + '/#calendar');
});
// calendar: prev/next month
if ($('#calendar-overview').length) {
if (isMobile()) {
$('#calendar-overview').height($('#calendar-overview ul li:first').height());
}
var animating = false;
var setHeight = (function () {
var height = 0;
$('#calendar-overview ul li').each(function () {
height += $(this).outerHeight()+17;
});
$('#calendar-overview ul').height(height);
}());
var asYM = function(monthData) {
var _parts = monthData.split('-');
return {
year:  parseInt(_parts[0], 10),
month: parseInt(_parts[1], 10)
};
};
var toggleCalendarControls = function() {
/*var first = asYM($('#calendar-overview li:first').data('month'));
if ((first.year == 2013 && first.month <= 1) || first.year < 2013) {
$('#calendar-overview > a.prev').addClass('inactive');
}
var last = asYM($('#calendar-overview li:last').data('month'));
if ((last.year == 2015 && last.month >= 1) || last.year > 2015) {
$('#calendar-overview > a.next').addClass('inactive');
}*/
};
var getLink = function(date) {
var params = 'rox=true&method=getMonthCalendar&date=' + date.year + '-' + date.month + '&lang=' + UME_LANG;
var cat    = parseInt($('.filteroptions a.active').attr('href').replace('?cat=', ''), 10);
if (cat) {
params += '&cat=' + cat;
}
return '?' + params;
}
var getHeight = function (html) {
var testDiv = $('<div class="test-height-div">' + html + '</div>');
$('body').append(testDiv);
var height = testDiv.outerHeight();
testDiv.remove();
return height;
}
$('#calendar-overview > a.prev').click(function(e) {
e.preventDefault();
if (animating) return;
animating = true;
var date = asYM($('#calendar-overview li:first').data('month'));
if (date.month == 1) {
date.year--;
date.month = 12;
} else {
date.month--;
}
$.ajax(getLink(date)).done(function(content) {
if (isMobile()) {
var c = $(content);
var w = 313;
c.css('margin-left', -w);
$('#calendar-overview  ul').prepend(c);
c.animate({'margin-left': 0}, {complete: function () {
$('#calendar-overview ul li:last').remove();
animating = false;
}, duration: 200});
$('#calendar-overview').css({'height': c.height()});
toggleCalendarControls();
return;
}
var h = getHeight(content);
var c = $(content);
c.css('margin-top', -(h+14));
$('#calendar-overview ul').prepend(c);
c.animate({'margin-top': 0}, {complete: function(){
$('#calendar-overview ul li:last').remove();
}, duration: 200});
var height = 0;
$('#calendar-overview ul li').not(':last').each(function () {
height += $(this).outerHeight()+17;
});
$('#calendar-overview ul').animate({'height': height}, {duration: 200, complete: function() {
animating = false;
}});
toggleCalendarControls();
});
});
$('#calendar-overview > a.next').click(function(e) {
e.preventDefault();
if (animating) return;
animating = true;
var date = asYM($('#calendar-overview li:last').data('month'));
if (date.month == 12) {
date.year++;
date.month = 1;
} else {
date.month++;
}
$.ajax(getLink(date)).done(function(content) {
$('#calendar-overview ul').append(content);
if (isMobile()) {
var first = $('#calendar-overview ul li:first');
var next = first.next();
first.animate({'margin-left': -(first.outerWidth())}, {complete: function () {
animating = false;
first.remove();
}, duration: 200});
toggleCalendarControls();
$('#calendar-overview').css({'height': next.height()});
return;
}
var height = 0;
$('#calendar-overview ul li').not(':first').each(function () {
height += $(this).outerHeight()+17;
});
$('#calendar-overview ul').animate({'height': height}, {duration: 200});
var first = $('#calendar-overview ul li:first');
first.animate({'margin-top': -(first.outerHeight() + 14)}, {complete: function () {
animating = false;
first.remove();
}, duration: 200});
toggleCalendarControls();
});
});
toggleCalendarControls();
}
// Mobile instagram slider
$('body.mobile article.type-instagram').minislide({type: 'instagram'});
// Mobile tweet slider
$('body.mobile article.type-tweet').minislide({type: 'tweet'});
// Featured items
$('article.type-feature .dot-nav .dot').on('click', function () {
var index = $(this).index();
var list = $(this).parent().parent().find('ul');
var width = $(this).parent().parent().width();
list.animate({'left': index*(-width)});
$(this).siblings().removeClass('active');
$(this).addClass('active');
});
var FeaturedSlider = function (element) {
var index, width, count, INTERVAL, timer, that;
that     = this;
element  = $(element);
count    = element.find('.dot').length;
width    = element.width();
INTERVAL = 6000;
var slide = function () {
var current = element.find('.active');
index       = current.index();
index++;
if (index == count) index = 0;
current.removeClass('active');
$(element.find('.dot').get(index)).addClass('active');
element.find('ul').animate({'left': index*(-width)})
}
this.start = function () {
timer = setInterval(slide, INTERVAL);
}
this.stop = function () {
clearInterval(timer);
}
}
$('article.type-feature').each(function(i, a) {
var f = new FeaturedSlider(this);
f.start();
});
$('body.page-template-page-project-php .project-aside, body.page-template-page-events-php #main').minislide({type: 'project'});
// news archive
$('.ume_archive').each(function() {
$(this).click(function(e) {
$yheader=$(this);
e.preventDefault();
$yheader.next("ul").slideToggle(function(){
if ($(this).is(":visible")) {
$yheader.addClass('expanded').removeClass('collapsed');
} else {
$yheader.addClass('collapsed').removeClass('expanded');
}
});
});
if (!$(this).hasClass('expanded')) {
$(this).addClass('collapsed').next("ul").hide();
}
});
// favorites
$('a.favorite').live('click', function(e) {
e.preventDefault();
var trigger = $(this);
var item = trigger.closest('.item');
if (item.length == 0) {
window.console && console.warn('no item class found');
return;
}
var id   = item.data('id');
var type = item.data('type');
if (type == 'project') {
var method = trigger.hasClass('is-favorite') ? 'removeProjectFavorite' : 'addProjectFavorite';
} else if (type == 'event') {
var method = trigger.hasClass('is-favorite') ? 'removeEventFavorite' : 'addEventFavorite';
} else {
return; // silent ignore
}
$.ajax('?rox=1&method=' + method + '&id=' + id).done(function(response) {
// sync not only with trigger item but with all items of same id and type
var items = $('.item[data-id=' + id + '][data-type=' + type +']');
items.find('a.favorite').text(response).toggleClass('is-favorite');
// special case: favorite page
items.each(function() {
var item    = $(this);
var trigger = item.find('a.favorite');
if(!trigger.hasClass('is-favorite') && trigger.closest('.favorites.listview').length) {
var list = item.parent('ul.eventlist');
//console.log(list.length, list.children('li').length);
if (list.length && list.children('li:visible').length <= 1) { // an event list with only one event coming to delete ..
list.prev('div.date-separator').slideUp(); // .. hide date separator as well
}
item.slideUp(function() {
item.remove();
if ($('#content li.item').length == 0) {
// show message 'no favorites'
$('div.no-favorites').removeAttr('hidden').hide().slideDown();
}
});
}
});
});
});
// endless scrolling
(function() {
if ($('#eventcalendar').length == 0 || $('#calendar ul.eventlist').length == 0 || $('#calendar').hasClass('favorites')) {
return;
}
if (isMobile()) {
return;
}
var w = $(window), d = $(document), b = $('body');
var lock = function() {
b.addClass('scroll-process');
}
var isLocked = function() {
return b.hasClass('scroll-process');
}
var release = function() {
b.removeClass('scroll-process');
}
w.scroll(function() {
if (!isLocked() && w.scrollTop() / (d.height() - w.height()) > 0.95) {
lock();
$('#calendar').append('<div class="throbber"></div>').hide().fadeIn();
var _d        = $('#calendar ul.eventlist:last').data('date').split('-');
var date      = new Date(_d[0], _d[1] - 1, _d[2]);
date.setTime(date.getTime() + 86400000);
var dateParam = date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate();
var params    = $.parseQuerystring();
var url       = location.pathname.replace(/[0-9\/]*$/, '') +  '/' + dateParam + '?xhr=1';
if (params.cat) {
url += '&cat=' + params.cat;
}
$.ajax(url).done(function(response) {
if (response) {
$('#calendar').append(response);
release();
} else {
// console.log('nothing more to load');
}
$('#calendar div.throbber').remove();
});
}
});
}());
// init disqus
(function() {
if (isMobile() || !window.disqus_shortname) {
return;
}
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
// Video page
$("#overlay").click(function(){
$(this).hide();
$("body").css("overflow","auto");
$("#overlaycontent").empty().hide();
});
$(".video").click(function(e) {
var ID=this.id.replace("video_","");
if (isMobile()) {
window.location=document.getElementById("video_link_"+ID).href;
} else {
e.preventDefault();
$("body").css("overflow","hidden"); // when clicking on sth below the fold
$("#overlay").show();
$("#overlaycontent").show().html(eval("video_html_"+ID));
}
});
// Sound page
$(".js_changesound").click(function (e){
e.preventDefault();
e.stopPropagation();
if (this.tagName.toUpperCase()!=='A') {
var url=$(this).find('a')[0].getAttribute('data-ajax-url');
} else {
var url=this.getAttribute('data-ajax-url');
}
if (!url.match(/17-18$/)) {
$.ajax(url).done(function(response) {
if (response) {
$('#defaultcontent').hide();
$('#soundcontent').html(response).show();
initSound();
} 
});
}
});
function initSound() {
$(".playpause").click(function(e){
e.preventDefault();
var $audio=$(this).prev("audio")[0];
if ($audio.paused || $audio.currentTime===0) {
$audio.play();
$(this).children('.ispaused').hide();
$(this).children('.isplaying').show();
} else {
$audio.pause();
$(this).children('.isplaying').hide();
$(this).children('.ispaused').show();
}
});
}
initSound();
}); // end ready()
function tilePopup(article) {
var classes     = article.attr('class');
var left        = parseInt(classes.match(/\bl(\d)\b/)[1], 10);
var top         = parseInt(classes.match(/\bt(\d)\b/)[1], 10);
var isInstagram = /\btype-instagram\b/.test(classes);
var isTweet     = /\btype-tweet\b/.test(classes);
var growLeft    = left >= 3;
var growTop     = top  >= 2;
var width       = article.is('.size-small') ? 1 : 2;
var height      = article.is('.size-large') ? 2 : 1;
var leftOffset  = isInstagram ? -1 : -4;
var topOffset   = isInstagram ? -1 : -2;
var newLeft     = growLeft ? left + width + leftOffset : left;
var newTop      = growTop  ? top + height + topOffset  : top;
var newArticle = article.clone()
.attr('class', classes.replace(/(\b[lt]\d\b)/g, ''))
.addClass('active-popup')
.addClass('l' + newLeft)
.addClass('t' + newTop)
.addClass(growLeft ? 'image-on-right' : 'image-on-left')
.addClass(growLeft ? 'grow-left' : 'grow-right')
.addClass(growTop  ? 'grow-top' : 'grow-bottom')
;
newArticle.find('div.close').click(function(e) {
e.preventDefault();
closePopup();
});
newArticle.find('a.share').on('click', function (e) {
e.preventDefault();
share($(this));
});
newArticle.find('div.thumb img').removeAttr('style');
newArticle.append(newArticle.find('div.thumb'));
newArticle.find('a div.thumb').remove();
article
.closest('.article-group')
.append(newArticle)
.closest('#cover')
.append($('<div class="popup-overlay"></div>'))
;
$('#cover .popup-overlay').animate({'opacity': '0.5'}, 200);
article.find('img').hide();
animateOpenPopup(newArticle)
if (isTweet){
newArticle.minislide({type: 'tweet'});
} else if (isInstagram) {
newArticle.minislide({type: 'instagram'});
}
}
function share (button) {
if ($('body > .share-popup').length > 0){
$('body > .share-popup').slideUp(100, function () {
$(this).remove();
});
return;
}
var originalPopup = button.parent().find('.share-popup');
var popup = originalPopup.clone();
popup.css({'left': (button.offset().left - originalPopup.width()+35), 'top': button.offset().top + 20});
$('body').append(popup);
popup.slideToggle(100);
}
function getArticleType(article) {
var _matches = article.attr('class').match(/\btype-(\w+)\b/)
return _matches ? _matches[1] : undefined;
}
TILE_LARGE_W     = 312; // @tile-large-w:	312px;
TILE_LARGE_H     = 312; // @tile-large-h:	312px;
TILE_SMALL_W     = 152; // @tile-small-w:	152px;
TILE_SMALL_H     = 152; // @tile-small-h:	152px;
POPOUT_PADDING   = 7;
GRID_PADDING     = 8;
POPUP_SLIDE_TIME = 300;
POPUP_THUMB_TIME = 100;
function closePopup() {
// $('article').removeClass('hover');
$('body > .share-popup').remove();
var $popup = $('article.active-popup');
function postAnimation() {
$('#cover article div.thumb img').show();
$($popup).remove();
$('div.popup-overlay').remove();
}
if ($popup.length) {
var type = getArticleType($popup);
$popup.addClass("animating");
if(type == "project") {
type = "event"; // The same animation
}
/*
popup.removeClass('animation-2');
window.setTimeout(function() {
popup.removeClass('animation-1');
}, 200);
*/
function stage2Anim() {
if($popup.hasClass("size-small")) {
$popup.addClass("animating-stage-1");
$popup.find(".thumb, .minislide, img").not('.profile-pic').animate({width:TILE_SMALL_W,height:TILE_SMALL_H},POPUP_THUMB_TIME,postAnimation);
var expandAnim = {width:TILE_SMALL_W + POPOUT_PADDING * 2,height:TILE_SMALL_H + POPOUT_PADDING * 2};
if($popup.hasClass("grow-left")) {
if(type == "instagram") {
$.extend(expandAnim,{left:TILE_SMALL_W});
} else {
$.extend(expandAnim,{left:TILE_LARGE_W + GRID_PADDING + TILE_SMALL_W});
}
}
if($popup.hasClass("grow-top")) {
$.extend(expandAnim,{top:TILE_SMALL_H});
}
$popup.find(".expand").animate(expandAnim,POPUP_THUMB_TIME);
} else if($popup.hasClass("size-landscape")) {
var expandAnim = {width:TILE_LARGE_W + POPOUT_PADDING * 2,height:TILE_SMALL_H + POPOUT_PADDING * 2};
if($popup.hasClass("grow-left")) {
// Type:tweet
$.extend(expandAnim,{left:TILE_LARGE_W});
}
if($popup.hasClass("grow-top")) {
$.extend(expandAnim,{top:TILE_SMALL_H});
}
$popup.find(".expand").animate(expandAnim,POPUP_THUMB_TIME,postAnimation);
} else {
postAnimation();
}
}
if(type == "event" || type == "news") {
/*
popup = {background: "#fff"};
$popup.animate(popup,200);
*/
if($popup.hasClass("grow-left")) {
$popup.css({'margin-left': -4, 'margin-top': -4});
var options = {width: TILE_LARGE_W  + 14, left:TILE_LARGE_W};
} else {
$popup.css({'margin-left': -4, 'margin-top': -4});
var options = {width: TILE_LARGE_W  + 14};
}
$popup.find(".expand").animate(options,POPUP_SLIDE_TIME,stage2Anim);
} else if(type == "instagram") {
$popup.find(".expand").animate({height:TILE_LARGE_H + POPOUT_PADDING * 2},POPUP_SLIDE_TIME/2,stage2Anim);
} else if(type == "tweet") {
$popup.find(".expand").animate({height:TILE_LARGE_H + POPOUT_PADDING * 2},POPUP_SLIDE_TIME,stage2Anim);
} else {
postAnimation();
}
}
}
function animateOpenPopup($popup) {
// $popup.animate({height:TILE_LARGE_H + 14},300);
var type = getArticleType($popup);
$popup.addClass("animating");
if(type == "project") {
type = "event"; // The same animation
}
var growLeftMargin  = $popup.hasClass('grow-top') ? {'margin-left': -11, 'margin-top': -9} : {'margin-left': -11, 'margin-top': 4};
var growRightMargin = $popup.hasClass('grow-top') ? {'margin-left': 4, 'margin-top': -9}   : {'margin-left': 4, 'margin-top': 4};
function postAnim() {
$popup.removeClass("animating");
}
function postResize() {
if(type == "event" || type == "news") {
if($popup.hasClass("grow-left")) {
$popup.css(growLeftMargin);
$popup.find(".expand").animate({width:TILE_LARGE_W * 2 + POPOUT_PADDING * 2 + GRID_PADDING,left:-4},POPUP_SLIDE_TIME, postAnim);
} else {
$popup.css(growRightMargin);
$popup.find(".expand").animate({width:TILE_LARGE_W * 2 + POPOUT_PADDING * 2 + GRID_PADDING},POPUP_SLIDE_TIME,postAnim);
}
$popup.removeClass("animating-stage-1");
} else if(type == "instagram") {
$popup.find(".expand").animate({height:TILE_LARGE_H + POPOUT_PADDING * 2 + 40},POPUP_SLIDE_TIME/2,postAnim);
} else {
postAnim();
}
}
if($popup.hasClass("size-large")) {
postResize();
} else {
if(type == "tweet") { // 4x2
var expandAnim = {width:TILE_LARGE_W * 2 + GRID_PADDING + POPOUT_PADDING * 2,height:TILE_LARGE_H + POPOUT_PADDING * 2};
} else { // 2x2
var expandAnim = {width:TILE_LARGE_W + POPOUT_PADDING * 2,height:TILE_LARGE_H + POPOUT_PADDING * 2};
}
if($popup.hasClass("grow-left")) {
if(type == "instagram") {  // only 2x2 in the grid
$.extend(expandAnim,{left:-4});
} else if (type == 'tweet') {
$.extend(expandAnim);
} else { // 4x2 in the grid
$.extend(expandAnim,{left:TILE_LARGE_W + GRID_PADDING});
}
}
if($popup.hasClass("grow-top")) {
$.extend(expandAnim,{top:-4});
}
if(type == "event" || type == "news") {
$popup.addClass("animating-stage-1");
}
var animTime = POPUP_THUMB_TIME;
if(type == "tweet") {
animTime = POPUP_SLIDE_TIME
}
$popup.find(".expand").animate(expandAnim,{duration: animTime, complete: postResize});
$popup.find(".thumb, .minislide, img").not('.profile-pic').animate({width:TILE_LARGE_W,height:TILE_LARGE_H},animTime,postResize);
}
$popup.find('h2').shrinkToFit();
/*
window.setTimeout(function() {
$popup.addClass('animation-1');
$popup.addClass('animation-2');
}, 10);
*/
}
function showMore() {
$('article.more').fadeOut();
$('.article-group').slideDown();
var top = $('.article-group:last').offset().top;
window.setTimeout(function() {
$('body').animate({scrollTop : top - 200}, 'slow');
}, 100);
}
/*
start-grid load animation
*/
var animStartDelay = $.browser.mozilla ? 200 : 0;
var animDelay = 0;
$(".article-group").each(function() {
var group = this;
$("article.area",group).each(function() {
var width = $(this).width()+5; // added pixels to hide unsynced left/width animation
var height = $(this).height()+5;
var offset = $(this).position();
var $animDiv = $('<div class=init-anim></div>')
.css($.extend({width:width,height:height},offset))
.appendTo(group);
var animations = [{width:0},{height:0},{top:offset.top+height,height:0},{left:offset.left,width:0}];
animDelay+=40
setTimeout(function() {
//$animDiv.animate(animations[0],function() {
$animDiv.animate(animations[Math.floor(Math.random() * 4)],function() {
$animDiv.remove();
});
}, animDelay + 50 * (Math.floor(Math.random() * 6)) + animStartDelay);
});
});
setTimeout(function() {
$('body').addClass('animstart');
},animStartDelay);
$(window).load(function(){
$('body').addClass('loaded');
});
if (isIE7) {
// Inherit fix for ie7
$('.season .details').each(function(){
$(this).css({'background-color': $(this).parent().css('background-color')});
});
}
$.browser.mozilla && $('body').addClass('mozilla');
function isMobile() {
return window.MEDIAQUERY_ID == 'mobile';
}
function hideTimeline () {
if (($.browser.msie && parseInt($.browser.version, 10) < 9) || isMobile()) {
$('.menu-item a').each(function(){
if (this.href.match(/(tillbakablickar|flashbacks)/)) {
$(this).css('display', 'none');
    }
});
$('.timelinelink').css('display', 'none');
}
}
;// To  avoid triggering error when using console.log in ie7
if (!window.console) {
(function() {
var names = ["log", "debug", "info", "warn", "error",
"assert", "dir", "dirxml", "group", "groupEnd", "time",
"timeEnd", "count", "trace", "profile", "profileEnd"],
i, l = names.length;
window.console = {};
for ( i = 0; i < l; i++ ) {
window.console[ names[i] ] = function() {};
}
}());
}
// end of ie7 workaroud
$(document).ready(function(){
/*
* Samian slider
*/
(function(){
// Is one element focused by default?
var HAS_CURRENT =  ($(".season-nav .season.current").length > 0);
var CONTAINER_WITH = 952;
// With of an expanded element.
var WITH_EXP = $(".season-nav .season.last").width();
var CHILDS = 8;
// Default with of an element
var WITH = $(".season-nav .season:not(.current):not(.last)").width();
if(!HAS_CURRENT) {
// The with of the other elements when one is highligted.
var SHADOWED_WITH = (CONTAINER_WITH - WITH_EXP) / (CHILDS -1);
} else {
var CURRENT_WIDTH = $(".season-nav .season.current").width();
var WITH_EXP = 208;
var SHADOWED_WITH = WITH;
// The with of the current one when we are focusing on a season.
var SHADOWED_WITH_CURRENT = CURRENT_WIDTH - WITH_EXP  + SHADOWED_WITH;
}
//console.dir({with:WITH,shad_with:SHADOWED_WITH});
var ANIM_TIME = 500;
// Set the z-indexes.
var zIndex = 50;
$(".season-nav .season").each(function() {
$(this).css({"z-index":zIndex--});
});
$(".season-nav .season").hover(function() {
// enter
//console.log("enter " + $(".season-nav .season").index(this));
$(this).filter(":not(.last):not(.current)").stop().animate({width: WITH_EXP},ANIM_TIME);
if(HAS_CURRENT) {
$(".season-nav .season.current:not(.last)").not(this).stop().animate({width:SHADOWED_WITH_CURRENT},ANIM_TIME);
} else {
$(".season-nav .season:not(.last)").not(this).stop().animate({width:SHADOWED_WITH},ANIM_TIME);
}
}, function() {
// leaves
//console.log("exit " + $(".season-nav .season").index(this));
$(this).filter(":not(.last)").stop().animate({width: WITH},ANIM_TIME,
function(){
// To fix half pixel issiue.
$(this).css({width:""})
});
if(HAS_CURRENT) {
$(".season-nav .season.current").filter(":not(.last)").stop().animate({width:CURRENT_WIDTH},ANIM_TIME);
} else {
$(".season-nav .season").filter(":not(.last)").not(this).stop().animate({width:WITH},ANIM_TIME);
}
});
// Self invocing anonomus function end
})();
(function(){
var EXPANDED_HEIGHT = 100;
var ANIM_TIME = 500;
var COLAPSED_HEIGHT = $(".season-main .season .details").height();
$(".season-main .season").hover(function(){
// Enter
$(".details",this).stop().animate({height:EXPANDED_HEIGHT},ANIM_TIME);
}, function() {
// Leave
$(".details",this).stop().animate({height:COLAPSED_HEIGHT},ANIM_TIME);
});
})();
// End of document ready
});
;