window.name = "my_chat";
var buttonCaption = 'Send';
var buddyListWidth = 200;
var buddyListHeight = 400;

var isRefreshing = false;

var chatWindowWidth = 615;
var chatWindowHeight = 480;

function check_room_pwd(form_name, room_id)
{
	if(form_name.room_pswd.value == "")
	{
		alert('Please input password');
	}
	else
	{
		var chatWnd = openNewWindow('room_auth.php?room_id=' + room_id, 0, 0);
	}
}

function refreshChatWindow(room_id)
{
	isRefreshing = true;
	window.refr.document.location.href = 'refresh_chat.php?room_id='+room_id;
}

function openNewWindow(wnd_link, wnd_width, wnd_height, title)
{
	if(wnd_width == 0)
	{
		wnd_width = chatWindowWidth;
	}
	if(wnd_height == 0)
	{
		wnd_height = chatWindowHeight;
	}
	if(title == '')
	{
		title = "my_chat";
	}
	var left = parseInt(screen.availWidth - wnd_width - 60 - buddyListWidth);
	var top = 50;
	var chatWnd = window.open(wnd_link, title,'scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,width='+wnd_width+',height='+wnd_height+',left=' + left +',top=' + top + '')
	return chatWnd;
}

function chat_form_submit()
{
	document.chat_form.message_to_add.value = document.chat_form.msg_to_add.value;
	document.chat_form.submit();
	document.chat_form.msg_to_add.value='';
}

function chat_form_check()
{
	document.chat_form.message_to_add.value = document.chat_form.msg_to_add.value;
	document.chat_form.msg_to_add.value='';
}

function scrollWind()
{
	setTimeout(window.chat_history.scrollTo(0, 10000000),3000);
}

function raisePrivateChatWnd(room_id)
{
	var wnd = openNewWindow("private_chat.php?room_id="+room_id, 400, 600, "Private_Chat")
}

function createPrivateChat(s_room_id, partner_id)
{
	var wnd = openNewWindow("private_chat.php?s_room_id="+s_room_id+"&partner_id="+partner_id, 400, 600, "Private_Chat")
}


