$(document).ready(function() {
	// Lazyload Plugin
	$("img").lazyload({ effect: "fadeIn" });
	
	$("#submenu").css("opacity",0);
	$("#nav #galleries").hover(function() {
		$(this).removeClass("hide").stop().animate({ top: "-40px" }, 200);
		$("#submenu").stop().animate({ opacity: 1 }, 300);
	}, function() {
		$(this).addClass("hide").stop().animate({ top: "0px" }, 200);
		$("#submenu").stop().animate({ opacity: 0 }, 200);
	});
	
	// Homepage collage intro effect
	var timer = 0;
	$("#collage").css("opacity", 0).delay(1500).animate({ opacity: 1 });
	$(".collagethumb").css("opacity", 0).delay(1500).each(function(i) {
		timer = (timer + 200);
		$(this).animate({ opacity: 1 }, timer);
	}).hover(function() {
		$(".collagethumb").stop().animate({ opacity: 0.6 }, 300);
		$(this).stop().animate({ opacity: 1 }, 300);
	}, function() {
		$(".collagethumb").stop().animate({ opacity: 1 }, 300)
	});
	
	// Logo hover effect
	$("#logo").mouseover(function() {
		$(this).stop().animate({ left: "-2px" }, 130)
		.animate({ left: "2px", top: "-2px" }, 80)
		.animate({ left: "0px", top: "-1px" }, 50)
		.animate({ left: "2px", top: "2px" }, 65)
		.animate({ left: "0px", top: "0px" }, 80);
	});
	
	// Archive intro effect
	var timer2 = 0;
	$(".archive_post").css("opacity",0).delay(500).each(function(i) {
		timer2 = (timer2 + 200);
		$(this).animate({ opacity: 1 }, timer2);
	});
	$(".title").css("opacity",0.7);
	$(".archive_post").hover(function() {
		$(this).find(".title").stop().animate({ opacity: 0.9, paddingLeft: "20px", paddingRight: "5px" }, 150);
	}, function() {
		$(this).find(".title").stop().animate({ opacity: 0.7, paddingLeft: "10px", paddingRight: "15px" }, 150);
	});
	
	// Social Networking icon hover 
	$(".icon").hover(function() {
		$(this).stop().animate({ top: "-4px" }, 200);
	}, function() {
		$(this).stop().animate({ top: "0px" }, 200);	
	});
	
	// BC Logo fade effect
	$("#bclogo").css( 'opacity', '0.5').hover(function() {
		$(this).stop().animate({ opacity: 1 }, 200);
	}, function() {
		$(this).stop().animate({ opacity: 0.5 }, 200);
	});
	
	// Sticky footer
	positionFooter();
	
	$(window).scroll(positionFooter).resize(positionFooter);
	
	function positionFooter() {
		var docHeight = $(document.body).height() - $("#footer-push").height();
		if(docHeight < $(window).height()){
			var diff = $(window).height() - docHeight;
			if (!$("#footer-push").length > 0) {
				$("#footer").before('<div id="footer-push"></div>');
			}
			$("#footer-push").height(diff);
		}	
	}
	
});