

function ReloadIndex(industryId, stateId) {
	var url = "http://www.gesundheitsabc.at/index.aspx?stid=%SID%&bid=%IID%";

	if (industryId != 0){
		url = url.replace("%IID%", industryId);
	}
	else {
		url = url.replace("%IID%", "");
	}
	
	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://www.gesundheitsabc.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(clearState, clearDistrict,branchesDropDown, statesDropDown) {
	var stateId = statesDropDown.val();
	var branchId = branchesDropDown.val();
	
	if (branchId == undefined) {
		branchId = $('#hiddenIndustryId').val();
	}

	if (clearState) {
		ReloadIndex(branchId, '');
	}
    else if (clearDistrict)
    {
        ReloadIndex(branchId, stateId);
    }
	else {
		ReloadIndex(branchId, stateId);
	}
}

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);
}
