var whichShade = "0";
var whichTip = "0";

function base(){
	$("ul.top-ten li table td.open-close").each(function(){
		$(this).prepend("<span class='open'>Open</span><span class='close'>Close</span>");
	});
	$("ul.top-ten li table").each(function(){
		$(this).addClass("closed");
	});
	
	$("ul.top-ten li table").hover(
		function () { $(this).addClass("active"); }, 
		function () { $(this).removeClass("active"); }
	);
	
	$("ul.top-ten li table").click(function(){
		if( $(this).parent().attr("id") == whichShade){
			whichShade = "";
			$(this).addClass("closed");
			$(this).removeClass("open");
			$(this).siblings("div.content").slideUp(100);
		}
		else{
			whichShade = $(this).parent().attr("id");
			// swap buttons open/close for clicked
			$(this).addClass("open");
			$(this).removeClass("closed");
			
			// swap buttons open/close for all others
			$(this).parent("li").siblings("li").children("table").addClass("closed");
			$(this).parent("li").siblings("li").children("table").removeClass("open");
			
			// slide content
			$(this).parent("li").siblings().children("div.content").hide();
			$(this).siblings("div.content").slideDown(100);
		}
	});
	
	// rates pop up
	$("div.tip h4").prepend("<a class='tip-close'>Close</a>");
	$("div.rates a.tip-trigger").click(function(){
		$("div.tip").hide(300);			
		$(this).siblings("div.tip").show(300);
	});
	$("div.rates a.tip-close").click(function(){
		$(this).parent("h4").parent("div.tip").hide(300);
	});

	// branch content pop up
	$("div.branch-content h4").prepend("<a class='tip-close'>Close</a>");
	$("a.branch-trigger").click(function(){
		$(this).siblings("div.branch-content").show(300);
	});
	$("div.branch-content h4 a.tip-close").click(function(){
		$(this).parent("h4").parent("div.branch-content").hide(300);
	});

}
