String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function nextEl(el) {
	do {
		el = el.nextSibling;
	} while (el && el.nodeType != 1);
	return el;
}




var displayEvents = function(matchId, b) {
	var c = nextEl(b.parentNode.parentNode).getElementsByTagName('td')[0].firstChild;
	if (c) {
		if (b.innerHTML == '-') {
			c.style.display = 'none';
			c.parentNode.parentNode.style.display = 'none';
			b.innerHTML = '+';
		}
		else {
			c.style.display = 'block';
			c.parentNode.parentNode.style.display = '';
			b.innerHTML = '-';
			if (c.innerHTML == '')
				Ajax.call(c, '/matchdoodad.php?match_id=' + matchId);
		}
	}
};


if (!window.XMLHttpRequest) {
	window.XMLHttpRequest = function() {
		return (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null;
	}
}

var Ajax = {
	call: function(c, url, silent) {
		if (!silent) c.innerHTML = '<div align="center"><img src="http://cache.images.soccerway.com/new/loader.gif" width="16" height="16" alt="Loading" /></div>';
		var r = new XMLHttpRequest();
		if (!r) return false;
		r.onreadystatechange = function() {
			if (r.readyState == 4) {
				if (r.status == 200) {
					c.innerHTML = r.responseText;
				}
			}
		};
		r.open('GET', url, true);
		r.send(null);
		return true;
	}
};