
$("html").addClass("js");$(document).ready(function(){if($('#gallery').length){var write_tmp=document.write;$('#slideshow').cycle({prev:'#prev',next:'#next',timeout:0,before:function(currSlideElement,nextSlideElement,options,forwardFlag){gallery_url_title=document.location.href.substr(document.location.href.lastIndexOf('/')+1);_gaq.push(['_trackEvent','Galleries','Image View',gallery_url_title]);var container_width=$("#slideshow").width(),new_height;var caption_height=$("#slideshow figure:visible").children('figcaption').outerHeight();$("<img/>").attr("src",$(nextSlideElement).children('img').attr("src")+"?random="+Math.random()*99999).load(function(){if(this.width>container_width){new_height=(container_width/this.width)*this.height;}else{new_height=this.height;}
new_height+=caption_height;$('#slideshow').animate({'height':new_height},700);});},after:function(currSlideElement,nextSlideElement,options,forwardFlag){$('#deck').height("120px");if(typeof write_timeout!="undefined"){clearTimeout(write_timeout);};document.write=function(){$("#deck_script").html(arguments[0]);};$("#deck_script").load("/deck_code.php",function(){write_timeout=setTimeout(function(){document.write=write_tmp;},3000);});}});var buttons=$("#prev, #next"),top=buttons.offset().top,prev=$("#prev"),next=$("#next"),anchor=$(".photogallery"),anchorbottom=0;anchor.css({'position':'relative'});$(window).scroll(function(){anchorbottom=anchor.offset()['top']+anchor.height();if($(window).scrollTop()<top){prev.css({'position':'absolute','top':0,'left':-20});next.css({'position':'absolute','top':0,'left':anchor.width(),'right':-20});}else if($(window).scrollTop()>=anchorbottom-buttons.height()){buttons.css({'position':'relative','top':anchor.height()-buttons.height()});prev.css({'left':-20});next.css({'right':0,'left':20});}else if($(window).scrollTop()>=top){prev.css({'position':'fixed','top':0,'left':anchor.offset()['left']-20});next.css({'position':'fixed','top':0,'left':anchor.offset()['left']+anchor.width()});}});$(".photogallery").mousemove(function(event){if($(this).offset().left+($(this).width()/2)+($(this).width()/8)<event.pageX){$("#prev").removeClass('hover');$("#next").addClass('hover');$(this).css('cursor','pointer');}else if($(this).offset().left+($(this).width()/2)-($(this).width()/8)>event.pageX){$("#next").removeClass('hover');$("#prev").addClass('hover');$(this).css('cursor','pointer');}else{$("#photogallerynav a").removeClass('hover');$(this).css('cursor','default');}});$(".photogallery").mouseout(function(){$("#photogallerynav a").removeClass('hover');});$(".photogallery").click(function(){if($(".photogallery").width()/2<event.pageX){$("#next").trigger('click');}else{$("#prev").trigger('click');}});$('a[href*=#]').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){var targetOffset=$target.offset().top;$('html,body').animate({scrollTop:targetOffset},1000);return false;}}});}
if($('#commentform').length){$("#commentform").validate({rules:{name:"required",comment:"required",email:{required:true,email:true,}},errorElement:"div",errorPlacement:function(error,element){error.insertBefore(element);}});};});
