$j=jQuery.noConflict();

jQuery(function(){
	
	
	$j(".galleryRow").each(function(){
		$j(this).children("p:first").addClass("first");
	});


	$j(".galleryCell").each(function(){
		$j(this).children("p").children("a:first").attr('href',$j(this).children("p").children("a:first").attr('href') + 'show');	
	});

	$j("#pageLabel").remove();
	$j(".page-id-20 .galleryRow:first").addClass("first");
	$j(".slideshowlink").remove();
	$j("#slideshowLink a").show();

	var target = 0


	$j(".twoCol").each(function(){
		$j(this).children("div:first").addClass("first");
		$j(this).children("div:last").addClass("last");
	})


	$j(".wpcf7-radio").each(function(){
		$j(this).children(".wpcf7-list-item:even").addClass("even");
	});

	$j(".wpcf7-checkbox").each(function(){
		$j(this).children(".wpcf7-list-item:even").addClass("even");
	});

	$j(".ngg-singlepic").each(function(){
		$j(this).wrap('<div class="photo" />').wrap('<div class = "inner" />');
	});

	$j(".ngg-gallery-thumbnail img").each(function(){
		$j(this).wrap('<div class="photo" />').wrap('<div class = "inner" />');
	});
	

	/*$j(".photo").each(function(){
		$j(this).append("<div class = 'glowBox topLeft'>").append("<div class = 'glowBox topRight'>").append("<div class = 'glowBox bottomLeft'>").append("<div class = 'glowBox bottomRight'>").append("<div class = 'glowBox top'>").append("<div class = 'glowBox bottom'>").append("<div class = 'glowBox left'>").append("<div class = 'glowBox right'>");
	})*/
	
	
	$j(".photo").each(function(){
		
		
		
		if($j(this).children("div").children("img").height() < $j(this).children("div").children("img").width()) {
			$j(this).children("div").children("img").addClass("horizontal");
		};
		
		
	});
	
	$j(".ngg-gallery-thumbnail > a").removeAttr("title");

	$j(".page-id-28 .glowBox").remove();


	

	$j(".photo").hover(function(){
		$j(this).addClass("hover");
		} ,
		function(){
			$j(this).removeClass("hover");
		}
	);

	$j("li#gallery a").hover(
		function(){
			$j(this).addClass("hover");
			} ,
			function(){
				$j(this).removeClass("hover");
			}
		);

		$j(".page-id-28 .photo").parents("a").attr("href","#")

		$j(".page-id-20 .photo").parents("a").attr("href","#").css("cursor","hidden")

		$j(".wpcf7-validation-errors .wpcf7-not-valid-tip-no-ajax").hide();



		$j("form p").each(function(){
			if($j(this).text() = " "){
				$j(this).addClass("test");
			}
		});

		$j(".ngg-gallery-thumbnail").click(function(){
			$j('.ngg-galleryoverview').hide();
			$j("#viewLarger").html("&nbsp;");
		})
		
		$j(".parent-pageid-20 #slideshowLink").hide();
		
		
	$j("body.home .photo").removeClass("photo").addClass("homePhoto");

	
	})
	
	var ieKiller;
	var doNext = 1;

	function imgShow(image) {
	
		
		$j("#slideShowLink").addClass("showStarted")
		$j("#pageContent").append("<div class = 'picView'><img src = '" + image.src + "' > <div id = 'galNav'>" + $j("#shTitle").html() + "</div></div>");

		$j("#slideshowLink a").show();
		//$j("#slideshowLinkTwo a").hide();


		if ($j(".picView").width() < $j(".picView img").width()) {
			var ratio = $j(".picView").width() / $j(".picView img").width();
			var newWidth = $j(".picView img").width() * ratio;
			var newHeight = $j(".picView img").height() * ratio;
			$j(".picView img").width(newWidth).height(newHeight);
		}


		$j("#shDisplay").remove();

		$j("#shNext a").click(function(){
			$j(this).parents(".picView").remove();
		})

		$j("#shPrev a").click(function(){
			$j(this).parents(".picView").remove();
		})

	return false;

}

/*

function startShow() {
$j(".picView").remove();
going = setInterval ( "slideshowAdvance()", 5000 );
$j("#stopshow").show();
$j("#slideshowLink a").hide();
}

function slideshowAdvance() {
shutterReloaded.make($j("#shNext a").attr('title'));
$j(".picView").remove();
}

function clearWindow() {
$j('.ngg-galleryoverview').hide();
}

*/

function hideLoading(){



		    var vars = [], hash;
		    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

		    for(var i = 0; i < hashes.length; i++)
		    {
		        hash = hashes[i].split('=');
		        vars.push(hash[0]);
		        vars[hash[0]] = hash[1];
		    }
		
		if (vars[0] != 'show') {
			jQuery("#loading").hide();
		};
		



	
};
$j(window).load(function(){
	
	$j(".photo img").tooltip({ 
    track: true, 
    delay: 0, 
    showURL: false, 
    showBody: " - ", 
    fade: 250 
});
});

