// Hide these elements until the flash is loaded.
document.write('<style type="text/css">');
document.write("#results {display: none}");
document.write('</style>');

var fd_tabs;
var fd_tab_current;
var debug;

initTabPanel = function() {

	fd_tabs = getElementsBySelector("#tabs a");
	
	
	for(t in fd_tabs){
		tab = fd_tabs[t];
	  	EventUtils.addEventListener(tab,'click', tabClick);
		var tab_id = "#" + tab.href.split("#")[1];
		var tab_panel = getElementsBySelector(tab_id)[0];
		tab_panel.tab = tab;
		tab.tab_panel = tab_panel;
		tab.href="javascript:void(0);";
	}
	
	var fd_tab_panels = getElementsBySelector(".tab_panel");
	for(var t in fd_tab_panels)
		if(fd_tab_panels[t].className.indexOf("focus")>0)
			fd_tab_current = fd_tab_panels[t];
		else
			fd_tab_panels[t].style.visibility = FD_isSafari?"hidden":"visible";

}

function tabClick(){
	var el;
	if(window.event){
		el = window.event.srcElement;
	}
	else
		el = this;
	
	var tab_panel = el.tab_panel;
	
	if(tab_panel == fd_tab_current)
		return;
	
	tab_panel.className += " focus";
	tab_panel.tab.className = "focus";
	
	if(FD_isSafari){
		tab_panel.style.visibility = "visible";
		fd_tab_current.style.display = "hidden";
	}
	else{
		tab_panel.style.height = "10px";
		tab_panel.h = 10;
		
		if(tab_panel.revealInt > 0)
			window.clearInterval(tab_panel.revealInt);
		
	
		tab_panel.revealInt = window.setInterval("tab_reveal('" + tab_panel.id + "');", 10);
	}
	
	fd_tab_current.className = fd_tab_current.className.replace("focus","");
	fd_tab_current.className = fd_tab_current.className.replace("  ","");
	
	fd_tab_current.tab.className = "";
	
	fd_tab_current = tab_panel;
	
	el.blur();
}

function tab_reveal(tab_panel_id){

	var tab_panel = document.getElementById(tab_panel_id);
	if(tab_panel.h >= 228)
		tab_panel.h = 228;

	
	tab_panel.style.height = tab_panel.h + "px";

	if(tab_panel.h >= 228){
		window.clearInterval(tab_panel.revealInt);
		tab_panel.revealInt = 0;
	}
	
	tab_panel.h += 20;
	
}

EventUtils.addEventListener(window,'load',initTabPanel);
