function CitySelection( formName , cityBoxName, selectedCityBoxName, provinceSelector) {

	this.form = document.forms[formName]; //naam formulier
	this.cityBox = this.form[cityBoxName]; //naam van de plaatsen box
	this.selectedCityBox = this.form[selectedCityBoxName]; //naam geselecteerde plaatsen box
	this.provinceSelector = this.form[provinceSelector]; //naam provincie dropdown

	this.exists = function() {
		alert("cities");
	};

	
	this.searchCities = function() {
		var province = this.provinceSelector.options[ this.provinceSelector.selectedIndex ].value; 
		//disable city box
		this.cityBox.disabled = true;
		//clear option
		this.cityBox.options.length = 0;
		//search array for selected province...

		for (var i in citiesAndProvincesJS){
			if(i.toLowerCase() == province.toLowerCase()){	
				var obj = citiesAndProvincesJS[i].slice(0); //first element == province, elements 1 thru length == cities
			}
		}

/*		for(i=0;i<citiesAndProvincesJS.length;i++){
			if(citiesAndProvincesJS[i][0] == province){
				var obj = citiesAndProvincesJS[i].slice(1); //first element == province, elements 1 thru length == cities
			}
		}
*/

		this.cityBox.options.length = 0;
		if(obj.length) {
			for(i=0;i < obj.length; i++) {
				this.cityBox.options[i] = new Option(obj[i],obj[i]);
			}
		}
		this.cityBox.disabled = false;
	};
	this.addCity = function(text) {
		var selectedOption = this.cityBox.options[this.cityBox.selectedIndex];
		if( this.selectedCityBox.options.length >= 5) {
	 		alert( "U kunt maximaal 5 plaatsen selecteren" );
	 		return false;
		}
	
		var isSelected = false;
		for(y=0;y < this.selectedCityBox.options.length; y++) {
			if(this.selectedCityBox.options[y].value == selectedOption.value){
				isSelected = true;
			}	
		}
		if( !isSelected ) {
			if(!text){
				this.selectedCityBox.options[this.selectedCityBox.options.length] = new Option(selectedOption.text,selectedOption.value);
			}
			else{
				this.selectedCityBox.options[this.selectedCityBox.options.length] = new Option(selectedOption.text,selectedOption.text);
			}
			isSelected = false;
		}
	};
	this.removeCity = function() {
		for(i=0;i < f.selected_cities.options.length; i++) {
			if( this.selectedCityBox.options[i].selected ) {
				this.selectedCityBox.options[i] = null;
			}
		}
	};
	this.selectAll = function( name ) {
		if(name == "selected") {


			for(i=0;i < this.selectedCityBox.options.length ; i++) {
				this.selectedCityBox.options[i].selected = true;
			}
		} else {
			for(i=0;i < this.cityBox.options.length ; i++) {
				this.cityBox.options[i].selected = true;
			}
		}
	};
	return this;
}
