function refresh(oFormElement){
	oForm = oFormElement.form;

	//alert(oFormElement.value);
//	if(oFormElement.name == "place" && oFormElement.options[oFormElement.selectedIndex].textContent.indexOf('(') > -1){
//		oForm.date_start.value = "Wszystkie";
//		oForm.period.selecetedIndex = 0;
//	}

	selPlace = document.getElementById("find_place");

	i_ofert = selPlace.options[selPlace.options.selectedIndex].text;

	if(i_ofert.indexOf('(') > -1 || oFormElement.id != "find_place" || oFormElement.value == "0"){
		
		/*
		if(selPlace.options.selectedIndex == 0 && document.getElementById("find_period").options.selectedIndex == 0 && document.getElementById("find_date_start").value == "Wszystkie" && document.getElementsByName("find[catalog]").length == 0)
		{
			conn = new ajax_caller("tmp/all.xml", oForm);
			conn.get(putTo);
		}
		else
		{
		//*/
			conn = new ajax_caller("ajax.php", oForm);
			conn.addParam("ajax", "ajax_finder_neckermann_ogolny");
			conn.get(putTo);
		//}

	}else{
		oblicz_pokaz();
	}


}

function putTo(text){
	opcje = stripXML(text, "KrajeRegiony");

	//alert(opcje);

	aOpcje = getTagList(opcje, "option");




	buff = "";
	//alert(aOpcje.join("\n\n"));
	selPlace = document.getElementById("find_place");

	selectedValue = selPlace.options[selPlace.options.selectedIndex].value;

	selPlace.options.length=0;

	option_selected = false;
	for(i=0; i< aOpcje.length; i++){

		key = stripXML(aOpcje[i], "key").replace("\s", "");

		value = stripXML(aOpcje[i], "value").replace("\n", "");


		selPlace.options[i] = new Option(value ,key);

		selPlace.options[i].innerHTML = value;

		if(key == selectedValue && !option_selected){
			selPlace.options[i].selected = true;
			option_selected = true;
		}

		buff += "key: " + key;
		buff += "\t";
		buff += "value: " + value;
		buff +="\n\n";
	}





	opcje = stripXML(text, "Terminy");

	//alert(opcje);

	aOpcje = getTagList(opcje, "option");



	buff = "";
	//alert(aOpcje.join("\n\n"));
	selPeriod = document.getElementById("find_period");

	selectedValue = selPeriod.options[selPeriod.options.selectedIndex].value;

	selPeriod.options.length=0;


	option_selected = false;
	for(i=0; i< aOpcje.length; i++){

		key = stripXML(aOpcje[i], "key").replace("\s", "");

		value = stripXML(aOpcje[i], "value").replace("\n", "");


		selPeriod.options[i] = new Option(value ,key);

		selPeriod.options[i].innerHTML = value;

		if(key == selectedValue && !option_selected){
			selPeriod.options[i].selected = true;
			option_selected = true;
		}

		buff += "key: " + key;
		buff += "\t";
		buff += "value: " + value;
		buff +="\n\n";
	}

	oblicz_pokaz();

		//alert(buff);

}

function oblicz_pokaz(){
	selPlace = document.getElementById("find_place");

	i_ofert = selPlace.options[selPlace.options.selectedIndex].text;
	if(i_ofert.indexOf('(') > -1){
		i_ofert = i_ofert.substr((i_ofert.indexOf('(') + 1), (-(i_ofert.indexOf('(') + 1) + i_ofert.indexOf(')')));
		i_ofert = parseInt(i_ofert);
	}else{
		i_ofert = 0;
	}
	odmiana = "ofert";
	if(i_ofert < 5 || (i_ofert > 20 && parseInt(i_ofert.toString().substr(-1)) < 5 && parseInt(i_ofert.toString().substr(-1)) > 1)){
		odmiana = "oferty";
	}
	if(i_ofert == 1){
		odmiana = "ofertę";
	}
	if(i_ofert == 0){
		odmiana = "ofert";
	}

	document.getElementById("liczba_ofert").innerHTML = i_ofert;
	
	
	
	
	document.getElementById("liczba_ofert_odmiana").innerHTML = odmiana;

	
	pokaz_buton = document.getElementById("button_pokaz");

	if(i_ofert == 0){
		pokaz_buton.value = "Zmień kryteria";
		pokaz_buton.type = "reset";
		
	}else{
		pokaz_buton.type = "Submit";
		pokaz_buton.value = "Szukaj i rezerwuj on-line";// + i_ofert + " " + odmiana;
	}
}





