/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function(b){var e=function(){};b.extend(e.prototype,{name:"dropdownMenu",options:{mode:"default",itemSelector:"li",firstLevelSelector:"li.level1",dropdownSelector:"ul",duration:600,remainTime:800,remainClass:"remain",matchHeight:!0,transition:"easeOutExpo",withopacity:!0,centerDropdown:!1,reverseAnimation:!1,fixWidth:!1,fancy:null},initialize:function(e,j){this.options=b.extend({},this.options,j);var a=this,g=null,q=!1;this.menu=e;this.dropdowns=[];this.options.withopacity=b.browser.msie&&parseFloat(b.browser.version)<
9?!1:this.options.withopacity;if(this.options.fixWidth){var s=5;this.menu.children().each(function(){s+=b(this).width()});this.menu.css("width",s)}this.options.matchHeight&&this.matchHeight();this.menu.find(this.options.firstLevelSelector).each(function(p){var k=b(this),f=k.find(a.options.dropdownSelector).css({overflow:"hidden"});if(f.length){f.css("overflow","hidden");var d=b("<div>").data("dpwidth",parseFloat(f.width())).data("dpheight",parseFloat(f.height())).css({overflow:"hidden"}).append("<div></div>"),
e=d.find("div:first").css({"min-width":d.data("dpwidth"),"min-height":d.data("dpheight")});f.children().appendTo(e);d.appendTo(f);a.options.centerDropdown&&f.css("margin-left",(parseFloat(f.css("width"))/2-k.width()/2)*-1);a.dropdowns.push({dropdown:f,div:d,innerdiv:e})}k.bind({mouseenter:function(){q=!0;a.menu.trigger("menu:enter",[k,p]);if(g){if(g.index==p)return;g.item.removeClass(a.options.remainClass);g.div.hide()}if(f.length){k.addClass(a.options.remainClass);d.stop().show();var c=d.data("dpwidth"),
b=d.data("dpheight");switch(a.options.mode){case "showhide":c={width:c,height:b};d.css(c);break;case "diagonal":var h={width:0,height:0},c={width:c,height:b};if(a.options.withopacity)h.opacity=0,c.opacity=1;d.css(h).animate(c,a.options.duration,a.options.transition);break;case "height":h={width:c,height:0};c={height:b};if(a.options.withopacity)h.opacity=0,c.opacity=1;d.css(h).animate(c,a.options.duration,a.options.transition);break;case "width":h={width:0,height:b};c={width:c};if(a.options.withopacity)h.opacity=
0,c.opacity=1;d.css(h).animate(c,a.options.duration,a.options.transition);break;case "slide":f.css({width:c,height:b});d.css({width:c,height:b,"margin-top":b*-1}).animate({"margin-top":0},a.options.duration,a.options.transition);break;default:h={width:c,height:b};c={};if(a.options.withopacity)h.opacity=0,c.opacity=1;d.css(h).animate(c,a.options.duration,a.options.transition)}g={item:k,div:d,index:p}}else g=active=null},mouseleave:function(c){if(c.srcElement&&b(c.srcElement).hasClass("module"))return!1;
q=!1;f.length?window.setTimeout(function(){if(!(q||d.css("display")=="none")){a.menu.trigger("menu:leave",[k,p]);var b=function(){k.removeClass(a.options.remainClass);g=null;d.hide()};if(a.options.reverseAnimation)switch(a.options.mode){case "showhide":b();break;case "diagonal":var c={width:0,height:0};if(a.options.withopacity)c.opacity=0;d.stop().animate(c,a.options.duration,a.options.transition,function(){b()});break;case "height":c={height:0};if(a.options.withopacity)c.opacity=0;d.stop().animate(c,
a.options.duration,a.options.transition,function(){b()});break;case "width":c={width:0};if(a.options.withopacity)c.opacity=0;d.stop().animate(c,a.options.duration,a.options.transition,function(){b()});break;case "slide":d.stop().animate({"margin-top":parseFloat(d.data("dpheight"))*-1},a.options.duration,a.options.transition,function(){b()});break;default:c={};if(a.options.withopacity)c.opacity=0;d.stop().animate(c,a.options.duration,a.options.transition,function(){b()})}else b()}},a.options.remainTime):
a.menu.trigger("menu:leave")}})});if(this.options.fancy){var i=b.extend({mode:"move",transition:"easeOutExpo",duration:500,onEnter:null,onLeave:null},this.options.fancy),l=this.menu.append('<div class="fancy bg1"><div class="fancy-1"><div class="fancy-2"><div class="fancy-3"></div></div></div></div>').find(".fancy:first").hide(),n=this.menu.find(".active:first"),m=null,r=function(a,b){if(!b||!(m&&a.get(0)==m.get(0)))l.stop().show().css("visibility","visible"),i.mode=="move"?!n.length&&!b?l.hide():
l.animate({left:a.position().left+"px",width:a.width()+"px"},i.duration,i.transition):b?l.css({opacity:n?0:1,left:a.position().left+"px",width:a.width()+"px"}).animate({opacity:1},i.duration):l.animate({opacity:0},i.duration),m=b?a:null};this.menu.bind({"menu:enter":function(a,b,f){r(b,!0);if(i.onEnter)i.onEnter(b,f,l)},"menu:leave":function(a,b,f){r(n,!1);if(i.onLeave)i.onLeave(b,f,l)},"menu:fixfancy":function(){m&&l.stop().show().css({left:m.position().left+"px",width:m.width()+"px"})}});n.length&&
i.mode=="move"&&r(n,!0)}},matchHeight:function(){this.menu.find("li.level1.parent").each(function(){var e=0;b(this).find("ul.level2").each(function(){e=Math.max(b(this).height(),e)}).css("min-height",e)})}});b.fn[e.prototype.name]=function(){var o=arguments,j=o[0]?o[0]:null;return this.each(function(){var a=b(this);if(e.prototype[j]&&a.data(e.prototype.name)&&j!="initialize")a.data(e.prototype.name)[j].apply(a.data(e.prototype.name),Array.prototype.slice.call(o,1));else if(!j||b.isPlainObject(j)){var g=
new e;e.prototype.initialize&&g.initialize.apply(g,b.merge([a],o));a.data(e.prototype.name,g)}else b.error("Method "+j+" does not exist on jQuery."+e.name)})}})(jQuery);
