$(function () {

    $('#img').click(function () {
        $(this).direction("right");
    });
    $('#arror_right').click(function () {
        $(this).direction("right");
    });
    $('#arror_left').click(function () {
        $(this).direction("left");
    });


});

jQuery.fn.direction = function (param) {
    var url = $('#img').attr('src');
    counter = url.substr(-5, 1);
    console.log(counter);
    if (counter < 7 && param === "right") {
        counter++;
    }
    if (counter > 1 && param === "left") {
        counter--;
    }
    $('#img').attr("src", "img/4/" + counter + ".jpg");
};

