//<![CDATA[
// array of possible countries in the same order as they appear in the country selection list
var typ = new Array(4)
	typ["0"] = ["Wybierz"]; 
	typ["1"] = ["na sprzedaż", "do wynajęcia"];
	typ["2"] = ["na sprzedaż", "do wynajęcia"];
	typ["3"] = ["budowlane", "rolne", "rekreacyjne"];
	typ["4"]=  ["na sprzedaż", "do wynajęcia"];
/* CountryChange() is called from the onchange event of a select element.
 * param selectObj - the select object which fired the on change event.
 */
 
var powierzchnia = new Array(4)
	powierzchnia["0"] = ["Wybierz"]; 
	powierzchnia["1"] = ["< 100", "100-150", "150-200", "200-300", "300 <"];
	powierzchnia["2"] = ["< 35", "35-45", "45-60", "60 <"];
	powierzchnia["3"] = ["< 1000", "1000-2000", "2000-3000", "3000-5000", "5000-10000", "10000 <"];
	powierzchnia["4"]=  ["< 100", "100-150", "150-200", "200-300", "300 <"];

	
var tablica=new Array(5)
for (i=0; i <5; i++) tablica[i]=new Array(5)

tablica[0][0] = '0';
tablica[0][1] = '0';
tablica[0][2] = '0';
tablica[0][3] = '0';
tablica[0][4] = '0';
tablica[1][0] = '1';
tablica[1][1] = '2';
tablica[2][0] = '3';
tablica[2][1] = '4';
tablica[3][0] = '5';
tablica[3][1] = '6';
tablica[3][2] = '7';
tablica[4][0] = '10';
tablica[4][1] = '11';




	
function zmianaTypu(selectObj) {
	// get the index of the selected option
	var idx = selectObj.selectedIndex;
	
	// get the value of the selected option
	var which = selectObj.options[idx].value;
	// use the selected option value to retrieve the list of items from the coutnryLists array
	cList = typ[idx];

	// get the country select element via its known id
	var cSelect = document.getElementById("typOferty");
	// remove the current options from the country select
	var len=cSelect.options.length;
	while (cSelect.options.length > 0) {
		cSelect.remove(0);
	}
	var newOption;
	// create new options dla typ
	for (var i=0; i<cList.length; i++) {
		newOption = document.createElement("option");
		newOption.value = tablica[idx][i];  // assumes option string and value are the same
		//newOption.value = cList[i];
		newOption.text=cList[i];
		// add the new option
		try {
			cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE
		}
		catch (e) {
			cSelect.appendChild(newOption);

		}
	}
	cList2 = powierzchnia[idx];
	var cSelect2 = document.getElementById("powierzchnia");
	var len=cSelect2.options.length;
	while (cSelect2.options.length > 0) {
		cSelect2.remove(0);
	}
	// create new options dla powierzchnia
	for (var i=0; i<cList2.length; i++) {
		newOption = document.createElement("option");
		newOption.value = cList2[i];  // assumes option string and value are the same
		newOption.text=cList2[i];
		// add the new option
		try {
			cSelect2.add(newOption);  // this will fail in DOM browsers but is needed for IE
		}
		catch (e) {
			cSelect2.appendChild(newOption);

		}
	}
	zmianaPowierzchni(cSelect2); 
}
function zmianaPowierzchni(selectObj) {
	var idx = selectObj.selectedIndex;
	
	var powierzchnia_min = document.getElementById("powierzchnia-min");
	
	var powierzchnia_max = document.getElementById("powierzchnia-max");
	if(idx=='0') {
		var posplicie = selectObj.value.split('<');
		var min = 0;
		var max = posplicie[1];
	}
	else {
		var posplicie = selectObj.value.split('-');
		var min = posplicie[0];
		var max = posplicie[1];
	}
	if(max == undefined) {
		var posplicie = selectObj.value.split('<');
		var min = posplicie[0];
		var max = '';
	}
	
	powierzchnia_min.value = min;
	powierzchnia_max.value = max;
}

//]]>
