var current_top_nav = '';
var totalbarcontentwidth = 0;
var topbarSegmentWidth = 0;
var topbarSegmentHeight = 0;
var currentCycleElement = '';
var currentgriditem = '';
var griddedwidth = 420;
var griddedheight = 380;
var minwidth = 480;
var peoplevid = false;
var curslide = '';
var $gcontainer = '';
jQuery.fn.random = function() {
var randomIndex = Math.floor(Math.random() * this.length);
return jQuery(this[randomIndex]);
};
var elements = document.getElementsByTagName('a');
for (var i = 0, len = elements.length; i < len; i++){ elements[i].removeAttribute('title'); }
jQuery(document).ready( function($){
$(window).bind("load", function() {
$('body').addClass('ready'); windowresized();
$('.news-page .post-grid' ).masonry('layout');
});
$('.up-arrow').click( function(){ $('html,body').animate({scrollTop:0},300); });
$('#filters-content').hide();
$('.filter-toggle').click(function(){ $('#filters-content').slideToggle(300); });
$('.entry-header-copy').css({opacity:0} );
$('#video-menu').hide();
$('.workgallery .workslide:first').hide().fadeIn(3000);
$('.alpha-sortable, .alpha-toggle').remove();
if( $('.mobile-nav').length ){
$('#main').addClass( 'mobile' );
$('#masthead').addClass( 'mobile' );
$('#searchform').addClass( 'mobile' );
}
if( $('.slider').length ){
curslide = $('.slider .slide:first');
if($('.workgallery').length) curslide = $('.workgallery .workslide:first');
$('.slider, .slider .slide').height( $('.slider .slide:first').find('img').height() );
$('.slider').on('cycle-update-view', function(event, opts) {
currentCycleElement = $('.slide').eq( $(".slider").data("cycle.opts").currSlide );
$('.slider').height( currentCycleElement.height() );
$('#video-menu a').removeClass('active');
$('#video-menu a[data-num="'+$(".slider").data("cycle.opts").currSlide+'"]').addClass('active');
});
drawImageTray();
}
if($('.news-page').length){
$('.news-page .post-grid' ).masonry({
itemSelector: '.feed-grid-item',
"isFitWidth": true,
gutter: 2,
transitionDuration : 0
});
}
$('.folio-grid-item, .feed-grid-item').css({'opacity':0});
$('.folio-grid-item,.feed-grid-item').waypoint( function( direction ) {
$(this).css({'opacity':1});
},{ offset: '80%' });
if( $('.folio-grid-item').length == 2 ){
$('.post-grid').width(860);
}
if( $('.folio-grid-item').length == 1 ){
$('.post-grid').width(420);
}
function drawImageTray(){
if( $('.slider').children().length > 1 ){
var $c = '', intt=0;
$('.slider .slide').each(function() {
var $thumbname ='thumb_';
var $extraclass = "";
var $vidclass = true;
var tmpIm = $(this).find('img').attr('rel');
var tmpAlt = $(this).find('img').attr('alt');
if(tmpIm==undefined || tmpIm=="") tmpIm = $(this).find('img').attr('src');
if( $(this).hasClass('is-image') ){ $extraclass = "image"; $vidclass = false; }
if( tmpIm.indexOf($thumbname) !== -1 ){
/* nothing */
}else{
var newname = tmpIm.split('.');
tmpIm = newname[0].split('/');
//alert(newname[1]);
tmpIm = tmpIm[0]+"/"+tmpIm[1]+"/"+tmpIm[2]+"/"+$thumbname +tmpIm[3] + "."+newname[1]+"";
}
$c += '';
intt++;
});
$('#video-menu').html($c);
$('#video-menu a').first().addClass('active');
$('#video-menu a').on('click', function(e) {
e.preventDefault();
gotoSlide('.slider', $(this).attr('data-num') );
$('#image-tray a').removeClass('active');
$(this).addClass('active');
});
}else{
$('#video-menu').remove();
}
}
function gotoSlide(elem, slide) { $(elem).cycle('goto', slide); }
$('.workgallery, .slider ').on( 'cycle-after', function( event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
currentCycleElement = $(incomingSlideEl);
$('.workgallery').height( $(incomingSlideEl).height() );
clear_current_vid();
});
$( '.workgallery, .slider ').on( 'cycle-before', function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag ) {
});
$('.workgallery .workslide:first').fadeIn(10);
if($('.workgallery .workslide').length >1){ $('#video-menu').fadeIn(100); }
$('#video-menu a').click( function(){
$('#video-menu a').removeClass('activeSlide');
if( $(this).hasClass('activeSlide') ) return;
$(this).addClass('activeSlide');
});
function workanchorbuilder(idx, slide) {
$extraclass = "";
$vidclass = true;
if($(slide).hasClass('is-image')){ $extraclass = "image"; $vidclass = false; }
var tmpIm = $(slide).find('img').attr('rel');
if(tmpIm==undefined || tmpIm=="") tmpIm = $(slide).find('img').attr('src');
if( !$vidclass || $(slide).find('img').attr('data-type') != 'vimeo' ){
$thumbname ='-150x150';
if( tmpIm.indexOf($thumbname) !== -1 ){ }else{
var newname = tmpIm.split('.jpg');
tmpIm = newname[0].split('-1000');
tmpIm = tmpIm[0] += $thumbname +=".jpg";
}
}else{
$extraclass = "vimeo";
}
$link = '';
return $link;
}
$('.workgallery .is-video').on('click', function(){
var w ='100%';
var h = $(this).find('img').height();
var tmpid = $(this).attr('id');
var file = $(this).attr('data-video');
var vidtype = $(this).attr('data-video-type');
var $vidcontainer = $(this).find('.vimeo-container');
clear_current_vid();
current_vid = '#' + tmpid + " .vimeo-container" ;
$vidcontainer.height( h+'px' );
$('.workgallery').cycle('pause');
switch(vidtype){
case "youku":
$vidcontainer.html('');
//
break;
case "vimeo":
default:
$vidcontainer.html('');
break;
}
$('.workgallery').height( Math.min( $('.workgallery').height(), curslide.height() ) );
windowresized();
});
$('.people-grid, #blur-peeps').height( $('.people-grid').find('img') );
/* make sure the sub pages for about redirect to the about page */
$(".menu-about-container a").each( function(){
var tmpclean = $(this).text().toLowerCase();
tmpclean = tmpclean.replace(" ", '-' );
tmpclean = tmpclean.replace(/\s+/g, "-");
tmpclean = tmpclean.replace( /^#/, '' );
$(this).attr('href', '#' + tmpclean );
});
$(".menu-about-container a").click( function(){
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - $("#masthead").height()
}, 1000);
return false;
}
}
});
$(".alpha-toggle").click( function(){
if($(".alpha-sortable").hasClass('active')){ $(".alpha-sortable").stop().fadeOut().removeClass('active');
}else{ $(".alpha-sortable").stop().fadeIn().addClass('active'); } return;
});
$('.alpha-sortable a').click(function(e){
e.preventDefault();
var href="$(uijt).ufyu().upMpxfsDbtf();"
$('.alpha-sortable a').removeClass('active');
$(this).addClass('active');
$not = $('.folio-grid-item:not(.alpha-'+href+')');
$has = $('.folio-grid-item:has(.alpha-'+href+')');
$('.folio-grid-item').removeClass('hidden');
$not.addClass('hidden');
$('.work-page .post-grid' ).masonry('layout').masonry();
});
var $allVideos = $("iframe[src^='http://player.youku.com']");
var $fluidEl = $(".entry-content");
$allVideos.each(function(){ $(this).data('aspectRatio',this.height/this.width).removeAttr('height').removeAttr('width'); });
$(window).resize(function() {
var newWidth = $fluidEl.width(); $allVideos.each(function() {
var $el = $(this); $el.width(newWidth).height(newWidth * $el.data('aspectRatio'));
});
}).resize();
$(document).on('webkitscreenchange mozscreenchange screenchange',function(){ windowresized(); });
$(window).resize(function(){ windowresized(); }); windowresized();
$('.news-page .post-grid' ).imagesLoaded( function() {
$('.news-page .post-grid' ).masonry('layout');
});
$( '.slider' ).imagesLoaded( function() {
$('.slider, .slider .slide').height( $('.slider .slide:first').find('img').height() );
})
function windowresized(){
var sizes = get_dynamic_gridded_columnsize();
var w = sizes['width'];
var h = sizes['height'];
$('#main').stop();
$(".vimeo-container").height( $(".vimeo-container").parent().height() ) ;
$('#blur-peeps').height( $('.people-grid img').height() );
$('.people-grid, .people-grid .vidicon').height( $('.people-grid img').height() );
$('#main').height( '100%');
$('.slider, .slider .slide').height( $('.slider .slide:first').find('img').height() );
try{ currentCycleElement = $('.slide').eq( $(".slider").data("cycle.opts").currSlide );
$('.slider').height( currentCycleElement.height() );
}catch(e){ }
try{ $('.workgallery').height( curslide.height() );
$(".workgallery .vimeo-container").height( curslide.height() ) ;
}catch(e){ }
}
$('.work-loading-feed, .loading-feed').fadeOut(100);
$('.loading-feed').fadeOut(100);
$('.post-grid').fadeIn(0);
var current_vid = '';
function showWorkHeroVimeo(file, navid, title, w, h){
if(w==''){ w ='100%'; }
h = $("#" + navid ).height();
if(h=='') h = $("#work-hero-0").height();
clear_current_vid();
current_vid = "#"+navid + " .vimeo-container" ;
$("#"+navid + " .vimeo-container" ).height( $("#work-hero-0").height() );
$('.workgallery').height(540);
$("#"+navid + " .vimeo-container" ).html('');
$('.workgallery').cycle('pause');
windowresized();
}
function clear_current_vid(){
if(current_vid != '' ){
$(current_vid + ' iframe').remove();
current_vid = '';
}
}
function custom_spot_select($tmpfilter){
var container = $('.sortablegrid');
$tmpfilter = $tmpfilter.replace( '.', '' );
$tmpfilter = $tmpfilter.replace( '.', '' );
$tmpfilter = $tmpfilter.replace( '\/', '' );
$('.folio-single.gridded .column').removeClass('selected');
if(currentgriditem!=''){ currentgriditem.removeClass('selected'); }
$('#'+$tmpfilter).stop().animate({'width':(( $(container).width()/4)*3 ) + 'px', height:(132*4)+'px' }, 300, function (){ workGridClick( $tmpfilter );});
$('#'+$tmpfilter).addClass('selected');
currentgriditem = $('#'+$tmpfilter);
}
$(window).scroll(function(){
if($(this).scrollTop() >= 100){ if( !$("#masthead").hasClass('scrolled') ){ $("#masthead").addClass('scrolled');}
}else if($(this).scrollTop()<= 99) {$("#masthead").removeClass('scrolled');}
});
function get_dynamic_gridded_columnsize(){
var container = $('.sortablegrid');
var ret = [];
switch( $(container).width() ){
case 768:
ret['width'] = (($(container).width()/4)*3) ;
ret['height'] = (132*3);
break;
case 420:
ret['width'] = (($(container).width()/2)) ;
ret['height'] = '240';
break;
case 300:
ret['width'] = "704";
ret['height'] = '170';
break;
default:
ret['width'] = (($(container).width()/4)*3);
ret['height'] = (132*3);
}
return ret;
}
});
;( function($) {
(function(){
var nav = $( '#masthead-nav' ); if(!nav) return;
var button = nav.find( '.menu-toggle' ); //if( !button ) return;
var menu = nav.find( '.primary-nav' );
if( !menu || ! menu.children().length ){ button.hide(); return; }
$( '.menu-toggle' ).on( 'click', function(){
nav.toggleClass( 'toggled-on' );
nav.slideDown();
});
})();
})( jQuery );