<!--
var prev_fld = '';
function chkChrs(frm,fld,txt,searchfor,how){
 string = document.forms[frm].elements[fld].value;
 if(how){
   proof = searchfor.exec(string);
   stop = (proof != string);
 }
 else{
   stop = searchfor.test(string);
 }
 if(stop && (fld == prev_fld || prev_fld == '')){
     alert(txt);
     prev_fld = fld;
     document.forms[frm].elements[fld].focus();
     return
 }
 else prev_fld = '';
}

function chkISODate(frm,fld,txt){
 string = document.forms[frm].elements[fld].value;
 if(string != ""){
   searchfor = /^\d\d\d\d-\d\d-\d\d$/;
   result = searchfor.test(string);
   if(result == false){
     alert(txt);
     document.forms[frm].elements[fld].focus();
     return
   }
   if(chkISODate.arguments.length == 4){
     x = "";
     i = -1;
     while(x != fld) {
          i++;
          x = document.forms[frm].elements[i].name;
     }
     i--;
     if(document.forms[frm].elements[i].value > document.forms[frm].elements[fld].value){
       txt = chkISODate.arguments[3];
       alert(txt);
       document.forms[frm].elements[i].focus();
       return
     }
   }
 }
}

function chkForm() {
   if( document.frm.account) {
   if( !Trim( document.frm.account.value ) ) {
      if( !check_textbox( "frm", "account", "following field: Account" ) ) {
         return false;
      }
   }
   }
   if( document.frm.passwd) {
   if( !Trim( document.frm.passwd.value ) ) {
      if( !check_textbox( "frm", "passwd", "following field: Password" ) ) {
         return false;
      }
   }
   }
   if( document.frm.loginname) {
   if( !Trim( document.frm.loginname.value ) ) {
      if( !check_textbox( "frm", "loginname", "following field: Account LL" ) ) {
         return false;
      }
   }
   }
   if( document.frm.password) {
   if( !Trim( document.frm.password.value ) ) {
      if( !check_textbox( "frm", "password", "following field: Password LL" ) ) {
         return false;
      }
   }
   }
   if( document.frm.account && document.frm.domain ) {   //for groupware
          document.frm.login.value = document.frm.domain.value+document.frm.account.value;
   }
  if( document.frm.loginname && document.frm.domain ) {  //for openwebmail
          document.frm.loginname.value = document.frm.domain.value+document.frm.loginname.value;
   }
   return true;
}

function check_textbox( form_name, element_name, element_msg ) {
   value_var = "document."+form_name+"."+element_name+".value";
   res_value_var = eval( value_var );
   if( !Trim( res_value_var ) ) {
      alert("Please enter the " + element_msg );
      focus_var = "document."+form_name+"."+element_name+".focus()";
      eval(focus_var);
      return false;
   }
   return true;
}

function Trim( str ) {
   for( i=0; i < str.length; i++ ) {
      if(str.charAt(i) != " ") break;
   }
   for( j=str.length - 1; j >= 0; j-- ) {
      if(str.charAt(j) != " ") break;
   }
   if( i == str.length ) {
      str="";
   }
   else {
      str=str.substring(i,j+1);
   }
   return str;
}
//-->

