if (!help_rootpath) var help_rootpath = "";

var help_panel;

function loadPanelNav(_arg1,_arg2) {
	_str = "";
	tab_links = new Array;
	// crazy IE WORKAROUD
	tab_table = document.getElementById("table_tab_id");
	tab_tds = tab_table.getElementsByTagName("td");
	tab_tds_length = tab_tds.length;
	
	//alert(tab_tds_length)
	
	for(i=0;i<tab_tds_length;i++) { 
		if(tab_tds[i].getAttribute('name')=="tab_tab") tab_links.push(tab_tds[i]);
	}
	
	for ( var i in tab_links ) {
		tab_links[i].className = "table_tab_tab_off";
	}
	
	document.getElementById("tab_tab_" + _arg1).className = "table_tab_tab_on";
	
	if(!_arg2) _arg2 = _arg1
	
	switch(_arg2) {

		case "personal" :
		break;
		
		case "stats" :
		break;
		
		case "empty" :
		break;
		
	}
	
	document.getElementById('table_tab_nav').innerHTML = _str
	
	
}

function loadPanel(_div,_panel,_arg1) {
	help_panel = _panel;
	document.getElementById(_div).innerHTML = '<div id="'+_panel+'"></div>';
	
	_this = "";
	_this += "&x=" + _panel;
	if (_arg1) _this += "&v=" + _arg1;
	
	loadPanel_SubmitReq('LOADPANEL', _this);
	
}
function loadPanel_SubmitReq(_process, _this) {
	
			switch (_process){

				case "LOADPANEL": 
					_params = _this;
					//alert(_params);
					//alert(help_rootpath+'php/help_loadpanel.php');
					loadPanel_ajaxReq('POST', help_rootpath+'php/help_loadpanel.php', _params, _process, false);
					
					break;
							
				default : alert( _process + " Not Recognized");
			} // end switch
}

var http;
///////////////////////////////////////////////////////
// Ajax Request
function loadPanel_ajaxReq(_action, _url, _params, _process, _asych) {
	http = createRequestObject();
	// always keep at true
	_asych = true;
	
	//if (http.overrideMimeType) {
		//http.overrideMimeType('text/xml'); //mozilla
	//}
	http.open(_action, _url, _asych);
	http.onreadystatechange = function() {
			loadPanel_handleAjaxReq(_process);
	}
	
	//http.onreadystatechange =new Function("handleAjaxReq('"+_process+"')");

	switch (_action) {
		case "POST":
			http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			http.send(_params);
			break;
		case "GET":
    		http.send(null);
			break
	}
}
//////////////////////////////////////////////////////////////
// Ajax Result
function loadPanel_handleAjaxReq(_process) {
    if (http.readyState == 4) {
		if (http.status == 200) {
			switch (_process){
			
				case "LOADPANEL": 
					LOADPANEL(http);
					break;
			
				default : alert( _process + " Not Recognized");
			} // end switch
		} else {
			// status not ok
			alert("Ajax Error: " + http.status);
		}
    } // end ready state
} // end HandleAjaxReq



///////////////////////////////////////////////////////////////////
// Ajax Application Functions
function LOADPANEL(_http) {
	var response = _http.responseText;
	//alert(response);
	
	if (response == "ERROR") {
		document.getElementById(help_panel).innerHTML = "Error : " + response;
	} else {
		document.getElementById(help_panel).innerHTML = response;
		
		try {
			tab_links = new Array;
			// crazy IE WORKAROUD
			tab_table = document.getElementById("table_tab_nav");
			tab_as = tab_table.getElementsByTagName("a");
			tab_as_length = tab_as.length;

			for(i=0;i<tab_as_length;i++) { 
				if(tab_as[i].getAttribute('name')=="tab_nav") tab_links.push(tab_as[i]);
			}
			for ( var i in tab_links ) {
				tab_links[i].className = "table_tab_nav";
			}
			document.getElementById("tab_nav_" + help_panel).className = "table_tab_nav_on";
		} catch (ex) {
			// skip
		}
	}
	
}
