(function($){$.fn.simpleCarousel=function(settings){var G={config:{orientation:'h',nextSelector:'.next',prevSelector:'.prev',scrollItemSelector:'li',scrollItems:3},$this:this};if(settings){$.extend(G.config,settings);}
function init(el){var wrapper,totalWidth,parent,totalItems,$el;G.$this.each(function()
{$el=this;totalItems=$(this).find(G.config.scrollItemSelector).length;totalWidth=0;$(this).data({'simpleCarousel':{'currentItem':1,'totalItems':totalItems,'prevLink':'','nextLink':''}}).css({'overflow':'hidden','position':'relative'});if(G.config.orientation!=='v')
{$(this).find(G.config.scrollItemSelector).each(function(i){totalWidth+=$(this).outerWidth(true);});wrapper=$('<div></div>').css({'width':$(this).outerWidth(),'overflow':'hidden'});$(this).css({'width':totalWidth,'position':'absolute','left':0}).wrap(wrapper);}
parent=(G.config.orientation==='h')?$(this).parent().parent():$(this).parent();$(this).data().simpleCarousel.prevLink=parent.find(G.config.prevSelector);$(this).data().simpleCarousel.nextLink=parent.find(G.config.nextSelector);parent.find(G.config.nextSelector).data({'simpleCarousel':{'carousel':$el}}).click(function(e){e.preventDefault();var $el=$($(this).data().simpleCarousel.carousel),data=$el.data().simpleCarousel;if(data.currentItem<data.totalItems){data.currentItem+=G.config.scrollItems;data.currentItem=(data.currentItem>data.totalItems)?data.totalItems:data.currentItem;doScroll($el,data);disableLinks(this,data);data.currentItem=(data.currentItem>(data.totalItems-G.config.scrollItems))?(data.totalItems-(G.config.scrollItems-1)):data.currentItem;}});parent.find(G.config.prevSelector).data({'simpleCarousel':{'carousel':$el}}).click(function(e){e.preventDefault();var $el=$($(this).data().simpleCarousel.carousel),data=$el.data().simpleCarousel;if(data.currentItem>1){data.currentItem-=G.config.scrollItems;data.currentItem=(data.currentItem<0)?1:data.currentItem;doScroll($el,data);disableLinks(this,data);}}).addClass('disabled');});}
function doScroll($el,data){if(G.config.orientation==='h'){var w=0;$el.find(G.config.scrollItemSelector+':lt('+(data.currentItem-1)+')').each(function(){w+=$(this).outerWidth(true);});$el.animate({'left':w-(w*2)});}
else{$el.animate({'scrollTop':Math.ceil($el.find(G.config.scrollItemSelector+':nth-child('+data.currentItem+')').position().top)+$el.scrollTop()});}}
function disableLinks(el,data){var $nav=$(el).parent();if(data.currentItem>=data.totalItems){data.nextLink.addClass('disabled');}
else{data.nextLink.removeClass('disabled');}
if(data.currentItem<=1){data.prevLink.addClass('disabled');}
else{data.prevLink.removeClass('disabled');}}
init(this);return this;};})(jQuery);

(function($){$.fn.simpleTabs=function(settings){var G={config:{show:function($el){$el.show();},hide:function($el){$el.hide();},activeClass:'selected'},$this:this};if(settings){$.extend(G.config,settings);}
function init()
{var sID='';G.$this.each(function(i){$(this).find('li:gt(0)').each(function(y){sID+=','+$('a',$(this)).attr('href');});if ($('#contact').length == 0) {$(this).find('li:first').addClass(G.config.activeClass)};$(this).find('li').click(function(e){e.preventDefault();switchTabs(this);});});if(sID!==''){sID=sID.substr(1);$(sID).hide();}}
function switchTabs(el)
{var $sel=$('.'+G.config.activeClass,$(el).parent());G.config.hide($($('a',$sel).attr('href')));$sel.removeClass(G.config.activeClass);G.config.show($($('a',$(el)).attr('href')));$(el).addClass(G.config.activeClass);}
init();return this;};})(jQuery);

(function(){Shadowbox.init({'overlayOpacity':0.7,'handleOversize':'drag'});$(document).ready(function(){$('#nav-main ul > li').hover(function(){$(this).addClass('hover');$(this).find('ul').fadeIn('fast');},function(){$(this).removeClass('hover');$(this).find('ul').fadeOut('fast');});$('.carousel').simpleCarousel({nextSelector:'.next a',prevSelector:'.prev a',scrollItems:1});$('#case-study .tabs-nav').simpleTabs({activeClass:'active'});$('.image-list li').hover(function(){$(this).find('.info').show().animate({'top':'-=10'},300,'easeOutQuad');},function(){$(this).find('.info').css('top','').hide();});$('.teaser').find('.opacity').each(function(){$(this).data({'tarHeight':$(this).parent().outerHeight(),'iniHeight':$(this).outerHeight()});});$('.teaser').hover(function()
{var height=$(this).find('.opacity').data('tarHeight');$(this).addClass('hover').find('.opacity').css('cursor','pointer').animate({'height':height},200,'easeOutQuad');},function()
{var height=$(this).find('.opacity').data('iniHeight');$(this).removeClass('hover').find('.opacity').animate({'height':height},100,'easeOutQuad');});$('.teaser .opacity, .spotlight').bind('click',function(e){e.preventDefault();location.href=$(this).find('a:first').attr('href');});$('dl .tout').click(function(e){e.preventDefault();location.href=$(this).find('a:first').attr('href');}).hover(function(){$(this).css('cursor','pointer');});$('.flickr-carousel').flickr({api_key:"922071e1d8e37bbb75e224d71332c9e5",per_page:10,type:'search',user_id:'96697218@N00',sort:'date-posted-desc',randomise:true,thumb_size:'m',callback:function()
{$('.flickr-carousel .carousel').simpleCarousel({nextSelector:'.next a',prevSelector:'.prev a',scrollItems:1});}}).find('ul[class!=nav-carousel]').addClass('carousel');var $articleImg=$('#article #article-content img:first');if($articleImg.length)
{$('#article .hero').css('background','url('+$articleImg.attr('src')+') no-repeat right top');$articleImg.hide();$('#article .hero img:gt(0)').css('visibility','visible');}
else
{$('#article .hero img').css('visibility','visible');}
$('#view-work').click(function(e){e.preventDefault();$(this).parent().find('a[rel^=shadowbox]:first').trigger('click');});});})();
