/////////////////////////////////////
//		Global Variables
/////////////////////////////////////

// Break out of any frames that may try to wrap this page.
if (top.location != location) {
	top.location.href = document.location.href;
}

/////////////////////////////////////
//		Initialize page functions
/////////////////////////////////////
$(document).ready(function() {
	// preload swap images.
	jQuery.each($("#thumbs_gallery ul li a"), function() {
		jQuery ('<img src="' + $(this).attr('href') + '" />');
	});


	// Set secondary navigation to swapping text
	$("#secondmenu li a").hover(function(){
		swapTextTitle(this);
	}, function(){
		swapTextTitle(this);
	});
	
	// Swap out gallery images and captions.
	$("#thumbs_gallery ul li a").click(function(){
		$("#gallery_photo_full img").attr('src',$(this).attr('href'));
		var thisCaption = $(this).next('div').html();
		if (thisCaption) {
			$("#gallery_caption").html(thisCaption);
		} else {
			$("#gallery_caption").html($("#main_caption_text").html());
		}
		return false;
	});

	
	$(".showbookmarks").bind('click', function() {
		if ($(".showbookmarks").hasClass('boxopen')) {
			$(".sharinglinks").animate({width: '1px'}, 600);
			$(".showbookmarks").removeClass('boxopen');
		} else {
			$(".sharinglinks").animate({width: '324px'}, 600);
			$(".showbookmarks").addClass('boxopen');
		}
		return false;
	});
});

/////////////////////////////////////
//		Menu Functions
/////////////////////////////////////
function swapTextTitle(e) {
	var title = $(e).attr('title');
	var content = $(e).text();
	$(e).text(title);
	$(e).attr('title',content);
}