$(document).ready(function() {
	var sHeight = $("#main").height();
	var cHeight = $("#content").height();
	var mHeight = $("#menu").height();
	
	sHeight = sHeight - mHeight - 35;
	
	if (sHeight > cHeight) {
		$("#content").css("height", sHeight + "px");
	}
	
	verticalCenter(".bluebox");
	
	fixFaq();
});

function verticalCenter(sDiv)
{
	var oSpan = $("<div>").attr("id", "tmpJqDiv").html($(sDiv).html()).css("lineHeight", "18px").css("textTransform", "uppercase").css("fontSize", "14px").css("fontWeight", "bold").css("width", "131px").appendTo($("body"));
	var iH = oSpan.height();
	
	var fM = iH/2;
	
	var iD = $(sDiv).height();
	var iP = (iD / 2) - fM;
	iD = iD - iP;
	
	$("#tmpJqDiv").remove();
	
	$(sDiv).css("paddingTop", iP + "px").css("height", iD + "px");
}

function fixFaq()
{
	var oList = $("dl.faq");
	
	if (oList.length > 0) {
		var sHash = location.hash;
		
		if (sHash.indexOf("#faq_") > -1)
		{
			var iId = sHash.replace("#faq_", "");
			showFaq(iId);
		}
		
		$("dl.faq a.faqquestion").bind("click", function() {
			var iId = this.id.replace("faq_", "");
			if ($("dd.faqanswer_" + iId).css("display") == "none") {
				showFaq(iId);
			} else {
				closeFaq();
			}
			return false;
		});
		
		$("ul.faq a").bind("click", function() {
			var iId = this.rel;
			if ($("dd.faqanswer_" + iId).css("display") == "none") {
				showFaq(iId);
			} else {
				closeFaq();
			}
		});
	}
}

function showFaq(iId)
{
	closeFaq();
	
	$("dd.faqanswer_" + iId).css("display", "block");
	$("a#faq_" + iId).parent("dt").css("fontWeight", "bold");
	$("a#faq_" + iId).css("color", "#ff6608").bind("mouseover", function() { this.style.color = '#002c42'; }).bind("mouseout", function() { this.style.color = '#ff6608'; });
}

function closeFaq()
{
	$("dl.faq dt").css("fontWeight", "normal");
	$("dl.faq dd").css("display", "none");
	$("dl.faq dt a").css("color", "#002c42").bind("mouseover", function() { this.style.color = '#ff6608'; }).bind("mouseout", function() { this.style.color = '#002c42'; });
}
