// prefix: pb
// funkcni pouze pro jeden picturebox na strance
//eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('8 7;8 2;8 i=j;$(f).e(c(){$(\'.4-3 a:6(0)\').b(\'5\');7=$(".4-3 a").d();2=0;g("9()",l)});c 9(){$(\'.4-3 a:6(\'+(2)+\')\').k(\'5\');2=2+1;h(2==7)2=0;$(\'.4-3 a:6(\'+2+\')\').b(\'5\')}',22,22,'||pb_current|box|picture|slow|eq|pb_count|var|pb_nextPicture||fadeIn|function|size|ready|document|setInterval|if|pb_active|true|fadeOut|4000'.split('|'),0,{}))

var pb_count;
var pb_current;
var timer = null;
var pb_active = true;

$(document).ready(function() {
    galleryInit();
});

function galleryInit() {
    CB_Init();
    if (timer != null) clearInterval(timer);
    $('.picture-box .pb-cc a:eq(0)').fadeIn('slow');
    pb_count = $(".picture-box .pb-cc a").size();
    pb_current = 0;
    $("#picture-box-container").hover(
        function() {
            pb_active = false;
            $("#pb-bullets").fadeIn('fast');
        },
        function() {
            pb_active = true;
            $("#pb-bullets").fadeOut('slow');
        }
    );
    $("#pb-bullets a").hover(function() {
        pb_showFast($(this).attr('id').split('_')[1]);
        },
        function() {
            // nope
        }
    );
    if (pb_count != 1) timer = setInterval("pb_nextPicture()", 5000);
}

function pb_showFast(index) {
    //alert(index);
    pb_current = index;
    //console.log('pb_current == '+pb_current);
    $('.picture-box .pb-cc a').hide();
    $('.picture-box .pb-cc a:eq('+index+')').show();
}


function pb_nextPicture() {
    if (pb_active) {
        $('.picture-box .pb-cc a:eq('+(pb_current)+')').fadeOut('slow');
        pb_current = Number(pb_current) + 1;
        if (pb_current == pb_count) pb_current = 0;
        $('.picture-box .pb-cc a:eq('+pb_current+')').fadeIn('slow');
        //console.log('.picture-box .pb-cc a:eq('+pb_current+')');
    }
}
