
function ob_onload() {
  if (document.getElementById("ob_search_form") != null) {
    document.getElementById("ob_search_form").ob_pw.focus();
    // register event
    document.getElementById("ob_searchword").onkeydown = ob_check_enter;
  }
  if (document.getElementById("ob_comment_form") != null)
    document.getElementById("ob_comment_form").ob_comments.focus();
  if (document.getElementById("ob_comment_form") != null)
    ob_counter();
}

function ob_onsearch() {
  document.getElementById("ob_search_form").ob_searchword.focus();
  document.getElementById("ob_search_form").submit();
}

function ob_add_char(ch) {
  document.getElementById("ob_search_form").ob_searchword.value += ch;
  document.getElementById("ob_search_form").ob_searchword.focus();
}

function ob_check_enter(e) {
  if(window.event)
    var key = window.event.keyCode; // IE
  else
    var key = e.which;              // Firefox, etc.
  if (key == 13)
    document.getElementById("ob_search_form").submit();
}

function ob_counter() {
  var ob_max_length = 200;
  var ob_c = document.getElementById("ob_comment_form").ob_comments;
  var ob_c_length = ob_c.value.length;
  if (ob_c_length > ob_max_length) { 
    ob_c.value = ob_c.value.substring(0, ob_max_length);
    document.getElementById("ob_written").innerHTML = ob_max_length;
  }
  else {
    document.getElementById("ob_written").innerHTML = ob_c_length;
  }
  if (ob_c_length == 0) {
    document.getElementById("ob_button").disabled = true;
    document.getElementById("ob_button").style["color"] = '#888888';
  }
  else {
    document.getElementById("ob_button").disabled = false;
    document.getElementById("ob_button").style["color"] = '#333333';
  }
}

function ob_show_comment(l, ob_written, ob_written_max, ob_text, ob_entry, ob_dir) {
  var ob_comment_span = document.getElementById('ob_comment_span');
  if (ob_comment_span.firstChild == null) {
    ob_comment_span.innerHTML =
    ob_written + ' <SPAN ID="ob_written"></SPAN> ' + ob_written_max +
    '<P></P>' +
    '<FORM ID="ob_comment_form" METHOD="POST" ACTION="ob_search.php?l=' + l + '" TARGET="ob_search_frame">' +
    '  <TEXTAREA NAME="ob_comments" ROWS="4" WRAP="ON" onBlur="ob_counter()" onChange="ob_counter();" onClick="ob_counter();" onFocus="ob_counter();" onKeyUp="ob_counter();" CLASS="ob_textfield"></TEXTAREA>' +
    '  <P></P>' +
    '  <INPUT TYPE="HIDDEN" NAME="ob_entry" VALUE="' + ob_entry + '">' +
    '  <INPUT TYPE="HIDDEN" NAME="ob_dir"   VALUE="' + ob_dir   + '">' +
    '  <INPUT TYPE="SUBMIT" ID="ob_button"  VALUE="' + ob_text  + '" CLASS="ob_comment_button">' +
    '</FORM>';
    document.getElementById("ob_comment_form").ob_comments.focus();
  }
  else {
    ob_comment_span.innerHTML = '';
  }
}

function ob_hilite(ob_dir) {
  if (ob_dir == 'is') {
    document.getElementById("ob_span_dir_is").style["color"] = '#333333';
    document.getElementById("ob_span_dir_cz").style["color"] = '#777777';
    document.getElementById("ob_dir_is").checked = true;
  }
  else {
    document.getElementById("ob_span_dir_is").style["color"] = '#777777';
    document.getElementById("ob_span_dir_cz").style["color"] = '#333333';
    document.getElementById("ob_dir_cz").checked = true;
  }
}

function ob_corr_word(corr_word) {
  if (parent.ob_main_frame != undefined)
    parent.ob_main_frame.document.getElementById('ob_searchword').value = corr_word;
}


