var PasswordError = "Incorrect password length (from 3 to 12) or composition (only letters and digits)";

function RightEmail(str) {
  return str.match(/^(\w|-|\d|_)+(\.(\w|-|\d|_)+)*@(\w|-|\d)+(\.(\w|-|\d)+)+$/);
}

function RightPassword(str) {
  return str.match(/^\w{3,12}$/);
}

function KillSpaces(str) {
  return (str.replace(/(^\s*)|(\s*$)/g,"")).replace(/\s\s+/g," ");
}

function RightNumber(str) {
  return(str.match(/^\d+(\.\d+){0,1}$/));
}

function IndOfArr(p_Arr, p_sEl) {
   for (j=0; j<p_Arr.length; j++) if ( p_Arr[j]==p_sEl ) return(j+1);
   return(-1);
}

function check_form_no_spaces(frm,field_names,err_texts) {
  var i, obj;
  for (i=0;i<field_names.length;i++) {
    obj = eval("frm."+field_names[i]);
    if (KillSpaces(obj.value)=="") {
      alert("Field \""+err_texts[i]+"\" cannot be empty");
      obj.select();
      obj.focus();
      return(false);
    }
  }
  return(true);
}

