function allSelect() {
var box_1 = document.forms['searchForm'].city_1;
var box_2 = document.forms['searchForm'].city;
var list = box_2.options.length;

box_1.options[box_1.selectedIndex] = null;

	for (i=0;i<box_2.length;i++)
	{
	 box_2.options[i].selected = true;
	}
}

function submitForm() {
var box = document.forms['searchForm'].provincie;
var box_1 = document.forms['searchForm'].city_1;
var box_2 = document.forms['searchForm'].city;
var frm_submit = true;
	
	if (box_2.options.length == 0 && document.searchForm.heleprovincie.checked == false)
	{
	alert("In welke plaatsen wilt u zoeken?");
	document.searchForm.elements['provincie'].focus();
	frm_submit = false;
	return;
	}

	if (document.searchForm.heleprovincie.checked == true && box.options[box.selectedIndex].value == '')
	{
	alert("In welke provincie wilt u zoeken?");
	document.searchForm.elements['provincie'].focus();
	frm_submit = false;
	return;
	}
	
	if (parseInt(document.searchForm.elements['van'].value) > parseInt(document.searchForm.elements['tot'].value))
	{
	alert("De vanaf prijs moet kleiner zijn dan de tot prijs");
	document.searchForm.elements['tot'].focus();
	frm_submit = false;
	return;
	}

	if (frm_submit == true)
	{
	if (document.searchForm.heleprovincie.checked == false) {
		allSelect();
	}
	box.options[box.selectedIndex].value = box.options[box.selectedIndex].text;
	document.searchForm.submit();
	}
}

function submitActForm() {
var box = document.forms['searchForm'].provincie;
var box_1 = document.forms['searchForm'].city_1;
var box_2 = document.forms['searchForm'].city;
var frm_submit = true;
	
	if (box_2.options.length == 0 && document.searchForm.heleprovincie.checked == false)
	{
	alert("In welke plaatsen wilt u zoeken?");
	document.searchForm.elements['provincie'].focus();
	frm_submit = false;
	return;
	}

	if (document.searchForm.heleprovincie.checked == true && box.options[box.selectedIndex].value == '')
	{
	alert("In welke provincie wilt u zoeken?");
	document.searchForm.elements['provincie'].focus();
	frm_submit = false;
	return;
	}

	if (frm_submit == true)
	{
	if (document.searchForm.heleprovincie.checked == false) {
		allSelect();
	}
	box.options[box.selectedIndex].value = box.options[box.selectedIndex].text;
	document.searchForm.submit();
	}
}

function loadPlaatsen(provincie) {
	var box_1 = document.forms['searchForm'].city_1;
	var box_2 = document.forms['searchForm'].city;
	var list = province[provincie];
	
	box_1.options.length = 0;
	
	for(i=0;i<list.length;i++)
	{
		box_1.options[i] = new Option(list[i],list[i]);
	}
}

function loadPlaatsenBuitenland(provincie) {	
	var box_1 = document.forms['searchForm'].city_1;
	var box_2 = document.forms['searchForm'].city;
	
	if (provincie == 999) { 
		loadAll();
	} else {
		document.getElementById("regioText").innerHTML = "Doorzoek hele regio";
		var list = province[provincie];
		
		box_1.options.length = 0;
		
		for(i=0;i<list.length;i++)
		{
			box_1.options[i] = new Option(list[i],list[i]);
		}		
	}
}

function selPlaatsen() {
	var box_1 = document.forms['searchForm'].city_1;
	var box_2 = document.forms['searchForm'].city;
	var list_2 = box_2.options.length;
	
	if (box_1.selectedIndex>=0) {
		for (y=0;y<box_1.options.length;y++) {
			var s = box_2.options.length;
			if (box_1.options[y].selected) {
				for(i=0;i<list_2;i++) {
					if (box_2.options[i].text.indexOf(box_1.options[y].text) >= 0) {
					return;
					}
				}
				box_2.options[s] = new Option(box_1.options[y].text);
			}
		}
	}
}

function delPlaatsen(plaats) {
	var box_2 = document.forms['searchForm'].city;
	
	if (box_2.selectedIndex>=0) {
		var i = box_2.options.length-1;
		while (i>=0) {
			if (box_2.options[i].selected) {
				box_2.options[i] = null;
			}
			i=i-1;
		}
	}
}

function pageReturn() {
	document.forms['searchForm'].provincie.selectedIndex = 0;
	document.forms['searchForm'].heleprovincie.checked = false;
}

function UncheckAll(){
count = document.searchForm.type.length;
    for (i=0; i < count; i++) 
	{
    if(document.searchForm.type[i].checked == 1)
    	{document.searchForm.type[i].checked = 0; }
    else {document.searchForm.type[i].checked = 1;}
	}
}

function allProvince() {
var box_1 = document.forms['searchForm'].city_1;
var box_2 = document.forms['searchForm'].city;
	
	if (document.searchForm.heleprovincie.checked == true) {
		box_1.disabled = true;
		box_2.disabled = true;
	}
	
	if (document.searchForm.heleprovincie.checked == false) {
		box_1.disabled = false;
		box_2.disabled = false;
	}
}

function goBOG() {
	if (document.searchForm.typeBOG.checked == true) {
		location.href='index_buitenland.asp?type=bog';
	} else {
		location.href='index_buitenland.asp';
	}
}

function loadAll() {
	document.getElementById("regioText").innerHTML = "Doorzoek het hele land";
	var box_1 = document.forms['searchForm'].city_1;
	var list = allcities;
	
	box_1.options.length = 0;
	
	
	for(i=0;i<list.length;i++)
	{
		box_1.options[i] = new Option(list[i],list[i]);
	}
}
