$(document).ready(function(){
	//EASING
	jQuery.easing.def = "easeOutQuad";
	
	//scroll on click
	$('#menu-main').localScroll({
		duration:400,
		hash:true,
		offset: -60
	});
	
	//Bio Toggle
	var closebio = "- CLOSE BIO";
	var showbio = "+ READ BIO";
	$(".bio-link").html(showbio);
	$(".bio").hide();
	$(".bio-link").toggle(function() {
	    $(this).html(closebio).next('.bio').fadeIn();
	},function(){    
	    $(this).html(showbio).next('.bio').fadeOut();
	});
	
	//SCROLL TO TOP
	$.fn.scrollToTop = function() {

		$(this).hide().removeAttr("href");

		if ($(window).scrollTop() >= "128") {
			$(this).fadeIn("fast")
		}
		var scrollDiv = $(this);

		$(window).scroll(function() {
			if ($(window).scrollTop() <= "128") {
				$(scrollDiv).fadeOut("fast")
			} else {
				$(scrollDiv).fadeIn("fast")
			}
		});

		$(this).click(function() {
			$("html, body").animate({
				scrollTop: 0
			},
			"fast");
		});
	}
	$("#toTop").scrollToTop();
	
	//SLIDES
	$('#carousel').slides({
		preload: true,
		preloadImage: 'http://staging.nycpetshow.com/wp/wp-content/themes/nycpetshow/images/slide-loading.gif',
		generateNextPrev: false,
		hoverPause: true,
		effect: 'fade',
		crossfade: true,
		play: 10000,
		pause: 5000
	});

	$('#photos-carousel').slides({
		preload: true,
		preloadImage: 'http://staging.nycpetshow.com/wp/wp-content/themes/nycpetshow/images/slide-loading.gif',
		generateNextPrev: true,
		generatePagination: false,
		effect: 'fade',
		crossfade: true,
		play: 10000,
		pause: 5000
	});
	
	//NAV LOCK
	if (window.XMLHttpRequest) {
		if (document.documentElement.scrollTop > 128 || self.pageYOffset > 128) {
			$('#access').css('position', 'fixed');
			$('#access').css('z-index', '99999');
			$('#access').css('top', '0');
		} else if (document.documentElement.scrollTop < 128 || self.pageYOffset < 128) {
			$('#access').css('position', 'absolute');
			$('#access').css('z-index', '99999');
			$('#access').css('top', '128px');
		}
	}

	window.onscroll = function() {
		if (window.XMLHttpRequest) {
			if (document.documentElement.scrollTop > 128 || self.pageYOffset > 128) {
				$('#access').css('position', 'fixed');
				$('#access').css('top', '0');
			} else if (document.documentElement.scrollTop < 128 || self.pageYOffset < 128) {
				$('#access').css('position', 'absolute');
				$('#access').css('top', '128px');
			}
		}
	}
	
	//VIDEO
	$("ul.vidlist").ytplaylist();
	
});

$(window).bind("load", function() {	

	//INTRO FADE IN
	$('#content').css({
		opacity: 0
	}).animate({
		opacity: 1
	}, 400);

	$('#footer').css({
		opacity: 0
	}).delay('400').animate({
		opacity: 1
	}, 400);
	
	//SCROLL ON LOAD
	$.localScroll.hash({
		duration: 400,
		offset: -60
	});
	
});
