/* 
 *
 * index.js ※トップページ用
 * 
 * Copyright(c) INVOGUE.CO,. Ltd. ALL Rights Reserved.
 * http://www.invogue.co.jp/
 * 
 */
(function($) {
	$.index = {
		tabEffect: function(options){
			var c = $.extend({
				area       : '',
				navigation : '',
				target     : ''
			}, options);
			
			$(c.navigation).each(function(){
				$(this).hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});
			});
			$(c.navigation).click(function(){
				//初期化
				$(c.navigation).removeClass("active"); //クラス名(active)を削除
				$(c.target).fadeOut(); //コンテンツを非表示
				
				$(this).addClass('active'); //クラス名(active)を追加
				var activeArea = $(this).attr('id');
				$(c.area).find('.'+activeArea).fadeIn();
			});

			//高さの計算と適用
			var Height = [
					 $("#Content-top div.recommend div.east").height(),
					 $("#Content-top div.recommend div.west").height(),
					 $("#Content-top div.recommend div.other").height()
			];
			var MaxHeight = Math.max.apply(null, Height) + 85;
			$("#Content-top div.recommend").height(MaxHeight);
			
			$(c.navigation).css("cursor","pointer");
			$(c.target).hide();
			$(c.navigation+':first').click();
		},
		acordionMenu: function(options){
			var c = $.extend({
				area       : '',
				navigation : '',
				target     : '',
				title      : ''
			}, options);
			$(c.title).click(function(){
				if($(this).parent().hasClass('active')){
					 //閉じる
					 $(this).parent().removeClass("active");
					 $(this).next().slideUp();
				}else{
				//初期化
				$(c.title).each(function(){
					if($(this).parent().hasClass("active")){
						 $(this).parent().removeClass("active");
						 $(this).next().slideUp();
					  }
					});
					var activeArea = $(this).parent().attr('class').substr(c.target.length);
					$(this).parent().addClass('active');
					$(c.area).find('.'+activeArea+' div').slideDown();
					//flickable-1.0b3.min.jsの呼び出し
					var flickTarget = "#" + $(c.area).find('.'+activeArea+' div').attr('id');
					var scrollwide = $(flickTarget+' div.section-wrapper div.object').length*310;
					$('div.TabContent div.section-wrapper').css("width",scrollwide);
					$(flickTarget).flickable();
				}
			});
			$(c.title).css("cursor","pointer");
			$(c.navigation).hide();
			$(c.target+' div').hide();
			//$(c.title+':first').click();
		}
	};
})(jQuery);
