(function(o,e){"use strict"; var t=o(".nav"),s=t.children("li").children("a"),i=t.find("ul").find("a"),n=t.find("ul").length,r=function(e){this.themecolor={blue:{},dark:{}},this.defaults={},this.settings=o.extend({},this.defaults,e),this.settings.itemwidth=this.settings.itemwidth-0,this.ismobile=!!navigator.useragent.match(/applewebkit.*mobile.*/)}; r.prototype={init:function(){this.setdefaulttheme().setdefinedtheme().setfirstmenu().setsecondmenu().responsivelayout().supportfastclick()},setdefaulttheme:function(){function e(o,e){s.css({color:o,backgroundcolor:e}),i.css({color:o,backgroundcolor:e})}function n(e,s){var i,n; t.find("a").hover(function(){var t=o(this); t.css("color"); n=t.css("backgroundcolor"),t.css({color:e,backgroundcolor:s})},function(){o(this).css({color:i,backgroundcolor:n})})}var r=this; switch(r.settings.theme){case"blue":e(r.themecolor.blue.fontcolor,r.themecolor.blue.bgcolor),!r.ismobile&&n(r.themecolor.blue.hoverfontcolor,r.themecolor.blue.hoverbgcolor); break; case"dark":e(r.themecolor.dark.fontcolor,r.themecolor.dark.bgcolor),!r.ismobile&&n(r.themecolor.dark.hoverfontcolor,r.themecolor.dark.hoverbgcolor)}return r},setdefinedtheme:function(){var o=this.settings.theme; return o&&"string"==typeof o&&"blue"!=o&&(this.settings.fontcolor=this.themecolor[o].fontcolor,this.settings.bgcolor=this.themecolor[o].bgcolor,this.settings.hoverfontcolor=this.themecolor[o].hoverfontcolor,this.settings.hoverbgcolor=this.themecolor[o].hoverbgcolor,this.settings.subfontcolor=this.themecolor[o].fontcolor,this.settings.subbgcolor=this.themecolor[o].bgcolor,this.settings.subhoverfontcolor=this.themecolor[o].hoverfontcolor,this.settings.subhoverbgcolor=this.themecolor[o].hoverbgcolor),this},setfirstmenu:function(){var e=this; return s.css({height:e.settings.height,lineheight:e.settings.height+"px",fontsize:e.settings.fontsize,color:e.settings.fontcolor,backgroundcolor:e.settings.bgcolor}).parent("li").each(function(t,s){var i=o(this); i.width()}).not(t.children("li").first()).css({}),e},setsecondmenu:function(){var e=this; return n&&(i.css({height:e.settings.height,lineheight:e.settings.height+"px",fontsize:e.settings.subfontsize,color:e.settings.subfontcolor,backgroundcolor:e.settings.subbgcolor}).parent("li").css({height:e.settings.height,lineheight:e.settings.height+"px"}),o.each(s,function(t,i){var n=o(this).next("ul"); n.css("top",e.settings.height),n.width()+e.settings.itemwidth
'),n=o(".btnopen"),n.css("",0).on("click",function(){o(".zhe").length||o(".menu").length||o('
').css("background",s.settings.mmaskcolor).appendto(".topbar").after('").next().find("ul, li, a").removeattr("style"),r?(s.animate(o(".zhe"),r,s.settings.speed,"open"),s.animate(o(".menu"),r,s.settings.speed,"open")):(o(".zhe").show(),o(".menu").show()),o(".menu > li").not(".btnclose").find("ul").find("a").css({background:s.settings.msubbgcolor,color:s.settings.msubfontcolor}),o(".menu > li").not(".btnclose").unbind("click").on("click",function(e){r?o(this).find("ul").toggle(150):o(this).find("ul").toggle()}),o(".btnclose").css("",s.settings.mclosebtncolor).children("div").on("click",function(){r?(s.animate(o(".zhe"),r,s.settings.speed,"close"),s.animate(o(".menu"),r,s.settings.speed,"close")):(o(".zhe").hide(),o(".menu").hide())})}).children("div").css(s.settings.mmenubtncolor)):n.length&&(t.show(),n.hide()),s},supportfastclick:function(){if(this.ismobile)try{fastclick&&fastclick.attach(document.body)}catch(o){console.log("fastclick.js is not found.you are still using normal 'click'")}else this.sethovercss(); return this},animate:function(o,e,t,s){var i={},n={}; switch(e){case"fade":"open"==s?(o.hide(),o.fadein(t)):"close"==s&&o.fadeout(t); break; case"slide":o.stop(!0,!0),"open"==s?(i.height=0,n.height="100%"):"close"==s&&(i.height="100%",n.height=0),o.css(i).animate(n,t)}}},o.fn.menu=function(e){var t=new r(e); return t.init(),o(window).resize(function(o){t.responsivelayout()}),this}})(jquery,window);