﻿function ShowNHide(control)
{
    try
    {
        var objStyle = $get(control).style;
        
        if (objStyle.display == 'none')
        {
            objStyle.display = 'block';
        }
        else
        {
            objStyle.display = 'none';
        }
    }
    catch (e)
    {
    }
}

function CountChars(textID, countID)
{
    try
    {
        document.getElementById(countID).innerHTML = String(document.getElementById(textID).value.length) + ' chars';
    }
    catch (e)
    {
    }
}

// taken from http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript .
function InsertAtCursor(control, text)
{
    var objControl = document.getElementById(control);
    
    if (document.selection)
    {
        objControl.focus();
        var objSelection = document.selection.createRange();
        objSelection.text = text;
    }
    else if (objControl.selectionStart || objControl.selectionStart == 0)
    {
        var intStart = objControl.selectionStart;
        var intEnd = objControl.selectionEnd;
        objControl.value = objControl.value.substring(0, intStart) + text + objControl.value.substring(intEnd, objControl.value.length);
    }
    else
    {
        objControl.value += text;
    }
}

function SkipError()
{
    return true;
}

window.onerror = SkipError;
