$(document).ready(function() {
	$('.menuitem').each(function(idx, item) {
		$(this).click(function() {
			// Create the gray background on the question
			$(this).parent().parent().toggleClass('selected');
		});
	});
	
	var anchor = window.location.hash.substring(1); //anchor without the # character
	//var anchor=$(this).attr("hash");  
	if (anchor.length) {
		$("a[name="+anchor+"]").each(function(idx, item) {
			// Create the gray background on the question
			$(this).parent().parent().toggleClass('selected');
			
			// Change the Plus image to a Minus image
			var plusImg = this.parentNode.getElementsByTagName('img');
			var checktest= new RegExp("(^|\\s)statusicon(\\s|$)");
			for (var i=0;i<plusImg.length;i++) {
				if (checktest.test(plusImg[i].className)) {
					plusImg[i].src = "/img/ca/global/icon/minus.gif";
				}
			}
			
			// Display the answer
			var answerTag = this.parentNode.parentNode.getElementsByTagName('li');
			var checktest= new RegExp("(^|\\s)answer(\\s|$)");
			for (var i=0;i<answerTag.length;i++) {
				if (checktest.test(answerTag[i].className)) {
					answerTag[i].style.display = "block";
				}
			}
			
			// Scroll back to the top of the page
			$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
		});
	}
});
