$(document).ready(function(){
    
    $(document).pngFix();
    
    // nasazeni colorBoxu
    $("a[rel='colorbox']").colorbox();
    
    $(".sipka-left").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");})
    $(".sipka-right").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");})
    
    var pocetFotek = $("div.fotky-box-scr > div.foto").size();
    var velikostFotky = 220;
    var posuvnikWidth = 880;
    var posunuto = true;
    
    if (pocetFotek > 4) {
        $("div.fotky-box-scr").css({width: (velikostFotky*pocetFotek)+"px"});
        posuvnikWidth = parseInt($("div.fotky-box-scr").css("width"));
    }
    
    $(".sipka-left").click(function(){
        if (posunuto == true) {
            posunuto = false;
            var _posun = false;
            var _left = parseInt($(".fotky-box-scr").css("left"));
            
            if (_left <= -(velikostFotky*2)) {
                _posun = '+='+(velikostFotky*2);
                _cas = 500;
            }
            else if (_left <= -velikostFotky) {
                _posun = '+='+velikostFotky;
                _cas = 250;
            }
            
            if (_posun != false) {
                $(".fotky-box-scr").animate({left: _posun}, _cas, function(){posunuto = true;});
            }
            else {
                posunuto = true;
            }
        }
    });
    $(".sipka-right").click(function(){
        if (posunuto == true) {
            posunuto = false;
            var _posun = false;
            var _left = parseInt($(".fotky-box-scr").css("left"));
            
            if ( (posuvnikWidth - 880 + _left) >= (velikostFotky*2)  ) {
                _posun = '-='+(velikostFotky*2);
                _cas = 500;
            }
            else if ( (posuvnikWidth - 880 + _left) >= (velikostFotky) ) {
                _posun = '-='+velikostFotky;
                _cas = 250;
            }
            
            if (_posun != false) {
                $(".fotky-box-scr").animate({left: _posun}, _cas, function(){posunuto = true;});
            }
            else {
                posunuto = true;
            }
        }
    });
    
});

