
/* PLACEHOLDER */
(function(){
	var ls2=document.getElementsByTagName('input');
	for(var i=0,input;input=ls2[i++];){
		if(input.className.match(/(^|\s)placeholder($|\s)/)&&input.title){
			if(!input.value||input.value==input.title){
				input.value=input.title;
				input.placeholderActive=true;
			}
			input.onfocus=function(){
				if(this.placeholderActive){
					this.value='';
					this.placeholderActive=false;
				}
			};
			
			input.onblur=function(){
				if(!this.value){
					this.value=this.title;
					this.placeholderActive=true;
				}
			};
			
			input.form.onsubmit=function(){
				var lsx=this.getElementsByTagName('input');
				for(var i=0,input;input=lsx[i++];){
					if(input.className.match(/(^|\s)placeholder($|\s)/)&&input.placeholderActive){
						input.value='';
					}
				}
				return true;
			}
		}
	}
})();


/* PRETTY CHECKBOX */
jQuery.fn.prettyCheckboxes=function(a){
	a=jQuery.extend({
		checkboxWidth:17,
		checkboxHeight:17,
		className:"prettyCheckbox",
		display:"list"
	},a);
	$(this).each(function(){
		$label=$('label[for="'+$(this).attr("id")+'"]');
		$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");
		if($(this).is(":checked")){
			$label.addClass("checked")
		}
		$label.addClass(a.className).addClass($(this).attr("type")).addClass(a.display);
		$label.find("span.holderWrap").width(a.checkboxWidth).height(a.checkboxHeight);
		$label.find("span.holder").width(a.checkboxWidth);
		$(this).addClass("hiddenCheckbox");
		$label.bind("click",function(){
			$("input#"+$(this).attr("for")).triggerHandler("click");
			if($("input#"+$(this).attr("for")).is(":checkbox")){
				$(this).toggleClass("checked");
				$("input#"+$(this).attr("for")).checked=true;
				$(this).find("span.holder").css("top",0)
			}else{
				$toCheck=$("input#"+$(this).attr("for"));
				$('input[name="'+$toCheck.attr("name")+'"]').each(function(){
					$('label[for="'+$(this).attr("id")+'"]').removeClass("checked")
				});
				$(this).addClass("checked");
				$toCheck.checked=true
			}
		});
		$("input#"+$label.attr("for")).bind("keypress",function(b){
			if(b.keyCode==32){
				if($.browser.msie){
					$('label[for="'+$(this).attr("id")+'"]').toggleClass("checked")
				}else{
					$(this).trigger("click")
				}
				return false
			}
		})
	})
};

checkAllPrettyCheckboxes=function(b,a){
	if($(b).is(":checked")){
		$(a).find("input[type=checkbox]:not(:checked)").each(function(){
			$('label[for="'+$(this).attr("id")+'"]').trigger("click");
			if($.browser.msie){
				$(this).attr("checked","checked")
			}else{
				$(this).trigger("click")
			}
		})
	}else{
		$(a).find("input[type=checkbox]:checked").each(function(){
			$('label[for="'+$(this).attr("id")+'"]').trigger("click");
			if($.browser.msie){
				$(this).attr("checked","")
			}else{
				$(this).trigger("click")
			}
		})
	}
};


/* PRETTY SELECTBOX */
(function(a){
	a("html").addClass("stylish-select");
	Array.prototype.indexOf=function(c,d){
		for(var b=(d||0);b<this.length;b++){
			if(this[b]==c){
				return b
			}
		}
	};
	
	a.fn.extend({
		getSetSSValue:function(b){
			if(b){
				a(this).val(b).change();
				return this
			}else{
				return a(this).find(":selected").val()
			}
		},
		resetSS:function(){
			var b=a(this).data("ssOpts");
			$this=a(this);
			$this.next().remove();
			$this.unbind(".sSelect").sSelect(b)
		}
	});
	a.fn.sSelect=function(b){
		return this.each(function(){
			var i={
				defaultText:"Please select",
				animationSpeed:0,
				ddMaxHeight:""
			};
			
			var l=a.extend(i,b),e=a(this),j=a('<div class="selectedTxt"></div>'),r=a('<div class="newListSelected" tabindex="0"></div>'),z=a('<ul class="newList"></ul>'),t=-1,d=-1,m=[],w=false,v=false,x;
			a(this).data("ssOpts",b);
			r.insertAfter(e);
			j.prependTo(r);
			z.appendTo(r);
			e.hide();
			j.data("ssReRender",!j.is(":visible"));
			if(e.children("optgroup").length==0){
				e.children().each(function(B){
					var C=a(this).text();
					var A=a(this).val();
					m.push(C.charAt(0).toLowerCase());
					if(a(this).attr("selected")==true){
						l.defaultText=C;
						d=B
					}
					z.append(a('<li><a href="JavaScript:void(0);">'+C+"</a></li>").data("key",A))
				});
				x=z.children().children()
			}else{
				e.children("optgroup").each(function(){
					var A=a(this).attr("label"),C=a('<li class="newListOptionTitle">'+A+"</li>");
					C.appendTo(z);
					var B=a("<ul></ul>");
					B.appendTo(C);
					a(this).children().each(function(){
						++t;
						var E=a(this).text();
						var D=a(this).val();
						m.push(E.charAt(0).toLowerCase());
						if(a(this).attr("selected")==true){
							l.defaultText=E;
							d=t
						}
						B.append(a('<li><a href="JavaScript:void(0);">'+E+"</a></li>").data("key",D))
					})
				});
				x=z.find("ul li a")
			}
			var o=z.height(),n=r.height(),y=x.length;
			if(d!=-1){
				h(d,true)
			}else{
				j.text(l.defaultText)
			}
			function p(){
				var B=r.offset().top,A=jQuery(window).height(),C=jQuery(window).scrollTop();
				if(o>parseInt(l.ddMaxHeight)){
					o=parseInt(l.ddMaxHeight)
				}
				B=B-C;
				if(B+o>=A){
					z.css({
						top:"-"+o+"px",
						height:o
					});
					e.onTop=true
				}else{
					z.css({
						top:n+"px",
						height:o
					});
					e.onTop=false
				}
			}
			p();
			a(window).bind("resize.sSelect",function(){
				p()
			});
			a(window).bind("scroll.sSelect",function(){
				p()
			});
			function s(){
				r.css("position","relative")
			}
			function c(){
				r.css("position","static")
			}
			j.bind("click.sSelect",function(A){
				A.stopPropagation();
				if(a(this).data("ssReRender")){
					o=z.height("").height();
					n=r.height();
					a(this).data("ssReRender",false);
					p()
				}
				a(".newList").not(a(this).next()).hide().parent().removeClass("newListSelFocus");
				z.toggle();
				s();
				x.eq(d).focus()
			});
			x.bind("click.sSelect",function(B){
				var A=a(B.target);
				d=x.index(A);
				v=true;
				h(d);
				z.hide();
				r.css("position","static")
			});
			x.bind("mouseenter.sSelect",function(B){
				var A=a(B.target);
				A.addClass("newListHover")
			}).bind("mouseleave.sSelect",function(B){
				var A=a(B.target);
				A.removeClass("newListHover")
			});
			function h(A,D){
				x.removeClass("hiLite").eq(A).addClass("hiLite");
				if(z.is(":visible")){
					x.eq(A).focus()
				}
				var C=x.eq(A).text();
				var B=x.eq(A).parent().data("key");
				if(D==true){
					e.val(B);
					j.text(C);
					return false
				}
				e.val(B);
				e.change();
				j.text(C)
			}
			e.bind("change.sSelect",function(A){
				$targetInput=a(A.target);
				if(v==true){
					v=false;
					return false
				}
				$currentOpt=$targetInput.find(":selected");
				d=$targetInput.find("option").index($currentOpt);
				h(d,true)
			});
			function q(A){
				a(A).unbind("keydown.sSelect").bind("keydown.sSelect",function(D){
					var C=D.which;
					v=true;
					switch(C){
						case 40:case 39:
							u();
							return false;
							break;
						case 38:case 37:
							k();
							return false;
							break;
						case 33:case 36:
							g();
							return false;
							break;
						case 34:case 35:
							f();
							return false;
							break;
						case 13:case 27:
							z.hide();
							c();
							return false;
							break
					}
					keyPressed=String.fromCharCode(C).toLowerCase();
					var B=m.indexOf(keyPressed);
					if(typeof B!="undefined"){
						++d;
						d=m.indexOf(keyPressed,d);
						if(d==-1||d==null||w!=keyPressed){
							d=m.indexOf(keyPressed)
						}
						h(d);
						w=keyPressed;
						return false
					}
				})
			}
			function u(){
				if(d<(y-1)){
					++d;
					h(d)
				}
			}
			function k(){
				if(d>0){
					--d;
					h(d)
				}
			}
			function g(){
				d=0;
				h(d)
			}
			function f(){
				d=y-1;
				h(d)
			}
			r.bind("click.sSelect",function(){
				q(this)
			});
			r.bind("focus.sSelect",function(){
				a(this).addClass("newListSelFocus");
				q(this)
			});
			r.bind("blur.sSelect",function(){
				a(this).removeClass("newListSelFocus")
			});
			a("body").bind("click.sSelect",function(){
				r.removeClass("newListSelFocus");
				z.hide();
				c()
			});
			j.bind("mouseenter.sSelect",function(B){
				var A=a(B.target);
				A.parent().addClass("newListSelHover")
			}).bind("mouseleave.sSelect",function(B){
				var A=a(B.target);
				A.parent().removeClass("newListSelHover")
			});
			z.css("left","0").hide()
		})
	}
})(jQuery);


/* PRICE SLIDER */

// jQuery minMaxSlider Plugin
//
// Version 1.10
//
// Lindsay Stuart
// Flameweb Web Development (http://www.flameweb.net/)
// 7 January, 2010
//
// Visit http://www.flameweb.net/minmaxslider for more information
//
// Usage: $("div#slider").minMaxSlider(options)
//
// Options: slider  		By default the slider is attached to the calling element. With this option you can set it to something else.
//			min_input 		This is the tag that identifies the minimum input box for the slider.
//			max_output 		This is the tag that identifies the maximum input box for the slider.
//			min_size 		This sets the minimum size of the slider, default = 0.
//			max_size 		This sets the maxium size of the slider, default = 500.
//			sync_inputs 	This sets whether the input values and slider values are synchronised at all times. For instance this may be useful when you allow the max input to have a higher value then might be displayed on the slider.
//
// History:
//
// 1.00 - released (7 January, 2010)
// 1.10 - released (14 March, 2010)
//
// TERMS OF USE
//
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC.

(function($) {
	
	$.fn.minMaxSlider = function(settings) {
		var config = {
			'slider'		:			 $(this),           		// the tag of the selected slider
			'min_input'		:			'#min_input',				// the tag of the associated min input
			'max_input'		:			'#max_input',				// the tag of the associate max input
			'min_size'		:			0,							// the min value of the slider
			'max_size'		:			500,						// the max value of the slider
			'sync_inputs'	:			true						// sets whether input fields are identical to slider fields
			
		};
		
		if (settings) {
			settings = $.extend(config, settings);
		}
		
		this.each(function() {
			// get input values and set as slider defaults
			var min_value = $(settings.min_input).attr("value");
			var max_value = $(settings.max_input).attr("value");
			// add the slider
			$(this).slider({
				range: true,
				min: settings.min_size,
				max: settings.max_size,
				values: [min_value, max_value],
				slide: function(event, ui) {
					$(settings.min_input).val(ui.values[0]);
					$(settings.max_input).val(ui.values[1]);
				}
				
			});
			// add listener to min input
			$(settings.min_input).change(changeSlider);
			// add listener to max input
			$(settings.max_input).change(changeSlider);
			return this;
		});
		
		function changeSlider() {
			// change the slider handles based on value of inputs
			var new_value = parseInt($(this).val()); // value of input
			
			//document.title = 'KK';
			// alert( new_value );
			
			var index; // which handle to move
			if ($(this).attr('name') == $(settings.min_input).attr('name')) {
				// min slider
				index = 0;
				new_value = Math.min(new_value, parseInt($(settings.max_input).val()));
			}
			else {
				// max slider
				index = 1;
				new_value = Math.max(new_value, parseInt($(settings.min_input).val()));
			}
			if (new_value < settings.min_size) new_value = settings.min_size;
			else if (new_value > settings.max_size) new_value = settings.max_size;
						
			// sync if allowed
			if (settings.sync_inputs) 
				$(this).val(new_value);
			// set the slider
			$(settings.slider).slider('values',index,new_value);
			return this;
		}
	};
	
})(jQuery);



/**
                * @author trixta
                */
(function($){
	
	$.bind = function(object, method){
		var args = Array.prototype.slice.call(arguments, 2);
		if(args.length){
			return function() {
				var args2 = [this].concat(args, $.makeArray( arguments ));
				return method.apply(object, args2);
			};
		} else {
			return function() {
				var args2 = [this].concat($.makeArray( arguments ));
				return method.apply(object, args2);
			};
		}
	};
	
})(jQuery);


/**
                * @author alexander.farkas
                * @version 1.3
                */
(function($){
	$.widget('ui.checkBox', {
		_init: function(){
			var that = this,
			
			opts = this.options,
			
			toggleHover = function(e){
				if(this.disabledStatus){
					return false;
				}
				that.hover = (e.type == 'focus' || e.type == 'mouseenter');
				that._changeStateClassChain();
			};
			if(!this.element.is(':radio,:checkbox')){
				return false;
			}
			this.labels = $([]);
			
			this.checkedStatus = false;
			this.disabledStatus = false;
			this.hoverStatus = false;
			
			this.radio = (this.element.is(':radio'));
			
			this.visualElement = $('<span />')
			.addClass(this.radio ? 'ui-radio' : 'ui-checkbox')
			.bind('mouseenter.checkBox mouseleave.checkBox', toggleHover)
			.bind('click.checkBox', function(e){
				that.element[0].click();
				//that.element.trigger('click');
				return false;
			});
			
			if (opts.replaceInput) {
				this.element
				.addClass('ui-helper-hidden-accessible')
				.after(this.visualElement[0])
				.bind('usermode', function(e){
					(e.enabled &&
						that.destroy.call(that, true));
				});
			}
			
			this.element
			.bind('click.checkBox', $.bind(this, this.reflectUI))
			.bind('focus.checkBox blur.checkBox', toggleHover);
			
			if(opts.addLabel){
				//ToDo: Add Closest Ancestor
				this.labels = $('label[for=' + this.element.attr('id') + ']')
				.bind('mouseenter.checkBox mouseleave.checkBox', toggleHover);
			}
			
			this.reflectUI({
				type: 'initialReflect'
			});
		},
		_changeStateClassChain: function(){
			var stateClass = (this.checkedStatus) ? '-checked' : '',
			baseClass = 'ui-'+((this.radio) ? 'radio' : 'checkbox')+'-state';
			
			stateClass += (this.disabledStatus) ? '-disabled' : '';
			stateClass += (this.hover) ? '-hover' : '';
			
			if(stateClass){
				stateClass = baseClass + stateClass;
			}
			
			function switchStateClass(){
				var classes = this.className.split(' '),
				found = false;
				$.each(classes, function(i, classN){
					if(classN.indexOf(baseClass) === 0){
						found = true;
						classes[i] = stateClass;
						return false;
					}
				});
				if(!found){
					classes.push(stateClass);
				}
				
				this.className = classes.join(' ');
			}
			
			this.labels.each(switchStateClass);
			this.visualElement.each(switchStateClass);
		},
		destroy: function(onlyCss){
			this.element.removeClass('ui-helper-hidden-accessible');
			this.visualElement.addClass('ui-helper-hidden');
			if (!onlyCss) {
				var o = this.options;
				this.element.unbind('.checkBox');
				this.visualElement.remove();
				this.labels
				.unbind('.checkBox')
				.removeClass('ui-state-hover ui-state-checked ui-state-disabled');
			}
		},
		
		disable: function(){
			this.element[0].disabled = true;
			this.reflectUI({
				type: 'manuallyDisabled'
			});
		},
		
		enable: function(){
			this.element[0].disabled = false;
			this.reflectUI({
				type: 'manuallyenabled'
			});
		},
		
		toggle: function(e){
			this.changeCheckStatus((this.element.is(':checked')) ? false : true, e);
		},
		
		changeCheckStatus: function(status, e){
			if(e && e.type == 'click' && this.element[0].disabled){
				return false;
			}
			this.element.attr({
				'checked': status
			});
			this.reflectUI(e || {
				type: 'changeCheckStatus'
			});
		},
		
		propagate: function(n, e, _noGroupReflect){
			if(!e || e.type != 'initialReflect'){
				if (this.radio && !_noGroupReflect) {
					//dynamic
					$(document.getElementsByName(this.element.attr('name')))
					.checkBox('reflectUI', e, true);
				}
				return this._trigger(n, e, {
					options: this.options,
					checked: this.checkedStatus,
					labels: this.labels,
					disabled: this.disabledStatus
				});
			}
		},
		
		reflectUI: function(elm, e){
			var oldChecked = this.checkedStatus,
			oldDisabledStatus = this.disabledStatus;
			e = e ||
			elm;
			
			this.disabledStatus = this.element.is(':disabled');
			this.checkedStatus = this.element.is(':checked');
			
			if (this.disabledStatus != oldDisabledStatus || this.checkedStatus !== oldChecked) {
				this._changeStateClassChain();
				
				(this.disabledStatus != oldDisabledStatus &&
					this.propagate('disabledChange', e));
				
				(this.checkedStatus !== oldChecked &&
					this.propagate('change', e));
			}
			
		}
	});
	$.ui.checkBox.defaults = {
		replaceInput: true,
		addLabel: true
	};
	
})(jQuery);


function InitSlider()
{
	// var min_max = $('#slider').slider( "option", "values" );
	//   alert("InitSlider call..");
	$('#testovaci').text(' - ');
	$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),function (data){
		
		//callback function
		if(data.object_multiple){
			GetCoutnObjectInMountains(data);
		}
		SearchDisplayResultControler(data.object_count);
	}, "json");
}

function GetLokality(formular)
{
	//nacteni seznamu
	//   alert("GetLokality call..");
	$.get(GG_ROOT_DIR+"/ajax/aj_lokality.php", $(formular).serialize(),
		function (data){
			//callback function checked="checked"
			if(data.pohori)
			{
				var row = '<ol>'
				for(i = 0;i<data.pocet_pohori; i++)
				{
					row = row + '<li><input type="checkbox" class="check"  id="checkbox-1-'+(i+1)+'" name="lokalita[]" value="'+data.pohori[i].id+'" /><label for="checkbox-1-'+(i+1)+'">'+data.pohori[i].pohori+'</label></li>';
				}
				row = row + '</ol>';
				$('#loc-content').html(row);
				$('input.check').checkBox();
				if($("#search-lokality-box").is('*')){	
					$("#search-lokality-box").show();
				}
				FormEvent();
			}
			else
			{
				
				$('#loc-content').html('<ol><li>Žádné lokality nenalezeny</li></ol>');
				if($("#search-lokality-box").is('*')){
					$("#search-lokality-box").hide();
				}
			}
		}, "json");
}

function SearchDisplayResultControler(result_count)
{
	if(result_count){
    
		if(result_count == 0)
		{
			$('#testovaci').text("0");
			$('#is-zero').show();
			$('#not-zero').hide();
		}
		else
		{
			$('#testovaci').text(result_count);
			$('#is-zero').hide();
			$('#not-zero').show();
		}

	}else{
		$('#testovaci').text("0");
		$('#is-zero').show();
		$('#not-zero').hide();
	}

	if($("#testovaci-top").is("*"))
	{
		if(result_count){

			if(result_count == 0)
			{
				$('#testovaci-top').text("0");
				$('#is-zero-top').show();
				$('#not-zero-top').hide();
			}
			else
			{
				$('#testovaci-top').text(result_count);
				$('#is-zero-top').hide();
				$('#not-zero-top').show();
			}

		}else{
			$('#testovaci-top').text("0");
			$('#is-zero-top').show();
			$('#not-zero-top').hide();
		}
	}

}
//kontrolni flagy -> zamezeni zacykleni
var f_cz_m = 0;
var f_hory = 0;
var f_hory_object = 0;
function FormEvent()
{
	//alert("FormEvent call.."+f_cz_m);
	if(f_cz_m == 0){
		//alert("Assign Pretty select..");
		$('#cz-m').bind('change', function()
		{
			$('#testovaci').text(' - ');
			//alert("Pretty select fired..");
			if($("#"+SET_MAP).is("*"))
			{
				var idx = $('#cz-m').val();
			//alert("Odchyceno :" + idx );
				if(idx != '')
					mapka.maphilight({
						idx: idx
					});
			}
			$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),
				function (data){
					//callback function
					SearchDisplayResultControler(data.object_count);

				}, "json");
		
			//nacteni seznamu
			$.get(GG_ROOT_DIR+"/ajax/aj_lokality.php", $("#srch").serialize(),
				function (data){
					//callback function checked="checked"
					if(data.pohori)
					{
						var row = '<ol>'
						for(i = 0;i<data.pocet_pohori; i++)
						{
							row = row + '<li><input type="checkbox" class="check"  id="checkbox-1-'+(i+1)+'" name="lokalita[]" value="'+data.pohori[i].id+'" /><label for="checkbox-1-'+(i+1)+'">'+data.pohori[i].pohori+'</label></li>';
						}
						row = row + '</ol>';
						$('#loc_content').html(row);
						$('input.check').checkBox();
						f_cz_m = 1;
						if($("#search-lokality-box").is('*')){	
							$("#search-lokality-box").show();
						}
						FormEvent();
					}
					else
					{
						if($("#search-lokality-box").is('*')){	
							$("#search-lokality-box").hide();
						}
						$('#loc_content').html('<ol><li>Žádné lokality nenalezeny</li></ol>');
											
					}
				}, "json");
		});
	}else{
		f_cz_m = 0;
	}
	$("input").bind('click', function() {
		$('#testovaci').text(' - ');
		//alert("Input fired..");
		$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),
			function (data){
				//callback function
				SearchDisplayResultControler(data.object_count);
			}, "json");
	});
	$("#aside-desc").bind('change', function() {
		$('#testovaci').text(' - ');
		//alert("Input fired..");
		$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),
			function (data){
				//callback function
				SearchDisplayResultControler(data.object_count);
			}, "json");
	});
	
	//form-objekty
	//pro hory

	if(f_hory == 0)
	{
		$("#fid-hory-objekt").bind('change', function() {
			//alert("#fid-hory-objekt fired..");
			GetLokality("#form-objekty");
		});
	}
	else{
		f_hory = 1;
	}

	if(f_hory_object == 0){
		$("#fid-hory").bind('change', function() {
			//alert("#fid-hory fired..");
			GetLokality("#form-objednavky");
		});
	}else{
		f_hory_object = 1;
	}
}

function GetCoutnObjectInMountains(data){
	for(var a=0; a < data.mount_count; a++ ){
		$("#li_hide_"+data.mountains[a].id).show();
		$("#li_show_"+data.mountains[a].id).hide();
		$("#result_hide_"+data.mountains[a].id).text(" (0)");
	}
	for(a=0; a < data.data_count; a++ ){
		if( data.object_data[a].id != null){
			$("#result_"+data.object_data[a].id).text(" ("+data.object_data[a].count+")");
			$("#li_hide_"+data.object_data[a].id).hide();
			$("#li_show_"+data.object_data[a].id).show();
		}
	}
}

function ShowDet(id){
	$("#lm_detail_"+id).show();
	$("#lm_nahled_"+id).hide();
}

function HideDet(id){
	$("#lm_detail_"+id).hide();
	$("#lm_nahled_"+id).show();
}

function ShowSection(section,id){
	$(section+id).show();
}
function HideSection(section,id){
	$(section+id).hide();
}

function CheckMountains(id){
	//alert("CheckMountains call..");
	$("input[name='cz_m']").val(id);
	GetLokality("#srch");
	
	$('#testovaci').text(' - ');
	$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),function (data){
		//callback function
		for(var a=0; a < data.mount_count; a++ ){
			if(id == data.mountains[a].id){
				$("#hory-"+id).css("font-weight","bolder");
			}else{
				$("#hory-"+data.mountains[a].id).css("font-weight","");
			}
		}
		
		if(data.object_count)
		{
			$('#testovaci').text(data.object_count);
		}
		else
		{
			$('#testovaci').text("0");
		}
	}, "json");
}

var hide_show = 0;
function OdkrytiDalsichParametru()
{
	$("#test-skryvani").bind('click', function(){
		//alert("#test_skryvani fired..");
		if(hide_show == 0)
		{
			$('#par-vice').hide();
			$('#par-mene').show();
			$("#hide-show-box").show();
			hide_show = 1;
		}
		else if(hide_show == 1)
		{
			$('#par-mene').hide();
			$('#par-vice').show();
			$("#hide-show-box").hide();
			hide_show = 0;
		}
		return(false);
	});
}

function FormSerialize()
{
	if($("#srch").is("*")){
		var result = $("#srch").serialize();
		if(result == 'cz_m=0&cena_od=0&cena_do=5000'){
			return("");	
		}else{
			return(result);	
		}
	}else{
		return("");
	}
}


$(document).ready(function(){
	//$('input.check').prettyCheckboxes();
	$('select.pretty-select').sSelect({
		ddMaxHeight: '200px'
	});
	var $test_tab = $('#tabs').tabs();
  
  
	$('#slider').minMaxSlider({
		'min_input'	: '#min_price',
		'max_input' : '#max_price',
		'min_size'  : SET_SLIDER_MIN,
		'max_size'  : SET_SLIDER_MAX
	});
	$(".more-photos").easySlider({
		//auto: true,
		//continuous: true
		prevText: 		'',
		nextText: 		''
	});

	$('input.check').checkBox();

	$('#slider').bind( "slidechange",
		function(event, ui)
		{
			//alert("#slider call..");
			$('#testovaci').text(' - ');
			$.get(GG_ROOT_DIR+"/ajax/aj_search.php", FormSerialize(),function (data){

				//callback function
				if(data.object_multiple){
					GetCoutnObjectInMountains(data);
				}
				SearchDisplayResultControler(data.object_count);
			}, "json");
		});
	//alert("serialize = "+$("#srch").serialize());
	FormEvent();
	OdkrytiDalsichParametru();
	//GetLokality("#form-objednavky");
	InitSlider();

	$('#rate-call').bind('click', function(){
		$('#tabs').tabs( "select" , 1 );
	});
	$('#tabs-i').tabs();
	
	$('#currency_id').bind('change', function(){
		$('#currency').submit();
	});

});
