$(document).ready(function() {


	var resizeMainDiv = function () {
		var parentDiv = $("#answerBox").parent().get(0);
		$(parentDiv).css('height', $(document).height()
			- $(parentDiv).offset().top
			- 150
		);
	
		var parentH = $(window).height()-350;
		var parentW = $($("#answerBox").parent().get(0)).innerWidth()
			- $('.boxList').outerWidth()
			- 50;
		parentH = parentH > 150 ? parentH : 150;
		$("#answerBox").css({
			'width': parentW + 'px',
			'height': parentH + 'px'
		});
	};
	
	resizeMainDiv();
	$(window).bind('resize', resizeMainDiv);
	
	$("#answerBox").css({
		'fontFamily': '"Lucida Sans" sans-serif',
		'float': 'right',
		'overflow': 'auto'
	});

	$(".boxList > li").bind('mouseenter mouseleave', function(e) {
		$(this).toggleClass('highlighted');
	});
	$(".boxList > li").bind('click', function(e) {
		if (e.target.nodeName == 'LI') {
			$(e.target).children().click()
		}
		$(this).addClass('clicked').siblings().removeClass('clicked');
	});
	$(".boxList").find("a").bind('click', function (e) {
		e.preventDefault();
		var id = e.target.href.replace(/^[^#]*#/, '');
		var div = document.getElementById(id);
		$(div).slideDown('fast').siblings().slideUp('fast');
	});
});
