////////////////////////////////////////////////////////////////////////////////
// toppage.js
////////////////////////////////////////////////////////////////////////////////
(function($) {
	//--------------------------------------------------------------------------
	//  Variables
	//--------------------------------------------------------------------------
	var _dtop, _htop;
	
	//--------------------------------------------------------------------------
	//  Entry Point
	//--------------------------------------------------------------------------
	/**
	 * トップページ
	 */
	$(document).ready(function () {
		//リンク内のテキスト名をIDにもつ説明文を表示
		$("#Index ul:eq(0) a").each(function() {
			var $this = $(this);
			var $target = $("#"+ $this.text().replace(/ /g, ""));
			
			$this.hover(
				function () { $target.floatIn() },
				function () { $target.floatOut() }
			);
		});
		
		//説明文の位置調整
		// $(window).bind("resize", function () {
		// 	var l = $("#Index").position().left;
		// 	if (l > 500) {
		// 		_htop = 110;
		// 		_dtop = 180;
		// 		$(".balloon").css({left: 60, right: 0, top: _htop});
		// 	} else {
		// 		_htop = 300;
		// 		_dtop = 350;
		// 		$(".balloon").css({left: "auto", right: 110, top: _htop});
		// 	}
		// });
		
		//背景描画
		var isMSIE = /*@cc_on!@*/0;
		if (isMSIE) return;
		
		var canvas = document.createElement("canvas");
		$("body").append(canvas);
		
		var bubble = new Bubble(canvas);
		$(window).bind("resize", $.proxy(bubble.draw, bubble));
		
		$(window).trigger("resize");
	});
	//--------------------------------------------------------------------------
	// jQuery extend
	//--------------------------------------------------------------------------
	jQuery.fn.extend({
		/**
		 * 表示
		 */
		floatIn: function (speed, easing) {
			speed = speed || 350;
			easing = easing || "easeOutQuart";
			this.show().stop(true, false).animate({
				opacity: 1,
				top: _dtop
			}, speed, easing);
		},
		
		/**
		 * 非表示
		 */
		floatOut: function (speed, easing) {
			speed = speed || 250;
			
			this.stop(true, false).animate({
				opacity: 0,
				top: _htop
			}, speed, easing, function() {
				$(this).hide();
			});
		}
	});
	
})(jQuery);
