// 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(
                              "durften","dürften","-",
                              "gewinnen","gewönnen","würden gewinnen",
                              "helfen","halfen","hülfen",
                              "kommen","kämen","würden kommen",
                              "können","könnten","-",
                              "lesen","läsen","würden lesen",
                              "mussten","müssten","-",
                              "schlagen","schlugen","schlügen",
                              "sprechen","sprächen","würden sprechen",
                              "wussten","wüssten","würden wissen"
                             );

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(
"Wenn","es","hier","doch","nur","heller","wäre!",
"Wenn","er","doch","nur","leiser","singen","würde!",
"Wenn","der","Wein","doch","nur","besser","schmecken","würde!",
"Wenn","die","Aufgabe","doch","nur","einfacher","wäre!",
"Wenn","das","Mädchen","doch","nur","größer","wäre!",
"Wenn","er","doch","nur","die","Tür","nicht","zugemacht","hätte!",
"Wenn","Ute","heute","doch","nur","bei","mir","bleiben","würde!",
"Wenn","er","doch","nur","schneller","fahren","würde!",
"Wenn","Klaus","doch","nur","eine","Freundin","hätte!",
"Wenn","der","Bus","doch","nur","früher","abfahren","würde!"
                              );

function Ergebnis_uebung_02(){
	cnt = 0;
	for(i = 0,cnt=31;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=31;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(
"Wenn","Johannes","fleißiger","wäre,","könnte","er","die","schwere","Prüfung","bestehen.",
"Wenn","ich","keine","Lohnerhöhung","bekommen","würde,","würde","ich","mir","einen","neuen","Job","suchen.",
"Wenn","der","Schiedsrichter","pfeifen","würde,","würde","es","einen","Elfmeter","geben.",
"Wenn","das","Wetter","heute","besser","wäre,","würde","ich","spazieren","gehen.",
"Wenn","der","Zug","pünktlicher","wäre,","würde","Herr","Leu","nicht","zu","spät","zur","Arbeit","kommen.",
"Wenn","der","Autofahrer","langsamer","fahren","würde,","müsste","er","keine","Geldstrafe","zahlen.",
"Wenn","Herr","Mau","Frau","Lau","sehen","würde,","würde","er","sie","grüßen.",
"Wenn","Oliver","größer","wäre,","könnte","er","über","die","Mauer","klettern.",
"Wenn","Hans","seine","Hausaufgaben","machen","würde,","dürfte","er","heute","ins","Kino","gehen.",
"Wenn","es","geregnet","hätte,","wären","Flüsse","und","Seen","nicht","ausgetrocknet."
                          );

function Ergebnis_uebung_03(){
	cnt = 0;
	for(i = 0,cnt=107;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=107;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;
	}
}











