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();
  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 {
          ShowAlert("serv");
	  }
    }
  }
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();

  var tdivId;
  typeId == 1 ? tdivId = "lastAnek" : tdivId = "lastStatm";
  $("#"+tdivId).html("Загрузка... <img src='images/wait.gif' border='0' />");

    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(($("#act").css("display") == "block")||($("#tct").css("display") == "block")||($("#tca").css("display") == "block")) {
    $("#act2").empty();
    $("#tca2").empty();
    $("#tct2").empty();
    $("#act2").append("&#8595;");
    $("#tca2").append("&#8595;");
    $("#tct2").append("&#8595;");
    if($("#act").css("display") == "block")
      $("#act").css("display", "none");
    if($("#tct").css("display") == "block")
      $("#tct").css("display", "none");
    if($("#tca").css("display") == "block")
      $("#tca").css("display", "none");
    Nifty("#act3","normal");
    Nifty("#tct3","normal");
    Nifty("#tca3","normal");
    }
  if($("#"+contp).css("display") == "none") {
    $("#"+contp).show("highlight", 1000);
    if($("#"+contp).text().length == 0)
      $("#"+contp).append("<img src='images/wait.gif' border='0' /><br />Идёт загрузка...");
    $("#"+contp+"2").empty();
    $("#"+contp+"2").append("&#8593;");
    $("#"+contp+"3 b").remove();
    $("#"+contp+"3").css("padding","3px 4px");
    Nifty("#"+contp+"3","normal top");
    }
  else {
    $("#"+contp).hide("highlight", 1000);
    $("#"+contp+"2").empty();
    $("#"+contp+"2").append("&#8595;");
    Nifty("#"+contp+"3","normal");
    }
    gotonw();
  viewTags(typeId, tId);
  }

function gotonw() {
  if($(".nw-auth").size() > 0)
    $(".cite-tags").scrollTo(".nw-auth", {speed:900});
  }

function scrollToTop() {
    $('html').scrollTo('#aon-top2', {speed:900});
  if(!($.browser.opera))
  $('body').scrollTo('#aon-top2', {speed:900});
  }

function scrollToSimb(toSimb) {
  $('html').scrollTo('#am'+toSimb, {speed:900});
  $('body').scrollTo('#am'+toSimb, {speed:900});
  $('#km2'+toSimb).show("highlight", 3500);
  }

function subs() {
  if($('#subsmail').val() == "Введите E-mail")
    $('#subsmail').val("");
  if($('#options').css('display') == 'none')
    $('#options').show("blind", 1500);
  }

function subs2() {
  if($('#subsmail').val() == "")
    $('#subsmail').val("Введите E-mail") ;
  }

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 {
          ShowAlert("serv");
	  }
    }
  }

var tarf;
function chk() {
  if (arr = /#(.*)/.exec(document.location)) {
    tarf = arr[1];
    testme(tarf);
    }
  }

function testme(moreper) {
  if(moreper == "test") {
    $("html").append("<div id='mynewtest'></div>");
    $("#mynewtest").css("width","100%");
    $("#mynewtest").css("height","100%");
    $("#mynewtest").css("position","fixed");
    $("#mynewtest").css("top","0px");
    $("#mynewtest").css("z-index","3000");
    $("#mynewtest").css("background","#212121");
    $("#mynewtest").css("opacity","0.87");
    $("#mynewtest").append("<center><div id='mynewform'><div class='lst_anek_div' style='padding:15px 0px 20px 0px;text-align:center;border-bottom:1px solid #aa9889;width:95%;'><h2>Добавить анекдот или высказывание на сайт</h2></div><div style='width:95%;'><table><tr><td style='text-align:left;font-size:140%;padding:15px;'>Ваш e-mail<br /><!-- /td><td style='text-align:left;font-size:140%;padding:6px 15px;' --><input type='mail' name='mail' style='font-size:100%;width:400px;color:#000080' /></td></tr><tr><td style='text-align:left;font-size:140%;padding:15px;vertical-align:top;'>Ваш анекдот (высказывание)<br /><!-- /td><td style='text-align:left;font-size:140%;padding:6px 15px;' --><textarea style='width:400px;height:200px;font-size:100%;'></textarea></td></tr></table><div style='padding:10px 0px 15px 0px;margin-top:5px;width:95%;border-top:1px solid #aa9889;'><b style='font-size:140%;font-weight:normal;color:#9399aa;'><a href='#close' onclick='closeform();'>Отмена</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</b><input type='submit' value='Отправить' style='font-size:120%;' /></div></div></div></center>");
    Nifty("#mynewform","big");
    $("#mynewtest").css("background","none");
    $("#mynewtest").css("opacity","1.00");
    $("#mynew").css("background","black");
    $("#mynew").css("opacity","0.87");
    $("#mynew").css("width","600px");
    $("#mynewform").css("margin","70px 0px 0px 0px");
    $("#mynewform").css("width","600px");
    $("#mynewform").css("background","white");
    $("#mynewform").css("opacity","1.00");
    $("html").append("<div id='mynewtest2'></div>");
    $("#mynewtest2").css("width","100%");
    $("#mynewtest2").css("height","100%");
    $("#mynewtest2").css("position","fixed");
    $("#mynewtest2").css("top","0px");
    $("#mynewtest2").css("background","black");
    $("#mynewtest2").css("opacity","0.87");
    $("#mynewtest2").css("z-index","2999");
    }
  }

function closeform() {
  if($("#mynewtest").size() > 0);
    $("#mynewtest").remove();
  if($("#mynewtest2").size() > 0);
    $("#mynewtest2").remove();
  }

var colnumb = 0;
function thisResult(col,typeId) {
  var rnd = Math.round(Math.random()*1000000000);
  if(xmlHttp5.readyState == 4) {
    if(xmlHttp5.status == 200) {
      if($("embed").size() > 0);
	$("object").parent().remove();
      if($("embed").size() > 0);
	$("embed").parent().remove();
      colnumb = xmlHttp5.responseText;

  if(typeId == 1) {
    if(one1 == -1)
      one1 = colnumb;
    $("#tal2").css("display","inline");
    }
  if(typeId == 2) {
    if(parseInt(one2) == -1)
      one2 = colnumb;
    $("#tal").css("display","inline");
    }
  if(typeId == 3) {
    if(parseInt(one3) == -1)
      one3 = colnumb;
    $("#tal3").css("display","inline");
    }
  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","inline");
  if(one2 == colnumb)
    $("#tal").css("display","none");
  if(one2 == 1)
    $("#tar").css("display","none");
  if(one2 > 1)
    $("#tar").css("display","inline");
  if(one1 == colnumb)
    $("#tal2").css("display","none");
  if(one1 == 1)
    $("#tar2").css("display","none");
  if(one1 > 1)
    $("#tar2").css("display","inline");
      }
    }
  }

function _niftload() {
  Nifty("div.secMenu div.dvsm","normal");
  Nifty("div.secMenu2 div.dvsm2","normal");
  Nifty("div.buff","small transparent");
  Nifty("a.buff2","small transparent");
  Nifty("a.rate-p","small transparent");
  Nifty("a.rate-m","small transparent");
  Nifty("a.rate-or","small transparent");
  Nifty("a.rate-ol","small transparent");
  Nifty("span.anum a","small left transparent");
  Nifty("span.rate","small right transparent");
  Nifty("span.date_ct","right transparent");
  }

function sLogin(param) {
  $("#logindiv").css("display","block");
  $("#logindiv").load("auth.php", {com: param}, function() {Nifty("#logindiv","normal");});
  }

function subscribe() {
  var param1 = $('#subsmail').val();
  var regx = /[а-я]/i;
  var regx2 = /^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/i;
  if(param1 != "Введите E-mail"&&regx.test(param1)==false&&regx2.test(param1)==true) {
    var param2 = $('input[id^=params]:checked').val();
    var param3 = $('#filtr:checked').val();
    $.post("subsc.php", {mail: param1, params: param2, filtr: param3}, function(data) {$('#subsdiv').html(data);});
    }

  if(param1 == ""||param1 == " "||regx.test(param1)==true||param1 == "Введите E-mail")
    if($('#vemltest').length == 0)
      $('#subsdiv').prepend("<b class='veml' id='vemltest'>Укажите адрес электронной почты.</b><br />");
    else
      $('#vemltest').html("Укажите адрес электронной почты.");
  if(regx.test(param1)==false&&regx2.test(param1)==false)
    if($('#vemltest').length == 0)
      $('#subsdiv').prepend("<b class='veml' id='vemltest'>Email введён не верно.</b><br />");
    else
      $('#vemltest').html("Email введён не верно.");
  }

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;
	  $("#"+divId).empty();
	  $("#"+divId).append(textResponse);

  var tdivId;
  typeId == 1 ? tdivId = "lastAnek" : tdivId = "lastStatm";
  $("#"+tdivId).html("");

	  $("#"+divId+" .main-ct").effect("highlight", 2500);
	  $("a.swlike").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
          $("a.swliketh").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
// ----
_niftload();
	  }
	else {
          ShowAlert("serv");
	  }
    }
  }

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);
  }

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 {
      }
    }
  }

function lastAddAnek(typeId) {
  var nTextAnek;
  var nTextAnek2;
  typeId == 1 ? nTextAnek = "(Добавлены только что: <b>" + newCount + "</b>)" : nTextAnek2 = "(Добавлены только что: <b>" + newCount2 + "</b>)";
  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, telemid) {
  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 = function() {handleServerResponse3(telemid);};
    xmlHttp3.send(null);
    }
  }

function ShowAlert(mess) {
  $("#show_mess").empty();
  if(mess == "vote")
    $("#show_mess").html("Вы уже голосовали за этот материал.");
  if(mess == "serv")
    $("#show_mess").html("При обращении к серверу возникли проблемы, попробуйте обратиться позже.");
  if(mess == "save")
    $("#show_mess").html("Выбранный фоновый рисунок сохранён до конца работы с сайтом.");
  if(mess == "err")
    $("#show_mess").html("При выборе фонового рисунка произошла ошибка, попробуйте повторить действие ещё раз.");
  if(mess == "clr")
    $("#show_mess").html("Выбранная картинка отменена.");
  $("#show_mess").show("highlight", 3000);
  $("#show_mess").hide("highlight", 2000);
  }

function handleServerResponse3(telemid) {
  var rateid = telemid + rivote;
  if(xmlHttp3.readyState == 4) {
    if(xmlHttp3.status == 200) {
      textResponse = xmlHttp3.responseText;
      if(textResponse > 0) {
        if($('#'+rateid).css('display') == 'inline')
	  $('#'+rateid).attr("class", 'p');
        if($('#bpl_'+rateid).css('display') == 'inline')
	  $('#bpl_'+rateid).attr("class", 'p');
        }
      if(textResponse < 0) {
        if($('#'+rateid).css('display') == 'inline')
	  $('#'+rateid).attr("class", 'm');
        if($('#bpl_'+rateid).css('display') == 'inline')
	  $('#bpl_'+rateid).attr("class", 'm');
        }
      if(textResponse == 0) {
        if($('#'+rateid).css('display') == 'inline')
	  $('#'+rateid).attr("class", '');
        if($('#bpl_'+rateid).css('display') == 'inline')
	  $('#bpl_'+rateid).attr("class", '');
        }
      if(textResponse == "x") {
	ShowAlert("vote");
	}
      else {
        if($('#'+rateid).css('display') == 'inline')
	  $('#'+rateid).html(textResponse);
        if($('#bpl_'+rateid).css('display') == 'inline') {
	  $('#bpl_'+rateid).html(textResponse);
	  }
        }
var changelem;
      if($('#'+rateid).css('display') == 'inline') {
	changelem = '.'+$('#'+rateid).parent().parent().parent().attr("class");
	$(changelem +':has(b[id='+rateid+'])'+ ' .rate-p').attr("class", "rate-or");
	$(changelem +':has(b[id='+rateid+'])'+ ' .rate-m').attr("class", "rate-ol");
	}
	//document.getElementById(rateid).innerHTML = textResponse;
      if($('#bpl_'+rateid).css('display') == 'inline') {
	changelem = '.'+$('#bpl_'+rateid).parent().parent().parent().attr("class");
	$(changelem +':has(b[id=bpl_'+rateid+'])'+ ' .rate-p').attr("class", "rate-or");
	$(changelem +':has(b[id=bpl_'+rateid+'])'+ ' .rate-m').attr("class", "rate-ol");
	}
      }
    else {
      ShowAlert("serv");
//      alert("При обращении к серверу возникли проблемы: " + xmlHttp3.statusText);
      }
    }
  }

var actn;

function login(act) {
  actn = act;
  if(act == "can") {
    $("#logindiv").css("display","none"); /*
    $("#actmsg").css("background","#ffffff");
    $("#actmsg").empty();
    $("#actmsg").append("&nbsp;"); */
    $("#ontop").removeClass("on-top");
    $("#ontop").addClass("on-top2");
    $("#ontop b").css("display","block");
    }
  else {
  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;");
      $("#actmsg").css("display","none");
      $("#logindiv").css("display","block");
      $("#ontop").removeClass("on-top");
      $("#ontop").addClass("on-top2");
      $("#ontop b").css("display","block");
      document.getElementById('pfline').innerHTML = textResponse;
      }
    else {
      ShowAlert("serv");
//      alert("При обращении к серверу возникли проблемы: " + xmlHttp4.statusText);
      }
    }
  }

function registration() {
  if(document.getElementById('cod').value == "") {
    $("#actmsg").empty();
    $("#actmsg").css("display","block");
    $("#actmsg").css("background","#ffeecc");
    $("#actmsg").append("Введите код регистрации.");
//    alert("Введите свой электронный адрес!");
    }
  else {
    $("#actmsg").empty();
    $("#actmsg").css("display","block");
    $("#actmsg").css("background","#ffeecc");
    $("#actmsg").append("Вы ввели код: "+$('#cod').val());
    }
  }

function enter() {
  var lgn = document.getElementById('lgn').value;
  var psw = document.getElementById('psw').value;
  if(lgn == ""||psw == "") {
//    alert("Введите логин и пароль!");
    $("#actmsg").empty();
    $("#actmsg").css("display","block");
    $("#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;");
      $("#actmsg").css("display","none");
      $("#ontop b").css("display","none");
      $("#ontop").removeClass("on-top2");
      $("#ontop").addClass("on-top");
      document.getElementById('pfline').innerHTML = textResponse;
      }
    else {
      $("#actmsg").empty();
      $("#actmsg").css("display","block");
      $("#actmsg").css("background","#ffeecc");
      $("#actmsg").append("При обращении к серверу возникли проблемы: " + 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);
  }

function changeImg(val) {
  var num_img;
  var imgArray = Array("i/top/main-top13.jpg", "i/top/main-top5.jpg", "i/top/main-top16.jpg", "i/top/main-top17.jpg", "i/top/main-top19.jpg", "i/top/main-top20.jpg", "i/top/main-top22.jpg");
  if(parseInt(val) != 0) {
    var str = $('div.toppage').css('background-image');
    for(var i = 0; i < imgArray.length; i++) {
      num_img = str.indexOf(imgArray[i]);
      if(num_img != -1) {
	num_img = i;
	break;
	}
      }
    var res;
    res = num_img + parseInt(val);
    if(res < 0)
      res = imgArray.length - 1;
    if(res > imgArray.length - 1)
      res = 0;
    var imgUrl = "url('templates/main/"+imgArray[res]+"') center top no-repeat";
    $('div.toppage').css('background', imgUrl);
    $('b#chhr').html(' (<a href="#" onclick="changeImg(\'0\');return false;" class="ch-clr">сброс</a>)');
    res += 1;
    $.post("chpa.php", {fonimg: res}, function(data) {if(data == "-1") ShowAlert("err");});// else ShowAlert("save");
    }
  else {
    var now = new Date()
    var nowday = now.getDay();
    if(nowday == 0)
      nowday = 7;
    res = -1;
    $('b#chhr').html('');
    thisday = parseInt(nowday) - 1;
    var imgUrl = "url('templates/main/"+imgArray[thisday]+"') center top";
    $('div.toppage').css('background', imgUrl);
    $.post("chpa.php", {fonimg: res}, function(data) {if(data == "-1") ShowAlert("err"); else {if(data == "clr") {ShowAlert("clr");}}});// else ShowAlert("save");
    }
  }

function CloseBlock() {
  if($("#mr_b").css("display") == "block")
    $("#mr_b").css("display","none");
  if($("#mr_b2").css("display") == "block")
    $("#mr_b2").css("display","none");
  $.post("chpa.php", {clr: "close"}, function(data) {if(data == "-1") ShowAlert("err"); else {if(data == "clr") {ShowAlert("err");}}});
  }

function ShowBlock() {
  if($("#mr_b").css("display") == "none")
    $("#mr_b").css("display","block");
  if($("#mr_b2").css("display") == "none")
    $("#mr_b2").css("display","block");
  $("#alt_txt").text('[рекламные объявления будут показываться со следующего обновления страницы]');
  $.post("chpa.php", {clr: "view"}, function(data) {if(data == "-1") ShowAlert("err"); else {if(data == "clr") {ShowAlert("err");}}});
  }

var thiscid = 0;
var slt_close = 0;
var view_bpl_anek = 1;
var view_bpl_cite = 1;
function ShowButPanel(comm) {
  if(comm == "upd" && $(".pan-botpanel").css('display') == 'block') {
    $.post("mylike.php", {act: "upd"}, function(data) {if(data == "<a href=\"#\" onclick=\"CloseLTh();return false;\" id=\"bpl_swift\">&ndash;</a><a href=\"#\" onclick=\"ShowButPanel(0);return false;\" id=\"bpl_close\">&times;</a><h4>У вас ещё нет избранных высказываний или анекдотов.</h4>&nbsp;") {slt_close = -1;
  $("#panbpl2").html(data);CloseListTh();$('#bpl_swift').corner("7px");$('#bpl_close').corner("7px"); $('.ch-img a').corner("3px");} else {
$("#panbpl2").html(data);$('#bpl_swift').corner("7px");$('#bpl_close').corner("7px");$('.ch-img a').corner("3px");$("#bpl_help").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
  if($(data).text().find("Анекдоты") == false)
    view_bpl_anek = 0;
  else
    view_bpl_anek = 1;
  if($(data).text().find("Высказывания") == false)
    view_bpl_cite = 0;
  else
    view_bpl_cite = 1;
}});
    }
  else {
    if($(".pan-botpanel").css('display') == 'none') {
      $(".pan-botpanel").effect("slide", 500);
      $(".botpanel").css("z-index","40");
      $.post("mylike.php", {act: "upd"}, function(data) {if(data == "<a href=\"#\" onclick=\"CloseLTh();return false;\" id=\"bpl_swift\">&ndash;</a><a href=\"#\" onclick=\"ShowButPanel(0);return false;\" id=\"bpl_close\">&times;</a><h4>У вас ещё нет избранных высказываний или анекдотов.</h4>&nbsp;") {slt_close = -1; $("#panbpl2").html(data);CloseListTh();$('#bpl_swift').corner("7px");$('#bpl_close').corner("7px");} else {$("#panbpl2").html(data);$('#bpl_swift').corner("7px");$('#bpl_close').corner("7px");$('.ch-img a').corner("3px");
      $('.ch-a').cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|' });$("#bpl_help").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
  if($(data).text().find("Анекдоты") == false)
    view_bpl_anek = 0;
  else
    view_bpl_anek = 1;
  if($(data).text().find("Высказывания") == false)
    view_bpl_cite = 0;
  else
    view_bpl_cite = 1;

if($('#bpl_close').css('display') == 'block')
$('#bpl_swift').corner("7px");$('#bpl_close').corner("7px");
}});
$("a.bbtop").css("height", "45px");
$("a.bbtop").corner("5px");
      }
    else {
      CloseLTh();
      $(".pan-botpanel").hide("slow", function() {$("a.bbtop").css("height", "18px");$("a.bbtop").uncorner().corner("top 5px");});
      $(".botpanel").css("z-index","-1");
      }
    }
  $('.ch-img a').corner("3px");
  }

function CheckLike(obj, cid, typeid) {
  var testDate = new Date();
  var option = { path: "/", expires: 365 };
  var val_cook = '';
  if(typeid == 1)
    val_cook = "anek";
  else
    val_cook = "cite";

  if($(obj).attr("class") == "swlike") {
    $(obj).attr("class","swliketh");
    $(obj).attr("title","Закладки|Удалить из закладок на сайте");
    $.cookie("Prof_iniline["+typeid+"]["+cid+"]", val_cook, option);
    $("a.swliketh").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
    }
  else {
    $(obj).attr("class","swlike");
    $(obj).attr("title","Закладки|Добавить в закладки на сайте");
    $.cookie("Prof_iniline["+typeid+"]["+cid+"]", null, option);
    $("a.swlike").cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|'});
    }

  ShowButPanel('upd');
  ShowListTh(typeid, 'upd');
  }

var panel_is_close = 0;
var count_panel = 0;
function choisePanel(param) {
  count_panel += 1;
  panel_is_close = param;
  }

function CloseLTh() {
  if(panel_is_close == 1)
    ShowListTh(now_type, '');
  choisePanel(1);
  $("#panbplst").css('display','none');
  $("#panbplct").css('display','none');
  $("#panbpl").css("opacity","1.00");
  $(".pan-botpanel").animate({
	marginTop: 0,
	height: 30
	}, 1000 );
  $(".pan-botpanel").uncorner("5px");
  $('#bpl_anek1').corner("top");
  $('#bpl_cite2').corner("top");
  $('.ch-img a').corner("3px");
  $('#bpl_swift').corner("7px");
  $('#bpl_close').corner("7px");
  check_open = 0;
  slt_close = 0;
  now_type = '';
  $("#bplsortpan").css('display','none');
  }

function CloseListTh() {
  if(slt_close == -1 || (view_bpl_anek == 0 && view_bpl_cite == 0)) {
    CloseLTh();
    if(slt_close == -1)
      slt_close = 0;
    }
  }

var bpl_sort = 2;

function bplSortStart(tpid, sortid) {
  bpl_sort = sortid;
  ShowListTh(tpid, 'upd');
  }

function GetCountListTh(data, comm, thiscidTh, tpid) {
if(panel_is_close == 1)
  $("#bplsortpan").css('display','none');
else
  $("#bplsortpan").css('display','block');

  var countlist;
  thiscid = thiscidTh;
  countlist = data;

    if(tpid == 1 && countlist > 0) {
      $("#bpl_anek1").css("background", "#ffffff");
      $("#bpl_cite2").css("background", "#d9cec5");
      $("#bpl_anek1").corner("top");
      $("#bpl_cite2").uncorner("top");
      }
    if(tpid == 2 && countlist > 0) {
      $("#bpl_anek1").css("background", "#d9cec5");
      $("#bpl_cite2").css("background", "#ffffff");
      $("#bpl_anek1").uncorner("top");
      $("#bpl_cite2").corner("top");
      }

  var bpl_reload = false;
  if(tpid == 1 && thiscid == 1 && countlist == 0 && !bpl_reload) {
    tpid = 2;
    thiscid = 2;
    bpl_reload = true;
    }
  if(tpid == 2 && thiscid == 2 && countlist == 0 && !bpl_reload) {
    tpid = 1;
    thiscid = 1;
    bpl_reload = true;
    }

  if(bpl_reload) {
    $.post("mylike.php", {act: "num", typeid: tpid, sortid: bpl_sort}, function(data) {$("#panbplst").parent().append("<span id='bplsortpan'><a href='#' onclick='bplSortStart("+tpid+", 2);return false;' title='Сортировка|Сортировать по возрастанию'>&#8593;</a><a href='#' onclick='bplSortStart("+tpid+", 1);return false;' title='Сортировка|Сортировать по убыванию'>&#8595;</a></span>");$("#panbplst").html(data);$('.sh-info').cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|', positionBy: "mouse" });
});
    bpl_reload = false;
    }
  }

function CountListTh(tpid, comm, thiscidTh) {
  $.ajax({
url: "mylike.php",
type: "POST",
data: "act=cnt&typeid="+tpid,
timeout:3000,
beforeSend:function(){},
success:function(data) {GetCountListTh(data, comm, thiscidTh, tpid);},
error:function(xhr, status) {}
});
  }

var check_open = 0;
var now_type;
function ShowListTh(tpid, comm) {
  $("#panbplst").css('display','block');
  $("#panbplct").css('display','block');
  $("#bplsortpan").css('display','block');
  $("#panbplct").html("<p>Окно просмотра содержимого.</p><hr /><p><i>Для просмотра содержимого закладки, нажмите мышью на любую закладку в списке слева.</i></p><p><i>Для быстрого просмотра содержимого наведите мышь на текст &laquo;[инфо]&raquo; в закладке слева.</i></p>");
  if(($(".pan-botpanel").css("height") == 30||$(".pan-botpanel").css("height") == '30px'||$(".pan-botpanel").css("height") == '30 px') && (check_open == 0 && slt_close == 0)) {
    choisePanel(0);
    $(".pan-botpanel").animate({
	height: 250
	}, 1000, function() {$("#panbpl").css("opacity","0.90");$(".pan-botpanel").corner("bottom 5px");} );
    check_open = 1;
    }
  else {
    if(comm != 'upd' && now_type == tpid) {
      CloseLTh();
      }
    }
  now_type = tpid;
  thiscid = tpid;

  if((comm == 'upd' && tpid == thiscid) || comm == '' && panel_is_close == 0)
    $.post("mylike.php", {act: "num", typeid: tpid, sortid: bpl_sort}, function(data) {if(data == -1) {CloseLTh();} else {$("#bplsortpan").remove();$("#panbplst").parent().append("<span id='bplsortpan'><a href='#' onclick='bplSortStart("+tpid+", 2);return false;' title='Сортировка|Сортировать по возрастанию'>&#8593;</a><a href='#' onclick='bplSortStart("+tpid+", 1);return false;' title='Сортировка|Сортировать по убыванию'>&#8595;</a></span>");$("#panbplst").html(data);
$('.sh-info').cluetip({local: true, attribute: "none", cursor: "pointer", splitTitle: '|', positionBy: "mouse" });
$("#bplsortpan").css('display','block');
}

$('#bplsortpan a').corner("3px");
});

  CountListTh(tpid, comm, thiscid);
  }

function ShowContentTh(obj) {
  if($("embed").size() > 0);
    $("object").parent().remove();
  if($("embed").size() > 0);
    $("embed").parent().remove();
  $("#panbplct").empty();
  if($(obj).css("background-color") == "" || $(obj).css("background-color") == "#ffffd7" || $(obj).css("background-color") == "rgba(0,0,0,0)" || $(obj).css("background-color") == "transparent" || $(obj).css("background-color") == "rgb(255, 255, 215)" || $(obj).css("background-color") == "rgb(255,255,215)" || $(obj).css("background-color") == "#ffffff" || $(obj).css("background-color") == "rgb(255, 255, 255)" || $(obj).css("background-color") == "rgb(255,255,255)") {
    $("#panbplst div a.swliketh").uncorner();

    $("#panbplst div").css("background-color", "#ffffff");
    $(obj).css("background-color", "#abcdef");//#aee38f #9ea3ef 6495ed
    if(!$.browser.msie)
      $("#panbplst div a.swliketh").corner();
    }
  else {
    $(obj).css("background-color", "#ffffff");
    $("#panbplst div a.swliketh").uncorner();
    }
  var sct_num = $(obj).attr('rel');

  $.ajax({
url:"mylike.php",
type:"POST",
data:"act=one&numid="+sct_num+"&typeid="+thiscid,
timeout:3000,
beforeSend:function(){$("#panbplct").html("<img src='images/wait.gif' border='0' /><br />Загрузка...");},
success:function(data) {$("#panbplct").empty();$("#panbplct").append(data);_niftload();
  var scl = screen.width/2 - 82;
  scl += 'px';
  if($.browser.webkit == true) {
    $('.buff-cont').css('left', scl);
    $('.buff-cont').css('top', '237px');
    }
  if($.browser.webkit) {
    $("#panbplct .buff-cont").css("margin-left", "52px");
    $("#panbplct .buff-cont").css("margin-top", "-2px");
    }
},
error:function(xhr, status) {$("#panbplct").text("При загрузке произошла ошибка.");}});
  }

var bpl_save_atr = '';
var bpl_save_obj = '';

function bplTest() {
  $(bpl_save_obj).attr("title", bpl_save_atr);
  }

function onBackgrTh(elem) {
  if(bpl_save_atr != '') {
    bplTest();
    }

  if(bpl_save_atr != '' || bpl_save_obj != elem) {
    bpl_save_atr = $(elem).attr("title");
    bpl_save_obj = elem;
    }

  if($(elem).css("background-color") == "" || $(elem).css("background-color") == "rgba(0,0,0,0)" || $(elem).css("background-color") == "rgba(0, 0, 0, 0)" || $(elem).css("background-color") == "transparent" || $(elem).css("background-color") == "#ffffff" || $(elem).css("background-color") == "rgb(255, 255, 255)" || $(elem).css("background-color") == "rgb(255,255,255)")
    $(elem).css("background-color", "#ffffd7");
  }

function offBackgrTh(elem) {
  if(bpl_save_atr != '')
    bplTest();

  if($(elem).css("background-color") == "#ffffd7" || $(elem).css("background-color") == "rgb(255, 255, 215)" || $(elem).css("background-color") == "rgb(255,255,215)") {
    $(elem).css("background-color", "#ffffff");
    }
  }
var oldquery = '';
var oldtype = '';
var oldpage = '';
function SendQuery(page) {
  textquery = $('#textstr').val();
  textquery = textquery.replace(/[&]/g,'++');
  texttype = $('#tp').val();
  if(shag = '')
    shag = 20;
  if(oldpage != page) {
    $('html').scrollTo('#qsrch', {speed:900});
    if(!($.browser.opera))
      $('body').scrollTo('#qsrch', {speed:900});
    }
  $.ajax({
url: "myquery.php",
type: "POST",
data: "tp="+texttype+"&pg="+page+"&sg="+shag+"&mq="+textquery,
timeout:3000,
beforeSend:function(){if((textquery.length > 3) && ((oldquery != textquery) || (oldtype != texttype) || (oldpage != page))) $('#qres').html("<img src='images/wait.gif' border='0' /><br />Загрузка...");},
success:function(data) {if((textquery.length > 3) && ((oldquery != textquery) || (oldtype != texttype) || (oldpage != page))) ShowAnswer(data, textquery, texttype, page);},
error:function(xhr, status) {}
});
  }

function ShowAnswer(data, textquery, texttype, page) {
  $('.n_all').css('display','none');
  if($("embed").size() > 0);
    $("object").parent().remove();
  if($("embed").size() > 0);
    $("embed").parent().remove();
  $('#qres').empty();
  $('#qres').append(data);
  oldquery = textquery;
  oldtype = texttype;
  oldpage = page;
  }
  
function CloseAnswer() {
  $('#qres').empty();
  $('.n_all').css('display','block');
  $('#qres').append('<small class="qs_about_query">Введите фразу длиннее 3-х символов.</small>');
  oldquery = '';
  oldtype = '';
  oldpage = '';
  }

function testcookie() {
  alert($.cookie("Prof_iniline"));
  }

function jqTest() {
  alert($('link[rel*=style][0]'));
  }
