function spring()
{ 
	location.href = '#down';
	
  setTimeout("document.forms[1].elements[0].focus();", 50);
  setTimeout("document.forms[1].elements[0].focus();", 50);
}
  
	function ajax_load_img(){	
		document.getElementById("abfragewrapper").innerHTML='<img style="margin-left: 250px; margin-top: 20px; margin-bottom: 20px;" src="/filesystem/images/ajax-loader-big.gif" alt="ajax ladegrafik" />';
	}
	
	function create_user_inner(){		
		if(document.getElementById("intro"))
			document.getElementById("intro").style.display='none';
		if(document.getElementById("progress"))
			document.getElementById("progress").style.display='none';
		
		string = "";
	
		string += '<div id="create_user">';
		string += 'Das Anlegen eines Benutzers ist <span style="color: red;">freiwillig</span>, man kann';
		string += ' hier auch ohne Registrierung das 10-Fingersystem erlernen.';
		string += '<h2>Neuen Benutzer anlegen</h2>';
		string += '<table>';
		string += '<tr><td>Benutzername:</td><td>Passwort:</td></tr>';
		string += '<tr><td><input id="username" type="text" name="username" /></td>';
		string += '<td><input id="password" type="text" name="password" /></td></tr>';
		string += '<tr><td><input type="submit" value="Benutzer anlegen" onclick="new Ajax.Request(\'/ajaxscripts/ajax_create_user.php?username=\'+(document.getElementById(\'username\').value)+\'&password=\'+(document.getElementById(\'password\').value), {method:\'get\', asynchronous:true, onSuccess:function(){new Ajax.Updater(\'create_user\', \'/ajaxscripts/feedback_ajax_create_user.php\');}}); return false;"></td></tr>';
		string += '</table>';
		string += '<h3>Warum einen Benutzer anlegen?</h3>';
		string += '<p>Wenn du dir einen Benutzer anlegst kannst du deinen derzeitigen Fortschritt speichern und musst dir nicht merken welche Lektionen du schon gemacht hast.';
		string += ' Einen Benutzer kannst du ganz einfach anlegen, indem du einen Benutzernamen und ein Passwort wählst, eine Emailadresse ist nicht nötig.</p>';
		string += '</div>';
		
		document.getElementById("abfragewrapper").innerHTML=string;
	}

	function login_user_inner(){
		if(document.getElementById("intro"))
			document.getElementById("intro").style.display='none';
		if(document.getElementById("progress"))
			document.getElementById("progress").style.display='none';
				
		string = "";
	
		string += '<div id="create_user">';
		string += '<h2>Benutzer einloggen</h2>';
		string += '<table>';
		string += '<tr><td>Benutzername:</td><td>Passwort:</td></tr>';
		string += '<tr><td><input id="username" type="text" name="username" /></td>';
		string += '<td><input id="password" type="password" name="password" /></td></tr>';
		string += '<tr><td><input type="submit" value="Einloggen" onclick="new Ajax.Updater(\'abfragewrapper\', \'/ajaxscripts/ajax_login_user.php?username=\'+(document.getElementById(\'username\').value)+\'&password=\'+(document.getElementById(\'password\').value), {method:\'get\', asynchronous:true}); return false;"></td></tr>';
		string += '</table>';
		string += '</div>';
		
		document.getElementById("abfragewrapper").innerHTML=string;
	}
	
	function impressum(){
		if(document.getElementById("progress"))
			document.getElementById("progress").style.display='none';
		if(document.getElementById("intro"))
			document.getElementById("intro").style.display='none';
			
		string = "";
	
		string += '<div id="create_user">';
		string += '<h2>Impressum</h2>';
		string += 'Christian Strang<br />';
		string += 'Nibelungenring 15<br />';
		string += '53424 Remagen<br />';
		string += 'Telefon: +49 0176-20179842<br />';
		string += 'E-Mail: christianstrang@web.de<br />';
		string += 'Internet: webdesignblog.de<br />';
		string += '</div>';
		
		document.getElementById("abfragewrapper").innerHTML=string;
	}
	
	function getAbfrage(startid)
	{
		var idvorher = (startid-3);
		var tmp = startid;
		var startid2 = ++tmp;
		var startid3 = ++tmp;
		var nextid = ++tmp;
		
		document.getElementById('abfragewrapper').innerHTML = '<div class="task">'+abfrage[startid]+'</div><div class=""><div id="status_'+startid+'" style="background: #dddddd;"><input autocomplete="off" class="input_value" id="'+startid+'" maxlength="" name="eingabe_'+startid+'" tabindex="1" onkeyup="checkInput(\''+startid+'\', \''+abfrage[startid].length+'\');" /><input type="hidden" value=\''+abfrage[startid]+'\' id="hidden_'+startid+'"></div></div>';	
		
		if((typeof abfrage[startid2]) != "undefined")
			document.getElementById('abfragewrapper').innerHTML += '<div class="task">'+abfrage[startid2]+'</div><div class=""><div id="status_'+startid2+'" style="background: #dddddd;"><input autocomplete="off" class="input_value" id="'+startid2+'" maxlength="" name="eingabe_'+startid2+'" tabindex="1" onkeyup="checkInput(\''+startid2+'\', \''+abfrage[startid2].length+'\');" /><input type="hidden" value=\''+abfrage[startid2]+'\' id="hidden_'+startid2+'"></div></div>';	
		
		if((typeof abfrage[startid3]) != "undefined")
			document.getElementById('abfragewrapper').innerHTML += '<div class="task">'+abfrage[startid3]+'</div><div class=""><div id="status_'+startid3+'" style="background: #dddddd;"><input autocomplete="off" class="input_value" id="'+startid3+'" maxlength="" name="eingabe_'+startid3+'" tabindex="1" onkeyup="checkInput(\''+startid3+'\', \''+abfrage[startid3].length+'\');" /><input type="hidden" value=\''+abfrage[startid3]+'\' id="hidden_'+startid3+'"></div></div>';	
		

		if(startid < (abfrage.length-3))
			document.getElementById('abfragewrapper').innerHTML += '<input class="submit" style="margin-left: 320px;" type="submit" tabindex="1" id="submit_button" value="weiter" onclick="ajax_load_img(); getAbfrage(\''+nextid+'\'); getProgress(\''+nextid+'\'); spring();">';
		else
			document.getElementById('abfragewrapper').innerHTML += '<h2><a href="http://schnell-schreiben.de/" id="submit_button">Lektion '+lektion+' beenden</a></h2>';
		
		if(startid > 2)
			document.getElementById('abfragewrapper').innerHTML += '<br /><input class="submit" style="margin-left: 320px;" type="button" tabindex="1" value="zur&uuml;ck" onclick="ajax_load_img(); getAbfrage(\''+idvorher+'\'); getProgress(\''+idvorher+'\'); spring();">';

	}
	  
	function getProgress(startid)
	{
		//anzahl_abfragen;	
		//$res = ceil($res / 3);
	
		progress = Math.ceil(startid / 3);
	
		ausgabe = '';
		ausgabe += '<ul id="list_progress">';
		
		for(i=1; i<=anzahl_abfragen; i++)
		{
			if((progress+1) != i)
				ausgabe += '<li><a href="#down" onclick="getAbfrage(\''+((i-1)*3)+'\'); getProgress(\''+((i-1)*3)+'\'); spring();">'+i+'</a></li>';
			else
				ausgabe += '<li id="current_progress"><a href="#down" onclick="getAbfrage(\''+((i-1)*3)+'\'); getProgress(\''+((i-1)*3)+'\'); spring();">'+i+'</a></li>';
		}
		ausgabe += '</ul>';
		ausgabe += '<div style="clear: both;"></div>';
	
	
		document.getElementById('progress').innerHTML = ausgabe;
	}
	  
	function reportError(request)
	{
		alert('Sorry. There was an error.');
	}
	
function setzeCurser(){
	if (document.forms.length > 0) {
    var field = document.forms[0];
    for (i = 0; i < field.length; i++) {
      if ((field.elements[i].type == 'text') || (field.elements[i].type == 'textarea') || (field.elements[i].type.toString().charAt(0) == 's')) {
        document.forms[0].elements[i].focus();
        break;
      }
    }
  }	
}	