$j(function() {
	var openHelpingCtn = 'none';
	
	/* Show only the topics */
	$j('#gettingStartedCtn').hide();
	$j('#memberInformationCtn').hide();
	$j('#profileCtn').hide();
	$j('#facetCtn').hide();
	$j('#bookletsCtn').hide();
	$j('#otherCtn').hide();
	$j('#abuseCtn').hide();
	$j('#copyrightCtn').hide();
	
	/* When user click on one topic, we show the corresponding content and hide others topics */
	$j('#gettingStartedLnk').click(function(){
		$j('#gettingStartedCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'gettingStarted';
	});
	$j('#memberInformationLnk').click(function(){
		$j('#memberInformationCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'memberInfo';
	});
	$j('#profileLnk').click(function(){
		$j('#profileCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'profile';
	});
	$j('#facetLnk').click(function(){
		$j('#facetCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'facet';
	});
	$j('#bookletsLnk').click(function(){
		$j('#bookletsCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'booklets';
	});
	$j('#otherLnk').click(function(){
		$j('#otherCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'other';
	});
	$j('#abuseLnk').click(function(){
		$j('#abuseCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'abuse';
	});
	$j('#copyrightLnk').click(function(){
		$j('#copyrightCtn').show();
		$j('#gettingStartedLnk').hide();
		$j('#memberInformationLnk').hide();
		$j('#profileLnk').hide();
		$j('#facetLnk').hide();
		$j('#bookletsLnk').hide();
		$j('#otherLnk').hide();
		$j('#abuseLnk').hide();
		$j('#copyrightLnk').hide();
		openHelpingCtn = 'copyright';
	});
	
	/*Show all topics when clicking on back to topics link */
	$j('.backTopicsLnk').click(function(){
		$j('#gettingStartedLnk').show();
		$j('#memberInformationLnk').show();
		$j('#profileLnk').show();
		$j('#facetLnk').show();
		$j('#bookletsLnk').show();
		$j('#otherLnk').show();
		$j('#abuseLnk').show();
		$j('#copyrightLnk').show();
		if(openHelpingCtn == 'gettingStarted'){
			$j('#gettingStartedCtn').hide();
		}else{
			if(openHelpingCtn == 'memberInfo'){
				$j('#memberInformationCtn').hide();
			}else{
				if (openHelpingCtn == 'profile') {
					$j('#profileCtn').hide();
				}
				else {
					if (openHelpingCtn == 'facet') {
						$j('#facetCtn').hide();
					}
					else {
						if (openHelpingCtn == 'booklets') {
							$j('#bookletsCtn').hide();
						}
						else {
							if (openHelpingCtn == 'other') {
								$j('#otherCtn').hide();
							}
							else {
								if (openHelpingCtn == 'abuse') {
									$j('#abuseCtn').hide();
								}
								else {
									if (openHelpingCtn == 'copyright') {
										$j('#copyrightCtn').hide();
									}
								}
							}
						}
					}
				}
			}
		}
	});
	
	/* show help content */
	$j("#helpContentCtn").children().hide();
    $j(".toHide").children().hide();
    $j(".helpLink").click(function(e) {
		var change = false;
		var question = $j(e.target).attr('title');

        $j(".toHide h3").each(function() {
            if($j(this).html() == question) {
                $j(this).next().toggle(300);
				change = true;
                return false;
            }
        });
		
		if (change) {
			$j(".basicArrowSideIcon").each(function(){
				if ($j(this).attr('title') == question) {
					$j(this).removeClass('basicArrowSideIcon').addClass('basicArrowIcon');
					$j(this).attr('title', question + 'shown');
					change = false;
					return false;
				}
			});
		}
		
		if (change) {
			$j(".basicArrowIcon").each(function(){
				if ($j(this).attr('title') == question + 'shown') {
					$j(this).removeClass('basicArrowIcon').addClass('basicArrowSideIcon');
					$j(this).attr('title', question);
					change = false;
					return false;
				}
			});
		}
    });
})
