// JavaScript Document

$("document").ready(function() {
							 
	//hide all content panes except first when page is loaded
	$(".content").hide();	
	
	//bind click function to tabs
	$(".tab").click(function(e) {
		//unselect all tabs and hide the content panes
		$(".tab").each(function() {
			$(this).removeClass("selected");
			$(this).addClass("unselected");
			$("#" + this.id + "-content").hide();
		});
		//select the clicked tab and show the content pane
		$(this).removeClass("unselected");
		$(this).addClass("selected");
		$("#" + this.id + "-content").show();
		e.preventDefault();
	});
	
	//collapse all faqs
	$("li a.faq").next().css("display","none");
	
	//bind the toggle function for show/hide faq answers
	$("li a.faq").toggle(function(e) {
		$(this).next().slideDown('fast');
		e.preventDefault();
		}, function(e) {  
		$(this).next().slideUp('fast');
		e.preventDefault();
	});
	
    //find out what anchor we have and open that tab
	var loc = this.location.href;
	var anc = loc.split('#');
   	//setTimeout = dirty hack for safari
   	//show tab specified after # in URL, or first tab if invalid id
   	if ((anc.length > 1) && ($("#" + anc[1]).length > 0)) {
		setTimeout("$('#" + anc[1] + "').click();",20); 
   	} else {    //show first tab if none specified
	   setTimeout("$('.tab:first').click();",100);
   	}
   
   	//display nifty corners on tabs
	if(NiftyCheck()) {
		RoundedTop("div.tab","#f5faff","#4a4a48");
	}
});