// JavaScript Document
function reset_selector() {
	$.get(url+"includes/select_land.php", { selected:'' },fillxml);
	
	//$.get(url+"includes/select_categorie.php", { selected:'' },fillxml);
	document.getElementById('selectcat').selectedIndex=0;;
	
	$.get(url+"includes/select_stad.php", { selected:'' },fillxml);
	
	$.get(url+"includes/select_regio.php", { selected:'' },fillxml);
	
	document.getElementById('leftcolumn').innerHTML='';
}



function fill(type) {
	var landid = document.getElementById('selectland').options[document.getElementById('selectland').selectedIndex].value;
	
	
	var catid = document.getElementById('selectcat').options[document.getElementById('selectcat').selectedIndex].value;	
	
	var regioid = document.getElementById('selectregio').options[document.getElementById('selectregio').selectedIndex].value;
	var stadid = document.getElementById('selectstad').options[document.getElementById('selectstad').selectedIndex].value;
	
	if(type=='regio') {
		var stadid = '';
	} else if(type=='land') {
		var regioid = '';
		var stadid = '';
	} 
	//if(type=='regio') {
		//catid='';	
	//}
	
	if(type!='cat') {
		$.get(url+"includes/select_categorie.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:catid },fillxml);
	}
	if(type!='land') {
		
		$.get(url+"includes/select_land.php", { catid: catid, landid: landid, regioid: regioid,selected:landid },fillxml);
	}
	if(type!='regio') {
		$.get(url+"includes/select_regio.php", { catid: catid, landid: landid, regioid: regioid,selected:regioid },fillxml);
	}
	if(catid!=''||landid!=''||regioid!='') {
		$.get(url+"includes/zoekresultaten.php", { catid: catid, landid: landid,stadid: stadid, regioid: regioid },fillzoekres);
	}
	
	if(type!='stad') {
		$.get(url+"includes/select_stad.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:stadid },fillxml);
	}
	
	if(document.getElementById('banners_rechts')!=null) {
		$.get(url+"includes/banners_rechts.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid }, put_banners);
	}
}

function fillxml(data) {
	
	var regels = data.getElementsByTagName('regel');
	
	var type = data.firstChild.getAttribute("type") ;
	
	document.getElementById('select'+type).options.length=0;
	
	for(i=0;i<regels.length;i++) {
		
		var id = regels[i].childNodes[0].firstChild.nodeValue;	
		
		var waarde = regels[i].childNodes[1].firstChild.nodeValue;
		var selected = regels[i].childNodes[2].firstChild.nodeValue;
		
		if(id=='x') {
			id='';	
		}
		
		document.getElementById('select'+type).options[i] = new Option(waarde,id);
		
		if(selected==1) {
			document.getElementById('select'+type).options[i].selected=true;
		}
		
	}
	//document.getElementById('select'+type).selectedIndex=i;
	
	
	

}

function fillzoekres(data) {
	
	document.getElementById('leftcolumn').innerHTML=data;
}


function update_zoekresultaten(pagina) {
	if(pagina==null) {
			var pagina = document.getElementById('nummering').options[document.getElementById('nummering').selectedIndex].value;
	}
	var catid = document.getElementById('selectcat').options[document.getElementById('selectcat').selectedIndex].value;	
	var landid = document.getElementById('selectland').options[document.getElementById('selectland').selectedIndex].value;
	var regioid = document.getElementById('selectregio').options[document.getElementById('selectregio').selectedIndex].value;
	var stadid = document.getElementById('selectstad').options[document.getElementById('selectstad').selectedIndex].value;
	var letter = document.getElementById('alfabet').options[document.getElementById('alfabet').selectedIndex].value;


	$.get(url+"includes/zoekresultaten.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid , letter: letter , pagina: pagina },fillzoekres);
	
}



function reselect(catid, landid,regioid, letter, pagina,stadid) {
	if(catid!='') {
		$.get(url+"includes/select_categorie.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:catid },fillxml);
	}
	if(landid!='') {
		
		$.get(url+"includes/select_land.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:landid },fillxml);
	}
	if(landid!='') {
		$.get(url+"includes/select_regio.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:regioid },fillxml);
	}
	
	if(regioid!='') {
		$.get(url+"includes/select_stad.php", { catid: catid, landid: landid, regioid: regioid, stadid: stadid,selected:stadid },fillxml);
	}
	
	if(catid!=''||landid!=''||regioid!='') {
		$.get(url+"includes/zoekresultaten.php", { catid: catid, landid: landid,stadid: stadid, regioid: regioid, letter:letter,pagina:pagina },fillzoekres);
	}
	
	
}
