$(document).ready(function () {

    $('.ref_bg').hover(function() {
        $(this).children(".toAnimate").stop().animate({opacity: 1,height: "130px"}, 400);
    }, function() {
        $(this).children(".toAnimate").stop().animate({opacity: 0,height: "0px"}, 600);
    });


    $('#pane1').jScrollPane({scrollbarWidth: 11});
    $('#pane2').jScrollPane({scrollbarWidth: 11});

    $('.lang img#en').css('opacity',0.7);
    $('.lang img#en').hover(function() {
        $(this).animate({opacity: 1}, 400);
    }, function() {
        $(this).animate({opacity: 0.7}, 600);
    });
    $('.lang img#cz').css('opacity',0.7);
    $('.lang img#cz').hover(function() {
        $(this).animate({opacity: 1}, 400);
    }, function() {
        $(this).animate({opacity: 0.7}, 600);
    });

    $('.lang img#cz2').css('opacity',0.7);
    $('.lang img#en2').css('opacity',0.7);


	/*
     * Menu animation
     */

    //transitions
    //for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
    var style = 'easeOutQuint'; // easeOutElastic

    //Retrieve the selected item position and width
    var default_left = Math.round($('#lava li.selected').offset().left - $('#lava').offset().left);
    var default_width = $('#lava li.selected').width();

    //Set the floating bar position and width
    $('#box').css({left: default_left});
    $('#box .head').css({width: default_width});

    //if mouseover the menu item
    $('#lava li').hover(function () {
        //Get the position and width of the menu item
        left = Math.round($(this).offset().left - $('#lava').offset().left);
        width = $(this).width();
    $('#debug').html(left);
        //Set the floating bar position, width and transition
        $('#box').stop(false, true).animate({left: left},{duration:500, easing: style});
        $('#box .head').stop(false, true).animate({width:width},{duration:500, easing: style});

    //if user click on the menu
    }).click(function () {

        //reset the selected item
        $('#lava li').removeClass('selected');

        //select the current item
        $(this).addClass('selected');

    });

    //If the mouse leave the menu, reset the floating bar to the selected item
    $('#lava').mouseleave(function () {

        //Retrieve the selected item position and width
        default_left = Math.round($('#lava li.selected').offset().left - $('#lava').offset().left);
        default_width = $('#lava li.selected').width();

        //Set the floating bar position, width and transition
        $('#box').stop(false, true).animate({left: default_left},{duration:500, easing: style});
        $('#box .head').stop(false, true).animate({width:default_width},{duration:500, easing: style});

    });

});

function showNews(id) {
    $("#"+id).animate({height: 'toggle'});
}

function OpenWin(url) {
	window.open(url,"_blank","directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no,height=480,width=640,top=0,left=0",true);
}

function Size() {
    Img=document.getElementById('imgfr');
    ImgWidth=Img.width;
    ImgHeight=Img.height;
    HeadHeight=document.getElementById('headfr').offsetHeight;
    FooterHeight=document.getElementById('footerfr').offsetHeight;
    WinWidth = document.documentElement.clientWidth;
    WinHeight = document.documentElement.clientHeight;
    fWidth = ImgWidth-WinWidth;
    fHeight = (ImgHeight-WinHeight)+HeadHeight+FooterHeight;
    window.resizeBy(fWidth+30,fHeight+10);
    self.focus();
}
