/* javascript.js */

// for next and previous buttons and project heads
$(function(){
	$(".slide").click(function(event) {
		event.preventDefault();
		window.location = $(this).find(":first-child").attr("href");
	});
});

$(document).ready(function() {
	$('.slideshow').cycle('stop');
	$('.slideplay').html('<a href="#" class="pause">&nbsp;</a>');
	setPlayPause();
	$('#nav').html('');
	$('#slideshow').cycle({
		fx:'scrollLeft',
		timeout:5000,
		speed:800,
		pager:'#nav',
		before:hideCaption,
		after:showCaption
	});
});

// for the slideshow play/pause buttons:
function setPlayPause(){
	$('.pause').unbind('click');
	$('.pause').click(function(event) {
		event.preventDefault();
		$('#slideshow').cycle('pause');
		$(this).parent().html('<a href="#" class="play">&nbsp;</a>');
		setPlayPause();
	});
	$('.play').unbind('click');
	$('.play').click(function(event) {
		event.preventDefault();
		$('#slideshow').cycle('resume');
		$(this).parent().html('<a href="#" class="pause">&nbsp;</a>');
		setPlayPause();
	});
}



function hideCaption(){
	$('#caption').hide('fast');
}
function showCaption(){
	var caption = "";
	if(this.firstChild.alt){
		caption = this.firstChild.alt;
	}
	$('#caption').html(caption);
	$('#caption').show('fast');
}
