$(function(){
	
	$("a[rel=external]").live("click", function(){this.target="_blank"});
	$('#gnav li, #lnav li').css('cursor','pointer').click(function(e){e.stopPropagation(); if(this.firstChild.href)window.location=this.firstChild.href;});
	$(".IE6 li, .IE6 li").hover(function(){$(this).addClass('hover');}, function(){$(this).removeClass('hover');});
	$(".IE6 li:first-child").addClass('first-child'); 
	
	
	
	

	var popups = new Array();
	$(".PhotoGallery ul a").each(function(){ popups.push(new Image());popups[popups.length-1].src=this.href;}).live("click",function(){
		$("#content .wysiwyg").hide();
		$(".PhotoGallery ul").hide();
		$("#content").css("width","600px");
		$(this).closest(".PhotoGallery").prepend("<img src='"+this.href+"' alt='' class='bigimg' /><span class='body bigimg'>"+$(this).siblings("span.body").text()+"</span>");
		return false;
	});
	$(".PhotoGallery .bigimg").live("click",function(){
		$("#content .wysiwyg").show();
		$(".PhotoGallery ul").show();
		$("#content").css("width","");
		$(".bigimg").remove();
		return false;
	});
	$(".PhotoGallery .links .link").live("click", function(){
		$(".PhotoGallery .showing").removeClass("showing");
		$(".PhotoGallery .image"+$(this).text()).addClass("showing");
		if($(".bigimg").length > 0){
			$(".bigimg").remove();
			$(this).closest(".PhotoGallery").prepend("<img src='"+$(".PhotoGallery .image"+$(this).text() + " a").attr("href")+"' alt='' class='bigimg' /><span class='body bigimg'>"+$(".PhotoGallery .image"+$(this).text() + " a").siblings("span.body").text()+"</span>");
		}
		return false;
	});
	$(".PhotoGallery .links .next").click(function(){
		var showing = $(".PhotoGallery .links .showing");
		if(showing.next('.link').length > 0 )
			showing.next().click();
		else
			$(".PhotoGallery .links .link").eq(0).click();
		return false;
	});
	$(".PhotoGallery .links .back").click(function(){
		var showing = $(".PhotoGallery .links .showing");
		if(showing.prev('.link').length > 0 )
			showing.prev().click();
		else
			$(".PhotoGallery .links .link").eq($(".PhotoGallery .links .link").length-1).click();
		return false;
	});
 
});

