$(document).ready(function() {

	// animate global navigation elements
	// using opacity and jQuery animate
	$("#globalnav a").not("#activemenu a")
	.addClass('nav-over')
	.css('opacity', 0.42)
	.mouseenter(function() {
		$(this).stop().animate({opacity: 1}, 200);
	})
	.mouseleave(function() {
		$(this).stop().animate({opacity: 0.42}, 200);
	});

	// same here for introduction links,
	// but different opacity values
	$("#learn-more,#get-in-touch,#view-work")
	.addClass('link-over')
	.css('opacity', 0.6)
	.mouseenter(function() {
		$(this).stop().animate({opacity: 1}, 150);
	})
	.mouseleave(function() {
		$(this).stop().animate({opacity: 0.6}, 150);
	});

	// and same here for contact link in footer
	$("#contact-li a")
	.addClass('link-over')
	.css('opacity', 0.2)
	.mouseenter(function() {
		$(this).stop().animate({opacity: 1}, 100);
	})
	.mouseleave(function() {
		$(this).stop().animate({opacity: 0.2}, 100);
	});

	// fancybox for work showcase
	// but first check if fancybox was included
	// to prevent errors
	if (typeof $.fancybox === "function") {
		$("a.show-project").fancybox({
			padding: 0,
			transitionIn: 'elastic',
			transitionOut: 'elastic'
		});
	}

	// get preset work category and display it
	// or just show category web as standard
	$("#projects-web,#projects-logos,#projects-photos").hide();
	var cat = ((document.URL).split("#"))[1];
	if (cat == "web" || cat == "logos" || cat == "photos") {
		$("#projects-"+cat).show();
		$("a.active").removeClass("active");
		$(".project-tabs a.projects-"+cat).addClass("active");
	} else {
		$("#projects-web").show();
	}

	// change catgory view on tab click
	// change active status of tabs
	$("div.project-tabs a").click(function(e) {
		if ($(this).hasClass("active"))
			return;

		var elemClass = $(this).attr('class');
		$("#projects-web,#projects-logos,#projects-photos").hide();
		$("#"+elemClass).show();

		$("a.active").removeClass("active");
		$(this).addClass("active");
	});
});
