/*
 * 設定
 */
var searchString = '検索する文字列を入力';


$(function() {
	
	//ヘッダー検索部
	$('#hnaviSearchWord').css('color','#CCCCCC');
	$('#hnaviSearchWord').attr('value', searchString);
	$('#hnaviSearchWord').focus(function() {
		if($(this).attr('value') == searchString) {
			$(this).attr('value', '');
			$(this).css('color','#333333');
		}
	});
	$('#hnaviSearchWord').blur(function() {
		if(!$(this).attr('value')) {
			$(this).attr('value', searchString);
			$(this).css('color','#CCCCCC');
		}
	});
	
	
	//lnaviジャンル、シリーズ開閉
	$('#lnavi .section .switch').each(function() {
		if($(this).nextAll('ul').html() != null) {
			$(this).click(function() {
				if($(this).nextAll('ul').css('display') == 'block') {
					$(this).toggleClass('open');
					$(this).nextAll('ul').css('display', 'none');
				} else {
					$(this).toggleClass('open');
					$(this).nextAll('ul').css('display', 'block');
				}
			});
		}
		else{
			$(this).css('visibility','hidden');
		}
	});
	
	$('#lnavi .section .defaultOpen .switch').each(function() {
		if($(this).nextAll('ul').html() != null) {
			$(this).toggleClass('open');
		}
		if($(this).parents('li.categoryName').get() != null) {
			$(this).parents('li.categoryName').addClass('defaultOpen');
			$(this).parents('li.categoryName').children('a.switch').addClass('open');
		}
	});
	$('#lnavi .section .categoryName').each(function() {
		var aryCount = 0;
		var noDispCount = 0;
		$('.categoryName',$(this)).each(function() {
			if($(this).css('display') == 'none'){
				noDispCount++;
			}
			aryCount++;
		});
		
		if(aryCount == noDispCount){
			$('.switch',$(this)).css('visibility','hidden');
		}
		
	});
});

function swap(obj) {
	if (obj.src.match(/.+_on\.[gif|jpg|jpe|jpeg|png]/)) {
		obj.src = obj.src.replace(/(.+)_on(\.[gif|jpg|jpe|jpeg|png])/, '$1$2');
	} else {
		obj.src = obj.src.replace(/(.+)(\.[gif|jpg|jpe|jpeg|png])/, '$1_on$2');
	}
}

