
$(document).ready(function() {
	
	$("#navigation").ready(function() { // scan the page for any navigations
		$(".sub:not(.opened)").toggle(); // hide the sub menus
		$(".sub:not(.opened)").parent().find('a:first').toggle(
		function(){
			$(this).parent().addClass('act subnav');
			$(this).parent().children(".sub").toggle(); // show the sub menu
		},function(){
			$(this).parent().removeClass('act subnav');
			$(this).parent().children(".sub").toggle(); // hide the sub menu
		});
		$(".sub.opened").parent().find('a:first').toggle(
		function(){
			$(this).parent().removeClass('act subnav');
			$(this).parent().children(".sub").toggle(); // show the sub menu
		},function(){
			$(this).parent().addClass('act subnav');
			$(this).parent().children(".sub").toggle(); // hide the sub menu
		});
	});	

	if (window.inAction != true){
	
		$(".tests-box-internal a").hover(
			function ()
			{
				$(this).find("em")
					.stop()
					.animate({"left":65, opacity:1},300)
				;
			}
			,
			function ()
			{
				$(this).find("em")
					.stop()
					.animate({"left":25, opacity:0},300)
				;
			}
		);
	}

	$("ul.test-list").find('.test-desc').hide(); // hide the descriptions

	var strLocation = '';

	/* This method checks for changes in the location */
	var fnCheckLocation = function(){
		if (strLocation != window.location.href){
			strLocation = window.location.href;
			$(window.location).trigger("change");
		}
	}
	
	/* Set an interval to check the location */
	setInterval(fnCheckLocation, 100);
	window.parse_location = true;
	
	$(window.location).bind(
		'change',
		function(){
			if (window.location.hash.length != 0 && parse_location) {

				var regexp = /#nogo_(.*?)/gi;  
				if (window.location.hash.match(regexp)) {
					$id = window.location.hash.replace(regexp, "");
					//$(".test-list li .test-desc:visible")
					$(".test-list li > a[name=#" + $id + "]")
						.siblings('.test-desc')
						.hide()
						.parent("li")
						.removeClass("activated")
					;
					
				}
				
				$(".test-list li > a[name=" + window.location.hash + "]")
					.siblings('.test-desc')
					.show()
					.parent("li")
					.addClass("activated");	
				;
				
				$(".test-list li > a[name=" + window.location.hash + "]").siblings('.test-desc').children().each(function(index, object){
					if (object.nodeName == "BR" && !$(object).hasClass('clear')) {
						$(object).remove();
					}
				})
					
				var store_location = window.location;
				parse_location = false;
				window.location = store_location;
				parse_location = true;
			}
		}
	);
		
	$("#tab-box ul ul").hide();
	$("#tab-box li").hover(function(){
			$(this).addClass('hovered'); 
		//	$(this).children(".sub").fadeIn('medium'); 
	
		
		},function(){
			$(this).removeClass('hovered'); 
	});
	
	$("#tab-box li").click(function(){
			
			$("#tab-box li ul").hide();
			$("#tab-box li").removeClass('activated');
			$(this).addClass('activated').children("ul").show(); 

	});

});