
var items = [
	'searchOptions',
	'MySearchOptions',
	'strings',
	'drum',
	'horn',
	'piano',
	'keybord',
	'recording',
	'dj',
	'otherinst'
];


/* イニシャライズ
-----------------------------------*/
function init(ids,shopWatchTab) {
	var id_ary = ids.split(',');
	var id_count = id_ary.length;
	var count = items.length;

	//すべて閉じる
	for (i = 0; i < count; i++) {
		if(document.getElementById(items[i])){
			document.getElementById(items[i]).style.display = 'none';
		}
	}

	//表示設定
	for (j = 0; j < id_count; j++){
		if(id_ary[j] != ''){
			if(document.getElementById(id_ary[j])) document.getElementById(id_ary[j]).style.display = 'block';
			if(document.getElementById(id_ary[j] + 'Toggle')) document.getElementById(id_ary[j] + 'Toggle').style.backgroundPosition = '-155px 0.6em';
		}
	}

	//ウォッチリスト制御
	if(document.getElementById('watchList')){
		if(shopWatchTab){
			watchTab(1);
		}else{
			watchTab(0);
		}
	}
	//楽器検索オプション制御
	if(document.getElementById('narrowSearch')) document.getElementById('narrowSearch').style.display = 'none';

	if(navigator.userAgent.search('.*MSIE(\ |\/)5.*') != -1 || navigator.userAgent.search('.*Netscape6.*') != -1){
		return;
	}
	//
	SiteFacade.getOpenCategoryName(openCategory);
}

/* チャネルトップ用イニシャライズ
-----------------------------------*/
function initTop(ids,shopWatchTab) {
	var id_ary = ids.split(',');
	var id_count = id_ary.length;
	var count = items.length;

	//すべて閉じる
	for (i = 0; i < count; i++) {
		if(document.getElementById(items[i])){
			document.getElementById(items[i]).style.display = 'none';
		}
	}

	//表示設定
	for (j = 0; j < id_count; j++){
		if(id_ary[j] != ''){
			if(document.getElementById(id_ary[j])) document.getElementById(id_ary[j]).style.display = 'block';
			if(document.getElementById(id_ary[j] + 'Toggle')) document.getElementById(id_ary[j] + 'Toggle').style.backgroundPosition = '-155px 0.6em';
		}
	}

	//ウォッチリスト制御
	if(document.getElementById('watchList')){
		if(shopWatchTab){
			watchTab(1);
		}else{
			watchTab(0);
		}
	}
	//楽器検索オプション制御
	if(document.getElementById('narrowSearch')) document.getElementById('narrowSearch').style.display = 'none';

	if(navigator.userAgent.search('.*MSIE(\ |\/)5.*') != -1 || navigator.userAgent.search('.*Netscape6.*') != -1){
		return;
	}
	changeCategory12();
	//
	SiteFacade.getOpenCategoryName(openCategory);
}

function openCategory(categoryName){
	if(categoryName == null || categoryName == ""){ return; }
	var name_ary = categoryName.split(',');
	var name_count = name_ary.length;

	for(i = 0; i < name_count; i++){
		if(document.getElementById(name_ary[i])){
			objStyle = document.getElementById(name_ary[i]).style;
			tglStyle = document.getElementById(name_ary[i] + 'Toggle').style;
			if(objStyle.display == 'none') {
				objStyle.display = 'block';
				tglStyle.backgroundPosition = '-155px 0.6em';
			} else {
				objStyle.display = 'none';
				tglStyle.backgroundPosition = '5px 0.6em';
			}
		}
	}
}

/* 表示制御
-----------------------------------*/
function toggleDisplay(ids){
	obj = document.getElementById(ids);

	if(ids != 'searchOptions' && ids != 'MySearchOptions') tgl = document.getElementById(ids + 'Toggle');

	if(obj.style.display == 'none') {
		obj.style.display = 'block';
		if(ids != 'searchOptions' && ids != 'MySearchOptions') tgl.style.backgroundPosition = '-155px 0.6em';
	}
	else {
		obj.style.display = 'none';
		if(ids != 'searchOptions' && ids != 'MySearchOptions') tgl.style.backgroundPosition = '5px 0.6em';
	}

	if(navigator.userAgent.search('.*MSIE(\ |\/)5.*') != -1 || navigator.userAgent.search('.*Netscape6.*') != -1){
		return ;
	}

	if(ids != 'searchOptions' && ids != 'MySearchOptions') SiteFacade.updateOpenCategoryName(ids,voidfunction);
}

function voidfunction(){
}

/* ウォッチリスト制御
-----------------------------------*/
function watchTab(mode) {
	var watchlist = [
		['watchListInst', 'watchTabInst', '0 -20px', '0 0'],
		['watchListShop', 'watchTabShop', '-120px -20px', '-120px 0']
	];
	var setobj,settab,hideobj,hidetab,setpos,hidepos;

	setobj = document.getElementById(watchlist[mode][0]);
	settab = document.getElementById(watchlist[mode][1]);
	setpos = watchlist[mode][2];
	mode ^= 1;
	hideobj = document.getElementById(watchlist[mode][0]);
	hidetab = document.getElementById(watchlist[mode][1]);
	hidepos = watchlist[mode][3];

	setobj.style.display = 'block';
	hideobj.style.display = 'none';
	settab.style.backgroundPosition = setpos;
	hidetab.style.backgroundPosition = hidepos;
}


/* 楽器検索オプション制御
-----------------------------------*/
function toggleNarrowSearch(id){
	if( id ){
		var obj = document.getElementById(id);
		obj.value = (obj.value=='false');
	}
	applyNarrowSearch(id);
}
function applyNarrowSearch(id){
	var opend = true;
	if( id ){
		opend = document.getElementById(id).value=='true';
	}else{
		obj = document.getElementById('narrowSearch');
		opend = (obj.style.display == 'none');
	}
	obj = document.getElementById('narrowSearch');
	var disp = opend ? 'block' : 'none';
	obj.style.display = disp;
	if(document.getElementById('open_narrowSearch')){
		obj = document.getElementById('open_narrowSearch');
		var disp = opend ? 'none' : 'block';
		obj.style.display = disp;
	}
}

