var winChat = null
var chatRoomFileID  = 0;
var chatRoomFileKey = '';
var chatRoomID = 0
var chatRoomName = ''

function psOpenCurriculumChat( key )
	{
	var fileID  = 36; // RTS_FILE_CURRICULUM
	psOpenChat( fileID, key )
	}

function psOpenCourseChat( code )
	{
	var fileID  = 1; // RTS_FILE_COURSE
	psOpenChat( fileID, code )
	}

function psOpenChat( roomFileID, roomFileKey )
	{
	chatRoomFileID  = roomFileID;
	chatRoomFileKey = roomFileKey;

	chatRoomID = 0
	if (winChat == null || winChat.closed)
		{
		winChat = open( templatePath + "/ChatRoom.htm", "CW" +  objCore.getConnectionID(),
		                "resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,width=790,height=552,left=0,top=0,screenx=0,screeny=0")
		}
	else
		{
		winChat.focus()
		}
	}

function psOpenChatByID( roomID, roomName )
	{
	chatRoomFileID  = 0;
	chatRoomFileKey = '';

	chatRoomID = roomID
	chatRoomName = roomName
	if (winChat == null || winChat.closed)
		{
		winChat = open( templatePath + "/ChatRoom.htm", "CW" + objCore.getConnectionID(),
		                "resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,width=790,height=552,left=0,top=0,screenx=0,screeny=0")
		}
	else
		{
		winChat.focus()
		}
	}

function ExitChatRoom( w, roomID, msg )
	{
	if ( w == null )
		w = open( "", "chatexit", "resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,width=520,height=200" );

	psExitChatRoom( w, roomID, msg )
	winChat = null
	}

function UnloadChat()
	{
	if (winChat != null && !winChat.closed)
		{
		winChat.fCallExit = false
		winChat.close()
		}
	}

function isChatWindowOpen()
    {
    return ( (winChat != null) && (!winChat.closed) )
    }
