/* ****************************************************
Since : 2008-03-06
**************************************************** */


/* Definition of onload functions
---------------------------------------------*/
$(document).ready(function(){
	chapterView = '';
	$("#cantoNavi li a").mouseover(function(){
		attrClass = $(this).parent().parent().attr('class');
		
		if('#chapter'+attrClass.substr(5,1) != chapterView){
			//set 'on' to this
			if($('img', $(this)).attr('src').indexOf('off.')!=-1)
				temp=$('img', $(this)).attr('src').split('off.');
			else if($('img', $(this)).attr('src').indexOf('.')!=-1)
				temp = $('#cantoNavi .'+attrClass+' img').attr('src').split('.');
			$('#cantoNavi .'+attrClass+' img').attr('src',temp[0]+'on.'+temp[1]);
			
			//display control for chapterNavi
			if(chapterView)
				$('#chapterArea '+chapterView).css('display','none');
			$('#chapterArea #chapter'+attrClass.substr(5,1)).css('display','block');
			chapterView='#chapter'+attrClass.substr(5,1);
			
			//set 'off' to otherNavi
			$("#cantoNavi li").not('.'+attrClass).each(function(){
				if($('img', $(this)).attr('src').indexOf('on.')!=-1)
					temp=$('img', $(this)).attr('src').split('on.');
				else if($('img', $(this)).attr('src').indexOf('off.')!=-1)
					temp=$('img', $(this)).attr('src').split('off.');
				else if($('img', $(this)).attr('src').indexOf('.')!=-1)
					temp=$('img', $(this)).attr('src').split('.');
				$('img', $(this)).attr('src',temp[0]+'off.'+temp[1]);
			});
		}
	});
	$("#cantoNavi img").mouseout(function(){
		if(!chapterView){
			$("li img", "#cantoNavi").each(function(){
				if($(this).attr('src').indexOf('over.')!=-1)
					temp=$(this).attr('src').split('over.');
				else if($(this).attr('src').indexOf('off')!=-1)
					temp=$(this).attr('src').split('off.');
				$(this).attr('src',temp[0]+'.'+temp[1]);
			});
		}
		if(chapterView){
			$("li img", "#cantoNavi").each(function(){
				if($(this).attr('src').indexOf('over.')!=-1){
					temp=$(this).attr('src').split('over.');
					$(this).attr('src',temp[0]+'off.'+temp[1]);
				}
			});
		}
		//temp=$(this).attr('src').split('.');
	});
	$("#chapterArea .close").click(function(){
		$(chapterView).css('display','none');
		chapterView = '';
		$("#cantoNavi li img").each(function(){
			if($(this).attr('src').indexOf('on.')!=-1)
				temp=$(this).attr('src').split('on.');
			else if($(this).attr('src').indexOf('off.')!=-1)
				temp=$(this).attr('src').split('off.');
			$(this).attr('src',temp[0]+'.'+temp[1]);
		});
	});
});
