function addLoadEventV(func)	{
	var oldload = window.onload;
	if (typeof window.onload != 'function')	{
		window.onload = func;
	}
	else	{
		window.onload = function()	{
			oldload();
			func();
			}
	}
}	
function addEventV() {
	var ul = document.getElementById('vietvbb_topstats_t');
	var li = ul.getElementsByTagName('li');
	for (i=0; i < li.length - 1; i++)	{
		li[i].onmouseover = function()	{
			viewTabV(this);
			}
	}	
	var select = document.getElementById('vietvbb_topstats_s');
	select.onchange= function()	{
		viewMenuV(this.value);
		}
	var result_menu = document.getElementById('vietvbb_topstats_result');
	result_menu.onchange= function()	{
		topXReload();
		}	
	topXReload();
}
function viewTabV(a) {
	var id = a.id;
	var ul = document.getElementById('vietvbb_topstats_t');
	var li = ul.getElementsByTagName('li');
	for (i=0; i < li.length-1; i++)	{
		li[i].className='';
	}

	a.className='current';
	
	document.getElementById('vietvbb_topstats_t_loading').style.display = 'inline';
	//document.getElementById('vietvbb_topstats_t_content').innerHTML = "";
	top_requestT = new vB_AJAX_Handler(true);
	top_requestT.onreadystatechange(handleResponsesT);
	var url = 'ajax.php?do=vietvbb_stats&type=tab&top=' + id;
	if (document.getElementById('vietvbb_topstats_result'))	{
		url = url + '&result=' +document.getElementById('vietvbb_topstats_result').value;
	}
	top_requestT.send(url);	
}

function viewMenuV(a) {
	document.getElementById('vietvbb_topstats_s_loading').style.display = 'inline';
	//document.getElementById('vietvbb_topstats_s_content').innerHTML = "";
	top_requestS = new vB_AJAX_Handler(true);
	top_requestS.onreadystatechange(handleResponsesS);
	var url = 'ajax.php?do=vietvbb_stats&top=' + a;
	if (document.getElementById('vietvbb_topstats_result'))	{
		url = url + '&result=' +document.getElementById('vietvbb_topstats_result').value;
	}
	top_requestS.send(url);
}
function topXReload()	{
	var ul = document.getElementById('vietvbb_topstats_t');
	var li = ul.getElementsByTagName('li');
	for (i=0; i < li.length-1; i++)	{
		if (li[i].className == 'current')	{			
			viewTabV(li[i]);
		}
	}	
	var select = document.getElementById('vietvbb_topstats_s');
	viewMenuV(select.value);
}

function handleResponsesT() 
{
	if (top_requestT.handler.readyState == 4 && top_requestT.handler.status == 200)
	{
		document.getElementById('vietvbb_topstats_t_loading').style.display = 'none';				
		document.getElementById('vietvbb_topstats_t_content').innerHTML = top_requestT.handler.responseText;
    }
}
function handleResponsesS() 
{
	if (top_requestS.handler.readyState == 4 && top_requestS.handler.status == 200)
	{
		document.getElementById('vietvbb_topstats_s_loading').style.display = 'none';				
		document.getElementById('vietvbb_topstats_s_content').innerHTML = top_requestS.handler.responseText;
    }
}
addLoadEventV(addEventV);
