
    function ShowHideLayer(name, x)
     {
      if (document==null) return;
      if (document.all[name]==null) return;
      if (document.all[name].style==null) return;
      if (x)
       {
        document.all[name].style.display="none";
       }
        else
       {
        document.all[name].style.display="block";
       }
     }

function trimLength(textarea, maxChars)
{
     if(textarea.value.length <= maxChars) return;

     textarea.value = textarea.value.substr(0, maxChars)
}




function canAddCharacter(textarea, maxChars)
{
     if(typeof(textarea.onkeypress.arguments[0]) != 'undefined')
          var keyCode = textarea.onkeypress.arguments[0].keyCode;
     else
     {
          if(document.selection.createRange().text.length != 0) return true;
          var keyCode = event.keyCode;
     }

     var allowedChars = new Array(8, 37, 38, 39, 40, 46);     //Backspace, delete and arrow keys
     for(var x=0; x<allowedChars.length; x++) if(allowedChars[x] == keyCode) return true;

     if(textarea.value.length < maxChars) return true;

     return false;
}

 function select_quick_search() 
  {
    var sndr = window.event.srcElement;
    var key = window.event.keyCode;
    var char_code = String.fromCharCode(key);
    
    var re = new RegExp(sndr.smk_keystrokes + char_code, "i");

    var founded=-1;
    for(var i=0; i<sndr.options.length; i++) 
     {
        if(re.test(sndr.options[i].text)) 
         {
          if (founded>-1)
           {
            sndr.options[founded].selected=false;
           }
          founded=i;
          sndr.options[founded].selected=true;
          sndr.smk_keystrokes += char_code;
          break;
        }
     }

    window.event.returnValue = false;
  }
  
  
  
  
  function displayWindow(url, width, height, options, title) 
   {
    if (width==null) width = 1;
    if (height==null) height = 1;
    if (options==null) options = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent=yes,alwaysRaised=no';
    if (title==null) title = 'Popup';

    Win = window.open(url,'WinPopup', 'width='+width+',height='+height+','+options);
    //Win.onload=function(){Win.document.title=title;}

    Win.focus();
    //Win.blur();
    
   }

