jQuery(document).ready(function() {

	$('.hideInfo').click(function() {
		$(this).hide();
		$('.showInfo').show();
		$('#sub_category_info').animate({top: '80'});
	});
	$('.showInfo').click(function() {
		$(this).hide();
		$('.hideInfo').show();
		$('#sub_category_info').delay(500).animate({top: '0'});
	});
	
	$('.shrink').click(function() {
		$(this).hide();
		$('.expand').show();
		$('#sub_category_nav').animate({top: '80'});
	});
	$('.expand').click(function() {
		$(this).hide();
		$('.shrink').show();
		$('#sub_category_nav').delay(500).animate({top: '0'});
	});
	
	if ( $('body').hasClass("single") )
	{
		$('.expand').show();
		$('.shrink').hide();
		//$('#sub_category_nav').delay(500).animate({top: '0'});
	}
	
	$('#sub_category_nav a').each(function(event) {
		var $img = $(this).find('img[data-imagesrc]');
		
		$(this).click(function(event) {
			event.preventDefault();
			$(this).parent().find('a.active').removeClass('active');
			$(this).addClass('active');
			$('#body_photo #body_photo_img').attr('src', $img.data('imagesrc'));
		});
	});
	
	$('#go_fullscreen').click(function(event){
		event.preventDefault();
		$('.fullscreenhidden').hide();
		$('#sub_category_nav').superbgimage({ reload: true });//.superbgShowImage($('#sub_category_nav a.active').attr('href'));
		$('#exit_fullscreen').show();
		$('#sub_category_nav').appendTo('#sub_category_nav_temp');
	});
	
	$('#exit_fullscreen').click(function(event){
		$('.fullscreenhidden').show();
		$('#exit_fullscreen').hide();
		$('#sub_category_nav').appendTo('#sub_category_nav_holder');
		$('#superbgimage').html('');
		$.fn.superbgimage({ reload: true });
	});
	
	$('#category_nav_holder').serialScroll({
		items:'li',
		prev:'#cat_nav_left',
		next:'#cat_nav_right',
		offset:-140, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:1, //as we are centering it, start at the 2nd
		duration:200
	});
	$('#category_nav').css('width', $('#category_nav li').length*140 - 40);
	$('#category_nav li:last').css('margin-right', '0');

});

$(window).load(function() {
    $('.slider').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});

