// JavaScript Document

$(document).ready(function(){
	$('#head').cycle({
		fx: 'fade',
		speed:    800, 
	    timeout:  4000 
	});
/////////////////////////////////////////////////////////////////////////////////////////////////
////// submenu pro JH
/////////////////////////////////////////////////////////////////////////////////////////////////
	$("#slu").mouseover(function(event){
		$("#slu a:first").css({
			'color' : '#ecf1f3'
		});
	});

	$("#reg").mouseover(function(event){
		$("#reg a:first").css({
			'color' : '#ecf1f3'
		});
	});

	$("#dis").mouseover(function(event){
		$("#dis a:first").css({
			'color' : '#ecf1f3'
		});
	});

	$("#slu").mouseout(function(event){
		$("#slu a:first").css({
			'color' : '#55d9c9'
		});
	});

	$("#reg").mouseout(function(event){
		$("#reg a:first").css({
			'color' : '#55d9c9'
		});
	});

	$("#dis").mouseout(function(event){
		$("#dis a:first").css({
			'color' : '#55d9c9'
		});
	});

	$("#slu a:first, #reg a:first, #dis a:first").click(function(event){
		event.preventDefault();
	});
	
	var regVisible = false;
	var ureVisible = false;
	var sluVisible = false;

	$("#reg a:first").click(function(){
		if (regVisible){
			$("#jh_reg").slideUp(500);
			regVisible = false;
		} else {
			$("#jh_reg").slideDown(500);
			$("#jh_reg").bgiframe();
			regVisible = true;
		}
		$("#jh_ure").slideUp();
		$("#jh_slu").slideUp();
		ureVisible = false;
		sluVisible = false;
	});

	$("#dis a:first").click(function(){
		if (ureVisible){
			$("#jh_ure").slideUp(500);
			ureVisible = false;
		} else {
			$("#jh_ure").slideDown(500);
			$("#jh_ure").bgiframe();
			ureVisible = true;
		}
		$("#jh_reg").slideUp();
		$("#jh_slu").slideUp();
		regVisible = false;
		sluVisible = false;
	});

	$("#slu a:first").click(function(){
		if (sluVisible){
			$("#jh_slu").slideUp(500);
			sluVisible = false;
		} else {
			$("#jh_slu").slideDown(500);
			$("#jh_slu").bgiframe();
			sluVisible = true;
		}
		$("#jh_reg").slideUp();
		$("#jh_ure").slideUp();
		regVisible = false;
		ureVisible = false;
	});

/////////////////////////////////////////////////////////////////////////////////////////////////
////// horní menu obcí
/////////////////////////////////////////////////////////////////////////////////////////////////

	// nastavení kurzoru
	$("#topObce li").css({
		'cursor' : 'pointer'
	});

	// zruąení normální funkce odkazu
	$("#topObce li .noClick").click(function(event){
		event.preventDefault();
	});
	
	// hover efekt
	$("#topObce li").mouseover(function(){
		var thisId = this.id;
		var odkaz  = "#" + thisId + " a";
		
		$(odkaz).css({
			'color' : '#ecf1f3'
		});
		$("#subSel").css({
			'color' : '#55d9c9'
		});
	});

	// zruąení hover efektu
	$("#topObce li").mouseout(function(){
		var thisId = this.id;
		var odkaz  = "#" + thisId + " a";
		
		if ( $(this).hasClass("hov") )
			$(odkaz).css({
				'color' : '#003235'
			});
	});

	// efekt po kliku
	$("#topObce li").click(function(){
		// inicializace promenných
		var obecID   = this.id;
		var obecSub  = "." + obecID + "Sub";
		var obec     = "#" + obecID;
		var obecA    = obec + " a";

		// zrušení predchozích nastavení
		$("#topObce li a").css({
			'color' : '#003235'
		});
		$(obecA).css({
			'color' : '#ecf1f3'
		});
		

		if($("#txt").css("margin-top") == "33px") {
			$("#txt").animate({
				marginTop: "0px"
			}, 500);
			$("#topObce li div").slideUp(500);
		}
		
		$(".noBorTop").css({
			'border-top' : '#1c6a66 solid 2px'
		});

		// nastavení potrebných tríd všem prvkum
		$("#topObce li").addClass("hov");
		$("#topObce li").removeClass("sel");

		// nastavení potrebných tríd oznacenému prvku
		$(this).removeClass("hov");
		$(this).addClass("sel");

		if($("#txt").css("margin-top") == "33px") {
			$(obecSub).slideDown(2000);
		}
		$(obecSub).slideDown(1000);

		$("#txt").animate({
			marginTop: "33px"
		}, 1000);
	});

/*	$("#topObce div").click(function(){
			
		$(".roll").slideUp(1);
		$("#bat,#chv,#hav,#jiv,#lib,#mal,#mar,#rad,#rty,#suc,#upi,#vel").css({
			'color' : '#003235',
			'border-bottom' : '#1c6a66 solid 2px',
			'background-position' : 'center 0px',
			'background-color' : '#39a198'
		});
		$("#bat,#chv,#hav,#jiv,#lib,#mal,#mar,#rad,#rty,#suc,#upi,#vel").removeClass('sel');

		var obecID   = this.id;
		var obecSub  = "." + obecID + "Sub";
		var obec     = "#" + obecID;
//		alert (obec);

		$(obecSub).slideDown(1000);

		$(obec).css({
			'color' : '#ecf1f3',
			'border-bottom' : '#003235 solid 2px',
			'background-position' : 'center -81px',
			'background-color' : '#003235'
		});
//		$("#bat,#chv,#hav,#jiv,#lib,#mal,#mar,#rad,#rty,#suc,#upi,#vel").addClass('sel');
//		$(obec).removeClass('sel');

		$("#txt").animate({
			marginTop: "33px"
		}, 1000);
	});
	
/*	$(".batSub,.chvSub,.havSub,.jivSub,.libSub,.malSub,.marSub,.radSub,.rtySub,.sucSub,.upiSub,.velSub").click(function(){
		$(this).slideUp(1000);
	});
*/

/*	$("#topObce div").mouseout(function(){
		var obecID   = this.id;
		var obec     = "#" + obecID;

			$(obec).css({
				'color' : '#003235',
				'border-bottom' : '#1c6a66 solid 2px',
				'background-position' : 'center 0px',
				'background-color' : '#39a198'
			});
	});
*/

});