function Login() {
  this.in_array = function(val, arr) {
    var retVal = false;
    for (var item in arr) {
      if (val == arr[item]) {
        retVal = true;
        break;
      }
    }
    return retVal;
  }
  
  this.str_add = function(s_add, s_string, s_sep) {
    if (s_add == '')
      return s_string;
    s_string != '' ? s_string = s_string + s_sep : 0;
    s_string = s_string + s_add;
    return s_string;
  }
  
  this.onload = function(obj) {
    obj = document.getElementById('hdr_kennung');
    if (obj) {
      obj.value == '' ? obj.value = 'Benutzerkennung' : this.do_focus(obj);
      this.check_password();
    }
  }

  this.key_up = function(obj) {
    this.check_password();
  }
  
  this.check_password = function() {
    obj = document.getElementById('hdr_password_pass');
    obj.value != '' ? this.do_focus(obj) : 0;
  }
  
  this.do_focus = function(obj) {
    if (obj.name == 'Kennung') {
      obj.value == 'Benutzerkennung' ? obj.value = '' : 0;
      obj.className = obj.className.replace(/greyed_out/, '');
    } else if (obj.name == 'Passwort') {
      obj = document.getElementById('hdr_password_txt');
      obj.style.display = 'none';
    }
  }
  
  this.do_click = function(obj) {
    if (obj.id == 'hdr_password_txt') {
      obj.style.display = 'none';
      obj = document.getElementById('hdr_password_pass');
      obj.focus();
    }
  }
  
  this.do_blur = function(obj) {
    if (obj.name == 'Kennung') {
      obj.value == '' ? obj.value = 'Benutzerkennung' : 0;
      obj.value == 'Benutzerkennung' ? obj.className = this.str_add('greyed_out', obj.className, ' ') : 0;
    } else if (obj.name == 'Passwort' && obj.value == '') {
      obj = document.getElementById('hdr_password_txt');
      obj.style.display = 'inline';
    }
  }
  
  this.do_submit = function() {
    var err = '';
    var obj = document.getElementById('hdr_kennung');
    obj.value == '' || obj.value == 'Benutzerkennung' ? err += 'Bitte Benutzerkennung angeben' : 0;
    if (err == '') {
      var obj = document.getElementById('hdr_password_pass');
      obj.value == '' ? err += 'Bitte Passwort angeben' : 0;
      var obj = document.getElementById('hdr_password_txt');
    }
    if (err != '') {
      obj.focus();
      return false;
    } else
      return true;
  }
}

var login = new Login();
