var nuzkyOffset = -232;
var nuzkyAnimationTime = 500;
var menuAnimationTime = 200;

var IE;
//@cc_on IE = navigator.appVersion;

$(document).ready(function()
{       
    //some ugly computations to make offset ok
    nuzkyOffset = Math.round((GetWidth() - 799) / 2 - 9) * -1;
    if (IE)
    {
      nuzkyOffset -= 9;  
    }
    
    //discard all ".nuzky" from rendering and render only the ".active" one
    //(overrides :hover in css) 
    
    $(".nuzky").css("display","none");
    $(".active > .nuzky").css("display","block");
    $(".active > .nuzky").css("position","absolute");
    
    //place active .nuzky to its position, solves problem in IE.
    $("#hMenu > .active > .nuzky").css("left",""+($("#hMenu > .active").offset().left + nuzkyOffset) +"px" );
    
    //custom click, perform animation, then redirect
    $("#hMenu > li").click(function(){
        //Animate .nuzky, to the X position of the parent alement
       // alert($(this).offset().left);
        $(".active > .nuzky").animate({left: $(this).offset().left + nuzkyOffset },nuzkyAnimationTime);
        //prepare redirect link (read from the href attribute)
        var link = ($(this).children("a").attr("href"));
        //set timout for  redirect
        setTimeout("window.location.href='"+link+"'",nuzkyAnimationTime);
        //prevent default action of click on the link 
        return false;
      });
});

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}

/*
nikol rydvalova, polẹka 1, klatovy
*/
