// SBT-logic-at
// version 1.0
// 2008-04-11
// Copyright (c) 2008, Johannes Buchner
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select the right script, and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          sbt-logic-at
// @namespace     http://
// @description   Automatisch speichern wählen, wenn Bewertung geändert wird
// @include       https://sbt.logic.at/bewertungen.php
// ==/UserScript==


var mapping = new Array();

function onChangeLookup(){
	lastAnwesend = document.getElementsByName(mapping[this.name]);
	lastAnwesend[0].value = "ja";
}

function onload(){
	/*alert(document.form);*/
	allelements = document.getElementsByTagName("select");
	lastAnwesend = null;
	
	for(i = 0; i<allelements.length; i++){
		var el = allelements[i];
		if(el.name.substring("anwesend".length,0) == "anwesend"){
			lastAnwesend = el;
		}else if(el.name.substring("bewertung".length,0) == "bewertung"){
			mapping[el.name] = lastAnwesend.name;
			el.addEventListener('change', onChangeLookup, true);
		}
	}
	
	lastAnwesend = null;
}
onload()

