// JavaScript Document
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
  // alert(retValue);
   return retValue; // Return the trimmed string back to the user
}
var cnt = 0;
var arr_uebung_01 = new Array(
"cht",
"ger",
"ens",
"fte",
"ren",
"ang",
"hen",
"ach",
"hre",
"nen",
"en",
"nte",
"ibt",
"gern",
"mer",
"nnt",
"en",
"iker",
"ann",
"end",
"cht",
"em",
"hen",
"rer",
"atz"
                             );

function Ergebnis_uebung_01(){
	cnt = 0;
	//alert(cnt +arr_uebung_01.length );
	for(i = 0,cnt=1;i<arr_uebung_01.length;i++){
		 var txtVal = document.getElementById(cnt).value;
		 var txtTrimedString = trim(txtVal);
		// alert(arr_uebung_01[i] + txtTrimedString)
		 if(arr_uebung_01[i] == txtTrimedString)
		   document.getElementById(cnt).style.backgroundColor = "#66FF33";
		 else
		   document.getElementById(cnt).style.backgroundColor = "#ff0033";
		   cnt = cnt + 1;
	}
	
}
function Loesung_uebung_01(){
	
	for(i = 0,cnt=1;i<arr_uebung_01.length;i++){
		//alert('i :- '+i+'\ncnt :- '+cnt);
		if((document.getElementById(cnt).style.backgroundColor == 'rgb(255, 0, 51)'||document.getElementById(cnt).style.backgroundColor == '')||document.getElementById(cnt).style.backgroundColor == '#ff0033'||document.getElementById(cnt).style.backgroundColor == '' ){
  			 document.getElementById(cnt).value = arr_uebung_01[i];
			 document.getElementById(cnt).style.backgroundColor = "#CCCCCC";
		}
		 cnt = cnt + 1;
	}
	cnt = 0;
}
var arr_uebung_02 = new Array(
//Aufgabe 26 Lehrstellenmangel
"fen",
//Aufgabe 27
"nde",
//Aufgabe 28
"nen",
//Aufgabe 29
"scht",
//Aufgabe 30
"er",
//Aufgabe 31
"nde",
//Aufgabe 32
"cht",
//Aufgabe 33 
"bot",
//Aufgabe 34
"age",
//Aufgabe 35
"nen",
//Aufgabe 36
"ige",
//Aufgabe 37
"den",
//Aufgabe 38
"den",
//Aufgabe 39
"men",
//Aufgabe 40
"ten",
//Aufgabe 41
"ur",
//Aufgabe 42
"ren",
//Aufgabe 43
"bot",
//Aufgabe 44
"iert",
//Aufgabe 45
"dem",
//Aufgabe 46
"men",
//Aufgabe 47
"ass",
//Aufgabe 48 
"ber",
//Aufgabe 49
"sse",
//Aufgabe 50
"gen"
                              );

function Ergebnis_uebung_02(){
	cnt = 0;
	for(i = 0,cnt=26;i<arr_uebung_02.length;i++){
		 var txtVal = document.getElementById(cnt).value;
		 
		 var txtTrimedString = trim(txtVal);
		// alert(arr_uebung_02[i] + txtTrimedString)
		 if(arr_uebung_02[i] == txtTrimedString)
		   document.getElementById(cnt).style.backgroundColor = "#66FF33";
		 else
		   document.getElementById(cnt).style.backgroundColor = "#ff0033";
		   cnt = cnt + 1;
	}
}
function Loesung_uebung_02(){
	
	cnt = 0;
	
	for(i = 0,cnt=26;i<arr_uebung_02.length;i++){
		//alert(document.getElementById(cnt).style.backgroundColor);
         if((document.getElementById(cnt).style.backgroundColor == 'rgb(255, 0, 51)'||document.getElementById(cnt).style.backgroundColor == '')||document.getElementById(cnt).style.backgroundColor == '#ff0033'||document.getElementById(cnt).style.backgroundColor == '' ){
  		     document.getElementById(cnt).value = arr_uebung_02[i];
			 document.getElementById(cnt).style.backgroundColor = "#CCCCCC";
		 }
		 cnt = cnt + 1;
	}
}
var arr_uebung_03 = new Array(
//Aufgabe 51 Facharbeitermangel
"mit",
//Aufgabe 52
"nft",
//Aufgabe 53
"gel",
//Aufgabe 54
"rie",
//Aufgabe 55
"ken",
//Aufgabe 56
"tze",
//Aufgabe 57
"ung",
//Aufgabe 58
"ber",
//Aufgabe 59
"ind",
//Aufgabe 60
"ule",
//Aufgabe 61
"ere",
//Aufgabe 62
"aft",
//Aufgabe 63
"gen",
//Aufgabe 64 
"ern",
//Aufgabe 65
"dem",
//Aufgabe 66
"ige",
//Aufgabe 67
"ung",
//Aufgabe 68
"nen",
//Aufgabe 69
"atz",
//Aufgabe 70 
"ung"
                          );

function Ergebnis_uebung_03(){
	cnt = 0;
	for(i = 0,cnt=51;i<arr_uebung_03.length;i++){
		 var txtVal = document.getElementById(cnt).value;
		 
		 var txtTrimedString = trim(txtVal);
		// alert(arr_uebung_03[i] + txtTrimedString)
		 if(arr_uebung_03[i] == txtTrimedString)
		   document.getElementById(cnt).style.backgroundColor = "#66FF33";
		 else
		   document.getElementById(cnt).style.backgroundColor = "#ff0033";
		   cnt = cnt + 1;
	}
}
function Loesung_uebung_03(){
	
	cnt = 0;
	
	for(i = 0,cnt=51;i<arr_uebung_03.length;i++){
		//alert(document.getElementById(cnt).style.backgroundColor);
         if((document.getElementById(cnt).style.backgroundColor == 'rgb(255, 0, 51)'||document.getElementById(cnt).style.backgroundColor == '')||document.getElementById(cnt).style.backgroundColor == '#ff0033'||document.getElementById(cnt).style.backgroundColor == '' ){
  		     document.getElementById(cnt).value = arr_uebung_03[i];
			 document.getElementById(cnt).style.backgroundColor = "#CCCCCC";
		 }
		 cnt = cnt + 1;
	}
}

var arr_uebung_04 = new Array(
//Aufgabe 71 Bewerbungsschreiben
"ter",
//Aufgabe 72
"nem",
//Aufgabe 73
"atz",
//Aufgabe 74
"bot",
//Aufgabe 75
"sam",
//Aufgabe 76
"ten",
//Aufgabe 77
"atz",
//Aufgabe 78
"ich",
//Aufgabe 79
"rbe",
//Aufgabe 80 
"ich",
//Aufgabe 81 Absatz
"che",
//Aufgabe 82
"sse",
//Aufgabe 83
"ung",
//Aufgabe 84
"nen",
//Aufgabe 85
"en",
//Aufgabe 86
"nitt",
//Aufgabe 87
"ern",
//Aufgabe 88
"es",
//Aufgabe 89
"en",
//Aufgabe 90 
"cht",
//Aufgabe 91
"ert",
//Aufgabe 92
"chts",
//Aufgabe 93
"ut",
//Aufgabe 94
"elt",
//Aufgabe 95
"aß",
//Aufgabe 96
"ass",
//Aufgabe 97
"sen",
//Aufgabe 98
"gen",
//Aufgabe 99
"ung",
//Aufgabe 100
"ein"
                              );

function Ergebnis_uebung_04(){
	cnt = 0;
	for(i = 0,cnt=71;i<arr_uebung_04.length;i++){
		 var txtVal = document.getElementById(cnt).value;
		 
		 var txtTrimedString = trim(txtVal);
		// alert(arr_uebung_04[i] + txtTrimedString)
		 if(arr_uebung_04[i] == txtTrimedString)
		   document.getElementById(cnt).style.backgroundColor = "#66FF33";
		 else
		   document.getElementById(cnt).style.backgroundColor = "#ff0033";
		   cnt = cnt + 1;
	}
}
function Loesung_uebung_04(){
	
	cnt = 0;
	
	for(i = 0,cnt=71;i<arr_uebung_04.length;i++){
		//alert(document.getElementById(cnt).style.backgroundColor);
         if((document.getElementById(cnt).style.backgroundColor == 'rgb(255, 0, 51)'||document.getElementById(cnt).style.backgroundColor == '')||document.getElementById(cnt).style.backgroundColor == '#ff0033'||document.getElementById(cnt).style.backgroundColor == '' ){
  		     document.getElementById(cnt).value = arr_uebung_04[i];
			 document.getElementById(cnt).style.backgroundColor = "#CCCCCC";
		 }
		 cnt = cnt + 1;
	}
}









