jQuery(document).ready(function ($) {
	var shownum = $('#show-num').val();

	$('.show-image').css('display', 'none');
	
	$('#email-input').focus(function () {
		if ($(this).val() == 'Enter e-mail to join mailing list') {
			$(this).val('');
		}
	});
	
	$('#email-input').blur(function () {
		if ($(this).val() == '') {
			$(this).val('Enter e-mail to join mailing list');
		}
	});
	
	$('.show-cycle').each(function () {
		if ($(this).children('.show-image').length < 2) {
			$(this).next('.show-pager').css('display', 'none');
		}
	});
	
	$('.show-image p').append(' ');
	
	$(window).load(function () {
		for (var i = 1; i <= shownum; i += 1) {
			$('#show-cycle-' + i).cycle({
				activePagerClass: 'active',
				next: '#show-next-' + i,
				prev: '#show-prev-' + i,
				prevNextClick: function (next, j, slide) {
					$(slide).parent().next().children('span').text(j + 1);
				},
				speed: 500,
				timeout: 0
			});
			
			$('#show-thumbs-' + i + ' a').click(function () {
				var slide = $(this).attr('rel').split('-');
				$('#show-cycle-' + slide[0]).cycle(slide[1] - 1);
				return false;
			});
		}
	});
	
	// keep text below images in the same place (kinda hacky but i can't base the css position on an ancestor)
	/*if (('#show-cycle').length) {
		var h = $('#show-cycle').height();
		h = h - $($('.show-image p')[0]).height() - parseInt($($('.show-image p')[0]).css('margin-top')) * 2;
		$('.show-image p').css({ position: 'absolute', top: h + 'px' });
	}*/
});
