$(document).ready(function()
	{
		// Einklinken in a.tab, um neue Fenster zu öffnen
		$('a.tab').click(function(e)
			{
				window.open(this.href);
				e.preventDefault();
			});

		// Ajaxfunktionen unterjubeln
		$('form select.ajax').each(function()
			{
				$(this).change(function()
					{
						$('.replace').load(
								this.name + '?ajax=1',
								this.name + '=' + this.value
							);
					})
				.next('button:submit').hide(); // Fallbackknopf ausblenden
			});

		// Anmeldeformulare verschlüsseln
		$('form[action$=anmelden]') // $ ist erforderlich, falls die Url vervollständigt wird
			.submit(function()
			{
				if (this.timestamp.checked)
				{
					var time = String(new Date().getTime());
					this.timestamp.value = time;
					this.kennwort.value = sha1(sha1(this.kennwort.value) + time)
				}
			})
			.find('fieldset.senden')
				.append('<label title="Deaktivieren, wenn es nicht klappt…"><input type="checkbox" checked="checked" name="timestamp" /> Kennwort verschlüsselt übertragen</label>');

		// Formulare beim Abschicken überprüfen
		/*$('form').submit(function(e)
			{
				
			});*/

		// Feststelltaste in Kennwortfeldern monieren
		$('form input:password').keypress(function(e)
			{
				var key = e.which || e.keyCode;
				var shift = e.shiftKey || (e.modifiers && !!(e.modifiers & 4));
				var warnung = $(this).next('p.warnung');

				if (((65 <= key && key <= 90) && !shift) ||
					((97 <= key && key <= 122) && shift))
				{
					if (warnung.length == 0)
					{
						$(this).after('<p class="warnung">Deine Feststelltaste ist gedrückt!</p>')
							.next().hide().show('fast');
					}
				}
				else if (warnung.length == 1)
				{
					warnung.hide('fast', function()
							{
								$(this).remove();
							});
				}
			});
	});
