/*  Start /_templates/roottemplate/roottemplate_portal.js */

///////////////////////////////////////////////////////////////////////////////////////////////////////
// De scripts js wordt gebruikt voor scripts die voor beide roottemplates gebruikt worden //
///////////////////////////////////////////////////////////////////////////////////////////////////////


/*  End /_templates/roottemplate/roottemplate_portal.js */

/*  Start /_templates/search_rdc/search_rdc.js */

var urlRDC;

function showRDC(nr) {
	aParams = {};
	aParams.action = 'show';
	aParams.nr = nr;
	
	$('address').pgx('local.kaart', aParams);
}

function gotoRDC(nr) {		
	location = PGX.Path + urlRDC;
}

function showRDCInfo(rdcUrl, nameUrl) {	
	urlRDC = rdcUrl;	
	$('url').innerHTML = '<a href="'+rdcUrl+'">'+nameUrl+'</a>';
	$('clickurl').onclick = function() { 
		location = PGX.Path + rdcUrl;
	}	
}

function searchRDC() {
	aParams = {};
	aParams.action = 'search';
	aParams.postcode = $('postcode').getValue();
	aParams.onComplete = function(response) {
		
		check = trim(response.responseText);
		if (trim(response.responseText) == '') {
			$('postcode').value = 'geen resultaat';
		} else {
			showRDC(check);
		}
		
	}
	
	pgx('local.kaart', aParams);
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

/*  End /_templates/search_rdc/search_rdc.js */

