(function(g){var a={navigator:"navigator",container:"container",leftbtn:"leftbtn",rightbtn:"rightbtn",refresh:"refresh",dirbtn:"dirbtn",direct:"direct",layer:"layer",item:"item",focus:"focus",hover:"hover"},L={dirUrl:"/",dirVar:"dir",refreshButton:1},E=function(n,k){for(var o=0,e=0;e<n.length;e++){o+=n.charCodeAt(e)>255?2:1;if(o>k)break}if(o<=k)return n;for(k-=3;e--;){o-=n.charCodeAt(e)>255?2:1;if(o<=k)break}return n.substr(0,e+1)+"..."},F=g();g.fn.navigator=function(n){n=g.extend({},L,n||{});var k=
this.addClass(a.navigator).css("overflow","hidden"),o=0,e=g('<ul class="'+a.container+'" />').css({width:"auto",position:"absolute",left:0}),M=g("<ul/>"),t=0,G=function(d){var c=function(){if(!t){var b=d.pop();b===undefined||e.animate({left:b},"fast",c)}};c()},v=0,w=0,x=0,r=g('<div class="'+a.leftbtn+'" />').mousedown(function(){e.stop(1);t=0;v=1;r.addClass(a.focus);var d=e.position().left,c=r.outerWidth();if(!(d>=c)){for(var b=e.children("."+a.dirbtn),h=[],f=0,i=b.length;f<i;f++){var j=g(b[f]).position().left;
if(j+d<c)h.push(c-j);else break}G(h)}}).mouseup(function(){v&&(t=1,r.removeClass(a.focus),v=0)}).hover(function(){r.addClass(a.hover)},function(){r.removeClass(a.hover);v&&(t=1,r.removeClass(a.focus),v=0)}),l=g('<div class="'+a.rightbtn+'" />').mousedown(function(){e.stop(1);t=0;w=1;l.addClass(a.focus);var d=e.position().left,c=l.position().left;if(!(c>=e.outerWidth()+d)){for(var b=e.children("."+a.direct),h=[],f=b.length;f-- >0;){var i=g(b[f]),j=i.position().left;if(j+i.outerWidth()+d>c)h.push(c-
j-i.outerWidth());else break}G(h)}}).mouseup(function(){w&&(t=1,l.removeClass(a.focus),w=0)}).hover(function(){l.addClass(a.hover)},function(){l.removeClass(a.hover);w&&(t=1,l.removeClass(a.focus),w=0)});k.append(r).append(e).append(l);var p=null;if(n.refreshButton){p=g('<div class="'+a.refresh+'" />').mousedown(function(){x=1;p.addClass(a.focus)}).mouseup(function(){x&&(p.removeClass(a.focus),x=0,k.trigger("cd",[e.find("li.dirbtn:last").attr("path")]))}).hover(function(){p.addClass(a.hover)},function(){p.removeClass(a.hover);
x&&(p.removeClass(a.focus),x=0)});k.append(p);l.css("right",p.outerWidth())}else l.css("right",0);var y={},s={},N=function(d,c){var b=g('<li class="'+a.item+'"><span>'+E(d.name,20)+"</span></li>").click(function(){k.trigger("cd",[d.path]);c.data("btn").blur()}).hover(function(){b.addClass(a.hover)},function(){b.removeClass(a.hover)});c.append(b)},O=function(d){var c=0,b,h,f=function(){b&&(clearTimeout(b),b=null)},i=function(){h&&(clearTimeout(h),h=null)},j=function(){f();c&&h||(h=setTimeout(z,6E3))},
B=d.attr("path"),C=0,A=function(){i();f();if(!c){c=o=1;m.data("visable",1);m.addClass(a.focus);d.focus();var q=m.offset();u.css({top:q.top+parseInt(m.outerHeight()),left:q.left-9,display:"block"});setTimeout(function(){F.mousedown(H)},0);if(!C){C=1;g.ajax({dataType:"json",url:n.dirUrl,type:"POST",data:n.dirVar+"="+B,success:function(I){var D=0,J=I.length;if(J>0)for(u.empty();D<J;D++)N(I[D],u);else u.html('<li class="'+a.item+'">\u65e0\u5b50\u76ee\u5f55</li>')},complete:function(){C=0}})}}},z=function(){setTimeout(function(){F.unbind("mousedown",
H)},0);i();f();if(c){c=o=0;m.data("visable",0);m.removeClass(a.focus);d.blur();u.hide()}},H=function(q){q.target==u[0]||u.find(q.target.nodeName).index(q.target)!=-1||z()},m=g('<li class="'+a.direct+'"></li>').mousedown(function(){c?z():A()}).hover(function(){m.addClass(a.hover);if(o&&!c){for(var q in s)q==B||s[q].data("visable")&&s[q].blur();A()}else{i();c||b||(b=setTimeout(A,1792))}},function(){m.removeClass(a.hover);j()}).bind("blur",z).bind("focus",A),u=g('<ul class="'+a.layer+'" />').data("btn",
m).hover(i,j).css("display","none").appendTo(document.body);s[B]=m;d.after(m);return m},K=function(d,c){var b=g('<li class="'+a.dirbtn+'" path="'+d+'">'+E(c,20)+"</li>").appendTo(e),h=O(b);y[d]=b;if(d){var f=0;b.mousedown(function(){f=1;b.addClass(a.focus)}).mouseup(function(){f&&(b.removeClass(a.focus),k.trigger("cd",[d]),f=0)}).hover(function(){b.addClass(a.hover);if(o&&!h.data("visable")){for(var i in s)i==d||s[i].data("visable")&&s[i].blur();h.focus()}},function(){b.removeClass(a.hover);f&&(b.removeClass(a.focus),
f=0)}).focus(function(){b.addClass(a.focus)}).blur(function(){b.removeClass(a.focus)})}};k.bind("setNav",function(d,c,b){e.children().appendTo(M);g.isArray(c)||(c=c.split("/"));b?g.isArray(b)||(b=b.split("/")):b=[];d=c[0];var h=b[0]||c[0];y[d]?(e.append(y[d]),e.append(s[d])):K(d,h);for(var f=1,i=c.length;f<i;f++){d+="/"+c[f];h=b[f]||c[f];y[d]?(e.append(y[d]),e.append(s[d])):K(d,h)}var j=0;e.children().each(function(){j+=g.css(this,"width",false,"border")});e.css("width",j);j=e.outerWidth();k.innerWidth()-
(p?p.outerWidth():0)>j?(l.hide(),r.hide(),e.animate({left:0},"fast")):(l.show(),r.show(),e.animate({left:l.position().left-j},"fast"))});return this}})(jQuery);
