document.observe('dom:loaded', function() {
	// the print icon relies on javascript to work,
	// therefore we should insert it using javascript
	$$('#content div.print').invoke('observe', 'click', function(event) {
		event.stop();
		window.print();
	});
	
	// track all PDF downloads in a new tab
	$$('a[href$=.pdf]').invoke('observe', 'click', function(event) {
		// and track with Google Analytics, if installed
		Try.these(
			function() {
				pageTracker._trackPageview('/PDF/' + this.readAttribute('href')); }.bind(this),
			function() {
				urchinTracker('/PDF/' + this.readAttribute('href')); }.bind(this)
		);
	});
	
	// because we’re professionals: smooth scrolling anchors
	$$('a[href^=#]:not([href=#])').invoke('observe', 'click', function(event) {
		try {
			new Effect.ScrollTo(this.hash.substr(1));
		} catch (e) {}
	});
	
	try {
		var location_sub = /([^\/]+?)\/([^\/]+?)\.asp$/;
		var folder_name, file_name, window_location;
		window.location.href.gsub(location_sub, function (match) {
			window_location = match[0];
			folder_name = match[1];
			file_name = match[2];
		});
	
	
		$$('#menu a').each(function (element) {
			$(element).readAttribute('href').gsub(location_sub, function (match) {
				if (match[2] !== 'home') {
					if (match[0] === window_location) {
						element.addClassName('selected');
					}
			
					if (match[2] === folder_name) {
						element.addClassName('selected');
					}
				}
			});
		});
	
		$$('.sub a').each(function (element) {
			$(element).readAttribute('href').gsub(location_sub, function (match) {
				if (match[0] === window_location) {
					element.addClassName('selected');
				}
			});
		});
	} catch (err) {}
});