var before_choose_region_id=false;

var countryChange = function (){
	if(before_choose_region_id){
		$('#chooseRegion'+before_choose_region_id).hide('slow');
	}
	$('#chooseRegion'+$('#country').val()).show('slow');
	before_choose_region_id = $('#country').val();
};

var moreAreas = function(){
	$('#bigCities').hide('slow');
	$('#formSloupecVice').hide('slow');
	$('#chooseCountry').show('slow');
	$('#help').show('slow');
};

var searchFormSubmit = function () {
	if($('#searchFormAktivity').val() != 0){
		$('#search').submit();
	} else {
		alert('Musite zadat aktivitu.');
		return false
	}
};

var newSearch = function() {
	$.get("blank-form.php", { ajax: "true" }, function(data){
    document.getElementById('aForm').innerHTML = data;
    $('#aForm').show('slow');
    $('#newSearch').hide('slow');
    readyForm();
  });
};

$(document).ready(function (){
	$('#newSearch').bind('click',newSearch);
	if(typeof($('.lightbox').lightbox) == 'function' ){
		$(".lightbox").lightbox({fitToScreen: true});
	}
	readyForm();
});


function readyForm(){
	switch ($('#searchFormStatus').val()){
		case 'b':
			$('#bigCities').show('slow');
			break;
		case 'c':
			$('#chooseCountry').show('slow');
			break;
		case 'r':
			eval(countryChange);
			break;
	}
	$('#country').bind('change', countryChange);
	$('#searchFormMore').bind('click', moreAreas);
	$('#searchFormSubmit').bind('click',searchFormSubmit);
}

/*
#searchFormStatus - b,c,r
#searchFormAktivity - pri odeslani musi byt vyplneno
#bigCities - show/hide
#searchFormMore - primo odkaz
#formSloupecVice - div odkazu show/hide
#chooseCountry - show/hide
#country - podle toho nastavi show/hide regionChoose
#chooseRegion$id - show/hide
.formHidden - default hidden
#help	- show/hide
#searchFormSubmit - odeslani formu
*/

