// written in UTF-8

$(function() {
	/* 検索語句のヒンティング
	-----------------------------------*/
	$(function() {
		var word = 'サイト内検索';
		$('input#search-input, input#search-gourmet-input')
			// ロード時
			.load(function() {
				$(this).val(word);
				$(this).css('color', '#CCC');
			})
			// フォーカスが外れた時
			.blur(function() {
				if ($(this).val() == '' || $(this).val() == word) {
					$(this).val(word);
					$(this).css('color', '#CCC');
				}
			})
			// フォーカス時
			.focus(function() {
				if ($(this).val() == '' || $(this).val() == word) {
					$(this).val('');
					$(this).css('color', '#333');
				}
			})
		.load();
	});

	/* 現在のページにクラスを付ける
	-----------------------------------*/
	$(function() {
//		var name = location.pathname.split('/').pop() || '/';
		var name = location.search.split('&').shift() || 'index.php' || '/';
		$('.rollover li a').each(function() {
			if ($(this).attr('href') == name) {
				$(this).addClass('current');
			}
		});
	});

	/* タブ
	-----------------------------------*/
	$('#tabs').tabs();

	/* アコーディオン
	-----------------------------------*/
	$(function() {
		//春: 0 夏: 1 秋: 2 冬: 3 通年: 4
		var expose = 0;
		$('div#accordion h3.title').each(function() {
			$(this).click(function() {
				$(this)
				.toggleClass('open', $(this).next('div').is(':hidden'))
				.next('div').slideToggle();
			})
			.next('div').hide();
		});
		$('#trekking div#accordion h3.title').eq(expose).addClass('open').next('div').show();
		$('#trekking div#accordion h3.title').eq(4).addClass('open').next('div').show();
	});

	/* スペシャルページ
	-----------------------------------*/
	$('#special div.bar p img[title]').bind('load', function() {
		var span = $('<span class="caption">' + $(this).attr('title') + '</span>');
		span.css({
			position: 'absolute',
			left: 0,
			bottom: '10px',
			width: ($(this).attr('width') - 10) + 'px',
			padding: '5px',
			backgroundColor: '#000',
			color: '#FFF',
			opacity: 0.75,
			zIndex: 5
		});
		$(this).after(span);
		$(this).next().hide();
		$(this).parent().hover(
			function() { $(this).children('span').slideDown() },
			function() { $(this).children('span').slideUp() }
		);
	});
});
