/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function bezdiak(txt){
    var sdiak = "áäčďéěíĺľňóô öŕšťúů üýřžÁÄČĎÉĚÍĹĽŇÓÔ ÖŔŠŤÚŮ ÜÝŘŽ";
    var bdiak = "aacdeeillnoo orstuu uyrzAACDEEILLNOO ORSTUU UYRZ";
    var tx = "";
    for(var p = 0; p < txt.length; p++){
        if (sdiak.indexOf(txt.charAt(p)) != -1){
            tx += bdiak.charAt(sdiak.indexOf(txt.charAt(p)));
        }else tx += txt.charAt(p);
    }
    return  tx;
}
$(document).ready(function() {
    function flash_message(message,time,offset){
        $('body').prepend('<div id="flash_holder"><div id="flash'+offset+'">'+message+'</div></div>');
        $('#flash_holder').delay(offset).fadeIn(500,function(){
            $('#flash'+offset).delay(time*1000).animate({ },1000);
            $(this).delay(time*1000).animate({
                opacity:'0'
            },1000,function(){
                $(this).remove();
            });
        });
    }
    $("a[rel^='prettyPhoto']").prettyPhoto({
        theme:'facebook'
    });
    setInterval(blikej, 5000);
    function blikej(){
        $('#blikej:not(:hover)').animate({
            backgroundColor: '#ffbb44'
        },1000,function(){
            $(this).animate({
                backgroundColor: '#dddddd'
            },2500);
        });
    $('.show_next').click(function(){
        $('#show_next_div').hide();
        $('#hidden_next').slideDown(1000);
    });
        
    }
    $('#blikej').hover(
        function(){
            $(this).animate({
                backgroundColor: '#ffbb44'
            },1000);
        },function(){
            $(this).animate({
                backgroundColor: '#dddddd'
            },1000);
        });

    var t="pick_aerobic";
    var spd=200;
    var w=0;
    $('#nekompatibilni').hide();

    $(".tab_pick,.tab_pick_s").mousedown(function(){
        i = $(this).attr("id");
        $("#tab_" + t).fadeOut(spd,function(){
            $("#tab_" + i).fadeIn(spd);
        });
        $("#"+t).removeClass('selected');
        $("#"+i).addClass('selected');
        t = i;
    });

    $('.skupina_treneru:not(#treneri_{!$zamereni})').addClass('invis').hide();
    $('.skupina_treneru.m_ne').removeClass('invis').show();
    
    $('.trener_button').mousedown(function(){
        $('.trener_button:not(this)').removeClass('active');
        $(this).addClass('active');
        var skupina = bezdiak($(this).html());
        $('.skupina_treneru:visible').slideUp(500);
        $('#treneri_'+skupina).slideDown(500);
    });

    $('.small_medal').mousedown(function(){
        $('.small_medal:not(this)').removeClass('active');
        $(this).addClass('active');
    });


    setInterval(banner, 15000);

    var pocet = Math.floor( Math.random()*16 + 1);
    banner();

    function banner(){
        $('#slide').fadeIn(4000,function(){
            $(this).delay(7000).fadeOut(4000,function(){
                $('#slide img').attr('src','http://www.scymca.cz/imgs/slide/'+pocet+'.jpg');
            });
        });
        pocet++;

        if(pocet == 18){
            pocet = 1;
        }
    }
});

