roomlistdelay = 10000;
scrolldelay = 150;
aliveinterval = 50000;
refreshdelay = 6000;
logoutpage = "";
autokick = 0;

function showReminder()
{
	hwnd=window.open(cgi+"&action=reminder","reminder","resizable=yes,scrollbars=yes,width=430,height=200");
}

function setLocation(location,link)
{
	location.replace(link);
}

function doLogin()
{
	if (logoutpage == "")
		setLocation(parent.location,cgi.split("?")[0]);
	else
		setLocation(parent.location,logoutpage);
}
function doSend() {
	text=parent.input.document.inputForm.text2.value;
	parent.input.document.inputForm.text2.value = "";
	sendText(text);
	parent.input.document.inputForm.text2.focus();
}
function addText(text)
{
	parent.input.document.inputForm.text2.value += " "+text;
	parent.input.document.inputForm.text2.focus();
}
function sendText(text)
{
	parent.input.document.inputForm.text.value=text;
	parent.input.document.inputForm.submit();
	if (text!="/alive")
		parent.messages.document.form.lastactive.value=(new Date()).getTime();
}
function updateUserList()
{
	setLocation(parent.users.location,cgi+"&action=userlist");
}
function updateInput()
{
	setLocation(parent.input.location,cgi+"&action=inputframe");
}
function updateOptions()
{
	setLocation(parent.options.location,cgi+"&action=optionsframe");
}
function updateRoomList()
{
	setLocation(parent.rooms.location,cgi+"&action=roomlist");
}
function updateRoomList2()
{
	setTimeout("setLocation(parent.rooms.location,\""+cgi+"&action=roomlist\")",roomlistdelay);
}
function updateRefresh()
{
	setLocation(parent.refresh.location,cgi+"&action=refresh");
}
function viewProfile(user)
{
	hwnd=window.open(cgi+"&action=viewprofile&username="+user,user.substr(1),"resizable=yes,scrollbars=yes,width=430,height=480");
}
function editProfile(user)
{
	hwnd=window.open(cgi+"&action=modifyprofile&username="+user,user.substr(1),"resizable=yes,scrollbars=yes,width=430,height=480");
}
function viewRooms()
{
	hwnd=window.open(cgi+"&action=viewrooms","roomlist","resizable=yes,scrollbars=yes,width=600,height=450");
}
function showUsers()
{
	hwnd=window.open(cgi+"&action=searchuser","allusers","resizable=yes,scrollbars=yes,width=430,height=480");
}
function showAllUsers()
{
	hwnd=window.open(cgi+"&action=allusers","allusers","resizable=yes,scrollbars=yes,width=430,height=480");
}
function addToBanList(host,ip,forwardedfor)
{
	hwnd=window.open(cgi+"&action=modifybanlist&domain="+host+"&ip="+ip+"&forwardedfor="+forwardedfor,"admin","resizable=yes,scrollbars=yes,width=600,height=450");
}
function viewAdmin()
{
	hwnd=window.open(cgi+"&action=admin","admin","resizable=yes,scrollbars=yes,width=600,height=450");
}
function testcol(color)
{
	if (color.length!=6)
		return false;
	for (i=0;i<color.length;i++)
	{
		if ((color.charAt(i)<"0" || color.charAt(i)>"9") && (color.charAt(i)<"a" || color.charAt(i)>"f") && (color.charAt(i)<"A" || color.charAt(i)>"F"))
			return false;
	}
	return true;
}

function toInt(h)
{
	mask="0123456789abcdef";
	h=h.toLowerCase();
	return mask.indexOf(h.charAt(0))*16+mask.indexOf(h.charAt(1));
}

function toHex(i)
{
	mask="0123456789abcdef";
	if (i>255)
		i=255;
	if (i<0)
		i=0;
	return mask.charAt(i/16)+mask.charAt(i%16);
}

function selcol(color)
{
	if (color.charAt(0)=="#")
		color=color.substr(1);
	if (testcol(color))
	{
		if (document.form.color.style)
			document.form.color.style.color=color;
		else if (document.layer)
			document.layer.bgColor=color;
		document.form.red.value = toInt(color.substr(0,2));
		document.form.green.value = toInt(color.substr(2,2));
		document.form.blue.value = toInt(color.substr(4,2));
		color="#"+color;
	}
	else
	{
		if (document.form.color.style)
			document.form.color.style.color="black";
		else if (document.layer)
			document.layer.bgColor="black";
		document.form.red.value = "";
		document.form.green.value = "";
		document.form.blue.value = "";
	}
	document.form.color.value = color;
}



function combineColors()
{
	selcol(toHex(document.form.red.value)+toHex(document.form.green.value)+toHex(document.form.blue.value));
}

function msgOutput(msg)
{
	setTimeout("parent.refresh.location.reload()",refreshdelay);
	lines=msg.split("\n");
	for (i=0;i<lines.length;i++)
	{
		parent.messages.document.write(lines[i]+"\n");
	}
	if (parent.messages.document.form.scroll_always.value==1 || parent.options.document.form.scroll.checked)
		parent.messages.scroll(1,5000000);
}
function doScroll()
{
	setTimeout("doScroll()",scrolldelay);
	if (document.form.scroll_always.value==1 || parent.options.document.form.scroll.checked)
		scroll(1,5000000);
}

