function tlogin(mode, use_captcha){
	switch (mode) {
// Logon
	case 1:
		if (document.floginf.username.value == ""){
			alert('Пожалуйста, укажите логин!');
			return false;
		}
		if (document.floginf.userpassword.value == ""){
			alert('Пожалуйста, укажите пароль!');
			return false;
		}
		if (use_captcha){
			document.flogin.username.value = document.floginf.username.value;
			document.flogin.userpassword.value = document.floginf.userpassword.value;		
			do_block();
		}else{
			document.floginf.submit();
		}
		return false;
// Logout
	case 2:
		document.floginl.submit();
		return false;
	default:
		return false;	
	}
	return false;
}

function move(form) {
	var index = form.option.selectedIndex;
	if (form.option.options[index].value != "0") {
		if (form.option.options[index].value != "none") {
			location=form.option.options[index].value;
		}
	}
}

function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);
  
  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;

  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

// show item in new window
// used by db functionality
function showDBInfo(id, module, category){
	window.open(SITE_PATH + "/database/" + module + category + (module == "mobs" ? "" : "/detail") + "/" + id + ".html", "_blank", "status=no,resizable=no,width=900,height=560,screenX=100, screenY=50"); 
}
