$(function(){
	
	$("ul.thumbs a").click(function(event){
		event.preventDefault();
		showStore($(this).attr('href'));
	});
	
});
	
function showStore(target) {
	
	$("body").append('<div id="storeOverlay"></div>');
	$("body").append('<div id="openstore" style="display:none;"><a href="#" class="closeStore">Close (X)</a><div id="storedetails"></div></div>');
	$("#storeOverlay").fadeTo(400,.7);
	$("#openstore").fadeIn();
	$("#storedetails").load(target + '?nohead',function(){
		$("#storedetails h2.infohead").addClass('active').click(function(){	
			$("#storedetails h2.infohead").addClass('active');
			$("#storedetails h2.promohead").removeClass('active');
			$("#storeinfo").show();
			$("#storepromo").hide();
		});
		$("#storedetails h2.promohead").click(function(){	
			$("#storedetails h2.infohead").removeClass('active');
			$("#storedetails h2.promohead").addClass('active');
			$("#storeinfo").hide();
			$("#storepromo").show();
		});
		$("#storepromo").hide();

		$("ul.gallery li").each(function(){
			$(this).css("position","relative");
			$('a',$(this)).fancybox({titleShow:false, overlayShow:false}).prepend('<img src="/images/events/thumb-rounder.gif" style="position:absolute; left:0; top:0;" alt="round" />');
		});
				
	});
	
	$("#openstore .closeStore").click(function(event){
		event.preventDefault();
		hideStore();
	});
	
}

function hideStore() {

	$("#storeOverlay").fadeOut(function(){$(this).remove();});
	$("#openstore").fadeOut(function(){$(this).remove();});
	
}
