(function($){$.widget('cure.simpleSlideshow',{options:{'randomizeStart':false,'autoPlay':true,'transitionTime':500,'displayTime':3000},_create:function(){var self=this;$(this.element).each(function(){self.options.slides=$(this).children();self.options.length=self.options.slides.size();self.options.currentIndex=0;if(self.options.length>1){if(self.options.randomizeStart){self.options.currentIndex=Math.floor(Math.random()*self.options.length);}
self.options.slides.css({'position':'absolute','display':'none','opacity':0.0,'z-index':0});var firstSlide=self.options.slides.get(self.options.currentIndex);$(firstSlide).css({'opacity':1.0,'display':'block','filter':'','z-index':1});if(self.options.autoPlay){self._start();}}});},_start:function(){var self=this;window.setInterval(function(){if(self.options.currentIndex==self.options.length-1){self.setIndex(0);}else{self.setIndex(self.options.currentIndex+1);}},this.options.displayTime);},onIndexChanged:function(index,previousIndex){function fadeInNew(){$(self.options.slides[index]).css({'z-index':1,'display':'block'}).stop().animate({'opacity':1.0},self.options.transitionTime,'swing',function(){$(this).css('filter','');});}
function fadeOutOld(){$(self.options.slides[previousIndex]).css('z-index',0);window.setTimeout(function(){$(self.options.slides[previousIndex]).stop().animate({'opacity':0.0},self.options.transitionTime,'swing',function(){$(this).css({'display':'none'});});},self.options.transitionTime*0.2);}
var self=this;self.dispatchChangeEvent();fadeOutOld();fadeInNew();},next:function(){this.setIndex(this.options.currentIndex+1);},previous:function(){this.setIndex(this.options.currentIndex-1);},numSlides:function(){return this.options.length;},setIndex:function(index){if(index>=0&&index<this.options.length&&index!=this.options.currentIndex){var previousIndex=this.options.currentIndex;this.options.currentIndex=index;this.onIndexChanged(this.options.currentIndex,previousIndex);}},dispatchChangeEvent:function(){$(this.element).trigger('indexChanged',this.options.currentIndex);}});})(jQuery);var GSS=(function(module,$){module.createSlideshowControls=function(slideshow,selector){var controls=$("<p class='controls'><a class='previous' href='#previous'> &lt; </a><span class='current'></span> of <span class='total'></span><a class='next' href='#next'> &gt; </a></p>"),current=$(controls).find('.current'),total=$(controls).find('.total'),previous=$(controls).find('.previous'),next=$(controls).find('.next'),slides=$(slideshow).children(),numSlides=$(slides).size(),videoButtons=null;function createVideoButtons(){var buttons=[],buttonsHtml=null;$(slides).each(function(index,element){var videoButton;if($(this).hasClass('video')){title=$(this).find('h2').html();videoButton='<a class="video" href="#'+index+'">'+title+'</a>';buttons.push(videoButton);}});buttonsHtml=buttons.join(' / ');buttons=$(buttonsHtml);controls.append(buttons);return $(buttons).filter('a');}
function onIndexChanged(event,newIndex){$(current).html(newIndex+1);if(newIndex===0){$(controls).find('a.previous').each(function(){$(this).addClass('inactive');});}else{$(controls).find('a.previous').each(function(){$(this).removeClass('inactive');});}
if(newIndex==numSlides-1){$(controls).find('a.next').each(function(){$(this).addClass('inactive');});}else{$(controls).find('a.next').each(function(){$(this).removeClass('inactive');});}
$(videoButtons).each(function(){if(indexFromHash($(this).attr('href'))==newIndex){$(this).addClass('inactive');}else{$(this).removeClass('inactive');}});}
function indexFromHash(hash){return parseInt(hash.replace(/.*#/,''),10);}
function onControlsClick(event){var index,href;event.preventDefault();if($(this).hasClass("previous")){slideshow.simpleSlideshow("previous");}else if($(this).hasClass("next")){slideshow.simpleSlideshow("next");}else if($(this).hasClass("video")){index=indexFromHash($(this).attr("href"));slideshow.simpleSlideshow("setIndex",index);}}
if(numSlides>1){$(total).html(numSlides);$(selector).after(controls);videoButtons=createVideoButtons();$(slideshow).bind('indexChanged',onIndexChanged);onIndexChanged(null,0);$(controls).find('a').click(onControlsClick);}};module.hoverScroll=function(selector,direction){var contentWidth,scrollPane,containerWidth,offset,maxSpeed=12,speed=0,timerId;scrollPane=$(selector).find('.scroll-pane');containerWidth=$(selector).width();offset=$(scrollPane).offset();$(scrollPane).children().each(function(){contentWidth+=$(this).outerWidth(true);});$(scrollPane).width(contentWidth);function nudge(amount){var newValue=speed+$(selector).scrollLeft();newValue=newValue<0?0:Math.min(newValue,containerWidth);$(selector).scrollLeft(newValue);}
function onMouseMove(event){var velocityPercent=((event.pageX-offset.left-containerWidth/2)/containerWidth)*2;speed=velocityPercent*maxSpeed;}
$(selector).hover(function(event){$(selector).bind('mousemove',onMouseMove);timerId=window.setInterval(nudge,50);},function(event){$(selector).unbind('mousemove',onMouseMove);window.clearInterval(timerId);});};return module;}(GSS||{},jQuery));(function($){var TWEET_ANIMATE_TIME=750,TWEET_HOLD_TIME=5000;$(document).ready(function(){var textFields=$('input[type="text"]').add('textarea');$(textFields).each(function(){$.data(this,"label",$(this).attr("value"));});$(textFields).blur(function(){if($(this).attr("value")===""){$(this).attr("value",$.data(this,"label"));}});$(textFields).add('textarea').focus(function(){if($(this).attr("value")==$(this).data("label")){$(this).attr("value","");}});$('#twitter-updates').each(function(){var slidePane=$('<div class="slide-pane"></div>'),slideContainer=$('<div class="slide-container"></div>'),tweets=$(this).children('.update'),numTweets=$(tweets).size(),index=0;$(slideContainer).append(slidePane);$(this).append(slideContainer);$(slidePane).append(tweets);$(tweets).each(function(){$(this).css({'display':'block'});$(this).data('orig-top',$(this).position().top);});function update(){if(index>=numTweets){index=0;}
newTop=-$($(tweets).get(index)).data('orig-top');$(slidePane).animate({'top':newTop},TWEET_ANIMATE_TIME);index++;}
window.setInterval(update,TWEET_HOLD_TIME);update();});});}(jQuery));var GSS=GSS||{};GSS.parallax=(function($){var parallax={},_xPerc=0,_yPerc=0,_xOffset,_yOffset,_directionConf,_container,_slides,_rangeOfEffect=250;function _clamp(min,max,value){return Math.min(max,Math.max(min,value));}
function _update(){$(_slides).each(function(i,v){$(this).css({top:(_yPerc-_yOffset)*_displacementConf[i].y+$(this).data('initialTop'),left:(_xPerc-_xOffset)*_displacementConf[i].x+$(this).data('initialLeft')});});}
function _bindEvents(){var windowWidth,windowHeight,containerOffset=_container.offset(),containerHeight=_container.height();function onResize(e){windowWidth=$(window).width();windowHeight=$(window).height();}
$(window).resize(onResize);function onScroll(e){var focus={x:$(window).scrollLeft()+windowWidth/2,y:($(window).scrollTop()+windowHeight/2)};_yPerc=_clamp(0,1,(focus.y-containerOffset.top)/_rangeOfEffect);_update();}
$(window).scroll(onScroll);onResize();}
_recordInitialPositions=function(){$(_slides).each(function(){$(this).data('initialTop',parseInt($(this).css('top').replace('px;','')));$(this).data('initialLeft',parseInt($(this).css('left').replace('px;','')));});}
parallax.init=function(selector,displacementConf,directionConf){if(!directionConf){directionConf={v:'centre',h:'centre'};}
_container=$(selector);_slides=$(selector).find('.slide');_displacementConf=displacementConf;if(directionConf.x=='centre'){_xOffset=0.5;}else if(directionConf.x=='left'){_xOffset=0;}
if(directionConf.y=='centre'){_yOffset=0.5;}else if(directionConf.y=='top'){_yOffset=0;}
_recordInitialPositions();_bindEvents();}
parallax.setDisplacement=function(obj){if(obj.x&&obj.x!=_xPerc){_xPerc=_clamp(obj.x);}
if(obj.y&&obj.y!=_yPerc){_yPerc=_clamp(obj.y);}
_update();}
return parallax;}(jQuery));
