// Master application js

$(function(){
	
	// Enable resizing of fonts for accessibilty
	// var fontTransformationIndex = ($.cookie('font_transformation') === undefined) ? 0 : $.cookie('font_transformation');
  var fontTransformationIndex = 0;
	
	$('.font_controls').click(function(){		
		var resizeableText = $('body');
		var currentFontSize = resizeableText.css('fontSize');
		var finalNum = parseFloat(currentFontSize, 10);
		var stringEnding = currentFontSize.slice(-2);
		
		if(this.id == 'larger') {
			finalNum *= 1.2;
			fontTransformationIndex ++;
		}
		else if (this.id == 'smaller'){
			finalNum /=1.2;
			fontTransformationIndex --;
		}
		
		resizeableText.css('fontSize', finalNum + stringEnding);
		// $.cookie('font_transformation', fontTransformationIndex.toString());
		return false;
	});
	
	// External links
	$('a[href^="http://"]').attr({
		target: "_blank",
		title: "Opens this link in a new window"
	});
	
	// Hack to ensure the body bg image always remains at the bottom of the page
	if($(document.body).height() < $(window).height()) $(document.body).css({"height":$(window).height()})
	
	// Biogs
	$(".biog").hide();
	$("#biog_tip").show();
	$(".polaroid").live("mouseover", function(event, obj){
		var classes = $(this).attr('class').split(' ');
		var person  = classes[0];
		$(".biog").hide();
		$("#" + person).show();
	});
	$(".polaroid").live("mouseout", function(event, obj){
		$(".biog").hide();
		$("#biog_tip").show();
	});
	
});