$(function(){
	
/* Nivo Slider */
/*-------------------------------------------------------------------*/
	$('#slider').nivoSlider({
		directionNav : false,
		effect : 'fade', 
		pauseTime : 5000
	});
	
/* Content BG Fix */
/*-------------------------------------------------------------------*/
	var fixBg = function(){
		var footBot = $('footer').offset().top;		
		$('#content-bg, #content-bg-inner').css('height', footBot+'px');
	}	
	$(window).bind({
		'scroll resize': function(){
			fixBg();
		}
	});	
	fixBg();
	setTimeout(fixBg, 1000);
	
/* Home Feature Fade */
/*-------------------------------------------------------------------*/
	$('#home-features a').hover(function(){
		if(!($.browser.msie && $.browser.version < 8)){
			$(this).siblings().stop().fadeTo(300, .3);
		}
	}, function(){
		if(!($.browser.msie && $.browser.version < 8)){
			$(this).siblings().stop().fadeTo(600, 1);
		}
	});

/* Current Nav Highlight */
/*-------------------------------------------------------------------*/
	var htmlId = $('html').attr('id');
	$('#nav-'+htmlId).addClass('current');
	
/* Custom Scroll */
/*-------------------------------------------------------------------*/
	$('.scroll-pane').jScrollPane({
		verticalGutter: 10,
		verticalDragMinHeight: 10,
		verticalDragMaxHeight: 30
	});
	
/* Nav Dropdown */
/*-------------------------------------------------------------------*/
	var hoverTimeout = new Array();
	$('nav li').has('ul').each(function(){
		hoverTimeout.push($(this).index());	
	});
	$('nav li').has('ul').hover(function(){	
		var indexer = $(this).index();	
		clearTimeout(hoverTimeout[indexer]);
		if($.browser.msie){
			$(this).find('ul').show(0);
		} else {
			$(this).find('ul').stop(false,true).fadeTo(300, 1);
		}
	}, function(){
		var indexer = $(this).index();
		var obj = $(this).find('ul');
		hoverTimeout[indexer] = setTimeout(function(){
			if($.browser.msie){
				obj.hide(0, function(){obj.css('display', 'none')});
			} else {
				obj.stop(false,true).fadeTo(300, 0, function(){obj.css('display', 'none')});
			}
		}, 300);
	});
	
/* Gallery */
/*-------------------------------------------------------------------*/
	//$('#gallery .gal-image:nth-child(4n)').addClass('last');	
	$('#gallery .gal-image a').hover(function(){
		$('.gal-image').not($(this).parent()).stop().fadeTo(300, .3);
	}, function(){
		$('.gal-image').not($(this).parent()).stop().fadeTo(600, 1);
	});
	
	$('#kid-image-gallery a:nth-child(3n)').addClass('last');
	$('#kid-image-gallery a').hover(function(){
		$(this).siblings().stop().fadeTo(300, .3);
	}, function(){
		$(this).siblings().stop().fadeTo(600, 1);
	});
	
	$('#cage-hero-image-gallery a:nth-child(5n)').addClass('last');
	$('#cage-hero-image-gallery a').hover(function(){
		$(this).siblings().stop().fadeTo(300, .3);
	}, function(){
		$(this).siblings().stop().fadeTo(600, 1);
	});
	
	$('a[rel="colorbox"]').colorbox({
		initialWidth : 100,
		initialHeight : 100,
		opacity: .8,
		speed: 500,
		rel : "colorbox",
		maxWidth: '960px',
		maxHeight: '600px',
		current: '{current}/{total}'
	});
	
/* Shop */
/*-------------------------------------------------------------------*/
	$('#shop-gallery a:nth-child(4n)').addClass('last');
	
	$('#product-img, #product-photos a').append('<span />');
	
	$('#product-photos a:nth-child(3n)').addClass('last');
	
	$('#product-img, #product-photos a').hover(function(){
		$(this).find('span').stop().fadeTo(300, 1);
	}, function(){
		$(this).find('span').stop().fadeTo(300, 0);
	});
	
	$('.shop-button-set a').click(function(){
		$(this).siblings().removeClass('current');
		$(this).toggleClass('current');
	});
});
