function show(privat, color, from, to, dateReg, message)
{
	if(top.mcount > 300 || top.mcount == 0)
	{
		finish = 0;
		top.mcount = 1;

		if(top.mcount > 300)
		{
			finish = 1;
		}

		init(finish);
	}

	if(color > 0)
		message = '<font color="' + top.Color[color] + '">' + message + '</font>';

	if(privat < 2)
	{
		name = from;

		if(to != "")
		{
			status = "";

			if(privat == 1)
			{
				status = "(<b>ψεοχες</b>) ";
				name   = '<font color="#009900">' + name + '</font>';
			}       	
			else if(to == top.login)
			{
				name = '<font color="red">' + name + '</font>';

				alarm();
			}

			to = status+'<span onclick="top.chater(\''+to+'\');" class="web">' + to + '</span>, ';
		}

		if(from == top.login) name = "<font color='blue'>" + name + "</font>";

		from    = '<span onclick="top.chater(\'' + from + '\');\" class="web">' + name + '</span>';
		message = '<table><tr valign="top"><td>' + from + ':</td><td>' + to + ' ' + message + '</td></tr></table>';
	}
	else
	{
		if(from != "") from = "<span onclick=\"top.chater('" + from + "');\" class=\"web\"><b>" + from + "</b></span>";

		message = "<div class=\"system\"><img src=\"/files/smiles/sys.gif\"> " + from + " " + message + "</div>";

		chaterRefresh();
	}

	top.frames["msg"].document.writeln(message);

	top.mid = dateReg;
	top.mcount++;

	scroll();
}

function init(finish)
{
	if(finish==1)
	{
		top.frames["msg"].document.writeln('</body></html>');
		top.frames["msg"].document.close();
	}

	top.frames["msg"].document.open();
	top.frames["msg"].document.writeln('<html><head><link href="/includes/chat.css" type=text/css rel="stylesheet"><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></head><body>');
}

function chater(name)
{
	if(top.frames["form"].document.forms[0].to)
	{
		top.frames["form"].document.forms[0].to.value=name;
		msgFocus();
	}
}

function scroll()
{
	top.frames["msg"].scroll(1,1000000);
}

function send()
{
	parent.frames["form"].document.forms[0].message.value=parent.frames["form"].document.forms[0].temp.value;
	parent.frames["form"].document.forms[0].temp.value="";

	msgFocus();
}

function refresh(timeout, id)
{
	if(timeout) setTimeout("refresh(false, '"+id+"')", top.Refresh*1000);
	else top.frames["msgshow"].document.location.href="/chat/chat.php?action=show&id="+top.mid;
}

function chaterRefresh()
{
	top.frames["online"].document.location.href=top.frames["online"].document.URL;
}

function msgFocus()
{
	parent.frames["form"].document.forms[0].temp.focus();
}

function smile(symbol) 
{
	if(window.opener.top.frames['form'].document.forms[0].temp)
		window.opener.top.frames['form'].document.forms[0].temp.value+="[::"+symbol+"::]";
}

function openWindow(Path, width, height) 
{
	var Width=450;
	var Height=600;

	if(width>0) Width=width;
	if(height>0) Height=height;

	window.open(Path, "smile", "height="+Height+", width="+Width+", toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=1, left=200, top=50, resizable=1");
}

function alarm()
{
	if(!top.infocus)
	{
		window.focus();
		msgFocus();
	}
}

