$(document).ready(function(){	
	bind_hover ();
	bind_search ();
	bind_add_html ();
	bind_treeview ();
	bind_effects ();
	bind_cycle ();
});

/**
 * hover efekt na menu
 **/
function bind_hover ()
{
	$(".menu li, .path li, .submenu li, .listmethodcell, .subitems dl").hover(
		function() {
			$(this).addClass("sfhover");
		},
		function() {
			$(this).removeClass("sfhover");
		}
	);
}

/**
 * smazani textu v search input
 **/
function bind_search ()
{
	// vynulovani pole pri focusu
	$(".search-input").focus(function() {
		$(this).val('');
	});
}

/**
 * pridani kodu
 **/
function bind_add_html ()
{
	$('.path').each(function(){
		if ($('.path', this).length == 0)
			$("ul li a, ul li span", this).before('<strong>&raquo; </strong>');
	});
	
	$('.panels dl').each(function(){
		if ($('.panels dl', this).length == 0)
			$("dt", this).prepend('<strong>&raquo; </strong>');
	});
}

/* submenu treeview */
function bind_treeview ()
{
	$(".submenu ul li").each(function(){
		if($(this).hasClass("active")) {
			$(this).addClass("open");
		}
	});

	$(".submenu ul").treeview({
		collapsed: "true",
		animated: "fast"
	});
}

/*
 * animovani panelu na home
 **/
function bind_effects ()
{
	
	$('#panels dl').hoverIntent(
		function(){
			$('#panels dl').removeClass('sfhover');
			$(this).addClass('sfhover');
			$('#panels dl').each(function(){
				if (!$(this).hasClass('sfhover')) {
					$(this).animate({opacity:0.7},300);
				}
			});
		},function(){
			$('#panels dl').removeClass('sfhover').animate({opacity:1},100);
		}
	);
}

/**
 * cycle
 **/
function bind_cycle ()
{
	$('.news dl dd').cycle({ 
	    fx:      'scrollDown', 
    	speed:    1000, 
    	timeout:  7000 
	});
}

