var speed = 1000;

$(document).ready(
    function(){
        //mouseScrollEvent(".gallery");

        img1 = new GImage("#elem0");
        img2 = new GImage("#elem1");
        img3 = new GImage("#elem2");
        img4 = new GImage("#elem3");

        img1.moveRight();
        img2.moveRight();
        img2.moveRight();
        img3.moveRight();
        img3.moveRight();
        img3.moveRight();
        img4.moveRight();
        img4.moveRight();
        img4.moveRight();
        img4.moveRight();

        addEvents();
    }
);

function mouseScrollEvent(selector) {
    $(selector)
        .bind('mousewheel', function(event, delta) {
            if (delta > 0){
                $("#go-left-button").trigger('click');
            }else{
                $("#go-right-button").trigger('click');
            }

            speedV = 1000 - (200 * Math.abs(delta));

//            if (speedV < speed) {
//                speed = speedV;
//            }

            var aas = $("#infotext").html();
            
//            if (aas == '') {
//                 $("#infotext").text("10000");
//            }
//
//            if (aas > speed) {
//                $("#infotext").text(speed);
//            }

    
            return false;
        });
}

function addEvents() {
//    $("#elem1").toggle(
//        function() {
//            //img1.blur();
//            img1.moveRight();
//        },
//        function() {
//            //img1.focus();
//            //img1.goLeft();
//        }
//    );
    $("#left-area").click(
        function(){
            $("#go-right-button").trigger("click");
        }
    );

    $("#right-area").click(
        function(){
            $("#go-left-button").trigger("click");
        }
    );

    $("#go-left-button").click(
        function() {
            img1.moveLeft();
            img2.moveLeft();
            img3.moveLeft();
            img4.moveLeft();
        }
    );
    $("#go-right-button").click(
        function() {
            img1.moveRight();
            img2.moveRight();
            img3.moveRight();
            img4.moveRight();
        }
    );
}

//function goRight() {
//    $("#elem1 img.blur").fadeIn(1000);
//    $("#elem1").animate({
//        right: '0',
//        top: '100'
//    }, {
//        duration: 1000,
//        specialEasing: {
//          width: 'linear',
//          height: 'easeOutBounce'
//        }
//      });
//
//}
//
//
//
//function focus() {
//    $("#elem1 img.blur").fadeOut("slow");
//}

