function startSlideshow() {
var totalSlideCount = 1 + slideData.length;
var $slideshow = $('#cycle');
// markup contains only a single slide; before starting the slideshow we
// append one slide and prepend one slide (to account for prev/next behavior)
var preSlide = slideData.pop();
var appSlide = slideData.shift();
if(preSlide.href != '') {
$slideshow.prepend('
');
} else {
$slideshow.prepend('

');
}
if(appSlide.href != '') {
$slideshow.append('
');
} else {
$slideshow.append('
');
}
// prevent images without a link from being squished by the transition
$('#cycle>img').wrap('');
$slideshow.cycle({
fx:'custom',
timeout:7000,
// sync:0,
requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
requeueTimeout: 1500,
speed:1250,
cssBefore: {
height: 420,
bottom: 0,
left:0,
width: 0,
opacity: 0,
zIndex: 20
},
animIn: {
bottom: 0,
left:0,
width: 940,
height: 420,
opacity:1
},
animOut: {
width:0,
opacity:0
},
cssAfter: {
zIndex:1
},before:onBefore
});
function onBefore(curr, next, opts, fwd) {
// on Before arguments:
// curr == DOM element for the slide that is currently being displayed
// next == DOM element for the slide that is about to be displayed
// opts == slideshow options
// fwd == true if cycling forward, false if cycling backward
// on the first pass, addSlide is undefined (plugin hasn't yet created the fn yet)
if (!opts.addSlide)
return;
// shift or pop from our slide array
if(!slideData.length) return;
var nextSlide = slideData.shift();
if(nextSlide.href == '') {
slideToAdd = '
';
} else {
slideToAdd = '
';
}
// add our next slide
opts.addSlide(slideToAdd);
}
$('#cycle img:first').hide().fadeIn('slow');
}
// removes stuff and then calls showit
function removeIt(el,stuffToShow) {
// if element is already hidden don't try to hide it again
// this should reduce the length of el to 1 visible element on which to operate
el = el.filter(function(index) {
return $(this).css('display') != 'none';
});
if(stuffToShow.hasClass('album')) {
$('#back-nav dt').text(stuffToShow.attr('id').replace('_album',''));
}
if(stuffToShow.hasClass('gallery') || stuffToShow.attr('id')=='cycle') {
$('#back-nav').hide('fast');
if(!((document.all) && (typeof document.body.style.maxHeight == "undefined"))) $('#gallery h1').show('fast');
}
var targetHeight = el.height();
if(document.all) {
var li = el.find('li').css('opacity',1).fadeOut('fast');
el.animate({
opacity:0,
height:0
},500,function() {
showIt(stuffToShow);
$(this).css({height:targetHeight}).hide();
$('#secondary-nav').slideUp(750);
if(stuffToShow.hasClass('album') && !((document.all) && (typeof document.body.style.maxHeight == "undefined"))) {
$('#back-nav').show('fast');
$('#gallery h1').hide('fast');
}
});
} else {
el.animate({
opacity:0,
height:0
},500,function() {
showIt(stuffToShow);
$(this).css({height:targetHeight}).hide();
$('#secondary-nav').slideUp(750);
if(stuffToShow.hasClass('album') && !((document.all) && (typeof document.body.style.maxHeight == "undefined"))) {
$('#back-nav').show('fast');
$('#gallery h1').hide('fast');
}
});
}
}
// Shows the slideshow
function showIt(el) {
// if element is showing don't do stuff to it
el.filter(function() {
return $(this).css('display') == 'none';
});
var targetHeight = el.height();
if(document.all) {
var li = el.find('li');
li.each(function() {
$(this).css('opacity','0').hide();
});
el.css({height:'0px',opacity:'0'}).animate({
height:targetHeight,
opacity:1
},800,function() {
if(el.hasClass('gallery')) {
$('#secondary-nav').slideDown(750);
}
li.each(function() {
$(this).show().animate({'opacity':'1'},400);
});
});
} else {
el.css({opacity:0,height:0}).animate({
opacity:1,
height:targetHeight
},800,function() {
if(el.hasClass('gallery')) {
$('#secondary-nav').slideDown(750);
}
});
}
}
// Do some stuff on load
$(window).load(function () {
if($('#cycle').length) {
$('#primary-nav').hide().css({'height':0,'overflow':'hidden'}).animate({'height':60},2000,function() {
$('body').removeClass('loading');
$('#cycle').css({'width':0,'display':'block','opacity':0}).animate({'width':940,'opacity':1},'slow',function() {
$('div.hr:last').show('fast',function() {
$('#copyright a').show('fast');
});
});
});
}
if(!$('#cycle').length) $('body').removeClass('loading');
// displays preloader on slideshow
$('body').addClass('loaded');
if($('#home').length) startSlideshow();
});
function loadAnimation() {
// if we are on a gallery page
if(($('#gallery').length)) {
$('ul.gallery').slideDown(1000,function() {
$('ul.gallery li a img').animate({opacity:1},'fast',function() {
// delay
$('div.hr:last').show('fast',function() {
$('#copyright a,#secondary-nav').show('fast',function() {
if(!((document.all) && (typeof document.body.style.maxHeight == "undefined"))) $('#gallery h1').show('fast');
});
});
});
});
}
}
// Do some stuff asap
$(function() {
if(!$('body').hasClass('loading')) $('body').addClass('loading');
$('hr').wrap('');
$('div.hr:last,#copyright a,#primary-nav,#cycle,#secondary-nav,#back-nav,#gallery h1,ul.gallery').hide();
$('#meta').find('div.bio').append('
');
$('#scarf').append('');
// if not home page
if(!$('#cycle').length) $('#primary-nav').css({'height':0,'overflow':'hidden'}).animate({'height':60},2000,loadAnimation);
$('ul.gallery li a img').css({opacity:'0.1'});
$('ul.album a[rel],ul.gallery a').fancybox({
padding:0,
overlayOpacity:.85,
zoomOpacity:.3,
zoomSpeedChange:800,
imageScale:1
});
$('#cycle').find('a').css({'height':420,'width':940});
// append the span that fades in the triangle on hover
// set up the events for the primary nav album display
$('#primary-nav li a').append('').each(function() {
var $span = $('> span', this).css({'opacity':0,'cursor':'pointer'});
$(this).hover(function() {
$span.stop().fadeTo("slow",1);
}, function() {
$span.stop().fadeTo("slow",0);
})
// show the album, hide other albums and the home page slide show
$(this).click(function() {
if($(this).html().match("") && ($('ul.gallery').css('display') != 'none')) {
return false; // this is the currently showing nav section, don't do anything
} else if($(this).html().match("") && ($('ul.gallery').css('display') == 'none')) {
targetEl = 'ul.gallery';
} else {
targetEl = $(this).attr('href');
}
removeIt($('#cycle,ul.gallery,ul.album:not('+targetEl+')'),$(targetEl));
return false;
});
});
// going back to the gallery view
$("#back-nav").prepend("").find('a').click(function() {
if(!$('#home').length) {
removeIt($('ul.album'),$('ul.gallery'));
return false;
}
});
// hide stuff in parameter 1 and show the slideshow if it is not already showing
$('#home h1 a,#home #back-nav a').click(function() {
if($('#cycle').css('display') != 'block') {
removeIt($('ul.album'),$('#cycle'));
// stop browser from appending to url
return false;
}
})
$('a.activator,#meta-close').click(function() {
if(!($('#meta').hasClass('open'))) {
$('body').css({
'overflow-y':'hidden'
});
$('#meta').addClass('open').css({'height':420}).slideDown(800, function() {
$('#meta div.scarf').fadeIn('fast');
});
} else {
$('#meta div.scarf').fadeOut('fast');
$('#meta').removeClass('open').slideUp(800,function() {
$('body').css({
'overflow-y':'visible'
});
});
}
return false;
});
});