 // JScript File
 
    function textCounter(field,maxlimit) {
        if (field.value.length > maxlimit) {
            field.value = field.value.substring(0, maxlimit);
            alert('Your input text was too long and has been trimmed!');
        }
    }

function TelerikEditor_OnClientLoad(editor, args)
{
    //handles the right button click context menu appearing in firefox
   var toolAdapter = editor.get_toolAdapter(); 
   toolAdapter.isIE = false;

   //set the focus in the editor
   var editorObject = editor;
   setTimeout(function()
   {
        editorObject.setFocus();
   }, 10);
}

// limit number of words in the textbox
function LimitWordCount(textboxID,labelID,max)
{
    if (document.getElementById(textboxID).value !='')
    {
        var split_words = document.getElementById(textboxID).value.split(' ');
        if (split_words.length > max) 
        {
            var remain = '';
            for (var i=0;i<max;i=i+1)
            {
                if (split_words[i] != null)
                {
                    if (i != max -1)
                        remain = remain + split_words[i] + ' ';
                    else
                        remain = remain + split_words[i];
                }
            }
            document.getElementById(textboxID).value = remain;
            alert('Your input text was too long and has been trimmed! Only ' + max + ' words allowed');
        }
        
        document.getElementById(labelID).innerHTML = document.getElementById(textboxID).value.split(' ').length;
    }
    else
    {
        document.getElementById(labelID).innerHTML = "0";
    }
}
