// <![CDATA[
// jQuery for image range carousels.
$(document).ready(function() {

	// Fade in the images.
	var img = $('.imageList:first-child img:first-child');
	img.hide();
	if ($.browser.msie) {
		img.fadeIn(1500);
	} else {
		img.image(img.attr('src'), function() {
			img.fadeIn(1500);
		});
	}

	$('.previewControls .page').click(function() {
		var index = (parseInt($(this).text()) - 1) || 0;
		scroll($(this), index);
	});

	$('.prev').click(function() {
		var index = (parseInt($(this).parents('div').children('a.selected').text()) - 2);
		if (index >= 0) {
			scroll($(this), index);
		}
	});

	$('.next').click(function() {
		var index = parseInt($(this).parents('div').children('a.selected').text());
		var last = parseInt($(this).parents('div').children('a.page').length);
		if (index < last) {
			scroll($(this), index);
		}
	});

	function scroll(o, index) {
		o.parents('div').prev('div').stop().scrollTo('li:eq(' + index + ')', { speed: 750, axis: 'x' });
		o.parents('div').children('a.page').removeClass('selected');
		o.parents('div').find('a.page').eq(index).addClass('selected');
	}

	$(function() {
		var tabContainers = $('.imageList');

		$('#options a').click(function() {
			tabContainers.hide().filter(this.hash).fadeIn(1000);

			$('#options a').removeClass('selected');
			$(this).addClass('selected');

			return false;
		}).filter(':first').click();
	});

	// Fix images not showing in Opera.
	if ($.browser.opera == true) {
		$('#previewPane img').show();
	}

	// Fixes container explanding problems in IE6 by forcing CSS to refresh.
	if ($.browser.msie && $.browser.version <= 6) {
		$('#container').css('height', '680px');
		$('.container').css('width', '592px');
	}
});
// ]]>
