function mezeruj(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	return x1 + x2;
}

$(document).ready(function() {

	// hover
		$("#topmenu li,#menu li a,#static-submenu a,#lang a span").hover(
				function() {
					$(this).addClass("hover");
				}, function() {
					$(this).removeClass("hover");
				});

		// hover gif image -hover.gif
		$.each($(".hover-image"), function(i, val) {

			$(this).children("img").hover(function() {
				src = $(this).attr("src");
				novesrc = src.replace(".gif", "-hover.gif");
				$(this).attr("src", novesrc)
			}, function() {
				src = $(this).attr("src");
				novesrc = src.replace("-hover.gif", ".gif");
				$(this).attr("src", novesrc)
			});

		});

		// menu
		$("#menu li.submenu > ul").hide();
		$("#menu li.submenu > ul.active-menu").show();

		$("#menu li.submenu > a").click(function() {
			$(this).parent().children("ul").toggle();
			$(this).toggleClass("active");
			return false;
		});

		$("td.praha div").addClass("button-polozka");
		$("td.form-button div").addClass("button-polozka2");

		$.each($(".praha > div"), function(i, val) {
			$(this).click(function() {
				$(this).toggleClass("active");
				if ($(this).hasClass("active")) {
					$("input.input-polozka").eq(i).val("true");
				} else {
					$("input.input-polozka").eq(i).val("false");
				}				
				return false;
			});
		});

		$.each($(".form-button > div"), function(i, val) {
			$(this).click(function() {
				$(this).toggleClass("active");
				if ($(this).hasClass("active")) {
					$("input.input-polozka2").eq(i).val("true");
				} else {
					$("input.input-polozka2").eq(i).val("false");
				}				
				return false;

			});
		});

		/*
		$("a.ukaz-kosik").click(
				function(e) {
					var p = $(this);
					var position = p.position();

					$(this).parent().parent().next().show();

					//alert($(this).attr("id"));
					if ($(this).attr("id") == "historie-box") {
						$(this).parent().parent().next().css("left",
								position.left - 87);
						$(this).parent().parent().next().css("top",
								position.top + 92);

					} else {
						$(this).parent().parent().next().css("left",
								position.left - 87);
						$(this).parent().parent().next().css("top",
								position.top + 34);

					}

					return false;
				});
				

		$(".kosik-odkazy .zavrit-kosik").click(function() {
			$(this).parent().parent().parent().parent().hide();
			return false;
		});
		
		$(".kosik-odkazy .iframe").click(function() {
			$(this).parent().parent().parent().parent().hide();
		});
*/
		$("a[rel='external']").attr('target', '_blank');		
	});

