// JavaScript Document

$(function(){
	//初期設定
	$('.tabNav li img').each(function(){
		this.cPath = $(this).attr('src').replace('_open','');
		this.oPath = $(this).attr('src').replace('.gif','_open.gif');
		this.rPath = $(this).attr('src').replace('.gif','_on.gif');
		$(this).attr('src', this.cPath);
	});
	
	//
	$('.tabNav').each(function(){
		var tabNavList = $(this).find('a[href^=#], area[href^=#]');
		var tabBodyList;
		
		tabNavList.each(function(){
			this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
			var selecter = '#'+this.hrefdata.fragment;
			
			if (tabBodyList) {
				tabBodyList = tabBodyList.add(selecter);
			} else {
				tabBodyList = $(selecter);
			}
			
			$(this).unbind('click');
			$(this).click(function(){
				//タブクローズ
				tabBodyList.hide();
				//tabNavList.removeClass('active');
				//tabNavList.addClass('inactive');
				
				tabNavList.find('img').each(function(){
					$(this).attr('src', $(this).get(0).cPath);
					$(this).addClass('btn');
				});
				
				//タブオープン
				$(selecter).show();
				//$(this).addClass('active');
				//$(this).removeClass('inactive');
				
				var clickedTabImage = $(this).find('img');
				clickedTabImage.attr('src', clickedTabImage.get(0).oPath);
				clickedTabImage.removeClass('btn');
				
				return false;
			});
		});
		tabBodyList.hide();
		tabNavList.filter(':first').trigger('click');
	});
	
	//ロールオーバー設定
	/*$(this).unbind('hover');
	$('.tabNav a img.btn').hover(function(){
		//console.log('true');
		//$(this).attr('src', $(this).get(0).rPath);
	},function(){
		//$(this).attr('src', $(this).get(0).cPath);
	});*/
});
