﻿// vyska paticky
var minimalniPaticka = 50;
var odecetPaddingu = 16;

jQuery(document).ready(function() {
if ((jQuery('.hlavniTable').height() + minimalniPaticka) < jQuery(window).height()) {
        jQuery('.paticka').height(jQuery(window).height() - jQuery('.hlavniTable').height()-odecetPaddingu);
    }
    else
        jQuery('.paticka').height(minimalniPaticka);
});

jQuery(window).resize(function() {
if ((jQuery('.hlavniTable').height() + minimalniPaticka) < jQuery(window).height())
    jQuery('.paticka').height(jQuery(window).height() - jQuery('.hlavniTable').height() - odecetPaddingu);
    else
        jQuery('.paticka').height(40);
});


// animace obrazku v hlavicce
jQuery(document).ready(function() {

    var rychlostVymeny = 5000;
    var stopTimer = 0;
    var lastPozice = -1;

    window.setTimeout(function() { starttimer(); }, rychlostVymeny);

    function starttimer() {

        if (stopTimer == 1)
            return;

        var pocet = jQuery('.vnitrniObr').length;
        var pocetSkrytych = jQuery('.NvnitrniObr').length / pocet;

        var pozice = Math.floor(Math.random() * pocet);

        while (pozice == lastPozice)
            pozice = Math.floor(Math.random() * pocet);

        lastPozice = pozice;

        var pozice2 = (pozice * pocetSkrytych) + Math.floor(Math.random() * pocetSkrytych);

        //        jQuery('.vnitrniObr').eq(pozice).fadeOut(1000);
        //        jQuery('.vnitrniObr').eq(pozice).fadeIn(1000);
        //alert(pocet + ", " + pocetSkrytych + ", " + pozice + ", " + pozice2);

        jQuery('.vnitrniObr').eq(pozice).animate({ height: '400px', width: '0px', left: '96px', opacity: '0.1' }, 1000,
        function() { jQuery(this).attr('class', 'N2vnitrniObr'); });

        jQuery('.NvnitrniObr').eq(pozice2).delay(1000).attr('class', 'vnitrniObr').css({width: '0px',height: '400px',left: '96px',opacity:'0.1'}).animate({ height: '400px', width: '192px', left: '0px', opacity: '1' }, 1000,
        function() { jQuery('.N2vnitrniObr').attr('class', 'NvnitrniObr'); });


        window.setTimeout(function() { starttimer(); }, rychlostVymeny);
    }

});

jQuery(document).ready(function() {
    // menu polozky
    jQuery('.menuPol').hover(function() {
    var index = jQuery(this).index();
        jQuery('.menu2').stop().animate({ top: '63px' }, 500);
        jQuery('.menu1').find('a').css('color', '#aaa');
        
        if (jQuery(this).find('.menu2').css('top') == '0px') {
            jQuery('.menu1').eq(index).find('a').css('color', 'white');
        }
        jQuery(this).find('.menu2').stop().animate({ top: '0px' }, 300, function() {
            jQuery('.menu1').eq(index).find('a').css('color', 'white');
        });
    }, function() {
        jQuery(this).find('.menu2').stop().animate({ top: '63px' }, 500);
        jQuery(this).find('.menu1').find('a').css('color', '#aaa');
    });

    jQuery('.hlavickaObr').hover(function() {
    var index = jQuery(this).index();
        jQuery('.menu2').stop().animate({ top: '63px' }, 500);
        jQuery('.menu1').find('a').css('color', '#aaa');

        if (jQuery('.menu2').eq(index).css('top') == '0px') {
            jQuery('.menu1').eq(index).find('a').css('color', 'white');
        }        
        jQuery('.menu2').eq(index).stop().animate({ top: '0px' }, 300, function() {
            jQuery('.menu1').eq(index).find('a').css('color', 'white');
        });
    }, function() {
        jQuery('.menu2').eq(jQuery(this).index()).stop().animate({ top: '63px' }, 500);
        jQuery('.menu1').eq(jQuery(this).index()).find('a').css('color', '#aaa');
    });

    jQuery('.menuPol').click(function() {
        window.location = jQuery(this).find('a').attr('href');
    });

    jQuery('.hlavickaObr').click(function() {
        window.location = jQuery('.menu2').eq(jQuery(this).index()).find('a').attr('href');
    });
});


