$(document).ready(function() {
	$.Lightbox.construct({
		show_linkback:	false,
		download_link:	false
	});
	

	$("div.portfolioBody img:first").hover( // hover
		function() {
			$(this).css("cursor","pointer");
		},
		function() {
			$(this).css("cursor","normal");
		} 
	).bind("click", function() {
		$("div.portfolioBody div.ngg-gallery-thumbnail:first a").click();
	});

	$("div.portfolioBody div.ngg-gallery-thumbnail a img").each(function() { // fade
		$(this).fadeTo(1, 0.4);
		$(this).hover(
			function() {
				$(this).stop().fadeTo("fast", 1);
			},
			function() {
				$(this).stop().fadeTo("slow", 0.4);
			}
		);
	});

/* REMOVE LINK WHEN STUFFFFFFFFFFFFFFFFFFFFFF */

$("div.portfolioBody .portnav .portnext a").each(function() {
		var echome = $('ul.portfolio .current_page_item').next().find('a').attr('href');
		if (echome == 'undefined') {
			var unechome = $('ul.portfolio li.current_page_parent ul li:first').find('a').attr('href');

			$(this).attr('href',unechome);
		} else {
			$(this).attr('href',echome);
		}
	});

$("div.portfolioBody .portnav .portprev a").each(function() {
		var echome = $('ul.portfolio .current_page_item').prev().find('a').attr('href');
		if (echome == 'undefined') {
			var unechome = $('ul.portfolio li.current_page_parent ul li:last').find('a').attr('href');

			$(this).attr('href',unechome);
		} else {
			$(this).attr('href',echome);
		}
	});

	$("ul.portfolio ul").css("display","none");

	$("ul.portfolio li.page_item a:not(ul ul li a)").each(function() {
		if ($(this).parent().hasClass('current_page_ancestor')) {
			$(this).addClass('open').next('ul').css('display','block');
		} else {
			$(this).addClass('closed');
		}
		$(this).attr('href','#');
		$(this).click(function() {
			if ($(this).hasClass("closed")) {
				$(this).removeClass("closed").addClass("open");
				$(this).next("ul").slideDown("normal");
			} else if ($(this).hasClass("open")) {
				$(this).removeClass("open").addClass("closed");
				$(this).next("ul").slideUp("normal");
			}
		});
	});

});

