//
// ims 1.1 forum js lib
//
// COPYRIGHT (c)2002,2003 exsys GbR Emden
// ALL RIGHTS RESERVED
//

function isEmail(email) { 
  var filter  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 
  if (email.length == 0) return false; 
  if (filter.test(email)) return true; else return false; 
} 

function ChkEntryAddForm() {
  if (document.FRM_ENTRY_ADD.USER_NAME.value == "") {
     alert("Fehlerhafter Benutzername / Wrong username");
     document.FRM_ENTRY_ADD.USER_NAME.focus();
     return false;
  }
  if (document.FRM_ENTRY_ADD.USER_PASSWORD.value == "") {
     alert("Fehlerhaftes Passwort / Wrong password");
     document.FRM_ENTRY_ADD.USER_PASSWORD.focus();
     return false;
  }
  if (document.FRM_ENTRY_ADD.SUBJECT.value == "") {
     alert("Bitte geben Sie einen Text unter Betreff an / Subject is empty");
     document.FRM_ENTRY_ADD.SUBJECT.focus();
     return false;
  }
  return true;
}

function ChkEntryAddFormThemeAnon() {
  if (document.FRM_ENTRY_ADD.SUBJECT.value == "") {
     alert("Bitte geben Sie einen Text unter Betreff an / Subject is empty");
     document.FRM_ENTRY_ADD.SUBJECT.focus();
     return false;
  }
  return true;
}

function ChkUserAddForm() {
  if (document.FRM_USER_ADD.NAME.value == "") {
     alert("Fehlerhafter Benutzername / Wrong username");
     document.FRM_USER_ADD.NAME.focus();
     return false;
  }
  if (document.FRM_USER_ADD.EMAIL.value == "") {
     alert("Fehlerhafte eMail-Adresse / Wrong eMail address");
     document.FRM_USER_ADD.EMAIL.focus();
     return false;
  }
  return true;
}

function ChkUserEditForm() {
  if (document.FRM_USER_EDIT.USER_PASSWORD.value == "") {
     alert("Fehlerhaftes Passwort / Wrong password");
     document.FRM_USER_EDIT.USER_PASSWORD.focus();
     return false;
  }
  if (document.FRM_USER_EDIT.EMAIL.value == "") {
     alert("Fehlerhafte eMail-Adresse / Wrong eMail address");
     document.FRM_USER_EDIT.EMAIL.focus();
     return false;
  }
  return true;
}

function ChkUserLostPasswordForm() {
  if ((document.FRM_USER_LOSTPASSWORD.NAME.value == "") &&
      (document.FRM_USER_LOSTPASSWORD.EMAIL.value == "")) {
     alert("Benutzername oder eMail-Adresse ist erforderlich / Username or eMail address required");
     document.FRM_USER_LOSTPASSWORD.NAME.focus();
     return false;
  }
  if (document.FRM_USER_LOSTPASSWORD.EMAIL.value != "") {
     if (isEmail(document.FRM_USER_LOSTPASSWORD.EMAIL.value) == false) {
        alert("Die eMail-Adresse ist ungültig / Invalid eMail address");
        document.FRM_USER_LOSTPASSWORD.EMAIL.focus();
        return false;
	 }
  }
  return true;
}

function FormTextAddVal(frmName,txtName,val) {
  txtVal = this.window.document.forms[frmName].elements[txtName].value + val;
  this.window.document.forms[frmName].elements[txtName].value = txtVal;
  this.window.document.forms[frmName].elements[txtName].focus();
}

function ClientDateTime() {
  nowTime = new Date();
  theDayI = nowTime.getDate();
  theMonthI = nowTime.getMonth()+1;
  theYearI = nowTime.getYear();
  if (theYearI<100) theYearI+=1900;
  theDayS = ((theDayI < 10) ? "0" + theDayI : theDayI);
  theMonthS = ((theMonthI < 10) ? "0" + theMonthI : theMonthI);
  theHourI = nowTime.getHours();
  theMinuteI = nowTime.getMinutes();
  theSecondI = nowTime.getSeconds();
  theHourS = ((theHourI < 10) ? "0" + theHourI : theHourI);
  theMinuteS = ((theMinuteI < 10) ? "0" + theMinuteI : theMinuteI);
  theSecondS = ((theSecondI < 10) ? "0" + theSecondI : theSecondI);
  return theYearI+"-"+theMonthS+"-"+theDayS+" "+theHourS+":"+theMinuteS+":"+theSecondS;
}

function SetEntryDate() {
  this.window.document.forms["ENTRYEDIT"].elements["ENTRYDATE"].value = ClientDateTime();
}

function SetEntryLastEntryDate() {
  d = ClientDateTime();
  this.window.document.forms["ENTRYEDIT"].elements["ENTRYDATE"].value = d;
  this.window.document.forms["ENTRYEDIT"].elements["LASTENTRYDATE"].value = d;
}

function SetEntryCitation() {
  citMsg = this.window.document.forms["FRM_ENTRY_ADD"].elements["ENTRYCITATION"].value;
  orgMsg = this.window.document.forms["FRM_ENTRY_ADD"].elements["MSG"].value
  this.window.document.forms["FRM_ENTRY_ADD"].elements["MSG"].value = citMsg+"\n"+orgMsg;
}

