function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function ShowError( elem, text ) {
    if (errfound) 
        return;
    window.alert (text);
    elem.focus();
       
    errfound = true;
}
function ValidateSelect( obj ) {
    return ( obj.selectedIndex > 0 );
}
function ValidateEmpty( obj ) {
    return ( trim( obj.value) != "" );
}
function ShowPopup( lnk, width, height ) {
    popup = window.open( lnk, 'popup', 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width='+width+', height='+height+'');
    
    if (!popup .opener) 
        popup .opener = self;
    popup.focus();
    return false;
}
function TestNumber( e )
{
      var keynum;
      if(window.event) // IE
      {
        keynum = e.keyCode;
      }
      else if(e.which) // Netscape/Firefox/Opera
      {
        keynum = e.which;
      }  
      
      if ((keynum>=48 && keynum<=58) || (keynum>=96 && keynum<=105)) 
      {
          return true;
      }      
      if (keynum>=33 && keynum<=40) return true;
      if (keynum>=16 && keynum<=18) return true;
      switch(keynum)
      {
          case 27: return true;
        case 8: return true;
        case 9: return true;
        case 13: return true;
        case 46: return true;
        case 45: return true;
        case 189: return true; //- w ie
        case 109: return true; // - w firefox
      }
      return false;
}