function setup(params) {
    function shopEffect() {
        var scrollable = $('ScrollWrapper');
        var left = $('GoLeft');
        var right = $('GoRight');
        var images = $$('.PhotoList li');

        var effect;

        function move(options) {
            options.duration = Math.abs(options.x) / 80.0;
            effect = new Effect.Move(scrollable, options);
        }

        function scrollableWidth() {
            var width = 0;
            for (var i = 0; i < images.length; i++) {
                width += images[i].getWidth();
            }
            return width;
        }

        function moveLeft() {
            var offset = right.positionedOffset()[0] - (scrollableWidth() + scrollable.positionedOffset()[0]);
            move({x: offset});
        }

        function moveRight() {
            var offset = left.getWidth() - scrollable.positionedOffset()[0];
            move({x: offset});
        }

        function cancel() {
            if (effect) {
                effect.cancel();
                effect = null;
            }
        }

        function setup() {
            if (left && images.length >= 4) {
                left.observe('mouseover', moveRight);
                left.observe('mouseout', cancel);
                right.observe('mouseover', moveLeft);
                right.observe('mouseout', cancel);
            }
            
        }

        return {
            setup: setup
        };
    }

    function map() {
        function setup() {
            if (params.hasCoordinate) {
                googleMap({smallControl: true});
            }
        }

        return {
            setup: setup
        };
    }

    function image() {
        function swapImage( image_id ) {
            var oldLi = $$('li.NowView')[0];
            if (oldLi) {
                oldLi.removeClassName('NowView');
            }
            var img = $('room_image_'+image_id);
            $(img.parentNode).addClassName('NowView');
            $('main_image').src = anotherSizeOf( img, "w358h310.jpg" );;
            $('main_image_anchor').href = anotherSizeOf( img, "w600h600.jpg" );
        }
      
        function anotherSizeOf(img, filename){
           var split_url = img.src.split("/");
           split_url.pop();
          split_url.push( filename );
           return split_url.join("/");
        }

        function openImage( href ) {
            // アクセスカウンタ用にリクエストを投げる
            new Ajax.Request('/ikebukuro/shop/image/' + params.shopId, {
                method: 'get',
                asynchronous: true
            });
            window.open(href);
            return false;
        }

        function setup() {
            window.swapImage = swapImage;
            window.openImage = openImage;
        }

        return {
            setup: setup
        };
    }

    document.observe('dom:loaded', function () {
        shopEffect().setup();
        image().setup();
    });
    // 内部で使用しているメソッドが dom:loaded でイベント実行している
    map().setup();
}
setup({});
