var curtab = 1;
var news_block = new Object();
var link4 = '<a href="#" onClick="tabClick(4); return true;" style="color: red">моё</a>';
var link5 = '<a href="#" onClick="tabClick(5); return true;" style="color: red">участники</a>';
var link6 = '<a href="#" onClick="tabClick(6); return true;" style="color: red">темы</a>';

var orig_link = {
1:'Слежка: '+link4+' | '+link5+' | '+link6, 
2:'',
3:'',
4:'Слежка: '+'<u><b>'+link4+'</b></u> | '+link5+' | '+link6, 
5:'Слежка: '+link4+' | <u><b>'+link5+'</b></u> | '+link6, 
6:'Слежка: '+link4+' | '+link5+' | <u><b>'+link6+'</b></u>'
};

var data_block = {1:'', 
2:'/openforum/forum_last_table.inc',
3:'/openforum/forum_best_table.inc',
4:'/cgi-bin/openforum/bv.cgi?act_view_my=1',
5:'/cgi-bin/openforum/bv.cgi?act_view_nick=1',
6:'/cgi-bin/openforum/bv.cgi?act_view_thread=1'
};


function tabClick(tab){
	var curtab_class=document.getElementById("tab" + curtab);
	if (curtab_class){ curtab_class.className = "tab";}
	news_block[curtab]=gethtm('top_news');
	var tab_class=document.getElementById("tab" + tab);
	if (tab_class){ tab_class.className = "tab-selected";}
	var cur_text=news_block[tab];
	if (curtab == 1) { orig_link[1] = gethtm('next_link') };
	sethtm('next_link', orig_link[tab]);
	if (!cur_text){
		sethtm('top_news',  '<small><b>Загрузка...</b></small>' + news_block[curtab]);
		x_get_block(tab,'top_news');
	} else {
		sethtm('top_news', cur_text);
	}
	curtab = tab;
	if (tab == 2){
	    document.location.hash='#last';
	} else if (tab == 3){
	    document.location.hash='#pop';
	} else {
	    document.location.hash='#my';
	}
	return false;
}

function load_topic(forum){
	data_block[forum]='/openforum/topic_'+forum+'.inc';
	sethtm('topic_'+forum,  '<small>Загрузка...</small>');
	x_get_block(forum,'topic_'+forum);
	return false;
}


function sethtm(id, text){
	var item=document.getElementById(id);
	if (item){
		item.innerHTML=text;
	}
}

function gethtm(id){
	var item=document.getElementById(id);
	if (item){
		return item.innerHTML;
	}
}

function rs_init_object(){
	var A;
	try {
		A=new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			A=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			A=null;
		}
	}
	if(!A && typeof XMLHttpRequest != "undefined")
		A = new XMLHttpRequest();
	return A;
}
function x_get_block(id,tag){
	var x;
	x = rs_init_object();
	x.open("GET", data_block[id], true);
	x.onreadystatechange = function() {
	if (x.readyState != 4) {return;}
		sethtm(tag, x.responseText);
	}
	x.send(null);
}

function topic_jump(forum,form) {
    i = form.options[form.selectedIndex].value;
    window.location.href = "/cgi-bin/openforum/vsluhboard.cgi?az=list&forum="+forum+"&dir_topic=" + i;
}

