var cDocument;
var cWindow;

function insertMessages(content)
{
    if (!cDocument)
    {
        if (window.frames && window.frames['chat']) cWindow = window.frames['chat'];
            else if (chat.contentWindow) cWindow = chat.contentWindow;
            else cWindow = chat;

        if (cWindow.document) cDocument = cWindow.document;
            else cDocument = cWindow.contentDocument;
    }

    if (cDocument)
    {
        var newDiv = cDocument.createElement('DIV');
        newDiv.innerHTML = content;

        if (cDocument.getElementById('contents'))
        {
            cDocument.getElementById('contents').appendChild(newDiv);

            cWindow.scrollTo(0, cDocument.getElementById('contents').offsetHeight);

            if (window.focus) window.focus();

            document.getElementById('message').focus();
        }
    }
}

function resetForm()
{
    document.getElementById('message').value = '';
    document.getElementById('message').focus();
}

function playSound(soundname)
{
    var sound = eval("document." + soundname);

    try
    {
        sound.Stop();
        sound.Rewind();
    }
    catch (E)
    {
    }

    try
    {
        sound.DoPlay();
    }
    catch (E)
    {
        sound.Play();
    }
}
