$(function() {
	$("#navigation li").mouseover(function() {
		$(this).children("ul").show();
	});

	$("#navigation li").mouseout(function() {
		// hide the sub menu
		$(this).children("ul").hide();
	});
	
	/*
	$(".medical-terms li").click(function(){
		$(this).children("p").toggle(); // toggle detail
		$(this).siblings("li").children("p").hide(); // hide others
	});
	*/
});

/* This poll triggers a change event on window.location, nice */
$(function() {
                /* Default to the current location */
                var strLocation = window.location.href;
                var strHash = window.location.hash;
                var strPrevLocation = "";
                var strPrevHash = "";
                
                /* Yo Dawg, this method removes the hash from the hash so you can hash
                  while hashing the hash */
                var fnCleanHash = function(strHash) {
                                return (strHash.substring(1, strHash.length));
                }
                
                /* This method checks for changes in the location */
                var fnCheckLocation = function(){
                                // Check to see if the location has changed.
                                if (strLocation != window.location.href){
                                                
                                                // Store the new and previous locations.
                                                strPrevLocation = strLocation;
                                                strPrevHash = strHash;
                                                strLocation = window.location.href;
                                                strHash = window.location.hash;
                                                
                                                // The location has changed. Trigger a
                                                // change event on the location object,
                                                // passing in the current and previous
                                                // location values.
                                                $( window.location).trigger(
                                                                "change",
                                                                {
                                                                                currentHref: strLocation,
                                                                                currentHash: fnCleanHash( strHash ),
                                                                                previousHref: strPrevLocation,
                                                                                previousHash: fnCleanHash( strPrevHash )
                                                                }
                                                );
                                }
                }
                
                /* Set an interval to check the location */
                setInterval(fnCheckLocation, 100);
});

$(function() {
	$(window.location).bind(
		'change',
		function(objEvent, objData){
			if (objData.currentHash.length != 0) {
				$(".medical-terms li p").hide();
				$(".medical-terms li > a[name=" + objData.currentHash + "]").siblings('p').show();
			}
		}
	);
	
	$(window.location).trigger(
		'change',
        {
			currentHref: window.location.href,
			currentHash: window.location.hash.substring(1, window.location.hash.length)
		}
	);
});