/* functions for limiting nr of characters typed in a textarea element: */
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, 13, 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;
}

/* functions to enable a popup whenever the user clicks on the image link: */
function PopupPic(img){
 foto1= new Image();
 foto1.src=(img);
 CheckPicture(img);
}

function CheckPicture(img){

if((foto1.width!=0)&&(foto1.height!=0))
{
      viewPicture(img);
}
else
{
      uitvoering="CheckPicture('"+img+"')";
      interval=setTimeout(uitvoering,20);
}
}
function viewPicture(img){
 imgbreedte=foto1.width;
 imghoogte=foto1.height;
 vars="width="+imgbreedte+",height="+imghoogte+",left="+((screen.width-imgbreedte)/2)+",top="+((screen.height-imghoogte)/2);
 newwindow=window.open("","nieuwvenster",vars);
 newwindow.document.clear();
 newwindow.document.write("<html>\n<head>\n<title>Click in the window to close.     </title>\n");
 newwindow.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\">\n");
 newwindow.document.write("</head>\n\n<body style=\"margin:1px; padding:1px; background-color:black; \" onBlur=\"window.close()\">\n");
 newwindow.document.write("<img src=\""+img+"\" border=\"0\" onclick=\"javascript:window.close()\">\n");
 newwindow.document.write("</body>\n</html>\n");
 if (newwindow.document.focus) {newwindow.document.focus();}
 newwindow.document.close();
}
// end of script
