All pastes #173579 Raw Edit

yegs

public text v1 · immutable
·published 2006-09-17 02:43 UTC
rendered paste body
function init(){
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: false, height: true, duration: 400}
	);
	//check location hash
	var found = false;
	toggles.each(function(tog, i) {
		var link, links = tog.getElementsByTagName("a");
		if (links) {
			if (link = links[0]) { 
				if (window.location.href.indexOf(link.href) >= 0) {
					myAccordion.showThisHideOpen(stretchers[i]);
					found = true;
				}
			}
		}
	});
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
	// new section to give behavior to the extra link
	var extralink = document.getElementById('extraHello');
	if (extralink && stretchers[4]) {
		extralink.onclick = function() {
			myAccordion.showThisHideOpen(stretchers[4]);
		};
	}
}

--HTML--
<a id="extraHello" href="#fifth">Say Hello</a>