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

jQuery.extend( jQuery.easing,
{
	def: 'easeOutExpo',
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
});

(function($){

/***** ここから - 2011.07.02時点のjquery.pack.jsよりコピー (2011.08.19) *****/

/*----------------------------------------------------------------
    画像切り替え
----------------------------------------------------------------*/

    $.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;
    }

/***** ここまで - 2011.07.02時点のjquery.pack.jsよりコピー (2011.08.19) *****/

/***** ここから - 最新jquery.pack.jsよりコピー (2011.08.19) *****/

/*----------------------------------------------------------------
	マウスオーバー透過
----------------------------------------------------------------*/
	$.fn.imghover = function () {
		return this.each(function(){
			$(this).hover(
				function(){ $(this).stop().animate({ opacity: 0.7 }, 200 ); },
				function(){ $(this).stop().animate({ opacity: 1 }, 200 ); }
			);
		});
	}

/*----------------------------------------------------------------
	ページスクロール
----------------------------------------------------------------*/
	$.fn.scrollPage = function (){
		var userAgent = window.navigator.userAgent.toLowerCase();
		var appVersion = window.navigator.appVersion.toLowerCase();
		
		if (userAgent.indexOf("msie") > -1 && appVersion.indexOf("msie 6.0") > -1 &&
			appVersion.indexOf("msie 7.0") == -1 && appVersion.indexOf("msie 8.0") == -1) {
			// IE6
		} else {
			var _url  = location.href.split('#')[0];
			var _hash = location.hash;
			$('a', this ).each(function() {
				if (this.href.indexOf(_url + '#') == 0) {
					var _id = this.href.split('#')[1];
					$(this).click(function(){
							var _top = $('#' + _id).offset().top;
							$($.browser.safari?'body':'html').animate({scrollTop:_top-20},1500,'easeInOutExpo');
					});
					if(!($.browser.msie && $.browser.version==6))
						$(this).removeAttr('href');
					$(this).css('cursor','pointer');
				}
			});
			if(_hash != ('undefined'|''|null)){
				var _target = $(_hash);
				if(_target.length){
					var _top = _target.offset().top;
					$($.browser.safari?'body':'html').animate({scrollTop:_top-20},1500,'easeInOutExpo');
				}
			}
		}
	}

})(jQuery);

/***** ここまで - 最新jquery.pack.jsよりコピー (2011.08.19) *****/

$(function(){
	// 画像切り替え
	try {
		$('.over').imgchange({ name: '-o'});
		$('.hover').imghover();
	} catch (e) {
		//alert(e.message);
	}
	
	// スムーススクロール
	try {
		$('#article').scrollPage();
		//$('.btn-pagetop').scrollPage();
	} catch (e) {
		//alert(e.message);
	}
	
	// フッターメニュー内フロート要素の高さ揃え
	try {
		$('div[id=footmenu]').each(function () {
			var height = $(this).height();
			$(this).find('.page-group').height(height);
		});
	} catch (e) {
		//alert(e.message);
	}
	
	// フッターメニュー表示/非表示切り替え
	try {
		var footmenu = $('#footmenu');
		footmenu.hide();
		$("#btn-menu a").click(function(){
			var _offset = $('#footmenu','body').offset().top;
			footmenu.slideToggle(800);
			$("body,html").stop().animate({ scrollTop: _offset }, {duration: 800, easing: "swing"} );
			return false;
		});
	} catch (e) {
		//alert(e.message);
	}
});

