var user_info_arr_nick = new Array();
var user_info_arr_text = new Array();
if (navigator.appName != "Netscape") {
	pr_IE = 1;
} else {
	pr_IE = 0;
}
function user_info_creat(sug) {
	var table = '';
	if (sug.length>0) {
		if (sug[0]!='' || sug[10]!='') table += '<div style="text-align:center;margin-bottom:2px">';
		if (sug[10]!='') table += '<img src="http://i.sakh.name/user_photos/s/'+sug[10].substr(0,1)+'/'+sug[10].substr(1,1)+'/'+sug[10]+'.jpg" alt="Фото" border="0" hspace="1">';
		if (sug[0]!='') table += '<img src="http://i.sakh.name/a/'+sug[9]+'/'+sug[0]+'?nc='+sug[1]+'" alt="Аватара" border="0" hspace="1">';
		if (sug[0]!='' || sug[10]!='') table += '</div>';
		table += '<table cellspacing="2" cellpadding="2" border="0"><tr valign="top">';
		table += '<td width="50" class="small">Ник:</td><td class="'+sug[3]+'" nowrap>'+sug[2]+'&nbsp;<img src="http://sakhalin.name/i/pol_'+sug[3]+'.gif" border="0"></td>';
		if (sug[5]!='') table += '<tr><td width="50" class="small">Имя:</td><td nowrap>'+sug[5]+'</td></tr>';
		if (sug[6]!='') table += '<tr><td class="small">Дата<br>рождения:</td><td nowrap>'+sug[6]+'</td></tr>';
		if (sug[7]!='') table += '<tr><td class="small">Город<br>проживания:</td><td nowrap>'+sug[7]+'</td></tr>';
		if (sug[8]!='') table += '<tr><td class="small">Город, в котором<br>проживал'+(sug[3]=='f'?'а':'')+' раньше:</td><td nowrap>'+sug[8]+'</td></tr>';
		table += '<tr><td width="50" class="small">Дата<br>регистрации:</td><td nowrap>'+sug[4]+'</td></tr>';
		table += '</table>';
	} else {
		table = '&nbsp;';
	}
	return table;
}
function ShowMainMenu(el) {
	HideMainMenu();
	if (pr_IE) {
		x = window.event.clientX;
		y = window.event.clientY + document.body.scrollTop;
	} else {
		x = el.pageX;
		y = el.pageY;
	}
	if (x<270) x=0;
	x = x+20;
	y = y+5;
	document.getElementById('main_menu').style.left = x+'px';
	document.getElementById('main_menu').style.top = y+'px';
	document.getElementById('main_menu').style.width = "200px";
	document.getElementById('main_menu').style.visibility = "visible";
}
function HideMainMenu(){
	document.getElementById('main_menu').style.visibility = "hidden";
}
function ShowUserInfo(el, nick) {
	HideUserInfo();
	if (pr_IE) {
		x = window.event.clientX;
		y = window.event.clientY + document.body.scrollTop;
	} else {
		x = el.pageX;
		y = el.pageY;
	}
	if (x<270) x=0;
	x = x+20;
	y = y+5;
	go('user_info').style.left = x+'px';
	go('user_info').style.top = y+'px';
	go('user_info').style.visibility = "visible";
	load_user_info(nick);
}
function HideUserInfo(){
	go('user_info').innerHTML = '&nbsp;';
	go('user_info').style.visibility = "hidden";
	go('user_info').style.left = 0;
	go('user_info').style.top = 0;
}
function load_user_info(nick) {
	var load = true;
	for (i=0;i<user_info_arr_nick.length;i++) {
		if (nick==user_info_arr_nick[i]) {
			load = false;
			go('user_info').innerHTML = user_info_arr_text[i];
			break;
		}
	}
	if (load==true) {
		go('user_info').innerHTML = '<b>Информация о пользователе</b><br><br><img src="/i/'+top.design+'/loading.gif" width="13" height="13"> загрузка...';
		i++;
		var req_info = new JsHttpRequest();  
		req_info.onreadystatechange = function() { 
	        if (req_info.readyState == 4) { 
	        	if (req_info.responseText!='') {
	        		go('user_info').innerHTML = req_info.responseText;
	        		user_info_arr_nick[i] = nick;
	        		user_info_arr_text[i] = req_info.responseText;
	        	} else if (req_info.responseJS!='') {
	        		cnt = user_info_creat(eval(req_info.responseJS));
	        		go('user_info').innerHTML = cnt;
	        		user_info_arr_nick[i] = nick;
	        		user_info_arr_text[i] = cnt;
	        	}
	        }
	    }
	    req_info.open('GET', 'http://forum.sakh.com/js_user_info.php', true);
	    req_info.send({ q: nick });
	}
	return false;
}
function update_who_in_chat() {
	if (go('auto_refresh').checked == true) {
		var req = new JsHttpRequest();
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.responseText!='') {
					go('who_in_chat').innerHTML = req.responseText;
				}
			}
		}
		req.caching = false;
		req.open(null, 'js/new/index_who_in_chat.php?a=1', true); 
		req.send({ v: 1});
	}
	setTimeout('update_who_in_chat();', 5000);
}
function openlink(addr) {
	if (confirm(lang_open_link)==true) { 
		window.open('go.php?url='+addr);
	}
	return false;
}
function openWin(url,w,h,pos,name,attr) {
	var a_attr = new Array ('scrollbars','menubar','toolbar','location','status','resizable','titlebar','hotkeys');
	if( !attr ) attr = '10000100';
	if( !w ) w = 600;
	if( !h ) h = 400;
	var params = 'width='+w+',height='+h;
	for( var i=0; i<a_attr.length; i++ ) params += ','+a_attr[i]+'='+attr.charAt(i);
	if( (parseInt(navigator.appVersion) >= 4 ) && pos=='center' ) { x = (screen.width - w) / 2; y = (screen.height - h) / 2; }
	else if ( pos=='default' ) x=y=false;
	else if ( pos ) { var a_pos = pos.split(','); x = a_pos[0]; y = a_pos[1]; }
	if( x<0 ) x=0;
	if( y<0 ) y=0;
	if( x && y ) params += ',xposition='+x+',left='+x+',yposition='+y+',top='+y;
	if( !name ) name = "newWin";
	var newWin = window.open( url, name, params );
	//newWin.focus();
}
function openRules() { 
	top.openWin('rules.php',600,500,'center','ost_rules','10000100');
}