	var aHouseTypeAStreets = new Array("","Героев Сталинграда","Оболонская набережная");
	var aHouseTypeBStreets = new Array("Героев Сталинграда");
	var aHouseTypeCStreets = new Array("Оболонская набережная");
	
	var aHouseASt1NumberHouse = new Array("","4", "6", "6-Б", "8", "10-А");
	var aHouseASt2NumberHouse = new Array("3");
	var aHouseBSt1NumberHouse = new Array("","2-Г", "4-А", "6-А", "8-А");
	var aHouseCSt1NumberHouse = new Array("","7", "11", "15", "19");

	var aCorpus12 = new Array("","1","2");
	var aCorpus123 = new Array("","1","2","3");
	var aCorpus123345678 = new Array("","1","2","3","4","5","6","7","8");
	var aCorpus123345 = new Array("","1","2","3","4","5");

function setHouseFields(nHType,nStreet,nHouse,nCorp){
	var oHouseTypeList = document.getElementById("housetype");
	var oStreetList = document.getElementById("street_ind");
 	var oNumberHouseList = document.getElementById("nhouse_ind");
	var oNumberCorpList = document.getElementById("ncorp_ind");
  	
  	oHouseTypeList.selectedIndex = nHType;
  	//alert(nHType);
  	changeFSELImage(oHouseTypeList);
  	if(nHType==1){//A
  		//alert(nStreet);
  		oStreetList.selectedIndex = nStreet;
  		changeStreet(oStreetList);
  		
  		oNumberHouseList.selectedIndex = nHouse;
  		
  		changeNumberH(oNumberHouseList);
  		oNumberCorpList.selectedIndex = nCorp;
  		changeNumberC(oNumberCorpList);
  	}else if(nHType==2){//B
  		oNumberHouseList.selectedIndex = nHouse;
  		changeNumberH(oNumberHouseList);
  		if(nHouse == 1 || nHouse == 3){
  			oNumberCorpList.selectedIndex = nCorp;
  		}
  	}else if(nHType==3){//C
  		oNumberHouseList.selectedIndex = nHouse;
  		changeNumberH(oNumberHouseList);
  		oNumberCorpList.selectedIndex = nCorp;
  	}
}

function changeFSELImage(sel){
	changeImage(sel.selectedIndex);
	setStreet(sel);
}

function setStreet(sel){
	var oStreetList = document.getElementById("street_ind");
	var oFloorTotalField = document.getElementById("floortotal");
	var oNumberHouseList = document.getElementById("nhouse_ind");
	var oNumberCorpList = document.getElementById("ncorp_ind");
	
	clearSelects(new Array(oStreetList,oNumberHouseList,oNumberCorpList),oFloorTotalField);
	
	if(sel.selectedIndex>0){
		if(sel.selectedIndex == 2){
			setSelectOptions(oStreetList,aHouseTypeBStreets);
			setSelectOptions(oNumberHouseList,aHouseBSt1NumberHouse);
			if(oFloorTotalField) oFloorTotalField.value = "24";
			oStreetList.selectedIndex = 0;
		}else if(sel.selectedIndex == 1){
			setSelectOptions(oStreetList, aHouseTypeAStreets);
		}else if(sel.selectedIndex == 3){
			setSelectOptions(oStreetList,aHouseTypeCStreets);
			setSelectOptions(oNumberHouseList, aHouseCSt1NumberHouse);
			if(oFloorTotalField) oFloorTotalField.value = "4";
			oStreetList.selectedIndex = 0;
		}
	}
}

function changeStreet(oStreet){
	var oNumberHouseList = document.getElementById("nhouse_ind");
	var oNumberCorpList = document.getElementById("ncorp_ind");
	var oFloorTotalField = document.getElementById("floortotal");
	
	clearSelects(new Array(oNumberHouseList,oNumberCorpList),oFloorTotalField);

	if(oStreet.selectedIndex == 1){
		setSelectOptions(oNumberHouseList,aHouseASt1NumberHouse);
	}else if(oStreet.selectedIndex == 2){
		setSelectOptions(oNumberHouseList,aHouseASt2NumberHouse);
		oNumberHouseList.selectedIndex = 0;
		
		//alert(oStreet.selectedIndex);
		setSelectOptions(oNumberCorpList,aCorpus123);
	}
}

function changeNumberH(oHouse){
	var oHouseTypeList = document.getElementById("housetype");
	var oStreetList = document.getElementById("street_ind");
	var oFloorTotalField = document.getElementById("floortotal");
	var oNumberCorpList = document.getElementById("ncorp_ind");
	
	if(oHouseTypeList.selectedIndex == 1){
		clearSelects(new Array(oNumberCorpList),oFloorTotalField);
		
		//alert(oStreetList.selectedIndex+'\n'+oHouse.selectedIndex);
		if(oHouse.selectedIndex > 0){
			setSelectOptions(oNumberCorpList,aCorpus123345678);
		} else if(oStreetList.selectedIndex == 2 && oHouse.selectedIndex == 0){
			setSelectOptions(oNumberCorpList,aCorpus123);
		}
	}else if(oHouseTypeList.selectedIndex == 2){
		clearSelects(new Array(oNumberCorpList));
		if(oHouse.selectedIndex == 1 || oHouse.selectedIndex == 3){
			setSelectOptions(oNumberCorpList,aCorpus12);
		}
	}else if(oHouseTypeList.selectedIndex == 3){
		if(oHouse.selectedIndex == 0){
			clearSelects(new Array(oNumberCorpList));
		}else if(oHouse.selectedIndex == 2){
			setSelectOptions(oNumberCorpList,aCorpus123);
		}else{
			setSelectOptions(oNumberCorpList,aCorpus123345);
		}
	}
}

function changeNumberC(oNumberCorpList){
	var oHouseTypeList = document.getElementById("housetype");
	var oStreetList = document.getElementById("street_ind");
	var oFloorTotalField = document.getElementById("floortotal");
	
	if(oHouseTypeList.selectedIndex == 1){
		if(oFloorTotalField) oFloorTotalField.value = "";
		if(oStreetList.selectedIndex == 2){
			if(oNumberCorpList.selectedIndex == 1){
				if(oFloorTotalField) oFloorTotalField.value = "16";
			}else if(oNumberCorpList.selectedIndex == 2 || oNumberCorpList.selectedIndex == 3){
				if(oFloorTotalField) oFloorTotalField.value = "9";
			}
		}else if(oStreetList.selectedIndex == 1){
			if(oNumberCorpList.selectedIndex == 1 || oNumberCorpList.selectedIndex == 4){
				if(oFloorTotalField) oFloorTotalField.value = "16";
			} else if(oNumberCorpList.selectedIndex == 5 || oNumberCorpList.selectedIndex == 6){
				if(oFloorTotalField) oFloorTotalField.value = "12";
			}else if(oNumberCorpList.selectedIndex == 2 || oNumberCorpList.selectedIndex == 3){
				if(oFloorTotalField) oFloorTotalField.value = "9";
			}else if(oNumberCorpList.selectedIndex == 7 || oNumberCorpList.selectedIndex == 8){
				if(oFloorTotalField) oFloorTotalField.value = "7";
			}
		}
	}
}

function clearSelects(aSelect,oInput){
	var nSelect = aSelect.length;
	for(i=0; i < nSelect; i++){
		aSelect[i].length = 0;
		aSelect[i].disabled = true;
	}
	if(oInput) oInput.value = "";
}

function setSelectOptions(oSelect,aOptions){
	var nCurrOptionsCount = aOptions.length;
	oSelect.length = 0;
	for(i=0; i < nCurrOptionsCount; i++){
		if (document.createElement){
			var newListOption = document.createElement("OPTION");
			newListOption.text = aOptions[i];
			newListOption.value = i;
			(oSelect.options.add) ? oSelect.options.add(newListOption) : oSelect.add(newListOption, null);
		}else{
			oSelect.options[i] = new Option(aOptions[i], i, false, false);
		}
	}
	oSelect.disabled = false;
}
function changeImage(n){
	document.getElementById('house').src=myImages[n];
}

