function x_show_dates(school_id) {
	divs = document.getElementById("dates");
	if (school_id==0) {
	    x_hide_dates();
	    return false;
	}

	AjaxRequest.get({
		'url':'ajax_mijn_scholen/dates.php'
		,'school_id':school_id
		,'onLoading':function(req) 	{  }
		,'onSuccess':function(req) 	{ divs.innerHTML = req.responseText; }
		,'onError':function(req) 	{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function save_school() {
	
	if (document.getElementById("sel_school_id")) {
		school_id = document.getElementById("sel_school_id").value;
	} else {
	    x_hide_dates();
	    return false;
	}

	start = document.getElementById("start_date").value;
	end = document.getElementById("end_date").value;
	group = document.getElementById("group").value;

	usertype = getSelectedRadioValue(document.forms['frm_add_school'].usertype);
	if (usertype == 0) {
	   usertype = document.getElementById("usertype_sel").value;
	}

	divs = document.getElementById("save_stat");
	AjaxRequest.get({
		'url':'ajax_mijn_scholen/save_school.php'
		,'school_id':school_id
		,'start':start
		,'end':end
		,'group':urlencode(group)
		,'usertype':usertype
		,'save':1
		,'onLoading':function(req) 	{ /*divs.innerHTML = 'Loading';*/ }
		,'onSuccess':function(req) 	{ divs.innerHTML = req.responseText; }
		,'onError':function(req) 		{ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
	});
}

function x_hide_dates() {
	//alert("hello");
	document.getElementById("dates").innerHTML = '&nbsp;';
	if (!document.getElementById("dates")) {
		alert('dates not found');
		return false;
	}
}

function x_hide_schools() {
	document.getElementById("schools").innerHTML = '&nbsp;';
}

function x_hide_gem() {
	document.getElementById("sel2").innerHTML = '&nbsp;';
}

function urlencode(txt) {
	return escape(txt);
	t = txt.replace(new RegExp(/'/g), "&#39;");
	return encodeURIComponent(t);
}