function showPic(e)
{
  var url = this.getAttribute('pic');
  url = url.replace(/TN_/,"");

  var X = (document.all) ? event.clientX+document.body.scrollLeft : e.pageX;
  var Y = (document.all) ? event.clientY+document.body.scrollTop : e.pageY;

  var tip = document.getElementById('tip');

  if (!tip) {
    tip = document.createElement('IMG');
    tip.id = 'tip';

    with (tip) 
    {
      style.display = 'none';
      style.position = 'absolute';
//      src='i/null.gif';
      border=1;
      title = "Кликните чтобы закрыть";
    }
    tip.onclick = function () {this.style.display = 'none'};
    
    document.body.appendChild(tip);
  }

  with (tip)
  {
    width = 80;
    height = 60;
    removeAttribute('src');
    style.left=X+10;
    style.top=Y+10;
    style.display='inline';
    src='tn/80x60/'+url;
  }

  hidePic();
  return false;
}/*mouseOver*/

var hiding;
function hidePic()
{
  if(hiding) clearTimeout(hiding);
  hiding=setTimeout("document.images['tip'].style.display='none'",3000);
}/*mouseOut*/

function Init()
{
var list=document.getElementsByTagName("VAR");
for(i=0; i<list.length; i++) //if (list.item(i).className=='cover')
{
  var Parent = list.item(i);	// тег VAR

  if (!Parent.firstChild) continue;

  var Child = Parent.firstChild ? Parent.firstChild : Parent;
  var Value = Parent.firstChild ? Child.nodeValue : "";

  var user = Parent.getAttribute("user");
  var cookie = Parent.getAttribute("cookie");
  var pic = Parent.getAttribute("pic");
  var sex = Parent.getAttribute("sex");
  var online = Parent.getAttribute("online")==1 ? 1:0;
  var className = Parent.className;
  var href = Parent.getAttribute("href");

/*
  Parent.user = user;
  Parent.cookie = cookie;
  Parent.pic = pic;
  Parent.onclick = OnClick;
*/


  if (className == "small")
  {
  var Link=document.createElement("a");
  var TextNode = document.createTextNode("*");
  Link.appendChild(TextNode);
  Link.setAttribute("href", "#");
  Link.onclick = new Function ("SMSpopup('"+user+"','"+cookie+"');return false;");
  Link.setAttribute("title", "Отправить короткое соощение");
  Link.className = "online" + online;
  Parent.replaceChild(Link, Child);
  }
  else
  {
  var Image = document.createElement( 'img' );
  Image.width=18;
  Image.height=18;
  Image.src="http://groove.ru/i/online" + online + ".gif";
  Image.onclick = new Function ("SMSpopup('"+user+"','"+cookie+"');");
  Image.style.cursor = 'pointer';
  Image.title = "Отправить короткое соощение";
  Parent.replaceChild(Image, Child);
  }

  var Link=document.createElement("a");
  var TextNode = document.createTextNode(Value);
  Link.appendChild(TextNode);
  Link.setAttribute("href", (href?href:"/?user="+Value));
  Link.setAttribute("title", Value + " @ GROOVE.RU (открыть в новом окне)");
  if (!href) Link.setAttribute("target", "_blank");
  Link.className = (className=='small') ? (sex==1 ? "boy2" : "girl2") : (sex==1 ? "boy" : "girl");

  Link.setAttribute("pic", pic);
  Link.oncontextmenu = showPic;
  Parent.appendChild ( Link );

}
}/*Init*/

var SMSupdate=30;
var SMStimer;

// эта функция вызывает сама себя
var request;
function SMSrefresh()
{
if(SMStimer) clearTimeout(SMStimer);
SMStimer = setTimeout("SMSrefresh()",1000*SMSupdate);

try 
{ 
  request = new ActiveXObject('Microsoft.XMLHTTP'); 
} 
catch(e) // Mozilla
{ 
  try { request = new XMLHttpRequest() }
  catch (e) 
  { 
    return false;
  }
}


var postdata='';
request.open('POST','cgi-bin/groove_sms.cgi',true) 
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
request.send(postdata);

request.onreadystatechange = function() 
{ 
	if(request.readyState==4) 
      	{ 
		try 
		{ 
//		alert(request.responseText);
		eval(request.responseText);
		}
		catch (e) { 
//		alert("ОШИБКА:\n"+e.name+"\n"+e.message);
		}
      		delete request; 
      	}
}
}/*SMSrefresh*/

function SMSpopup(user,cookie)
{
handler='info_'+cookie;
var href='cgi-bin/groove_popup.cgi?cookie='+cookie+'&user='+user;
win_sms=window.open(href,handler,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=250', handler);
win_sms.focus();
}/*SMSpopup*/

var expDays = 1;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function SetCookie(sName, sValue, Expired)
{
if(!Expired){ document.cookie = sName + "=" + escape(sValue) + "; expires="+ exp.toGMTString(); }
else { document.cookie = sName + "=" + escape(sValue) + "; expires="+ Expired.toGMTString(); }
}/*SetCookie*/

function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
	return unescape(aCrumb[1]);
	}
return null;
}/*GetCookie*/

function DeleteCookie(sName)
{
document.cookie = sName + "=0; expires=Mon, 31 Dec 1999 23:59:59 UTC;";
}/*DeleteCookie*/

function email(string)
{
  href = string.replace(/([^\/]+)\/([^\/]+)\//, "$1@$2.");
  document.write("<a href=\"mailto:"+href+"\">"+href+"</a>");
}/*email*/

/* Предварительная загрузка картинок */
var Bg1 = new Image(); Bg1.src = "i/bg1x50.gif";
var Home = new Image(); Home.src = "i/arrow10x10.gif";
var Loading = new Image(); Loading.src = "i/vertical.gif";
var H2 = new Image(); H2.src = "i/h1-line.gif";
var H3 = new Image(); H3.src = "i/h3-dot.gif";
var H5 = new Image(); H5.src = "i/arrow-down.gif";
var H6 = new Image(); H6.src = "i/arrow-black.gif";

var Menu1 = new Image(); Menu1.src = "i/menu-dot.gif";
var Menu2 = new Image(); Menu2.src = "i/menu-line15x3.gif";
var Menu3 = new Image(); Menu3.src = "i/menu-line.gif";
var Menu4 = new Image(); Menu4.src = "i/menu-bg120x20.gif";
var Menu5 = new Image(); Menu5.src = "i/arrow-down15x15.gif";