﻿$(function(){
	
	//<a>タグするする IE6以外
	if (!/MSIE (6\.)/.test(navigator.userAgent)) {
		$('.anchor').click(function(){
			var $h = $(this).attr('href');
			fncSmoothScroll($h, 60, 1, 0.1);
			return false;
		});
		//別ページからのページ内リンク
		targetAnk();
	}
	// ファイルの種類により、Class追加
	$('a[href$=".pdf"]').addClass('list-pdf');
	
  // パンくず処理
	$('#topicpath li > a').after('<span>&nbsp;&gt;</span>');
	
	// ---------------------- 【Collection TOP】タブ -----------------------
	// 初期設定
	var $i = 1;
	var $j = 1;
	var $k = 1;
	$('#tab-collection').show();
	$('.brand-tit').hide();
	$('#content-collection').css('background', 'url(/collection/img/bg_tab-content.gif) center bottom');
	// タブ：<li>タグに"tb-●"を追加
	$('.tabclick > li').each(function(){
		$(this).addClass('tb-' + $i);
		$i++;
	});
	// リンク：<a>タグに"tb-●"を追加
	$('.tabclick > li a').each(function(){
		$(this).addClass('tb-' + $j);
		if($j == 1){	// タブ【1】だったら
			// 最初の<a>タグ画像on
			var $FirstSrc = $(this).children().attr("src");
			var $SearchResult = $FirstSrc.indexOf("_on.gif",0);
			if($SearchResult < 0){ // 画像がon画像でなければ
				var $FirstOnSrc = $FirstSrc.replace(/\.gif/, "_on.gif");
			}
			$(this).children().attr("src", $FirstOnSrc);
		}
		$j++;
	});
	// 内容：<div>タグに"tb-●"を追加
	$('.tabclick > div').each(function(){
		$(this).addClass('tb-' + $k);
		$k++;
	});
	// 初期設定
	$('.tabclick > div').hide();
	$('.tabclick > div:first').show();
	// Click時の処理
	$('.tabclick > li a').click(function(){
		// タブ表示
			// すべての画像をリセット
			$(".tabclick > li a").children().each(
				function(){
					var $ThisSrc = $(this).attr("src");
					var $ResetSrc = $ThisSrc.replace(/\_on.gif/, ".gif");
					$(this).attr("src", $ResetSrc);
				}
			);
			// on画像に変更
			var $ThisClickSrc = $(this).children().attr("src");
			var $OnSrc = $ThisClickSrc.replace(/\.gif/, "_on.gif");
			$(this).children().attr("src", $OnSrc);
		// 内容表示
		var $tabClass = $(this).attr('class');
		$('.tabclick > div').hide();
		$('.tabclick > div.' + $tabClass).fadeIn(300);
		return false;
	});
	
	// TAB指定OPENの設定
	 var thisUrl = location.href;
	 if(thisUrl.match(/#tb-/)) {
		var CollectionPm = location.hash.split("#")[1];
		// タブ表示
			// すべての画像をリセット
			$(".tabclick > li a").children().each(
				function(){
					var $ThisSrc = $(this).attr("src");
					var $ResetSrc = $ThisSrc.replace(/\_on.gif/, ".gif");
					$(this).attr("src", $ResetSrc);
				}
			);
			// on画像に変更
			var $ChangeSrc = $('.tabclick > li.' + CollectionPm + ' a').children().attr("src");
			var $SearchResult2 = $ChangeSrc.indexOf("_on.gif",0);
			if($SearchResult2 < 0){ // 画像がon画像でなければ
				var $ChangeOnSrc = $ChangeSrc.replace(/\.gif/, "_on.gif");
			}
			$('.tabclick > li.' + CollectionPm + ' a').children().attr("src", $ChangeOnSrc);
		// 内容表示
	 	$('.tabclick > div').hide();
	 	$('.tabclick > div.' + CollectionPm).fadeIn(300);
	 }
	
	// ---------------------- 【Collection ブランドTOP】一覧カテゴリー表示 -----------------------
	// 初期設定
	$('#cat-accessary').show();
	$('#cat-accessary > li a:first').addClass('on');
	$('#thumb-accessary > li:nth-child(5n)').after('<li class="line"></li>');
	// Click時の処理
	$('#cat-accessary > li a').click(function(){
		// リンク表示
		$('#cat-accessary > li a').removeClass('on');
	 	$(this).addClass('on');
		// サムネイル表示
		var $catClass = $(this).attr('href');
		$catClass = $catClass.split("#")[1];
		$('#thumb-accessary > li').hide();
		$('#thumb-accessary > li.line').remove();
		if($catClass != 'all') { // #allじゃなかったら
			$('#thumb-accessary > li.' + $catClass).fadeIn(300);
			var $catClassNo = 1;
			// 表示されている<li>タグに"catno-●"を追加
			$('#thumb-accessary > li:visible').each(function(){
				$(this).addClass('catno-' + $catClassNo);
				if($catClassNo % 5 == 0){
					$(this).after('<li class="line"></li>');
				}
				$catClassNo ++;
			});
		} else {
			$('#thumb-accessary > li').fadeIn(300);
			$('#thumb-accessary > li:nth-child(5n)').after('<li class="line"></li>');
		}
		return false;
	});
	// ---------------------- 【Collection detail】設定 -----------------------
	// 印刷用ページ 振り分け設定
	var thisUrl = location.href;
	if(thisUrl.match(/stylesheet=print/)) { // stylesheet=print だったら
			var $imgPrint = $('#img-fade li:first img').addClass('img-print');
			$('#detail-right dl:first').before($imgPrint);
		} else { // stylesheet=print じゃなかったら
			$('#detail-data #btn-print').show();
			// jcarousel 設定
			$('#related').jcarousel({
				visible : 5,
				scroll : 1
			});
			// InnerFade 設定
			$('#img-fade li').show();
			$('#img-fade').innerfade({
				speed : 1000,
				timeout : 4000
			});
			// <dl> border 設定
			var $dlBorderWidth = $('#detail-data dl').css('border-bottom-width');
			var $dlBorderStyle = $('#detail-data dl').css('border-bottom-style');
			var $dlBorderColor = $('#detail-data dl').css('border-bottom-color');
			$('#detail-data dl:first').css('border-top',$dlBorderWidth + ' ' + $dlBorderStyle + ' ' + $dlBorderColor);
			$('#detail-data dl:first').css('margin-top','20px');
	}
	// ---------------------- 【Close-up Collection TOP】カテゴリ一覧表示 -----------------------
	// 詳細ページ sidemenu設定
	var $thiscat = $('#special-detail h2 em').text();
	$('#special-detail ul#sidemenu > li > a + ul').hide();
	$('#special-detail ul#sidemenu > li > a + ul + p').hide();
	$('#special-detail ul#sidemenu > li > a').each(function(){
		var $nowcat = $(this).text();
		$nowcat = "［ " + $nowcat + " ］";
		if($thiscat == $nowcat) {
			$(this).nextAll().show();
			$(this).replaceWith('<span>' + $(this).text() + '</span>');
		}
	});
	// 現在開いてるカテゴリのリンクをアウト
	 var thisUrl = location.href;
	 if(thisUrl.match('(/special/categoryid-)')) {
		var SpecialPm = thisUrl.substring(thisUrl.lastIndexOf('/special/'),thisUrl.length);
		//ページネイションの余分なURLをCut
		if (SpecialPm.match(/_/i)) {
			var pagecut = SpecialPm.substring(SpecialPm.lastIndexOf('_'),SpecialPm.lastIndexOf('.'));
			SpecialPm = SpecialPm.replace(pagecut,'');
		}
		$('#special-list #sidemenu > li a').removeClass('on');
		$('#special-list #sidemenu > li a').filter(function(){
			return($(this).attr('href') == SpecialPm)
		}).addClass('on');
	 } else {
		$('#special-list #sidemenu > li a:first').addClass('on');
	 }
	 
	 // ---------------------- 【shoplist】カテゴリ一覧表示 -----------------------
	 // 現在開いてるカテゴリのリンクをアウト
	 var thisUrl = location.href;
	 if(thisUrl.match('(/shop/)')){
		var ShoplistPm = thisUrl.substring(thisUrl.lastIndexOf('/shop/'),thisUrl.length);
		$('#shoplist #sidemenu > li a').removeClass('on');
		$('#shoplist #sidemenu > li a').filter(function(){
		 	return($(this).attr('href') == ShoplistPm)
		}).addClass('on');
	 }
	 
});

//【ポップアップ】PC用メールマガジン登録
function pcmagazine(html) {
	SubWindow=window.open(html,"pcmagazine","width=700,height=740,left=50,top=50,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1");
	SubWindow.focus();
}

//【ポップアップ】お問合わせ
function contact(html) {
	SubWindow=window.open(html,"contact","width=775,height=740,left=50,top=50,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1");
	SubWindow.focus();
}

//【ポップアップ】Collection 詳細 印刷用画面表示
function displayPrint(html) {
	SubWindow=window.open(html,"displayPrint","width=700,height=740,left=50,top=50,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1");
	SubWindow.focus();
}

//【ポップアップ】Shop List 詳細
function shop(html) {
	SubWindow=window.open(html,"shop","width=700,height=740,left=50,top=50,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1");
	SubWindow.focus();
}

