

function ReloadIndex(stateId) {
	var url = "http://kronehit.gastrotipps.at/index.aspx?stid=%SID%";

	if (stateId != 0) {
		url = url.replace("%SID%", stateId);
	}
	else {
		url = url.replace("%SID%", "");
	}
	
	window.location = url;
}

function DoSearch(branchId, stateId, districtIds, keywords){
	var url = "http://kronehit.gastrotipps.at/result.aspx?stid=%SID%&dids=%DID%&bid=%BID%&kw=%KW%";
	
	if (branchId != 0){
		url = url.replace("%BID%", branchId);
	}
	else {
		url = url.replace("%BID%", "");
	}
	
	if (stateId != 0) {
		url = url.replace("%SID%", stateId);
	}
	else {
		url = url.replace("%SID%", "");
	}
	
	if (districtIds && districtIds.length != 0) {
		url = url.replace("%DID%", districtIds);
	}
	else {
		url = url.replace("%DID%", "");
	}
	
	url = url.replace("%KW%", keywords);
	
	window.location = url;
}

function DDchanged(statesDropDown) {
	var stateId = statesDropDown.val();
	
    ReloadIndex(stateId);
}

function DDChangedResult(clearDistrict, statesDropDown, districtsDropDown, industryDropDown, hiddenKeywords){
	var stateId = statesDropDown.val();
	var districtId = districtsDropDown.val();
	var industryId = industryDropDown.val();
	var keywords = hiddenKeywords.val();
	
	if (clearDistrict){
		DoSearch(industryId, stateId, '', keywords);
	}
	else {
		DoSearch(industryId, stateId, districtId, keywords);
	}
}

function SubmitOnEnter(myfield, e) {
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;
	}
	else if (e) {
		keycode = e.which;
	}
	else
		return true;

	if (keycode == 13) {
		DoKeywordSearch();
		return false;
	}
	else
		return true;
}

function DoKeywordSearch() {
	var keywords = document.getElementById("stichwortsuche");
	if (keywords == null) {
		alert("No Keywords!");
		return;
	}
	DoSearch(0, 0, new Array(), keywords.value);
}
