function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	try {
		// Opera, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer Browsers
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

//Change activity of a site
function changeActivity(id) {
	var ajaxRequest = ajaxFunction();
	/*ajaxRequest.onreadystatechange = function() {
		if(ajaxRequest.readyState == 4){
			document.getElementById('productlist_'+number).innerHTML = ajaxRequest.responseText;
		} else {
			//Loading
		}
	}*/
	ajaxRequest.open("GET", "?action=ajax&id="+id, true);
	ajaxRequest.send(null);	
}

//Change teamid's
function changeTeams() {
	var division = document.getElementById('division').value;
	var ajaxRequest = ajaxFunction();
	ajaxRequest.onreadystatechange = function() {
		if(ajaxRequest.readyState == 4){
			document.getElementById('hometeamid').innerHTML = ajaxRequest.responseText;
			document.getElementById('awayteamid').innerHTML = ajaxRequest.responseText;
		} else {
			//Loading
		}
	}
	ajaxRequest.open("GET", "?action=ajax&id="+division, true);
	ajaxRequest.send(null);	
}

function getPlayed(round) {
	var division = document.getElementById('division').value;
	var season = document.getElementById('season').value;
	var ajaxRequest = ajaxFunction();

	ajaxRequest.onreadystatechange = function() {
		if(ajaxRequest.readyState == 4){
			document.getElementById('played').innerHTML = ajaxRequest.responseText;
		} else {
			document.getElementById('played').innerHTML = "Loading...";
		}
	}
	ajaxRequest.open("GET", "?action=ajax&division="+division+"&season="+season+"&round="+round, true);
	ajaxRequest.send(null);	
}

//genereer veld voor extra image
function addImage() {
	var tbl,row,cell;
	var currentCell = 0;
	tbl = document.getElementById('keywords');
	row = tbl.insertRow(tbl.rows.length-1);
	row.className = 'stdtextconfig';
	row.bgColor = '#f6f6f6f';
	cell = row.insertCell(currentCell); currentCell++;
	cell.innerHTML = '&nbsp;';
	cell.width = 122;
	cell = row.insertCell(currentCell); currentCell++;
	cell.innerHTML = "<p><input type='file' name='afbeelding[]' /></p>";
	cell.width = 564;
}

//Verander Standen tabel
function changeStandings(category) {
	if(category == 'admin') {
		var season = document.getElementById('season').value;
		var division = document.getElementById('division').value;
		document.location.href = "?season="+season+"&division="+division;
	}
}

//Resize iframe
function resizeIframe() {
	var height = document.documentElement.clientHeight;
	height -= document.getElementById('frame').offsetTop;
	// not sure how to get this dynamically
	height -= 120; /* whatever you set your body bottom margin/padding to be */
	document.getElementById('frame').style.height = height +"px";
}


