var lastMatchID;

function storeMatchResult(matchID, goals1, goals2) {
	sendRequest('/fussball/admin/editGame/'+matchID, handleMatchResultStorage, 'quick=1&shtore='+goals1+'&satore='+goals2);
	lastMatchID = matchID;
}

function handleMatchResultStorage(req) {
	if (req.responseText) {
		el = document.getElementById("quickStoreButton"+lastMatchID)
		el.innerHTML = 'ok!';
	}
	else {
		alert ('und kawumm... das ging schief.');
	}
}



function sendRequest(url,callback,postData) {
	var req = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	if (postData)
		req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
//			alert('HTTP error ' + req.status);
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}

var XMLHttpFactories = [
	function () {return new XMLHttpRequest()},
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
	var xmlhttp = false;
	for (var i=0;i<XMLHttpFactories.length;i++) {
		try {
			xmlhttp = XMLHttpFactories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}

function insert_browser_button() {
	if (navigator.userAgent.indexOf('Firefox') > -1) {
		thediv = "<d"+'iv class="button"><a '+'href="http://my.opera.com/community/download.pl?ref=kuckus&p=opera_desktop"><img src="http://promote.opera.com/buttons/opera88x31-1.gif" border="0" alt="Opera web browser - download"></'+'a></di'+'v>';
	}
	else {
		thediv = "<d"+'iv class="button"><a href="http://www.spreadfirefox.com/?q=affiliates&amp;id=16760&amp;t=82"><img border="0" alt="Firefox 3" title="Firefox 3" '+'src="http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/FF3_80x15_g.png"/></'+'a></di'+'v>';
	}
	document.write(thediv);
}
