// Verbform Deluxe II

var kon_color = "#FF0066";
var dek_color = "#00CC00";
var misc_color = "#0066FF";
var adj_color = "#FF9900";

// checks for a Sonderzeichen
function checkSonderzeichen(zeichen)
{
  var erlaubte_zeichen = new Array("q","w","e","r","t","z","u","i","o","p","a","s","d","f","g","h","j","k","l","y","x","c","v","b","n","m","Q","W","E","R","T","Z","U","I","O","P","A","S","D","F","G","H","J","K","L","Y","X","C","V","B","N","M");
  var counter_sonderzeichen = 0;
  while(counter_sonderzeichen < erlaubte_zeichen.length)
  {
    if(erlaubte_zeichen[counter_sonderzeichen] != zeichen)
    counter_sonderzeichen++;
    else return false;
  }
  return true;
}


// creates a word list of all the words entered
function create_word_list()
{
  var word_index = 0;
  for(i=0; i<=text.length;i++)
  {
    if(checkSonderzeichen(text.charAt(i)) == true)
      word_index++;
    word_list[word_index] += text.charAt(i);
  }
}


// removes line breaks from the textarea before finding the forms
function filterLineBreaks (ta) {
  //ta.value = ta.value.replace(/\r\n|\r|\n/g, ' ');
  ta.value = ta.value.replace(/\r\n|\r|\n/g, '<br>');
}


// Opens new windows for HTML output
function htmlVerbformDeluxe()
{

  if(results.document.form.eingabe.value == "")
  {
    var wrong_text = "";
    wrong_text += "---------------------------------------------------\n";
    wrong_text += "Es konnte kein Text erkannt werden\n";
    wrong_text += "---------------------------------------------------\n";
    wrong_text += "Bitte geben Sie einen lateinischen Text\n";
    wrong_text += "in das Eingabefeld und klicken Sie danach\n";
    wrong_text += "auf 'Texterkennung'.\n\n";
    alert(wrong_text);
    return;
  }

// Declaration of aufwands_counter
//aufwands_counter = 0;

  // backup copy of the textarea
//  var textarea_backup  = results.document.form.eingabe.value;
  var textarea_backup = "";
  
  for(itext=0;itext<results.document.form.eingabe.value.length;itext++)
    {
      if(results.document.form.eingabe.value.charAt(itext) == "\"")
        textarea_backup += "&quot;";
      else
        textarea_backup += results.document.form.eingabe.value.charAt(itext);
    }
  
  
// Filter out all the nasty line breaks! ;)
filterLineBreaks(results.document.form.eingabe);

// Clear all result lists
clear_this(list_of_text_forms);
clear_this(list_of_dek_forms);
clear_this(list_of_adj_forms);
clear_this(list_of_sonst_forms);

// Insert
  // Get text from text area
  var text = results.document.form.eingabe.value;
  var textLength = text.length;

  // creates a new array for words and Sonderzeichen
  var text_list = new Array();
  // The words are expected to be at least 2 letters in length on the average!!!
  // Therefore, divided by TWO
  for(i=0; i<textLength/2; i++)
    text_list[i] = "";
  var word_index = 0;


//--------------------------------------------------------------------------BEGIN: word_array
  // screens the entire text letter by letter for Sonderzeichen
  for(i=0; i<text.length;i++)
  {
    // a Sonderzeichen generates a new word in the list
    if(checkSonderzeichen(text.charAt(i)))
    {
      // Detect words with the final addition of "que" == "AND" at the end... but exclude common terms such as "atque", "usque" and "quoque"
      if(endsWith(text_list[word_index],"que") && text_list[word_index]!="atque" && text_list[word_index]!="usque" && text_list[word_index]!="quoque" && lowercase(text_list[word_index])!="itaque"  && text_list[word_index]!="neque")
      {
      	// add the beginning part of the word to the word list, then enter "que" as a new word following the first
        text_list[word_index] = text_list[word_index].substring(0,text_list[word_index++].length-3);
        text_list[word_index++] = "que";
      }
      word_index++;

        text_list[word_index++] += text.charAt(i);

    }
    // if it is not a Sonderzeichen, the text is added to the word
    else
      text_list[word_index] += text.charAt(i);
  }
//--------------------------------------------------------------------------END: word_array


//--------------------------------------------------------------------------BEGIN: HTML-output of Search deluxe
  parent.results.document.open("text/html");
  parent.results.document.writeln('<link rel="stylesheet" type="text/css" href="css/kon.css" title="style1">');
  parent.results.document.writeln(html_beginning_1);
  parent.results.document.writeln("<title>" + konVersion + " - Texterkennung - www.lateinseiten.de</title>\n");
  parent.results.document.writeln(html_beginning_2);

// HTML-FILE: Page header
parent.results.document.writeln('<form name="form" method="POST" action="--WEBBOT-SELF--"><input type="hidden" name="eingabe" value="' + textarea_backup + '"></form>');
parent.results.document.writeln("<p align='center' id='head'><a name='top'><b><font size='4'>&lt;-&nbsp;" + konVersion + " - Texterkennung&nbsp; -&gt;</font></b><p><hr size='1'></p>");



//--------------------------------------------------------------------------BEGIN: Suchmodus
// Tabelle mit Suchmodusübersicht



if(parent.field_two.document.form.kon.value != "non" || parent.field_two.document.form.dek.value != "non" || parent.field_two.document.form.sonst.value != "non")
{

var suchmodus = '<table border="0" align="center"><tr>\n';

//if(parent.field_two.document.form.kon.value != "non")
  suchmodus += '<td width="10">&nbsp;</td>\n<td bgcolor="' + kon_color + '" width="10">&nbsp;</td>\n<td><a href="#kon" ><font color="#000000">Verbformen</font></a></td>\n<td width="10">&nbsp;</td>\n';
//if(parent.field_two.document.form.dek.value != "non")
  suchmodus += '<td width="10">&nbsp;</td>\n<td bgcolor="' + dek_color + '" width="10">&nbsp;</td>\n<td><a href="#dek"><font color="#000000">Substantive</font></a></td>\n<td width="10">&nbsp;</td>\n';
//if(parent.field_two.document.form.sonst.value != "non")
  suchmodus += '<td width="10">&nbsp;</td>\n<td bgcolor="' + adj_color + '" width="10">&nbsp;</td>\n<td><a href="#adj"><font color="#000000">Adjektive</font></a></td>\n<td width="10">&nbsp;</td>\n';
//if(parent.field_two.document.form.sonst.value != "non")
  suchmodus += '<td width="10">&nbsp;</td>\n<td bgcolor="' + misc_color + '" width="10">&nbsp;</td>\n<td><a href="#sonst"><font color="#000000">Sonstige Formen</font></a></td>\n<td width="10">&nbsp;</td>\n';

//<td width="10">&nbsp;</td>\n



suchmodus += '</tr></table>';

parent.results.document.write(suchmodus);
}
else
parent.results.document.write('<p><font size="2">Suchmodus: kein Modus ausgewählt</font></p>');

//--------------------------------------------------------------------------END: Suchmodus


parent.results.document.write('<p><font size="2">Eingegebener Text:</font></p>');


// START - Rewriting of text - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

parent.results.document.write('<font size="2" color="000066">');




//var old_title = parent.results.document.title;

var kmax = text_list.length;
  
for(k=0;k<text_list.length;k++)
{
	
// Counter for the stage of the text recognition ----------- BEGIN

  //if(k%15 == 0)
  top.window.status = "Texterkennung bei: " + Math.round(k/kmax*100) + "%";
  
// Counter for the stage of the text recognition ----------- END
	
  var result_form = "";
  var result_form_dekl = "";
  var result_form_misc = "";
  var result_form_adj = "";
  
  
  if(checkSonderzeichen(text_list[k].charAt(0)) || text_list[k].charAt(0) == "")
    result_form = "";
  else
  {
  	  
/*  	  
  // show status
  parent.results.document.title = Math.round(k/text_list.length*100) + "% done.";
  if(k >= text_list.length*3/5)
    parent.results.document.title = old_title;
*/


// Declension and Adjective detection
  	if(parent.field_two.document.form.dek.value != "non")
    {
      result_form_dekl = search_sub_form(text_list[k]);
      result_form_adj = search_adj_form(text_list[k]);
    }

// Misc form detection
  	if(parent.field_two.document.form.sonst.value != "non")
      result_form_misc = search_misc(text_list[k]);

// Conjugation detection
  	if(parent.field_two.document.form.kon.value == "text" || parent.field_two.document.form.kon.value == "texttab")
      result_form = search_form_deluxe(text_list[k]);
  }


// ----------------------------------------------------------------BEGIN: Text with detected words


  
  var result_text = text_list[k];
  //var result_deklinator = '<a href="#" title="' + rec_dekl + line + result_form_dekl + '">' + text_list[k].fontcolor(dek_color) + '</a>'
  //var result_konjugator = '<a href="#" title="' + rec_kon + line +  result_form + '">' + text_list[k].fontcolor(kon_color) + '</a>';
  //var result_misc = '<a href="#" title="' + rec_misc + line +  result_form_misc + '">' + text_list[k].fontcolor(misc_color) + '</a>';



  // K
  if(chk_search(result_form) && !chk_search(result_form_dekl) && !chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
  	//result_text = '.';
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }

  // D
  if(!chk_search(result_form) && chk_search(result_form_dekl) && !chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_dekl + '\')">' + text_list[k].fontcolor(dek_color) + '</a>';
  }

  // M
  if(!chk_search(result_form) && !chk_search(result_form_dekl) && !chk_search(result_form_adj) &&  chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_misc + '\')">' + text_list[k].fontcolor(misc_color) + '</a>';
  }

  // A
  if(!chk_search(result_form) && !chk_search(result_form_dekl) && chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_adj + '\')">' + text_list[k].fontcolor(adj_color) + '</a>';
  }


  // KD
  if(chk_search(result_form) && chk_search(result_form_dekl) && !chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }  


  // KM
  if(chk_search(result_form) && !chk_search(result_form_dekl) && !chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }    

  // KA
  if(chk_search(result_form) && !chk_search(result_form_dekl)  && chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_adj + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }  

  
  // DM
  if(!chk_search(result_form) && chk_search(result_form_dekl) && !chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(dek_color) + '</a>';
  }    

  // DA
  if(!chk_search(result_form) && chk_search(result_form_dekl) && chk_search(result_form_adj) && !chk_search(result_form_misc) )
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_dekl + '<br><br>' + result_form_adj + '\')">' + text_list[k].fontcolor(dek_color) + '</a>';
  }    

  // AM
  if(!chk_search(result_form) && !chk_search(result_form_dekl) && chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form_dekl + '<br><br>' + result_form_adj + '\')">' + text_list[k].fontcolor(dek_color) + '</a>';
  }    

  // KDM
  if(chk_search(result_form) && chk_search(result_form_dekl) && !chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }

  // KDA
  if(chk_search(result_form) && chk_search(result_form_dekl) && chk_search(result_form_adj) && !chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }

  // KAM
  if(chk_search(result_form) && !chk_search(result_form_dekl) && chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }

  // DAM
  if(!chk_search(result_form) && chk_search(result_form_dekl) && chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }

  // KDAM
  if(chk_search(result_form) && chk_search(result_form_dekl) && chk_search(result_form_adj) && chk_search(result_form_misc))
  {
    result_text = '<a href="#" onmouseover="return escape(\'' + result_form + '<br><br>' + result_form_dekl + '<br><br>' + result_form_misc + '\')">' + text_list[k].fontcolor(kon_color) + '</a>';
  }


  parent.results.document.write(result_text);
  
  // Script for introducing the hover-text effect

}
top.window.status = "Texterkennung bei: 100% - (Der " + konVersion + " von Nils Neuenkirchen auf www.lateinseiten.de)";
// ----------------------------------------------------------------END: Text with detected words

// checks if any result was found for a specific search
function chk_search(word)
{
  if(word != "" && word.charAt(word.length-1) != "0")
    return true;
  return false;
}


parent.results.document.write('</font>');


// END - Rewriting of text - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -






// Table of Results for KONJUGATOR
if(parent.field_two.document.form.kon.value=="tab" || parent.field_two.document.form.kon.value=="texttab")
{
  
  
  // Sort array of recognized words alphabetically
  list_of_text_forms.sort();

  // removes double entries from the array
  list_of_text_forms = remove_doubles_from_sorted(list_of_text_forms);


// List of detected Kon-forms is only printed if there is at least one form in the list
if(list_of_text_forms.length > 0)
{
  parent.results.document.write('<br><br><br>');
  parent.results.document.write('<p><font size="2"><a name="kon">Erkannte Verbformen (alphabetisch sortiert)</font><a href="#top"><font size="1" color="000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^ zurück zum Text ^</font></a></p>');


  // Liste der im Text erkannten Verben - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - 
  parent.results.document.write('<table width="100%">');
  with(parent.results.document)
  {
    writeln('<tr bgcolor="' + kon_color + '">');
    writeln('<td>Erkanntes Wort</td>');
    writeln('<td>Infinitiv</td>');
    writeln('<td>Form</td>');
    writeln('<td>Deutsche Übersetzung</td>');
    writeln('<td></td>');
    writeln('</tr>');
  }

  // Print the forms found in the recognition process
  for(i=0; i<list_of_text_forms.length; i++)
  {
    parent.results.document.write(list_of_text_forms[i]);
  }
  parent.results.document.write('</table>');  
}
} // END check whether kon_forms were detected

// Table of Results for DEKLINATOR
if(parent.field_two.document.form.dek.value=="tab" || parent.field_two.document.form.dek.value=="texttab")
{
  // Sort array of recognized words alphabetically
  list_of_dek_forms.sort();

  // removes double entries from the array
  list_of_dek_forms = remove_doubles_from_sorted(list_of_dek_forms);


// List of detected Sub-forms is only printed if there is at least one form in the list

if(list_of_dek_forms.length > 0)
{
  parent.results.document.write('<br><br>');
  parent.results.document.write('<p><font size="2"><a name="dek">Erkannte Substantive (alphabetisch sortiert)</font><a href="#top"><font size="1" color="000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^ zurück zum Text ^</font></a></p>');

  // Liste der im Text erkannten Substantive - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - 
  parent.results.document.write('<table width="100%">');
  with(parent.results.document)
  {
    writeln('<tr bgcolor="' + dek_color + '">');
    writeln('<td>Erkanntes Wort</td>');
    writeln('<td>Fall</td>');
    writeln('<td>Form</td>');
    writeln('<td>Deutsche Übersetzung</td>');
    writeln('<td></td>');
    writeln('</tr>');
  }

  // Print the forms found in the recognition process

  for(i=0; i<list_of_dek_forms.length; i++)
  {
    parent.results.document.write(list_of_dek_forms[i]);
  }

  parent.results.document.write('</table>');  
}
} // END check whether dek_forms were detected



// Table of Results for Adjective forms
if(parent.field_two.document.form.dek.value=="tab" || parent.field_two.document.form.dek.value=="texttab")
{
  // Sort array of recognized words alphabetically
  list_of_adj_forms.sort();

  // removes double entries from the array
  list_of_adj_forms = remove_doubles_from_sorted(list_of_adj_forms);


// List of detected Sub-forms is only printed if there is at least one form in the list

if(list_of_adj_forms.length > 0)
{
  parent.results.document.write('<br><br>');
  parent.results.document.write('<p><font size="2"><a name="dek">Erkannte Adjektive (alphabetisch sortiert)</font><a href="#top"><font size="1" color="000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^ zurück zum Text ^</font></a></p>');

  // Liste der im Text erkannten Substantive - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - 
  parent.results.document.write('<table width="100%">');
  with(parent.results.document)
  {
    writeln('<tr bgcolor="' + adj_color + '">');
    writeln('<td>Erkanntes Wort</td>');
    writeln('<td>Fall</td>');
    writeln('<td>Form</td>');
    writeln('<td>Deutsche Übersetzung</td>');
    writeln('<td></td>');
    writeln('</tr>');
  }

  // Print the forms found in the recognition process

  for(i=0; i<list_of_adj_forms.length; i++)
  {
    parent.results.document.write(list_of_adj_forms[i]);
  }

  parent.results.document.write('</table>');  
}
} // END check whether adj_forms were detected




// Table of Results for SONSTIGE
if(parent.field_two.document.form.sonst.value=="tab" || parent.field_two.document.form.sonst.value=="texttab")
{
  // Sort array of recognized words alphabetically
  list_of_sonst_forms.sort();

  // removes double entries from the array
  list_of_sonst_forms = remove_doubles_from_sorted(list_of_sonst_forms);

//DELETE//alert("Kon: " + list_of_text_forms.length + "\nDek: " + list_of_dek_forms.length + "\nMisc: " + list_of_sonst_forms.length);



// List of detected Sub-forms is only printed if there is at least one form in the list
if(list_of_sonst_forms.length > 0)
{
  parent.results.document.write('<br><br>');
  parent.results.document.write('<p><font size="2"><a name="sonst">Sonstige Formen (alphabetisch sortiert)</font><a href="#top"><font size="1" color="000066">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^ zurück zum Text ^</font></a></p>');

  // Liste der im Text erkannten Verben - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - 
  parent.results.document.write('<table width="100%">');
  with(parent.results.document)
  {
    writeln('<tr bgcolor="' + misc_color + '">');
    writeln('<td>Erkanntes Wort</td>');
    writeln('<td>Deutsche Übersetzung</td>');
    writeln('<td>Grammatikalische Anmerkung</td>');
    writeln('</tr>');
  }

  // Print the forms found in the recognition process

  for(i=0; i<list_of_sonst_forms.length; i++)
  {
    parent.results.document.write(list_of_sonst_forms[i]);
  }

  parent.results.document.write('</table>');
}

} // END check whether sonst_forms were detected

// END - Erkannte Formen - Tabelle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  // reset the textarea to the given value!
  //document.formseek.result_area.value = textarea_backup;

// aufwands_counter & word_lister
//parent.results.document.write('<p>Erstellte Stammformsätze: ' + aufwands_counter + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Durchsuchte Formen: ' + identify_counter + '</p>');
//parent.results.document.write('<p>Word_lister ' + word_lister + '</p>');


// Ending of html file
  parent.results.document.write(html_ending);
}



// Liste aller erkannten Worte eines Textes
// Wird in search_form_deluxe als Ablage für erkannte Formen benutzt
var list_of_text_forms = new Array();

function clear_this(array)
{
  for(i=0; i<array.length; i++)
    array[i] = "";
}


function add2list_of_text_forms(this_text)
{
  list_of_text_forms[list_of_text_forms.length++] = this_text;
}


// The same for the Deklinator
var list_of_dek_forms = new Array();
function add2list_of_dek_forms(this_text)
{
  list_of_dek_forms[list_of_dek_forms.length++] = this_text;
}

// The same for Adjective Forms
var list_of_adj_forms = new Array();
function add2list_of_adj_forms(this_text)
{
  list_of_adj_forms[list_of_adj_forms.length++] = this_text;
}

// The same for Misc Forms
var list_of_sonst_forms = new Array();
function add2list_of_sonst_forms(this_text)
{
  list_of_sonst_forms[list_of_sonst_forms.length++] = this_text;
}

// - - - - - - - - - - - - - - - - - - - - - -


// remove double entries from the list_of_text_forms - - - - - - - - - - - - - - - - - - - -
function remove_doubles_from_sorted(arrayA)
{
   var arrayB = new Array();
   if(arrayA.length != 0)
     arrayB[0] = arrayA[0];
   else
   {
     //alert("Es wurden keine Formen erkannt!");
     return arrayB;
   }
   
   for(i=1; i<arrayA.length; i++)
   {
     if(arrayB[arrayB.length-1] != arrayA[i])
       arrayB[arrayB.length] = arrayA[i];
   }
   return arrayB;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



// ------------------------------------------------------------------------------

// Function for single word search - decision between Latin and German
function single_word_decision(seek,filter)
{

  var single_search_text = "";
  single_search_text += konjugator_text + "";
  single_search_text += "Bitte geben Sie die zu suchende Form in das Eingabefeld ein\n";
  single_search_text += "wählen Sie den Suchmodus und klicken Sie auf Suchen!\n\n\n";
  single_search_text += "\t\tSuchen.";
  single_search_text += lateinseiten_text;

  if(seek == "")
    alert(single_search_text);
  else
  {
if(filter == "all")
{
  parent.results.form.eingabe.value = seek;
  htmlVerbformDeluxe();
}
if(filter == "deu")
  single_word_search(seek,filter);
  }

}


// Function to return a single form - Started by 'Verbformen suchen'
function single_word_search(seekform,filter)
{
	
	
	parent.results.document.open("text/html");
	parent.results.document.writeln('<link rel="stylesheet" type="text/css" href="css/kon.css" title="style1">');

  parent.results.document.writeln(html_beginning_1);
  parent.results.document.writeln("<title>" + konVersion + " - Texterkennung - www.lateinseiten.de</title>\n");
  parent.results.document.writeln(html_beginning_2);

  // HTML-FILE: Page header
  parent.results.document.writeln("<p align='center' id='head'><a name='top'><b><font size='4'>&lt;-&nbsp;" + konVersion + " - Suche nach deutschen Formen&nbsp; -&gt;</font></b><p><hr size='1'></p>");

  parent.results.document.writeln("<u>Gesuchte deutsche Form</u>: '" + seekform + "'");
  	  
    var deu_results = "";

if(seekform.length>2)
      {
      var kon_deu = "";
      var dek_deu = "";
      var adj_deu = "";
      var misc_deu = "";


      // Konjugator Forms
      for(j=0; j<stammformen_list.length; j++)
      {
      	if(lowercase(stammformen_list[j].trans).indexOf(lowercase(seekform)) != -1)
      	{
          kon_deu += "<tr><td id='formenerkennung_td'>" + stammformen_list[j].inf + "</td>";
          kon_deu += "<td id='formenerkennung_td'>" + stammformen_list[j].trans + "</td>";
          kon_deu += "<td align='center'><input type='button' id='buttons_kon' value='konjugieren' onClick='parent.conjugate_verb(\"" + stammformen_list[j].inf + "\");'>" + "</td></tr>";
        }
      }
      // Deklinator Forms
      for(j=0; j<suB_list.length; j++)
      {
      	if(lowercase(suB_list[j].sub_deutsch).indexOf(lowercase(seekform)) != -1)
      	{
          dek_deu += "<tr><td id='formenerkennung_td'>" + suB_list[j].nominativ + "</td>";
          dek_deu += "<td id='formenerkennung_td'>" + suB_list[j].sub_deutsch + "</td>";
          dek_deu += "<td align='center'><input type='button' id='buttons_dek' value='deklinieren' onClick='parent.declinate_sub(\"" + suB_list[j].nominativ + "\");'>" + "</td></tr>";
        }
      }
      // Adjective Forms
      for(j=0; j<adj_list.length; j++)
      {
      	if(lowercase(adj_list[j].adjTrans).indexOf(lowercase(seekform)) != -1)
      	{
          adj_deu += "<tr><td id='formenerkennung_td'>" + adj_list[j].adjNomM + "</td>";
          adj_deu += "<td id='formenerkennung_td'>" + adj_list[j].adjTrans + "</td>";
          adj_deu += "<td align='center'><input type='button' id='buttons_adj' value='deklinieren' onClick='parent.declinate_adj(\"" + adj_list[j].adjNomM + "\");'>" + "</td></tr>";
        }
      }
      // Misc forms
      for(j=0; j<misc_form_list.length; j++)
      {
      	if(lowercase(misc_form_list[j].misc_deutsch).indexOf(lowercase(seekform)) != -1)
      	{
          misc_deu += "<tr><td id='formenerkennung_td'>" + misc_form_list[j].misc_form + "</td>";
          misc_deu += "<td id='formenerkennung_td'>" + misc_form_list[j].misc_deutsch + "</td><td></td></tr>";
        }
      }

    parent.results.document.writeln("<form name='form' method='POST' action='--WEBBOT-SELF--'><input name='eingabe' type='hidden' value='" + seekform +  "'><table width='100%'>");
	
    if(kon_deu != "")
      deu_results += parent.results.document.writeln("<tr><td colspan='3'><h1>Konjugation</h1></td></tr>" + kon_deu);
    if(dek_deu != "")
      deu_results += parent.results.document.writeln("<tr><td colspan='3'><br><h1>Deklination - Substantive</h1></td></tr>" + dek_deu);
    if(adj_deu != "")
      deu_results += parent.results.document.writeln("<tr><td colspan='3'><br><h1>Deklination - Adjektive</h1></td></tr>" + adj_deu);
    if(misc_deu != "")
      deu_results += parent.results.document.writeln("<tr><td colspan='3'><br><h1>Sonstige Formen</h1></td></tr>" + misc_deu);
    if(kon_deu == "" && dek_deu == "" && adj_deu == "" && misc_deu == "")
      deu_results += parent.results.document.writeln("<tr><td colspan='3'>Es wurden keine Formen gefunden.</td></tr>");
    
    
    parent.results.document.writeln("</table></form>");
  }
  else
    parent.results.document.writeln("Bitte geben Sie ein Wort mit mehr als drei Buchstaben ein.");

parent.results.document.writeln('<form name="form" method="POST" action="--WEBBOT-SELF--"><input type="hidden" name="eingabe" value=""></form>');
  

  // Ending of html file
  parent.results.document.write(html_ending);
}
// ------------------------------------------------------------------------------


// Function to conjugate verbs that were retrieved from the German translations (Formenerkennung)
function conjugate_verb(verb)
{
parent.field_one.form.infinitiv.value = verb;
checkForInfinitive();
htmlOutput();
}

// Function to declinate substantives that were retrieved from the German translations (Formenerkennung)
function declinate_sub(sub)
{
parent.field_one.form.nominativ.value = sub;
apply_Dek_forms(sub + ' ');
}
