stdurlroot = '[% blanklink pp=1 t=[% param t %] w=[% param w %] c=[% param c %] active=[% param active %] account=[% param account %] %]';

if (typeof _cgiorganisation == 'undefined')
	_cgiorganisation = "";
	
if (typeof _cgisearchterm == 'undefined')
	_cgisearchterm = "";

function selectProvince(repid) {
        document.location = stdurlroot+'&province='+repid.value+'#place';
}

function selectPlace(repid) {
        document.location = stdurlroot+'&place='+encodeURIComponent(repid.value)+'&province='+encodeURIComponent(_cgiprovince)+'#organisation';
}

function performSearch(searchterm) {
        document.location = stdurlroot+'&searchterm='+encodeURIComponent(searchterm)+'&place='+encodeURIComponent(_cgiplace)+'&province='+encodeURIComponent(_cgiprovince)+'#name';
}

function selectOrganisation(org) {
        document.location = stdurlroot+'&organisation='+encodeURIComponent(org.value)+'&place='+encodeURIComponent(_cgiplace)+'&province='+encodeURIComponent(_cgiprovince)+'#name';
}

function selectName(repid) {

   document.location = stdurlroot+'&organisation='+encodeURIComponent(_cgiorganisation)+'&searchterm='+encodeURIComponent(_cgisearchterm)+'&place='+encodeURIComponent(_cgiplace)+'&province='+encodeURIComponent(_cgiprovince)+'&repid='+repid+'#selectquestionnaire';
}	

function selectOpvangType(opvangtype) {
      document.location = stdurlroot+'&organisation='+encodeURIComponent(_cgiorganisation)+'&searchterm='+encodeURIComponent(_cgisearchterm)+'&place='+encodeURIComponent(_cgiplace)+'&province='+encodeURIComponent(_cgiprovince)+'&repid='+_cgirepid+'&opvangtype='+encodeURIComponent(opvangtype.value)+'#selectfase';
}	

function selectOpvangFase(opvangfase) {
      document.location = stdurlroot+'&organisation='+encodeURIComponent(_cgiorganisation)+'&searchterm='+encodeURIComponent(_cgisearchterm)+'&place='+encodeURIComponent(_cgiplace)+'&province='+encodeURIComponent(_cgiprovince)+'&repid='+encodeURIComponent(_cgirepid)+'&opvangtype='+encodeURIComponent(_cgiopvangtype)+'&opvangfase='+encodeURIComponent(opvangfase.value)+'#openquestionnaire';
}	

function showCrosstab(repid) {
	
	if (!repid) {
		alert('Er is geen vestiging geselecteerd!');
		return false;
	}

	

	document.body.style.cursor = 'wait';	// show waiting indicator while crosstab is loading
	// var respsource = document.forms[0].respsource;
	// var respsourceValue ;
	//for (var i=0; i<respsource.length; i++ ) {
	//	if (respsource[i].checked)
	//		respsourceValue = respsource[i].value; 	
	//}
	// var start_date = dojo.widget.byId('start_date').getValue();
	// var end_date = dojo.widget.byId('end_date').getValue();
	
	var newlocation = '[% blanklink pp=1 t=[% param t %] w=[% param w %] active=[% param active %] account=[% param account %] %]';

	document.location = newlocation+'&dbb=website&c=Resultaten/Crosstab&repid='+repid;
}

function selectNameByButton() {
	
	if (document.getElementById("sName")) {
        var repid = document.getElementById("sName").options[document.getElementById("sName").selectedIndex];
        if (repid.value && (repid.value > 0)) {
        	showCrosstab(repid.value);
        } else {
        	alert('Selecteer een vestiging.');
        }
	}
}

function meldVestigingAan() {
	document.location = scriptroot+'?account='+_cgiaccount+'&c=Aanmelden/Aanmelden';
}

function pageRequest(pageid) {
	document.location = scriptroot+'?account='+_cgiaccount+'&pp=1&page='+pageid;
}

function addLocation() {
	var org = document.getElementById('organisatie').value;
	var ves = document.getElementById('vestiging').value;
	var adr = document.getElementById('adres').value;
	var pos = document.getElementById('postcode').value;
	var pro = document.getElementById('provincie').value;
	var pla = document.getElementById('plaats').value;
	var naam_ouder = document.getElementById('naam_ouder').value;
	var email_ouder = document.getElementById('email_ouder').value;
	
	if (!(org && adr && ves && pos && pro)) {
		alert('Vul aub alle gemarkeerde velden in.');
		return false;
	}
	if (!email_ouder || !email_ouder.match(/^.+@[^\.].*\.[a-z]{2,}$/)) {
		alert('Het opgegeven e-mailadres is niet geldig.');
		return false;	
		
	}
	
	var parameters='&organisatie='+encodeURIComponent(org)+
	'&vestiging='+encodeURIComponent(ves)+
	'&adres='+encodeURIComponent(adr)+
	'&postcode='+encodeURIComponent(pos)+
	'&provincie='+encodeURIComponent(pro)+
	'&plaats='+encodeURIComponent(pla)+
	'&naam_ouder='+encodeURIComponent(naam_ouder)+
	'&email_ouder='+encodeURIComponent(email_ouder);
		document.location = scriptroot+'?account='+_cgiaccount+'&path=Aanmelden/Toevoegen'+parameters;	
}


function openQuestionnaire(url) {
	if (document.getElementById('voorwaarden').checked) {
		openWindow(url);
	} else {
		alert('U dient de voorwaarden te accepteren.');	
	}
}

function openWindow(url, width, height) {
		if (!width) width = 768;
		if (!height) height = 558;
		win = window.open(url, '', 'width=' + width + ',height=' + height + ',scrollbars=1,resizable=1');
}

