$(document).ready(function(){

 

    //$(document).pngFix();
    //$("div#holder").pngFix();
    //$("#footer").pngFix();




    $("#application-error").hide();
  
    $("#show-error").click(function (){
        $("#application-error").toggle("slow");
								   
    });
  

 $("ul li:last").addClass("last")


    $("#woodcorner #wcinsider").animate({
        "right":0
    }, 1500, "easeOutBounce");
    // return false;


    $("ul#mainmenu li").hover(

        function(){
            if(!$(this).find("a").hasClass("active")){
                $(this).find("a").stop().animate({
                    "paddingBottom":"20px",
                    "marginTop":"5px"
                }, 800,"easeOutElastic")
                }
        },function(){
            if(!$(this).find("a").hasClass("active")){
                $(this).find("a").stop().animate({
                    "paddingBottom":"5px",
                    "marginTop":"20px"
                }, 800, "easeOutBounce")
                }
        });


         $("ul#submenu li").hover(

        function(){
            if(!$(this).find("a").hasClass("active")){
                $(this).find("a").stop().animate({
                    "paddingBottom":"8px",
                    "paddingTop":"8px"
                }, 400,"easeOutExpo")
                }
        },function(){
            if(!$(this).find("a").hasClass("active")){
                $(this).find("a").stop().animate({
                    "paddingBottom":"3px",
                    "paddingTop":"3px"
                }, 400, "easeOutBounce")
                }
        });


  if($(".smsluzby").length>0){
                $('a[href="/sluzby/"]').addClass("active")

                }
	
    var url = document.URL
    $('a').each(function(){
	
        if (url == this.href) {
		
            $(this).addClass("active")
        }
   
    });

    $('a[href^="http://"]')
    .attr({
        target: "_blank"
    })
 
    //jQuery(document.body).favicons({insert: 'prependTo'})

setTimeout (function(){
          jQuery("#toptext img").eq(0).animate({
        "top": "50"
    },1000,"easeOutBounce",function(){
        var maximum = 2;
        var i = 0;
        setInterval(function(){
            if(i!=maximum-1) {


                jQuery("#toptext img").eq(i).animate({
                    "top": "-160"
                }, 300, function(){
                    i++;
                   jQuery("#toptext img").eq(i).animate({
                    "top": "50"
                }, 1000, "easeOutBounce");
                    
                });
            } else {
                 jQuery("#toptext img").eq(i).animate({
                    "top": "-160"
                }, 300, function(){
                    
                   jQuery("#toptext img").eq(0).animate({
                    "top": "50"
                }, 1000, "easeOutBounce");

                });
                i=0;
                
            }



        }, 10000);

    })
        }, 2000)
   

// rotace textu

  if($("#homeslidebox").length > 0) {
        //$("#homeslidebox h2:first").addClass("active")

        activateBox = function(elm){
            $("#homeslidebox .articlebox").removeClass("active");
            $(elm).addClass("active")
            $("#homeslidebox .articlebox").not(".active").fadeOut("slow");
            $(elm).fadeIn("slow");
        }
        //activateBox($("#homeslidebox .articlebox:first"))

        $("#homeslidebox .sbtn").not(".active").mouseover(
            function(){
                runOver($(this));
            })


        $("#homeslidebox").hover(function(){
            clearInterval(SliderInterval)
        }, function(){
            runSlideInterval()
        })

        runSlideInterval = function(){

            SliderInterval = setInterval(runNext, 5000);

        }


        runOver = function(elm) {
            $("#homeslidebox .sbtn").removeClass("active");
            $(elm).addClass("active");
            //alert($(this).prevAll("h2").length);
            activateBox($("#homeslidebox .articlebox:eq("+$(elm).prevAll(".sbtn").length+")"))
        }

        runNext = function(){

            if($("#homeslidebox .sbtn.active").prevAll(".sbtn").length+1 < $("#homeslidebox .sbtn").length) {
                runOver($("#homeslidebox .sbtn:eq("+($("#homeslidebox .sbtn.active").prevAll(".sbtn").length+1)+")"));
            }else{
               runOver($("#homeslidebox .sbtn:first"));
            }
            //runOver($("#homeslidebox h2:eq("+(i+1)+")"));
        }


runOver($("#homeslidebox .sbtn:first"));
runSlideInterval();


    }


  
});
Shadowbox.init();

