var xmlHttp, xmlHttp2, xmlHttp3, xmlHttp4, xmlHttp5, xmlHttp6, xmlHttp7;
var flag = false;
var anek = new Array();
var mcount, itmId, lastElId, itmId2, lastElId2;
function createXmlHttpRequestObject() {
  var xmlHttp = null;
  if(window.ActiveXObject) {
    try {
	  xmlHttp = new XMLHttpRequest();
	  }
	catch(e) {
	    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
		for(var i = 0; i < XmlHttpVersions.length && !xmlHttp; i++) {
		  try {
		    xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
		    }
		  catch(e) {}
		  }
	    }
	  }
  else {
    try {
	  xmlHttp = new XMLHttpRequest();
	  }
	catch(e) {
	  xmlHttp = false;
	  }
    }
  if(!xmlHttp) {
	document.getElementById("divMess").innerHTML = "Ошибка загрузки блока";
	flag = false;
	}
  else {
    flag = true;
    return xmlHttp;
	}
  }
var cnt = 0;
var t = 0;
var misc = 0;
var fpanel = '<div style="background:rgb(250, 180, 180);"><div style="border:2px solid rgb(220, 150, 170);padding:6px 5px;text-align:left;font-size:15px;color:#fff;"><strong>Случайный анекдот</strong></div></div>';
fpanel = '';
var panel = '';
function gen() {
  xmlHttp = createXmlHttpRequestObject();
  t = Math.round(Math.random()*12321);
  misc = Math.round(Math.random()*1000000000);
  anek[anek.length] = t;
  mcount = anek.length;
  if(anek.length > 0) {
    panel = '<div style="font-weight:bolder;font-size:12px;padding:3px;"><a href="javascript:back_a()">&lt;&lt; назад</a> <b style="color:#999;font-weight:normal;">|<!-- навигация | --></b> <a href="javascript:next_a()">вперёд &gt;&gt;</a> <b style="color:#999;font-weight:normal;">&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;</b> <a href=\"javascript:show_new()\">ещё >></a></div>';
	panel = '';
    }
  }
function show_new() {
  load_a();
  //pre_load2();
  process();
  }
function process() {
  gen();
  if(flag) {
    view_anek();
    }
  }
function view_anek() {
  if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
    xmlHttp.open("GET", "last.php?rnd=" + t +"&misc=" + misc, true);
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlHttp.onreadystatechange = handleServerResponse;
	xmlHttp.send(null);
    }
  cnt++;
  }
function handleServerResponse() {
  if(xmlHttp.readyState == 4) {
    if(xmlHttp.status == 200) {
      clearInterval(ntmid);
      mess = "";
      tmess = "";
      cnt_mess = 0;
	  textResponse = xmlHttp.responseText;
	  document.getElementById("divMess").innerHTML = fpanel+panel+textResponse;
	  _niftload();
	  }
	else {
	  alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
	  }
    }
  }
function view_a() {
  alert(anek)
  }
function next_a() {
  if(mcount+1 < anek.length) {
    xmlHttp = createXmlHttpRequestObject();
    misc = Math.round(Math.random()*1000000000);
    mcount+=1;
    t = anek[mcount];
	load_a();
	view_anek();
	}
  }
function back_a() {
  if(mcount==anek.length)
    mcount-=2;
  else
    if(mcount-1 >= 0)
      mcount-=1;
  if(mcount >= 0) {
    xmlHttp = createXmlHttpRequestObject();
    misc = Math.round(Math.random()*1000000000);
    t = anek[mcount];
	load_a();
	view_anek();
	}
  }
function load_a() {
  pre_load();
  }
var mess = "", tmess = "";
var cnt_mess = 0;
var d = document;
var ntmid = 0, ntmid2 = 0;

function counting() {
  cnt_mess++;
  if(cnt_mess < 6) {
    mess = ".";
	tmess += mess;
	}
  else {
    tmess = ".";
    cnt_mess = 1;
    }
  d.getElementById("load_a").innerHTML = "<span style='font-size:11px;color:#999;font-weight:normal;'><nobr><i>Загрузка:</i> <b style='font-size:35px;color:#800;'>" + tmess +"</b></nobr></span>";
  }
function pre_load() {
  clearInterval(ntmid);
  ntmid = setInterval("counting()",500);
  }
function pre_load2() {
  clearTimeout(ntmid2);
  ntmid2 = setTimeout("process()",2550);
  }
//----------
var idLink;
function last(numb,elemId,typeId) {
  typeId == 1 ? itmId = numb : itmId2 = numb;
  typeId == 1 ? lastElId = elemId : lastElId2 = elemId;
  xmlHttp = createXmlHttpRequestObject();
  if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
    xmlHttp.open("GET", "last.php?rnd=" + t +"&last=" + numb + "&type=" + typeId, true);
	xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlHttp.onreadystatechange = function() {handleServerResponse2(typeId)};
	xmlHttp.send(null);
    }
  cnt++;
  }

var one = -1;
var one1 = -1;
var one2 = -1;
var one3 = -1;
function oneAnek(col,typeId) {
  var rnd = Math.round(Math.random()*1000000000);
    xmlHttp5 = createXmlHttpRequestObject();
    if(xmlHttp5.readyState == 4 || xmlHttp5.readyState == 0) {
      xmlHttp5.open("GET", updURL+ "?rnd=" + rnd + "&typeid=" + typeId, true);
      xmlHttp5.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
      xmlHttp5.onreadystatechange = function() {thisResult(col,typeId)};
      xmlHttp5.send(null);
      }
  }
var flag_a = true;
var flag_b = true;
var flag_c = true;
function viewTags(typeId, tId) {
  if(typeId == 1&&flag_a||typeId == 2&&flag_b||typeId == 3&&flag_c) {
  var rnd = Math.round(Math.random()*1000000000);
    xmlHttp7 = createXmlHttpRequestObject();
    if(xmlHttp7.readyState == 4 || xmlHttp7.readyState == 0) {
      xmlHttp7.open("GET", "last.php?rnd=" + rnd + "&tagsid=" + typeId + "&tgsid=" + tId, true);
      xmlHttp7.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
      xmlHttp7.onreadystatechange = function() {thisTags(typeId, tId)};
      xmlHttp7.send(null);
      }
    }
  }

function moreTags(typeId, tId) {
  var contp;
  if(typeId == 1)
    contp = "act";
  if(typeId == 2)
    contp = "tct";
  if(typeId == 3)
    contp = "tca";
  if($("#"+contp).css("display") == "none") {
    $("#"+contp).show("highlight", 1000);
    if($("#"+contp).text().length == 0)
      $("#"+contp).append("Идёт загрузка...");
    $("#"+contp+"2").empty();
    $("#"+contp+"2").append("&#8593;");
    $("#"+contp+"3 b").remove();
    $("#"+contp+"3").css("padding","3px 4px");
    Nifty("div#act3","normal top");
    Nifty("div#tct3","normal top");
    Nifty("div#tca3","normal top");
    }
  else {
    $("#"+contp).hide("highlight", 1000);
    $("#"+contp+"2").empty();
    $("#"+contp+"2").append("&#8595;");
    Nifty("div#act3","normal");
    Nifty("div#tct3","normal");
    Nifty("div#tca3","normal");
    }
    gotonw();
  viewTags(typeId, tId);
  }

function gotonw() {
  if($(".nw-auth").size() > 0)
    $(".cite-tags").scrollTo(".nw-auth", {speed:900});
  }

function thisTags(typeId, tId) {
  var contp, textResponse;
  if(typeId == 1)
    contp = "act";
  if(typeId == 2)
    contp = "tct";
  if(typeId == 3)
    contp = "tca";
  if(xmlHttp7.readyState == 4) {
    if(xmlHttp7.status == 200) {
  if(typeId == 1)
    flag_a = false;
  if(typeId == 2)
    flag_b = false;
  if(typeId == 3)
    flag_c = false;
	  textResponse = xmlHttp7.responseText;
	  $("#"+contp).empty();
	  $("#"+contp).append(textResponse);
	  gotonw();
	  }
	else {
	  alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
	  }
    }
  }

var colnumb = 0;
function thisResult(col,typeId) {
  var rnd = Math.round(Math.random()*1000000000);
  if(xmlHttp5.readyState == 4) {
    if(xmlHttp5.status == 200) {
      colnumb = xmlHttp5.responseText;

  if(typeId == 1) {
    if(one1 == -1)
      one1 = colnumb;
    $("#tal2").css("display","block");
    }
  if(typeId == 2) {
    if(parseInt(one2) == -1)
      one2 = colnumb;
    $("#tal").css("display","block");
    }
  if(typeId == 3) {
    if(parseInt(one3) == -1)
      one3 = colnumb;
    $("#tal3").css("display","block");
    }
  xmlHttp = createXmlHttpRequestObject();
  if(typeId == 1) {
    one = parseInt(one1) + parseInt(col);
    one1 = one;
    }
  if(typeId == 2) {
    one = parseInt(one2) + parseInt(col);
    one2 = one;
    }
  if(typeId == 3) {
    one = parseInt(one3) + parseInt(col);
    one3 = one;
    }
  if(xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
    xmlHttp.open("GET", "last.php?rnd=" + rnd +"&one=" + one + "&type=" + typeId, true);
    xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    xmlHttp.onreadystatechange = function() {handleServerResponse2(typeId)};
    xmlHttp.send(null);
    }
  if(one3 == colnumb)
    $("#tal3").css("display","none");
  if(one3 == 1)
    $("#tar3").css("display","none");
  if(one3 > 1)
    $("#tar3").css("display","block");
  if(one2 == colnumb)
    $("#tal").css("display","none");
  if(one2 == 1)
    $("#tar").css("display","none");
  if(one2 > 1)
    $("#tar").css("display","block");
  if(one1 == colnumb)
    $("#tal2").css("display","none");
  if(one1 == 1)
    $("#tar2").css("display","none");
  if(one1 > 1)
    $("#tar2").css("display","block");
      }
    }
  }

function _niftload() {
  Nifty("div.secMenu div.dvsm","normal");
  Nifty("div.secMenu2 div.dvsm2","normal");
  Nifty("div.tags","normal");
  Nifty("div.buff","small transparent");
  }

function handleServerResponse2(typeId) {
  var divId;
  typeId == 1 ? divId = "lastMess" : divId = "lastMess2";
  if(typeId == 3)
    divId = "lastNews";
  if(xmlHttp.readyState == 4) {
    if(xmlHttp.status == 200) {
      clearInterval(ntmid);
      mess = "";
      tmess = "";
      cnt_mess = 0;
	  textResponse = xmlHttp.responseText;
//	  document.getElementById(divId).innerHTML = textResponse; //fpanel+panel+
//	  $("#"+divId).effect("fade", "fast");
	  $("#"+divId).empty();
	  $("#"+divId).append(textResponse);
	  $("#"+divId+" .main-ct").effect("highlight", 2500);
// ----
_niftload();
	  }
	else {
	  alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
	  }
    }
  }

function normaLink(typeId) {
  if(typeId == 1) {
    document.getElementById('a1').style.fontWeight = "normal";
    document.getElementById('a1').style.color = "#00f";
    document.getElementById('a1').style.fontSize = "12px";
    document.getElementById('a2').style.fontWeight = "normal";
    document.getElementById('a2').style.color = "#00f";
    document.getElementById('a2').style.fontSize = "12px";
    document.getElementById('a3').style.fontWeight = "normal";
    document.getElementById('a3').style.color = "#00f";
    document.getElementById('a3').style.fontSize = "12px";
    }
  else {
    document.getElementById('ta1').style.fontWeight = "normal";
    document.getElementById('ta1').style.color = "#4878fc";
    document.getElementById('ta1').style.fontSize = "12px";
    document.getElementById('ta2').style.fontWeight = "normal";
    document.getElementById('ta2').style.color = "#4878fc";
    document.getElementById('ta2').style.fontSize = "12px";
    document.getElementById('ta3').style.fontWeight = "normal";
    document.getElementById('ta3').style.color = "#4878fc";
    document.getElementById('ta3').style.fontSize = "12px";
    }
  }

// update mainframe
var updURL = "upd.php";
var updateInterval = 15000;
var lastMessageID = -1;
var newCount = 0;
var updateInterval2 = 12000;
var lastMessageID2 = -1;
var newCount2 = 0;
var nwCnt;
var nwCnt2;

function tracer() {
  nwCnt = setInterval("requestNewPost(1);", updateInterval);
//  nwCnt2 = setTimeout("requestNewPost(2);", updateInterval2);
  //alert('test');
  }

function requestNewPost(typeId) {
  misc = Math.round(Math.random()*1000000000);
  xmlHttp2 = createXmlHttpRequestObject();
  if(xmlHttp2.readyState == 4 || xmlHttp2.readyState == 0) {
    xmlHttp2.open("GET", updURL+ "?rnd=" + misc + "&typeid=" + typeId, true);
    xmlHttp2.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    xmlHttp2.onreadystatechange = function() { showThisResult(typeId) };
    xmlHttp2.send(null);
    }
  else {
    typeId == 1 ? clearInterval(nwCnt2) : clearInterval(nwCnt);
    typeId == 1 ? nwCnt = setInterval("requestNewPost(2);", updateInterval2) : nwCnt2 = setInterval("requestNewPost(1);", updateInterval);
    }
  }

function showThisResult(typeId) {
  var lastMessageID_tmp;
  var razn_tmp = 0, razn_tmp2 = 0;
  typeId == 1 ? lastMessageID_tmp = lastMessageID : lastMessageID_tmp = lastMessageID2;
  if(xmlHttp2.readyState == 4) {
    if(xmlHttp2.status == 200) {
      textResponse = xmlHttp2.responseText;
if(isNaN(textResponse))
  location.reload();
      if(lastMessageID_tmp < 0 || lastMessageID_tmp > textResponse) {
	typeId == 1 ? lastMessageID = textResponse : lastMessageID2 = textResponse;
	lastMessageID_tmp = textResponse;
    typeId == 1 ? clearTimeout(nwCnt2) : clearTimeout(nwCnt);
    typeId == 1 ? nwCnt2 = setTimeout("requestNewPost(2);", updateInterval2) : nwCnt = setTimeout("requestNewPost(1);", updateInterval);
	}
      else {
	if(lastMessageID_tmp < textResponse) {
	  typeId == 1 ? lastMessageID = textResponse : lastMessageID2 = textResponse;
	  var if_tmp = lastMessageID_tmp;
	  if(if_tmp+1 < textResponse) {
	    typeId == 1 ? razn_tmp = textResponse - lastMessageID_tmp : razn_tmp2 = textResponse - lastMessageID_tmp;
	    }
	  else
	    typeId == 1 ? razn_tmp = 0 : razn_tmp2 = 0;
	  lastMessageID_tmp = textResponse;
	  if(itmId == null||itmId2 == null)
	    typeId == 1 ? last('1', 'a1', typeId) : last('1', 'ta1', typeId);
	  else
	    typeId == 1 ? last(itmId, lastElId, typeId) : last(itmId2, lastElId2, typeId);
	  if(typeId == 1)
	    razn_tmp == 0 ? newCount++ : newCount += razn_tmp;
	  else
            razn_tmp2 == 0 ? newCount2++ : newCount2 += razn_tmp2;
	  lastAddAnek(typeId);
	  }
    typeId == 1 ? clearTimeout(nwCnt2) : clearTimeout(nwCnt);
    typeId == 1 ? nwCnt2 = setTimeout("requestNewPost(2);", updateInterval2) : nwCnt = setTimeout("requestNewPost(1);", updateInterval);
	}
      }
    else {
//      alert("При обращении к серверу возникли проблемы: " + xmlHttp2.statusText);
      }
    }
//  typeId == 1 ?	document.getElementById('debu').innerHTML += "col: type = " + typeId + " -> new: " + razn_tmp + " || " + lastMessageID_tmp + "<br />" : document.getElementById('debu').innerHTML += "col: type = " + typeId + " -> new2: " + razn_tmp2 + " || " + lastMessageID_tmp + "<br />";
  }

function lastAddAnek(typeId) {
  var nTextAnek;
  var nTextAnek2;
  typeId == 1 ? nTextAnek = "(Добавлены только что: <b>" + newCount + "</b>)" : nTextAnek2 = "(Добавлены только что: <b>" + newCount2 + "</b>)";
//  typeId == 1 ?	document.getElementById('debu').innerHTML += "newCount:" + newCount + nTextAnek + "<br />" : document.getElementById('debu').innerHTML += "newCount2:" + newCount2 + nTextAnek2 + "<br />";
  typeId == 1 ? nTextAnek = document.getElementById("lastAnek").innerHTML = nTextAnek : document.getElementById("lastStatm").innerHTML = nTextAnek2;
    typeId == 1 ? clearTimeout(nwCnt2) : clearTimeout(nwCnt);
    typeId == 1 ? nwCnt2 = setTimeout("requestNewPost(2);", updateInterval2) : nwCnt = setTimeout("requestNewPost(1);", updateInterval);
  }

var rivote = 0;
function VoteAdd(vote, id, type) {
  rivote = id;
  misc = Math.round(Math.random()*1000000000);
  xmlHttp3 = createXmlHttpRequestObject();
  if(xmlHttp3.readyState == 4 || xmlHttp3.readyState == 0) {
    xmlHttp3.open("GET", "vote.php?rnd=" + misc + "&vote=" + vote + "&voteid=" + id + "&type=" + type, true);
    xmlHttp3.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    xmlHttp3.onreadystatechange = handleServerResponse3;
    xmlHttp3.send(null);
    }
  }

function handleServerResponse3() {
  var rateid = "rvid" + rivote;
  if(xmlHttp3.readyState == 4) {
    if(xmlHttp3.status == 200) {
      textResponse = xmlHttp3.responseText;
      if(textResponse > 0)
	document.getElementById(rateid).className = "p";
      if(textResponse < 0)
	document.getElementById(rateid).className = "m";
      if(textResponse == 0)
	document.getElementById(rateid).className = "";
      if(textResponse == "x")
	alert("Вы уже голосовали за этот материал!");
      else
	document.getElementById(rateid).innerHTML = textResponse;
      }
    else {
      alert("При обращении к серверу возникли проблемы: " + xmlHttp3.statusText);
      }
    }
  }

var actn;

function login(act) {
  actn = act;
  if(act == "can") {
    $("#actmsg").css("background","#ffffff");
    $("#actmsg").empty();
    $("#actmsg").append("&nbsp;");
    }
  misc = Math.round(Math.random()*1000000000);
  xmlHttp4 = createXmlHttpRequestObject();
  if(xmlHttp4.readyState == 4 || xmlHttp4.readyState == 0) {
    xmlHttp4.open("GET", "login.php?rnd=" + misc + "&act=" + act, true);
    xmlHttp4.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    xmlHttp4.onreadystatechange = addDivContent;
    xmlHttp4.send(null);
    }
  }

function addDivContent() {
  if(xmlHttp4.readyState == 4) {
    if(xmlHttp4.status == 200) {
      textResponse = xmlHttp4.responseText;
      $("#actmsg").css("background","#ffffff");
      $("#actmsg").empty();
      $("#actmsg").append("&nbsp;");
      document.getElementById('pfline').innerHTML = textResponse;
      }
    else {
      alert("При обращении к серверу возникли проблемы: " + xmlHttp4.statusText);
      }
    }
  }

function registration() {
  if(document.getElementById('eml').value == "") {
    $("#actmsg").empty();
    $("#actmsg").css("background","#ffeecc");
    $("#actmsg").append("Введите свой электронный адрес!");
//    alert("Введите свой электронный адрес!");
    }
  else {
    $("#actmsg").empty();
    $("#actmsg").css("background","#ffeecc");
    $("#actmsg").append("Вы ввели адрес: "+$('#eml').val());
    }
  }

function enter() {
  var lgn = document.getElementById('lgn').value;
  var psw = document.getElementById('psw').value;
  if(lgn == ""||psw == "") {
//    alert("Введите логин и пароль!");
    $("#actmsg").empty();
    $("#actmsg").css("background","#ffeecc");
    $("#actmsg").append("Введите логин и пароль!");
    }
  else {
    misc = Math.round(Math.random()*1000000000);
    misc2 = Math.round(Math.random()*1000000000);
    xmlHttp5 = createXmlHttpRequestObject();
    if(xmlHttp5.readyState == 4 || xmlHttp5.readyState == 0) {
      xmlHttp5.open("POST", "auth.php?rnd=" + misc + "&atn=" + misc2 + "&lgn=" + lgn + "&pwd=" + psw, true);
      xmlHttp5.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//      xmlHttp5.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
      xmlHttp5.onreadystatechange = addDivContent2;
      xmlHttp5.send("auth.php?rnd=" + misc + "&atn=" + misc2 + "&lgn=" + lgn + "&pwd=" + psw);
      }
    }
  }

function addDivContent2() {
  if(xmlHttp5.readyState == 4) {
    if(xmlHttp5.status == 200) {
      textResponse = xmlHttp5.responseText;
      $("#actmsg").css("background","#ffffff");
      $("#actmsg").empty();
      $("#actmsg").append("&nbsp;");
      document.getElementById('pfline').innerHTML = textResponse;
      }
    else {
      alert("При обращении к серверу возникли проблемы: " + xmlHttp5.statusText);
      }
    }
  }

function elem5(el) {
  var result, elem4, elem5;
  var abc1 = "g";
  var abc2 = "m";
  var abc3 = "a";
  var abc4 = "i";
  var abc5 = "l";
  elem5 = abc1+abc2+abc3+abc4+abc5;
  elem4 = "for"+abc4+"n"+abc4+abc5+abc4+"ne";
  var elem1 = "@";
  var elem2 = ".";
  var elem3 = "com";
  result = "<b><i>E</i></b>-<b>mail</b>: <"+"a"+" "+"h"+"r"+"ef"+"="+"\""+abc2+abc3+abc4+abc5+"to"+":"+elem4+elem1+elem5+elem2+elem3+"\""+">"+elem4+elem1+elem5+elem2+elem3+"<"+"/"+"a"+">";
  document.getElementById(el).innerHTML = result;
  }

var nowid = 0;
var cladd = '';
function showdopmenu(id) {
  if(nowid != 0)
    hidemenunow(nowid);
  nowid = id;
  document.getElementById(id).style.visibility = "visible";
  cladd = document.getElementById("t"+id).className;
  document.getElementById("t"+id).className = "acti4";
  clearTimeout(timeoutint);
  }

function hidemenunow(id) {
  document.getElementById(id).style.visibility = "hidden";
  if(cladd == "" || cladd == NaN || cladd == undefined || cladd == "acti4") {
    document.getElementById("t"+id).className = "";
    }
  if(id == "m1" && cladd == "acti2") {
    document.getElementById("t"+id).className = "acti2";
    }
  if(id == "m2" && cladd == "acti3") {
    document.getElementById("t"+id).className = "acti3";
    }
  if(id == "m4" && cladd == "acti") {
    document.getElementById("t"+id).className = "acti";
    }
  nowid = 0
  }

var timeoutint;
function hidemenu(id) {
  clearTimeout(timeoutint);
  timeoutint = setTimeout("hidemenunow('"+id+"')", 2000);
  }

function hidemainmenu() {
  if(nowid != 0)
    hidemenunow(nowid);
  }

var adrinirand = "http://www.iniline.ru/randoms.php";
var adr = "http://www.iniline.ru/randoms.php";
var tmp_flag = false;
var linearr1 = new Array();
var linearr2 = new Array();
var linearr3 = new Array();
var linearr = new Array(linearr1, linearr2, linearr3);
linearr[0] = "";
linearr[1] = "act=show";
linearr[2] = "t=a";
function show_adr(param_x, param_y) {
  adr = adrinirand;
  var adrarr1 = new Array();
  var adrarr2 = new Array();
  var adrarr3 = new Array();
  var adrarr = new Array(adrarr1, adrarr2, adrarr3);
  adrarr[0][0] = "";
  adrarr[0][1] = "e=koi8-r";
  adrarr[0][2] = "e=utf8";
  adrarr[1][0] = "act=show";
  adrarr[1][1] = "act=hide";
  adrarr[2][0] = "t=a";
  adrarr[2][1] = "t=s";
  adrarr[2][2] = "t=r";
  var adrarrtxt1 = new Array();
  var adrarrtxt2 = new Array();
  var adrarrtxt3 = new Array();
  var adrarrtxt = new Array(adrarrtxt1, adrarrtxt2, adrarrtxt3);
  adrarrtxt[0][0] = "windows-1251";
  adrarrtxt[0][1] = "koi8-r";
  adrarrtxt[0][2] = "utf8";
  adrarrtxt[1][0] = "без цензуры";
  adrarrtxt[1][1] = "с цензурой";
  adrarrtxt[2][0] = "анекдоты";
  adrarrtxt[2][1] = "высказывания";
  adrarrtxt[2][2] = "случайный";
  linearr[param_x] = adrarr[param_x][param_y];
  for(var i = 0;i < linearr.length; i++) {
    if((linearr[i].length != undefined && linearr[i].length != 0) && !tmp_flag) {
      adr += "?"+linearr[i];
      tmp_flag = true;
      }
    else
      if((linearr[i].length != undefined && linearr[i].length != 0) && tmp_flag)
        adr += "&"+linearr[i];
    }
  tmp_flag = false;
  adr = '<script type="text/javascript" src="'+adr+'"></script>'
  document.getElementById('adr_line').value = adr;
  document.getElementById("sa"+param_x+0).style.background = '#ddddee';
  document.getElementById("sa"+param_x+1).style.background = '#ddddee';
  document.getElementById("sa"+param_x+2).style.background = '#ddddee';
  document.getElementById("sa"+param_x+0).innerHTML = '<a href="javascript:show_adr('+param_x+', 0)">'+adrarrtxt[param_x][0]+'</a>';
  document.getElementById("sa"+param_x+1).innerHTML = '<a href="javascript:show_adr('+param_x+', 1)">'+adrarrtxt[param_x][1]+'</a>';
  if(param_x != 1)
    document.getElementById("sa"+param_x+2).innerHTML = '<a href="javascript:show_adr('+param_x+', 2)">'+adrarrtxt[param_x][2]+'</a>';
  document.getElementById("sa"+param_x+param_y).style.background = '#ffddcc';
  document.getElementById("sa"+param_x+param_y).innerHTML = adrarrtxt[param_x][param_y];
  document.body.blur();
  document.getElementById('adr_line').select();
  }

function reRun(bsid, params) {
  $(bsid).append(params);
  }