﻿var sURL = unescape(window.location.pathname) + '?' + window.location.search.substring(1);

function refresh()
{
    //  This version of the refresh function will cause a new
    //  entry in the visitor's history.  It is provided for
    //  those browsers that only support JavaScript 1.0.
    //
    window.location.href = sURL;
}

function textCounter(field, cntfield, maxlimit) {
    var numbreaks;
    numbreaks = field.value.substring(0, maxlimit).match(new RegExp('\n', 'g'));
    if (numbreaks == null)
        numbreaks = 0;
    else
        numbreaks = numbreaks.length;

    if ((field.value.length + numbreaks) > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, (maxlimit - numbreaks));
    else // otherwise, update 'characters left' counter
        cntfield.innerHTML = maxlimit - (field.value.length + numbreaks);
}

function textCounterById(fieldId, cntfieldId, maxLimit) {
    textCounter(document.getElementById(fieldId), document.getElementById(cntfieldId), maxLimit);
}