/***************************************************************************
Tabs Functions:
1.tabs mouse events
2.Ajax Requests
RMT Students .com All Right reserved
-------------------------------------
Developed By Cory Caines - Kreatednine.com
**************************************************************************/
tab_list = Array();
function init_tabs(){
	tabs = tag("div");
	for(i=0;i<=tabs.length-1;i++){
		if(tabs[i].getAttribute('typ') == "tab"){
			tab_list.push(tabs[i].id);
			tabs[i].onclick = function(){
				for(x=0;x<=tab_list.length-1;x++){
					$(tab_list[x]).className = "tab_off";	
				}
				this.className = "tab_sel";
				getCommunityCont(this.id);
			}
			tabs[i].onmouseover = function(){
				if(this.className == "tab_off"){
					this.className = "tab_ovr";
				}
			}
			tabs[i].onmouseout = function(){
				if(this.className == "tab_ovr"){
					this.className = "tab_off";
				}
			}
		}
	}
	
	//get the first entry
	getCommunityCont($(tab_list[0]).id);
}

function getCommunityCont(section){
	xmlHttp=makeRequest();
	if (xmlHttp==null){
		window.document.alert ("Browser does not support HTTP Request")
		return
	} 
	//set the loading image
	$("tabContent").innerHTML = "<img src=\"images/load.gif\" />";
	var url="ajax/getcommunitydata.php?section="+section;
	
	xmlHttp.onreadystatechange=updateCommunity;

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)	
}

function updateCommunity(){

	switch (xmlHttp.readyState) {
		case 1 : 
		break;
		case 4 :
			if (xmlHttp.status == 200) {
				//$("status").innerHTML = requestCnt+" : "+xmlHttp.responseText;
				data = xmlHttp.responseText.split("|");
				switch(data[0]) {
					case "success":
						$("tabContent").innerHTML = data[1];
					break;
					default:
						alert(xmlHttp.responseText);
				}
			} else { 
				msg("An Error Occured When Retrieving the Community Data"); 
			}
		break;
	}	
}

function makeRequest(){ 
	var objXMLHttp=null;
	
	if (window.XMLHttpRequest){
	  objXMLHttp=new XMLHttpRequest()
	}else if(window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}