Event.observe(window, 'load', function() {
	// do some CSS magic for no javascript version
	
	Element.addClassName('container', 'hasjs');
		var title = document.title;
	/*Element.addClassName($$('ol#pageNav li a').first(), 'active');
		
		var firstToShow = $$('ol#pageNav li a').first();

				firstToShow = firstToShow.id.substring(3);
				
				Element.addClassName(firstToShow, 'active');*/
				
				
		// find the default
		var id = 0;
		if (document.location.hash) {
			var initial = document.location.hash;
			initial = initial.match(/#(.*)/)[1];
			
			
			// set the page title
			var name = $('pn_'+initial);
			name = name.lastChild.nodeValue;
		    document.title = name+' / '+title;
		
		}else{
			Element.addClassName($$('ol#pageNav li a.swaphandle').first(), 'active');

			var firstToShow = $$('ol#pageNav li a.swaphandle').first();

		    firstToShow = firstToShow.id.substring(3);

			Element.addClassName(firstToShow, 'active');
						
			// set the page title
			var name = $('pn_'+firstToShow);
			name = name.lastChild.nodeValue;
			document.title = name+' / '+title;	
		 
		}
	
		Element.addClassName('pn_'+initial, 'active');
		Element.addClassName(initial, 'active');
	

	
	$$('ol#pageNav li a.swaphandle').each ( function(element) {
			// set a click event on the links
			Event.observe(element, 'click', function(event) {
				Event.stop(event);
				 
				
				var anchor = element.href.substring(40);
				
			    // alert(anchor);		
				// document.location.hash = anchor;
				
				$$('ol#pageNav li a.swaphandle').each ( function(element) { element.removeClassName('active'); });
				
				
				Element.addClassName(element, 'active');
				
				var toShow = element.id.substring(3);
												
				$$('.swapsection').each ( function(element) { element.removeClassName('active'); });
				Element.addClassName(toShow, 'active');
				
				// set the page title
				var name = element.lastChild.nodeValue;
				document.title = name+' / '+title;
				
		    })
		
		});
		
		
}, false);