/*----------------------------------------------------------------
    各種機能プラグイン

    画像切り替え
    フッター下付け処理

----------------------------------------------------------------*/

(function($){
/*----------------------------------------------------------------
    画像切り替え
----------------------------------------------------------------*/
    $.fn.imgchange = function(options){
        //初期値設定
        var m = $.extend({
            name:  "_over"
        }, options);

        return this.each(function(){
            if (!this) return false;
            //ファイル名取得
            var src   = $(this).attr("src");
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var hsrc  = src.replace(ftype, m.name + ftype);
            //オーバー画像読込み
            var img = new Image();
            img.src = hsrc;
            //ロールオーバー処理
            $(this).hover(function (){
                $(this).attr("src",hsrc);
            }, function(){
                $(this).attr("src",src);
            });
        });
        return this;
    }

/*----------------------------------------------------------------
    フッター下付け処理
----------------------------------------------------------------*/
    $.fn.footerBottom = function(options){

        return this.each(function(){
            if (!this) return false;
            var maxh  = $(window).height();
            var thish = $(this).innerHeight();
            var thisw = $(this).innerWidth();
            if(maxh > thish) {
                $("#main").css("min-height", maxh + "px");
                $("#footer").css({
                    position: "absolute",
                    bottom: "0px",
                    width: thisw + "px"
                })
            }
        });
        return this;
    }

})(jQuery);