﻿/**
 * HoverAccordion - jQuery plugin for intuitively opening accordions and menus
 * http://berndmatzner.de/jquery/hoveraccordion/
 * Copyright (c) 2007 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.2
 */
(function($){$.fn.hoverAccordion=function(options){options=jQuery.extend({speed:'normal',activateitem:'true',active:'active',header:'header',hover:'hover',opened:'opened',closed:'closed'},options);isHover=false;var u=window.location.href;function doHover(a){if($(a).html()==undefined)a=this;if(isHover==false){if($(a).children('ul').attr('opened')!=1){isHover=true;var b=$(a).parent().children('li').children('ul').filter(function(){return $(this).attr('opened')==1});$(a).children('ul').slideDown(options.speed).attr('opened',1);b.slideUp(options.speed).attr('opened',0).parent().children('a').addClass(options.closed).removeClass(options.opened);$(a).children('a').addClass(options.opened).removeClass(options.closed)}}resetHover=window.setTimeout("isHover=false",800)}function dontHover(){return true};itemNo=0;$(this).children('li').each(function(){itemNo++;$(this).children('a').hover(function(){$(this).addClass(options.hover)},function(){$(this).removeClass(options.hover)});var l=$(this).children('a');if(l.length>0){var h=l.attr('href');if(h=='#'){l.click(function(){return false})}else if(options.activateitem=='true'&&u.indexOf(h)>0&&u.length-u.lastIndexOf(h)==h.length){l.parent().addClass('active')}}if($(this).children('ul').length>0){$(this).children('ul').children('li.'+options.active).parent().parent().children('a').addClass(options.header);try{$(this).hoverIntent({sensitivity:1,interval:120,over:doHover,timeout:1200,out:dontHover}).children('ul').attr('opened',1)}catch(err){$(this).hover(function(){doHover(this)},function(){dontHover()}).children('ul').attr('opened',1)}if(options.activateitem=='true'){$(this).children('ul').children('li').each(function(){var m=$(this).children('a').attr('href');if(m){if(u.indexOf(m)>0&&u.length-u.lastIndexOf(m)==m.length){$(this).addClass('active')}}})}else if(parseInt(options.activateitem)==itemNo){$(this).addClass('active')}}$(this).children('ul').not($(this).parent().children('li.'+options.active).children('ul')).not($(this).children('ul').children('li.'+options.active).parent()).hide().attr('opened',0).parent().children('a').addClass(options.closed)})}})(jQuery);
