
// Created and set free in July of 2007 by Jenna .Blueberry. Fox <blueberry@creativepony.com>
// Released as public domain, with the request that credit is given for my contribution
// Also, I'd love to here where you've used or changed this code to do other interesting things!
// Requires MooTools 1.0 or newer with Accordion and Event

var AutoAccordion = Accordion.extend({
	initialize: function(handles, drawers, options) {
		this.addEvent('onActive', function(handle, i) {
			handle.addClass('selected');
		});
		this.addEvent('onBackground', function(handle, i) {
			handle.removeClass('selected');
		});
		
		// run parent initializer
		this.parent.apply(this, arguments);
		
		// this next part adds the automatic opening magic to each .Handle.
		this.togglers.each(function(handle, index, array) {
			// and the magic hover opening dealie!
			handle.hoverOpenTimer = null
/*			handle.getElement('a').addEvents({
				mouseover: function(thisHandle) {
					thisHandle.hoverOpenTimer = $clear(thisHandle.hoverOpenTimer);
					thisHandle.hoverOpenTimer = this.display.delay(300, this, index);
				}.bind(this, handle),
				mouseout: function(thisHandle) {
					thisHandle.hoverOpenTimer = $clear(thisHandle.hoverOpenTimer);
				}.bind(this, handle),
				focus: this.display.pass(index, this) // supports tab based keyboard navigation
			}); */
		}.bind(this));
	}
});


window.addEvent('domready', function(){
        var accordion = new Accordion('h4.atStart', 'div.atStart', {
                opacity: true,
                onActive: function(toggler, element){
                        toggler.setStyle('color', '#ff3300');
                },
                onBackground: function(toggler, element){
                        toggler.setStyle('color', '#595959');
                }
        }, $('accordion'));

//	var accordion = new AutoAccordion($$('.toggler', 'accordion'), $$('.element', 'accordion'));

});

/*
son of suckerfish menu script from:
http://www.htmldog.com/articles/suckerfish/dropdowns/
 */
 
 sfHover = function() {
        if (!document.getElementsByTagName) return false;
        var sfEls = document.getElementById("nav").getElementsByTagName("li");
        for (var i=0; i<sfEls.length; i++) {
                sfEls[i].onmouseover=function() {
                        this.className+=" sfhover";
                        this.style.zIndex=8200; //this line added to force flyout to be above relatively positioned stuff in IE
                }
                sfEls[i].onmouseout=function() {
                        this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
                }
        }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

