﻿// JScript File

function maxLength(field,maxChars)
 {
       if(field.value.length >= maxChars) {
          event.returnValue=false;
          return false;
       }
 }  

 function maxLengthPaste(field,maxChars)
 {
       event.returnValue=false;
       
       if((field.value.length +  window.clipboardData.getData("Text").length) > maxChars) 
       {
            field.value = field.value.sub(0, 500);
            event.returnValue=true;
       }
       
       event.returnValue=true;
 }


 function FitToContent(text, maxHeight, minHeight) {
     if (!text) return;

     var adjustedHeight = text.clientHeight;

     if (!maxHeight || maxHeight > adjustedHeight) {
         adjustedHeight = Math.max(text.scrollHeight, adjustedHeight);
         if (maxHeight)
             adjustedHeight = Math.min(maxHeight, adjustedHeight);
         if (adjustedHeight > text.clientHeight)
             text.style.height = adjustedHeight + "px";
     }

     if (!minHeight || minHeight < adjustedHeight) {
         adjustedHeight = Math.max(text.clientHeight, text.scrollHeight);
         if (minHeight)
             adjustedHeight = Math.max(minHeight, text.scrollHeight);
         if (adjustedHeight < text.clientHeight)
             text.style.height = adjustedHeight + "px";
     }
 }

 function ShowQuickComment(text, img, btn) {
     img.style.display = 'block';
     btn.style.display = 'block';
     text.style.height = 35;
 }
 function HideQuickComment(text, img, btn) {
     if (text.value == '') {
         img.style.display = 'none';
         btn.style.display = 'none';
         text.style.height = '15';
     } 
 }
