$(document).ready(function() {
	//rozměry obrázku a nastavení
	var sirka = screen.width;
	var vyska = (sirka / 1910) * 395;
	var vyska2 = (sirka / 1910) * 0;
	$("#banner img").width(sirka);
	$("#banner img").height(vyska);

	$("#main .banner-stin").width(sirka);
	$("#main .banner-stin").height(vyska2);

	//poloha h1 nadpisu
	var vyska_h1 = $("#banner h1").height();
	var margin = ((vyska - vyska_h1) / 2) - 10;
	$("#banner h1").css("margin-top", margin);

	//podmenu
// 	$("#menu ul li ul").show();
	$("#menu ul li ul").hide();
	$("#menu ul li").hover(
	function() {
		$(this).children("ul").show();
	},
	function() {
		$(this).children("ul").hide();
	});

	//jazyky
	$("#head ul li ul").hide();
	$("#head ul li").hover(
		function() {
			$(this).children("ul").show();
		},
		function() {
			$(this).children("ul").hide();
		}
	);

	//pozice #main_inner
	var marginn = -vyska2 + 50;
	$("#main .banner-stin").css("margin-bottom", marginn);

	//home - skrytí odstavců
	$("#home div h2").siblings().hide();
	$("#home div h2").hover(
		function() {
			$(this).siblings().show();
			$(this).siblings().hover(
				function () {
					$(this).show();
				},
				function () {
					$(this).hide();
				}
			);
		},
		function() {
			$(this).siblings().hide();
		}
	);

	//seznamy
	$("p:contains(ul)").css("background-color", "none");

	//fancybox
	$("#obsah a:has(img)").not(".img_clear").fancybox({
		autoScale: false,
		titleShow: false
	});

	//poptávkový formulář
	$("#poptavka").validate({
		rules: {
			jmeno: "required",
			prijmeni: "required",
			mesto: "required",
			telefon: "required",
			email: {required:false, email: true}
		},
		messages: {
			jmeno: "",
			prijmeni: "",
			mesto: "",
			telefon: "",
			email: {required: "", email: ""}
		}
	});

	$(".datum").datepicker({ 
		dateFormat: 'd. m. yy',
		showOn: "button",
		buttonImage: "http://ckd.960pixel.cz/app/templates/ckd/js/themes/smoothness/images/calendar.gif",
		buttonImageOnly: true
	});

	//žluté tlačítko
	$("#main #home .yellow #cms-articles p").hide();

	$("#main #home .yellow #cms-articles h3").hover(
		function () {
			$(this).prev().show();
			$(this).prev().hover(
				function () {
					$(this).show();
				},
				function () {
					$(this).hide();
				}
			);
		},
		function () {
			$(this).prev().hide();
		}
	);
});	

$(window).load(function () {
	//pozice footer
	var windowh = $(window).height();
	var documenth = $(document).height();
	var screenh = documenth - 50;

//  alert(windowh+"-"+documenth);
	if (documenth >= windowh) {
		$("#footer").css("position", "absolute");
		$("#footer").css("top", screenh);
	}
});

function poptavka() {
	$.post("/app/templates/ckd/poptavka.php", $("#poptavka").formSerialize(), function(data) {
		alert(data);
	});
}
