
/*Global Variables
	[tabs] - this array variable will hold the tab division ID's
	[tabTitle] - this array variable will hold the tab division Titles
*/


var tabs = new Array();
var tabTitle = new Array();

/*
	Function: tabSetup()
	
	Description:	This function will search the entire HTML page looking specifically
					for the Tab divisions. Each tab will be place within the tabs array for 
					easier access throughout the code as well as the Tat Titles; Also displaying 
					the content in a tab format!;
					
	Usage: setup(); this line must me included in any function inwhich the tabs will be displayed 
					in most cases will be used on the onload event of a page, or an onlclick event of
					an object/Element;					
*/
function tabSetup(){
	var cnt=1;
	while(document.getElementById("Tab"+cnt) != null){
		tabs[cnt] = "Tab"+cnt;
		hideTab(tabs[cnt]);
		var ttl = Element("lTab"+cnt);
		tabTitle[cnt] = ttl.value;
		cnt++;
	}
	
	
	var tabnum=document.getElementById("tabnum");
	showTab(tabs[tabnum.value]);
	td = Element("tabs");
	td.innerHTML += createTabs();
}

/*	
	Function: 		Element([name]);
	Description:	This function is design to return the object reference of an element;
	Usage:			Element(name);
	Variable:		[name] - string variable containing the id of the element on the HTML Document;
	
*/

function Element(name){
	return document.getElementById(name);
}

/*
	Function:		hideTab([tab])
	Description:	This function is design to hide the tabContentElement specified;
	Usage:			hideTab(tab);
					used within other Functions;
	Variable:		[tab] - string Containing the id of the element on the HTML; 
*/
function hideTab(Tab){
	var tabs = Element(Tab);
	tabs.style.display="none";
}


/*
	Function:		createTabs();
	Description:	This function is designed to generate the tab code
	Usage:			createTabs();
					used within other Functions;
*/

function createTabs(){
	var table = "<div>"
 	var	cnt=1;
	while(tabs[cnt] != null){
		
		if(cnt == 1){page='normal';}
		else if(cnt == 2 ){page='answer';}
		else if(cnt == 3 ){page='movie';}
		else if(cnt == 4 ){page='image';}
		else {page='normal';}
		
		var keyword=document.getElementById('searchkey').value;
		//var items = "<span class='sel' onclick=\"showHide('"+tabs[cnt]+"');\">"+ tabTitle[cnt] +"</span>";
		var items = "<li><span class='sel' ><a href=\"?page="+page+"&search="+keyword+"\">"+ tabTitle[cnt] +"</a></span></li>";
		table +=items;
		cnt++;
	}
	table +="</div>";
	return table;
}


/*
	Function:		showTab([tab])
	Description:	This function is design to diplay the select tab content
	Usage:			showTab(tab);
					used within another function
	Variable:		[tab] - a string containing the ID of the selected tab to display
*/

function showTab(tab){
	var tabs = Element(tab);
	tabs.style.display="inline";
}


/*
	Function:		showHide([stab])
	Description:	This functions is design to display only the tab that has been selected, 
					by hidding all and displaying the selected one.
	Usage:			showHide(tab);
	Variable:		[tab] - a string containing the ID of the selected tab to display
*/

function showHide(tab){
	var a=1;
	while (tabs[a] != null){
		hideTab(tabs[a]);
		a++;
	}
	showTab(tab);
}


