jQuery('document').ready(function(){
    goAlbum();
    functionReady();
});

function goLeft(){
        $('.goLeft').click(function(){
        var ileR = ile - 7;
        $.ajax({
            type: "POST",
            url: base_url+'site/getAlbum/'+ktora+'/'+ileR,
            success: function(msg){
                $('.wybor').empty();
                $('.wybor').append(msg);
                goLeft();
                goRight();
            }
        });
    });
}

function goRight(){
        $('.goRight').click(function(){
        var ileR = ile + 7;
        $.ajax({
            type: "POST",
            url: base_url+'site/getAlbum/'+ktora+'/'+ileR,
            success: function(msg){
                $('.wybor').empty();
                $('.wybor').append(msg);
                goLeft();
                goRight();
            }
        });
    });
}

function goAlbum(){
    $('.portfolio').click(function(ev){
        ev.preventDefault();
       $.ajax({
            type: "POST",
            url: base_url+'site/portfolioMini',
            success: function(msg){
                $('.wybor').empty();
                $('.wybor').append(msg);
                goRight();
                goLeft();
                goAlbum();
                functionReady(); 
            }
        });
    });
}


function functionReady(){
        $("ul.thumb li").hover(function() {
            $(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/
            $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
                    .animate({
                            left: '-10px',
                            top: '-5px',
                            width: '170px', /* Set new width */
                            height: '460px', /* Set new height */
                            padding: '10px'
                    }, 400); /* this value of "200" is the speed of how fast/slow this hover animates */

            } , function() {
            $(this).css({'z-index' : '1'}); /* Set z-index back to 0 */
            $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
                    .animate({
                            marginTop: '0', /* Set alignment back to default */
                            marginLeft: '0',
                            top: '0',
                            left: '0',
                            width: '160px', /* Set width back to default */
                            height: '450px', /* Set height back to default */
                            padding: '5px'
                    }, 400);
    });


    $('.album_img').click(function(){
        var ktora = $(this).attr('name');
        $.ajax({
            type: "POST",
            url: base_url+'site/getAlbum/'+ktora+'/'+ile,
            success: function(msg){
                $('.wybor').empty();
                $('.wybor').append(msg);
                goRight();
                goLeft();
            }
        });
    });

}
