window.onload = function() {
	Element.Storage={UID:1};Element.addMethods({getStorage:function(b){if(!(b=$(b))){return}if(Object.isUndefined(b._prototypeUID)){b._prototypeUID=Element.Storage.UID++}var a=b._prototypeUID;if(!Element.Storage[a]){Element.Storage[a]=$H()}return Element.Storage[a]},store:function(b,a,c){if(!(b=$(b))){return}b.getStorage().set(a,c);return b},retrieve:function(c,b,a){if(!(c=$(c))){return}var e=c.getStorage(),d=e.get(b);if(Object.isUndefined(d)){e.set(b,a);d=a}return d}});
	(function(){var b={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|mouse(?:down|up|over|move|out))$/};var a={pointerX:0,pointerY:0,button:0,ctrlKey:false,altKey:false,shiftKey:false,metaKey:false,bubbles:true,cancelable:true};Event.simulate=function(h,d){var f=Object.extend(a,arguments[2]||{});var c,g=null;h=$(h);for(var e in b){if(b[e].test(d)){g=e;break}}if(!g){throw new SyntaxError("Only HTMLEvents and MouseEvents interfaces are supported")}if(document.createEvent){c=document.createEvent(g);if(g=="HTMLEvents"){c.initEvent(d,f.bubbles,f.cancelable)}else{c.initMouseEvent(d,f.bubbles,f.cancelable,document.defaultView,f.button,f.pointerX,f.pointerY,f.pointerX,f.pointerY,f.ctrlKey,f.altKey,f.shiftKey,f.metaKey,f.button,h)}h.dispatchEvent(c)}else{f.clientX=f.pointerX;f.clientY=f.pointerY;c=Object.extend(document.createEventObject(),f);h.fireEvent("on"+d,c)}return h};Element.addMethods({simulate:Event.simulate})})();
	Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
	$$('#nav li ul').each(function(ul){
		var hide,animating = false;
		var li = ul.up('li');
		if (li.up('li')) return;
		ul.hide();
		li.down('a').addClassName('subnav');
		li.observe('mouseover',function(){
			clearTimeout(hide);
			var visible = ul.visible();
			li.addClassName('hover');
			if (!visible && !animating) {
				new Effect.BlindDown(ul.show().hide(),{afterFinish:function(){animating = false;},duration:0.2,queue:'end'});
				animating = true;
			}
		}).observe('mouseout',function(event){
			clearTimeout(hide);
			hide = function(){
				li.removeClassName('hover');
				ul.hide();
			}.delay(0.2);
		});
	});
	var active = false;
	var headings = $$('h4').each(function(element){
		var doBreak = false;
		var followers = [];
		var siblings = element.nextSiblings();
		var sibling = siblings.shift();
		while (sibling && sibling.tagName != 'H4' && !sibling.hasClassName('stop-bullets')) {
			followers.push(sibling.remove());
			sibling = siblings.shift();
		}
		element.store('content',followers);
		element.observe('click',function(){
			if (element.hasClassName('active')) return;
			if (active) {
				new Effect.Move(active,{
					afterFinish:function(){
						Element.remove(active);
					},
					duration:0.5,
					queue:'end',
					x:-320
				});
				$$('h4.active').each(function(heading){heading.removeClassName('active');});
			}
			var newActive = new Element('div',{'class':'sub-content-container'}).setStyle({left:'-320px'}).hide();
			newActive.insert(new Element('h4').update(element.innerHTML));
			element.addClassName('active').retrieve('content').each(function(contentItem){
				newActive.insert(contentItem);
			});
			newActive.insert(new Element('div',{'class':'sub-content-container-clear'}))
			$('content-image').insert(newActive);
			new Effect.Move(newActive,{
				afterFinish:function(){
					active = newActive;
				},
				beforeSetup:function(){
					newActive.show();
				},
				duration:0.5,
				queue:'end',
				x:320
			});
		});
	});
	// if (headings[0]) headings[0].addClassName('active').simulate('click');
}
