	function HandleKeyDown(theEvent)
	{
		if (typeof theEvent == 'undefined')		// Microsoft
			theKey = window.event.keyCode;
		else									// sonst
        	theKey = theEvent.which;

        theChar = String.fromCharCode(theKey);

        if ((theKey == 13)||(theKey == 3)||(theChar == ' '))
        {
			StartExercice(theBook);
        	return false;
        }	// if
        
        switch(theChar)
        {
        	case 'I':	document.input.elements['type'][0].checked = true; return false;
        	case 'T':	document.input.elements['type'][2].checked = true; return false;
        	case 'M':	document.input.elements['type'][3].checked = true; return false;
        	case 'Z':	document.input.elements['type'][4].checked = true; return false;
        	case 'K':	document.input.elements['type'][6].checked = true; return false;
        	case 'L':	document.input.elements['type'][7].checked = true; return false;
        	case 'A':	document.input.elements['type'][5].checked = true; return false;
        	case 'R':	document.input.elements['type'][10].checked = true; return false;
        	case 'G':	document.input.elements['type'][9].checked = true; return false;
        }	// switch
        return true;
        	
	}	// HandleKeyDown

	document.onkeydown = HandleKeyDown;

	function StartExercice(theBook)
	{
		theType = document.input.elements['type'];
		
		if (theType[0].checked)
			theFile = 'javavoci.php';
		else if (theType[1].checked)
			theFile = 'ask_prepare.php';
		else if (theType[2].checked)
			theFile = 'print_prepare.php';
		else if (theType[3].checked)
			theFile = 'memory_prepare.php';
		else if (theType[4].checked)
			theFile = 'zuordnen_prepare.php';
		else if (theType[5].checked)
			theFile = 'aufdecken_prepare.php';
		else if (theType[6].checked)
			theFile = 'kaertchen_prepare.php';
		else if (theType[7].checked)
			theFile = 'print_prepare.php';
		else if (theType[8].checked)
			theFile = 'print_prepare.php';
		else if ((theType[10] != null)&&(theType[10].checked))
			theFile = 'crosswords.php';
		else if (theType[9].checked)
			theFile = 'genera_bestimmen.php';
		else
			theFile = 'index.php';
			
		theLessons = '';
		
		isChecked = false;

		for (i=0;i<theNumOfCheckboxes;i++)
		{
			if (document.input.elements['checkbox_'+i].checked)
			{
				isChecked = true;
				break;
			}	// if
		}	// for
		
		if (!isChecked)
		{
			alert('Bitte mindestens eine Lektion anklicken!');
			return;
		}	// if
		
		for (i=0;i<theNumOfCheckboxes;i++)
		{
			if (document.input.elements['checkbox_'+i].checked)
			{
				if (theLessons != '')
					theLessons = theLessons+',';
			
				theLessons = theLessons + document.input.elements['checkbox_'+i].value;
			}	// if
		}	// for
						
		theQuery = '?pfad='+theBook+'&anzahl='+(theType[7].checked?'max':'10')+'&lektion='+theLessons;
		if (theType[7].checked)
			theQuery += '&exercice_type=list';		
		else if (theType[8].checked)
			theQuery += '&exercice_type=abfrage';

		if (document.input.interaktiv_type != null)
			theQuery += '&flash='+((document.input.interaktiv_type.selectedIndex == 1)?'on':'off');
						
		window.open('../'+theFile+theQuery,'_self');
		
	}	// StartExercice
