function _SearchF() {
	
	this._create = function() {
		addEvent(document.SearchForm.Lokacija1, 'change', this.createSubLocationMenu, true);
	}
	
	this.createSubLocationMenu = function(e) {
		SearchF.cleanSubLocationsSelect();
		SearchF.createSubLocationsTempSelect();
		aAjax.showInfo = false;
		aAjax.submitAjax(e,"SearchForm",'CreateSubLocationMenu','direct/create-sublocation-menu.php','');
	}

	this.cleanSubLocationsSelect = function() {
		var SubLocations = document.getElementById('Lokacija2');
		if (SubLocations.hasChildNodes() ) {
			while (SubLocations.childNodes.length >= 1 ) {
				SubLocations.removeChild(SubLocations.firstChild);
			} 
		}
	}
	
	this.createSubLocationsTempSelect = function() {
		var SubLocations = document.getElementById('Lokacija2');
		var newOption = document.createElement('option');
		newOption.value = '';
		newOption.innerHTML = '...molimo sacekajte';
		SubLocations.appendChild(newOption);
	}
	
	this.createSubLocationsSelect = function(newValues,newTitles) {
		var SubLocations = document.getElementById('Lokacija2');
		this.cleanSubLocationsSelect();
		for(var j=0; j < newValues.length; j++) {
			var newOption = document.createElement('option');
			newOption.value = newValues[j];
			newOption.innerHTML = newTitles[j];
			SubLocations.appendChild(newOption);
		}
	}

	_aAjax.prototype.onComplete = function(responseXML) {
		var LocationsMenu = responseXML.getElementsByTagName('LocationsMenu');
		if (LocationsMenu && LocationsMenu != null && LocationsMenu[0] && LocationsMenu[0] != null) {
			if (LocationsMenu[0].firstChild.data == 1) {
				var newValues = Array();
				var newTitles = Array();
				var SubLocations = responseXML.getElementsByTagName('SubLocations')[0];
				var SubLocationsOptions = SubLocations.getElementsByTagName('option');
				for (var j=0; j < SubLocationsOptions.length; j++) {
					newValues[j] = SubLocationsOptions[j].getElementsByTagName('value')[0].firstChild.data
					newTitles[j] = SubLocationsOptions[j].getElementsByTagName('title')[0].firstChild.data;
				}
				SearchF.createSubLocationsSelect(newValues,newTitles);
			}
		}
	}

}



