// JavaScript Document

$(document).ready(function() {
	
	
	$('#questionAnswerBox li').each(function(index){
		$(this).bind('click',{index:index},setSubCategory);
	});
	function setSubCategory(event){
		var target = document.URL.split('#');
		target = (target[1]) ? target[1] :1 ;
		target = (event) ? event.data.index : target -1;
		
		$('#backLinkToSubCategory').hide();
		$('#questionSubCategoryOrAnswer > h3').hide();
		$('#qa_box_header').attr('src','images/qa/qa_box_header_right.gif');
		
		$('#questionAnswerBox li').removeClass('selected');
		$('#questionAnswerBox li:eq(' + target + ')').addClass('selected');
		$('#questionSubCategoryOrAnswer > h2').text($('#questionAnswerBox li:eq(' + target + ')').text()).show();
		$('#questionAnswerDetailContents').html($('#subCategory' + (target+1)).html());
		$('#questionAnswerDetailContents > ul > li').each(function(index2){
			$(this).bind('click',{index:target,index2:index2},setAnswerDetail);			
		});
	}
	function setAnswerDetail(event){
		$('#backLinkToSubCategory').show();
		$('#qa_box_header').attr('src','images/qa/qa_box_header_right_back.gif').bind('click',{index:event.data.index},setSubCategory).css('cursor','pointer');
		$('#questionSubCategoryOrAnswer > h3').text($('#questionAnswerDetailContents li:eq(' + event.data.index2 + ')').text()).show();
		$('#questionAnswerDetailContents').html($('#answerDetail' + (event.data.index+1) + '-' + (event.data.index2+1)).html());
	}
	
	setSubCategory();
});
