/**
 * teppee web site
 *  indexページのjavascript
*/
(function($) {
    $.fn.movingItem = function(toX , duration, callback, over) {
        if(null == duration) {
            duration = 280;
        }
        //Private method
        var _priv = {
            /*
             * get global left margin
             *
             *  現在のページの左マージン数を取得
            */
            getLeft : function () {
                var _m = $('#headerContainer').position();
                return _m.left;
            }
        };

        //現在の位置から行くべき場所へアニメーション
        var _toLeft = _priv.getLeft() + toX;
        $(this).animate({
            left : _toLeft
        }, duration,null, callback);

        //riseze で場所補正
        var _this = this;
        $(window).resize(function() {
            $(_this).css('left' , _priv.getLeft() + toX);
        });

        //MouseOverの動き
        if(over) {
            $(this).mouseover(function() {
                $(_this).animate({left : '+=5'}, 80, null, function() {
                    $(_this).animate({left : '-=10'}, 160, null, function() {
                        $(_this).animate({left : '+=5'}, 80);
                    });
                });
            });
        }
    }
})(jQuery);

$(document).ready(function() {
    layoutHack.contentBG();
    layoutHack.heightFit();

    $('h1').movingItem(3, null, function(){
        $('#headerContainer p').movingItem(175, 360, function() {
            $('#gNavi .navi01Schedule').movingItem(54, 280, null, true);
            $('#gNavi .navi02about').movingItem(59, 640, null, true);
            $('#gNavi .navi03blog').movingItem(64, 330, null, true);
            $('#gNavi .navi04contact').movingItem(69, 780, null, true);
        });
    });
    setColorBox();
});
