// Enable rel="external" links // JSTarget function by Roger Johansson, www.456bereastreet.com var JSTarget = { init: function(att,val) { if (document.getElementById && document.createElement && document.appendChild) { var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att; var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val; var oWarning; var arrLinks = document.getElementsByTagName('a'); var oLink; var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)"); for (var i = 0; i < arrLinks.length; i++) { oLink = arrLinks[i]; if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) { oWarning = document.createElement("em"); oLink.appendChild(oWarning); oLink.onclick = JSTarget.openWin; } } oWarning = null; } }, openWin: function(e) { var event = (!e) ? window.event : e; if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) { return true; } else { var oWin = window.open(this.getAttribute('href'), '_blank'); if (oWin) { if (oWin.focus) oWin.focus(); return false; } oWin = null; return true; } }, // addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html addEvent: function(obj, type, fn) { if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() {obj["e"+type+fn]( window.event );} obj.attachEvent("on"+type, obj[type+fn]); } } }; JSTarget.addEvent(window, 'load', function() {JSTarget.init("rel","external");}); // Hide the non-root lists $('#sidebar ul.menu > li > ul').hide(); // Append an arrow beside each parent that has a child element $('#sidebar ul.menu > li > ul').parent().find('a:first').after('>'); var toggleMenu = function () { var li = $(this).parent(); if ($(li).find('ul:first').css('display') == 'none') { // SlideUp everything that isn't a parent of this item $('#sidebar ul.menu').not($(li).parents()).slideUp(); $(li).find('ul:first').slideDown(); } else { $(li).find('ul:first').slideUp(); } } // Bind all parent ul's with the toggleMenu event $('#sidebar ul.menu > li > ul').parent().find('img.arrow').bind('click', toggleMenu); // Display the menu down to the level of the currently selected link var currentPage = $('#sidebar ul.menu').find('.selected'); if (currentPage) { $.each($(currentPage).parents('ul'), function () { $(this).show(); }); $(currentPage).find('a:first').addClass('hover'); $.each($(currentPage).parents('li'), function () { $(this).find('a:first').addClass('hover'); }); } // Show the child links for the currently selected page, if any exist $(currentPage).parent().find('ul:first').show();