/**
 * HoverAccordion - jQuery plugin for intuitively opening accordions and menus
 * http://berndmatzner.de/jquery/hoveraccordion/
 * Copyright (c) 2008 Bernd Matzner
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Version: 0.5.0
 */

(function($){$.fn.hoverAccordion=function(options){options=jQuery.extend({speed:'fast',activateitem:'true',active:'active',header:'header',hover:'hover',opened:'opened',closed:'closed',keepheight:'true'},options);var thislist=this;var thisurl=window.location.href;var i=0;function doHover(obj){if($(obj).html()==undefined)obj=this;if(!thislist.is(':animated')){var newelem=$(obj).parent().children('ul');var oldelem=$(obj).parent().parent().children('li').children('ul:visible');if(options.keepheight=='true'){thisheight=maxheight;}else{thisheight=newelem.height();}if(!newelem.is(':visible')){newelem.children().hide();newelem.animate({height:thisheight},{step:function(n,fx){newelem.height(thisheight-n);},duration:options.speed}).children().show();oldelem.animate({height:'hide'},{step:function(n,fx){newelem.height(thisheight-n);},duration:options.speed}).children().hide();oldelem.parent().children('a').addClass(options.closed).removeClass(options.opened);newelem.parent().children('a').addClass(options.opened).removeClass(options.closed);}}};var itemNo=0;var maxheight=0;$(this).children('li').each(function(){var thisitem=$(this);itemNo++;var thislink=thisitem.children('a');if(thislink.length>0){thislink.hover(function(){$(this).addClass(options.hover);},function(){$(this).removeClass(options.hover);});var thishref=thislink.attr('href');if(thishref=='#'){thislink.click(function(){doHover(this);this.blur();return false;});}else if(options.activateitem=='true'&&thisurl.indexOf(thishref)>0&&thisurl.length-thisurl.lastIndexOf(thishref)==thishref.length){thislink.parent().addClass(options.active);}}var thischild=thisitem.children('ul');if(thischild.length>0){if(maxheight<thischild.height())maxheight=thischild.height();thischild.children('li.'+options.active).parent().parent().children('a').addClass(options.header);thislink.hover(function(){var t=this;i=setInterval(function(){doHover(t);clearInterval(i);},400);},function(){clearInterval(i);});if(options.activateitem=='true'){thischild.children('li').each(function(){var m=$(this).children('a').attr('href');if(m){if(thisurl.indexOf(m)>0&&thisurl.length-thisurl.lastIndexOf(m)==m.length){$(this).addClass(options.active).parent().parent().children('a').addClass(options.opened);}}});}else if(parseInt(options.activateitem)==itemNo){thisitem.addClass(options.active).children('a').addClass(options.opened);}}thischild.not($(this).parent().children('li.'+options.active).children('ul')).not(thischild.children('li.'+options.active).parent()).hide().parent().children('a').addClass(options.closed);});return this;};})(jQuery);

/*
(function(h){h.fn.hoverAccordion=function(a){function m(d,f,b){var e=h(o).find("."+a.classOpen).closest("li").find("ul:first");if(false===e.is(":animated")){if(a.keepHeight==true)b=k;if(f.hasClass(a.classOpen)==false){d.children().show();d.animate({height:b},{step:function(c){d.height(b-c)},duration:a.speed});e.animate({height:0},{step:function(c){d.height(b-c)},duration:a.speed}).children().hide();f.addClass(a.classOpen).removeClass(a.classClosed);e.closest("li").removeClass(a.classActive).find("a:first").addClass(a.classClosed).removeClass(a.classOpen)}}} a=jQuery.extend({speed:"fast",activateItem:true,keepHeight:false,onClickOnly:false,classActive:"active",classHeader:"header",classHover:"hover",classOpen:"opened",classClosed:"closed"},a);var o=this,g=window.location.href,l=0,n=0,k=0;h(this).children("li").each(function(){var d=h(this),f=false;n++;var b=d.find("a:first").addClass(a.classHeader);if(b.length>0){b.hover(function(){b.addClass(a.classHover)},function(){b.removeClass(a.classHover)});var e=b.attr("href");if(e=="#")b.click(function(){this.blur(); return false});else if(a.activateItem==true&&g.indexOf(e)>0&&g.length-g.lastIndexOf(e)==e.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}var c=d.find("ul:first");if(c.length>0){var i=c.height();if(k<i)k=i;a.onClickOnly==true?b.click(function(){m(c,b,i)}):b.hover(function(){l=setInterval(function(){m(c,b,i);clearInterval(l)},400)},function(){clearInterval(l)});if(a.activateItem==true)c.children("li").each(function(){var j=h(this).find("a").attr("href"); if(j)if(g.indexOf(j)>0&&g.length-g.lastIndexOf(j)==j.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}});else if(parseInt(a.activateItem,10)==n){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}if(!f){b.removeClass(a.classOpen);if(c.length>0){c.children().hide();b.addClass(a.classClosed)}}});return this}})(jQuery);
*/


