(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'y',duration:1};$scrollTo.window=function(scope){return $(window).scrollable();};$.fn.scrollable=function(){return this.map(function(){var win=this.parentWindow||this.defaultView,elem=this.nodeName=='#document'?win.frameElement||win:this,doc=elem.contentDocument||(elem.contentWindow||elem).document,isWin=elem.setInterval;return elem.nodeName=='IFRAME'||isWin&&$.browser.safari?doc.body:isWin?doc.documentElement:this;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this.scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(targ)){targ=both(targ);break;}
targ=$(targ,this);case'object':if(targ.is||targ.style)
toff=(targ=$(targ)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],Dim=axis=='x'?'Width':'Height',dim=Dim.toLowerCase();if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=targ[dim]()*settings.over[pos];}else
attr[key]=targ[pos];if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max(Dim));if(!i&&settings.queue){if(old!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings);});};function max(Dim){var attr='scroll'+Dim,doc=elem.ownerDocument;return win?Math.max(doc.documentElement[attr],doc.body[attr]):elem[attr];};}).end();};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);(function($){})(window.jQuery);window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments));}};(function(doc){var write=doc.write;doc.write=function(q){log('document.write(): ',arguments);if(/docwriteregexwhitelist/.test(q))write.apply(doc,arguments);};})(document);var ro={};ro.script={};ro.gallery={};ro.hero={};ro.CON={"x":"inCon"};(function(window,script,CON,jQuery,undefined){var hacks,setConstants,bindAjaxEvents,bindTabs,testWindowLocation,tab,gallery;script.init=function(){ro.isHandheld=($('.sms:visible').length>0);hacks();ro.gallery.init();ro.hero.init();bindAjaxEvents();bindTabs();$('.print').live('click',function(){window.print();});};hacks=function(){return true;};bindAjaxEvents=function(){$('.jQloadMe').each(function(){var me=$(this).attr('data-selector');var url=$(this).attr('data-href');$(me).load(url,{ajax:true});});return true;};bindTabs=function(){$('.tab').live('click',tab);var current=testWindowLocation();$('a[data-js-href="'+current+'"]').click();return true;};testWindowLocation=function(){if(window.location.hash!==''){return window.location.hash;}else{return false;}};tab=function(e){e.preventDefault();$('#links').scrollTo('linear',300);var tabbed=$(e.target).attr('data-js-href')||$(e.target).parents('a:eq(0)').attr('data-js-href');$('article section').addClass('hidden');$(tabbed).removeClass('hidden');$('nav .selected').removeClass('selected');$('nav a[data-js-href*="'+tabbed+'"]').parents('li').addClass('selected');return true;};gallery=function(){return true;};})(window,ro.script,ro.CON,$);(function(window,gallery,CON,jQuery,undefined){var prepareSlideShow,testGalleryIndex,bindOpen,bindClose,createControls,showControls,hideControls,destroyControls,destroyVeil,createSlide,showSlide,hideSlide,loadSlides,next,prev,jumpTo,highlightCurrentControl;var current=0;var count=0;var projector=$('#gallery');var slideDefault={title:'(c) Copyright Rowan Lamb Wedding Photography'};var slideHolder={className:'slide'};var controls;var controlDefault={className:'control'};var resize=true;gallery.slide={};gallery.init=function(){if(projector&&!ro.isHandheld){loadSlides();bindOpen();testGalleryIndex();}};prepareSlideShow=function(){if(count>0){return false;}
count=gallery.slide.length;$.each(gallery.slide,createSlide);createControls();};testGalleryIndex=function(){if((window.location.hash+'')==='#gallery'){createVeil();}};bindOpen=function(){$('.gallery').click(function(e){e.preventDefault();prepareSlideShow();createVeil();$(window).bind('resize',showSlide);});};bindClose=function(){$('#veil, .close').live('click',function(e){e.preventDefault();hideControls();hideSlide();$('#veil').fadeOut(500,destroyVeil);$('body').trigger('hero.restart');$(window).unbind('resize',showSlide);$('#veil, .close').die('click');});};createControls=function(){if(gallery.slide.length<2){return false;}
var control=$.extend(controlDefault,{'href':'#'});var nxt=$('<a/>',control).text('next').bind('click',function(e){next(e);});var prv=$('<a/>',control).text('previous').bind('click',function(e){previous(e);});var liPrv=$('<li/>').append(prv);var liNxt=$('<li/>').append(nxt);var ul=$('<ul/>').append(liPrv);$.each(gallery.slide,function(i,v){var jump=$('<a/>',{href:'#',className:'control jump'}).text(i+1).bind('click',function(e){jumpTo(e,i);});var li=$('<li/>').append(jump);$(ul).append(li);});$(ul).append(liNxt);controls=$('<nav/>',{id:'controls',className:''}).append(ul).hide();$(projector).after(controls);return true;};showControls=function(){$('#controls').fadeIn(500);};hideControls=function(){$('#controls').fadeOut(300);};destroyControls=function(){};next=function(e){e.preventDefault();if((current+1)>=gallery.slide.length){return false;}
hideSlide();current=current+1;showSlide();return true;};previous=function(e){e.preventDefault();if(current<=0){return false;}
hideSlide();current=current-1;showSlide();return true;};jumpTo=function(e,num){e.preventDefault();hideSlide();current=num;showSlide();return true;};highlightCurrentControl=function(){$(controls).find('.jump').removeClass('selected').eq(current).addClass('selected');return true;};createVeil=function(func){ro.hero.isGo=false;var veil=$('<div id="veil" />');$(projector).before(veil);$('#veil').fadeTo(1500,0.5,function(){showControls();showSlide();bindClose();});};destroyVeil=function(){$('#veil').remove();};createSlide=function(i,v){v=$.extend(slideDefault,v);var img=$('<img/>',v);var close=$('<a/>',{className:'close',href:'#',title:'Close gallery'}).text('[x]');var holder=$('<figure/>',slideHolder).append(close).append(img).hide();$(projector).append(holder);};positionSlide=function(callback){var center=$(window).width()/2;var slide=$(projector).find('.slide').eq(current);var w=$(slide).css({visibility:'hidden',display:'block'}).find('img').width()/2;$(slide).css({visibility:'visible',display:'none',left:center-w}).find('.close').css({left:(w*2)-5+'px'});callback();};showSlide=function(){var callback=function(){$(projector).find('.slide').eq(current).fadeIn(300);highlightCurrentControl();};positionSlide(callback);};hideSlide=function(){$(projector).find('.slide').eq(current).fadeOut(300);};loadSlides=function(){$.ajax({url:"/photo_gallery/json.json",success:function(loaded){gallery.slide=loaded.slide;}});};})(window,ro.gallery,ro.CON,$);(function(window,hero,CON,jQuery,undefined){hero.timer=null;hero.isGo=true;hero.init=function(){if(ro.isHandheld){return false;}
$.ajax({url:'/includes/slideshow.php',success:function(html){$('#canvas').prepend(html);$('#canvas img:last').prev().ready(function(){doAnimation($('#canvas img:last'));});},error:function(a,b,c){alert(a,b,c);}});$('body').bind('hero.restart',function(){ro.hero.isGo=true;doAnimation($('#canvas img:last'));});return false;};doAnimation=function(last){if(!hero.isGo){return false;}
if(!Modernizr.cssanimations){$(last).fadeOut(4000,function(){var img=$(this);$(img).remove();$('#canvas').prepend(img);$('#canvas img:first').attr('style','').fadeIn(0);var last=$('#canvas img:last');doAnimation(last);});}else{$(last).addClass('jQanimate');hero.timer=setTimeout(function(){var img=$(last);$(img).removeClass('jQanimate').remove();$('#canvas').prepend(img);last=$('#canvas img:last');doAnimation(last);},4000);}};})(window,ro.hero,ro.CON,$);
