var fancyOptions = { 
	'centerOnScroll': false,
	'zoomSpeedIn': 200, 
	'zoomSpeedOut': 200, 
	'overlayShow': false,
	'hideOnContentClick': false,
	'frameWidth': 600,
	'frameHeight': 470,
	'frameLeft': 20,
	'frameTop': 220
};

$(function() {
	var $hoverBubble = $("#hoverBubble");
	function showFace(face) {
		//face.find("img").css("visibility", "visible");
		var facePos = face.offset();
		var faceText = face.find("img").attr("alt");
		
		$hoverBubble.css({"left": facePos["left"] - $hoverBubble.width(), 
						 "top": facePos["top"] + face.height() - $hoverBubble.height()}) //place bubble in line with bottom of link
					.find("span").html(faceText + "!").end()
					.show();
	}
	function hideFace(face) {
		//face.find("img").css("visibility", "hidden");
		$hoverBubble.hide();
	}
	
	$(".piecechows div").hover(function() {showFace($(this));}, function () {hideFace($(this));})
		.not("#blogChow")
		.find("a").fancybox(fancyOptions);	
	
	$("a.popup").fancybox(fancyOptions);
		
	$("#blogChow a").click(function (e) { 
		e.preventDefault(); 
		window.open(this.href);
	});
	
	$("#footerNav a").hover(function() {showFace($("#" + this.rel));}, function () {hideFace($("#" + this.rel));})
		.click(function (e) {e.preventDefault(); $("#" + this.rel).find("a").click();});
		
	
	//make sure all external links always open in new window, and others open in fancybox
	$("a[href^=http]").live("click", function (e) { 
		e.preventDefault(); 
		window.open(this.href);
	});	
	
	/////////////////////
	// theme specific! //
	/////////////////////
	/*$('#albumCover').hover(
		function() {$(this).attr("src", "images/self_titled-cover_back.jpg");}, 
		function () {$(this).attr("src", "images/self_titled-cover.jpg");}
	);*/
});


//fix spamproof emails
function fixEmails() {
	$(".emailAt").replaceWith("@");
	$(".emailLink").each(function() {
		var t = $(this);
		var addr = t.html();
		t.html("<a href='mailto:" + addr + "'>" + addr + "</a>");
	});
}
