function getAgricastData(page, resultPage) {
	//alert(page);
	advAJAX.get({
		url : base+'pl/' + page + '/getData',
		onSuccess : function (obj) {
			if(obj.responseText == 'ok') {
				if(resultPage) {
					window.location = base + 'pl/' + page + resultPage;
				} else {
					window.location = base + 'pl/' + page;
				}
			} else if(obj.responseText == 'error') {
				$('centerContent').innerHTML = '<div class="form_message">Wystapily problemy techniczne, prosimy sprobowac ponownie pozniej</div>'; 
			} else {
				$('centerContent').innerHTML = obj.responseText;
			}
		},
		onError: function (obj) {
			alert('Wystapily problemy, prosimy sprobowac ponownie pozniej.');
		}
	});
}

function setUserGeoData(page) {
	var geoData = document.locationForm.locationsFound.options[document.locationForm.locationsFound.selectedIndex].value;
	advAJAX.get({
		url : base+'pl/' + page + '/geodata/' + geoData,
		onSuccess : function (obj) {
			if(obj.responseText == 'ok') {
				window.location = base + 'pl/' + page;
			}
		},
		onError: function (obj) {
			alert('Wystapily problemy, prosimy sprobowac ponownie pozniej.');
		}
	});
}

function getGeoData(city, page) {
	if(city != '') {
		$('centerContent').innerHTML = "<div class='waitInfo'><div><img src=\"" + img + "syngenta_logo_2.gif\" style='margin-top:30px;'><br/><img src=\"" + img + "preloader_midi.gif\" style='margin-top:30px;'><br/>Trwa pobieranie danych...</div></div>";
		advAJAX.get({
			url : base+'pl/'+ page +'/getGeoForCity/' + city,
			onSuccess : function (obj) {
				if(obj.responseText == 'ok') {
					window.location = base + 'pl/' + page + '/miejscowosc/' + city;
				} else if(obj.responseText == 'error') {
					$('centerContent').innerHTML = '<div class="form_message">Wystapily problemy techniczne, prosimy sprobowac ponownie pozniej</div>'; 
				} else {
					$('centerContent').innerHTML = obj.responseText;
				}
			}
		})
	} else {
		alert('Nieprawidłowa nazwa.');
	}
}

function getEvent(e, page) {
	var kod = (window.event) ? window.event.keyCode : e.which;
	if(kod == 13) {	
		getGeoData($('locationCity').value, page);
	}
}