(function(b){b.fn.menu=function(o,c){var k,n,t,i;k=0;n="";t=0;i=o;c=b.extend({direction:"down",currentL1:0,inSpeed:500,outSpeed:500,closeDelay:100,showL3s:!0,reverseL2:!0,debug:!1},c);return this.each(function(){function o(){for(var a=0;a<i.length;a++){var h=b("#"+l.attr("id")+"_"+i[a].id),d=i[a].id;d==c.currentL1&&b("#"+l.attr("id")+"_"+d).addClass("on");var f,g;if(i[a].L2.length>0){l.after("<div id='L2"+j+"_"+d+"' class='submenu"+c.direction+"'></div>");f=b("#L2"+j+"_"+d);g=b("<div class='link-holder'></div>");
f.append(g);f.css("display","none");c.direction=="up"&&c.reverseL2&&i[a].L2.reverse();for(var e=0;e<i[a].L2.length;e++)if(typeof i[a].L2[e].url!=="undefined"){var p=i[a].L2[e].target==!0?"_blank":"_self",s=b(document.createElement("a")).addClass("subMenuItems"+c.direction).attr("href",i[a].L2[e].url).attr("target",p).attr("id","L2Item"+j+"_"+i[a].L2[e].id).append("<span>"+i[a].L2[e].title+"</span>");s.hover(function(){var a=b(this).attr("id").split("_")[1];y(a);if(b("#L3"+j+"_"+a).length>0){var h=
b("#L2Item"+j+"_"+a),d=b("#L3"+j+"_"+a),a=b("#L3"+j+"_"+a+" div:first"),e=h.getTopLeft(),f=h.parent().parent().parent();c.debug&&b.log(f.top+" : "+e.top);var g=0,i=0;switch(c.direction){case "up":g=parseInt(e.top)+parseInt(f.css("top"));i=parseInt(e.left)+parseInt(f.css("left"))+h.width();break;case "down":g=parseInt(e.top)+parseInt(f.css("top"));i=parseInt(e.left)+parseInt(f.css("left"))+h.width();break;case "left":case "right":g=parseInt(e.top)+parseInt(f.css("top"));i=parseInt(e.left)+parseInt(f.css("left"))+
h.width();break;case "horizontal":g=parseInt(e.top)+parseInt(f.css("top"))+h.height();i=parseInt(e.left)+parseInt(f.css("left"));break;default:g=parseInt(e.top)+parseInt(f.css("top")),i=parseInt(e.left)+parseInt(f.css("left"))+h.width()}d.css("top",g+"px");d.css("left",i+"px");h.addClass("on");a.queue("fx",[]).stop();d.show().css("z-index",1E3);switch(c.direction){case "up":a.animate({left:0},c.inSpeed);break;case "down":a.animate({left:0},c.inSpeed);break;case "left":case "right":a.animate({left:0},
c.inSpeed);break;case "horizontal":a.animate({top:0},c.inSpeed);break;default:a.animate({left:0},c.inSpeed)}}},function(){});g.append(s);if(i[a].L2[e].L3.length>0&&c.showL3s){var q;l.after("<div id='L3"+j+"_"+i[a].L2[e].L3[0].parentid+"' class='L3Menu"+c.direction+"'></div>");q=b("#L3"+j+"_"+i[a].L2[e].L3[0].parentid);q.css("display","none");for(var m=0;m<i[a].L2[e].L3.length;m++)typeof i[a].L2[e].L3[m].url!=="undefined"&&(p=i[a].L2[e].L3[m].target==!0?"_blank":"_self",p=b(document.createElement("a")).addClass("L3MenuItems"+
c.direction).attr("href",i[a].L2[e].L3[m].url).attr("target",p).append("<span>"+i[a].L2[e].L3[m].title+"</span>"),p.hover(function(){k=d;clearTimeout(n);c.debug&&b.log("CLEARED TIMEOUT")},function(){k=0;n=setTimeout(function(){r()},c.closeDelay);c.debug&&b.log("L3 OUT!")}),q.append(p));q.prepend("<div id='L3menu-header'><\!-- --\></div>").append("<div id='L3menu-footer'><\!-- --\></div>").wrapInner("<div id='holder'></div>").css("overflow","hidden");m=q.children();m.children().filter(function(){return b(this).attr("id")==
"L3menu-header"||b(this).attr("id")=="L3menu-footer"}).hover(function(){k=d;clearTimeout(n)},function(){k=0;n=setTimeout(function(){r()},c.closeDelay)});s.data("hasMenu",!0).addClass("submenu");z(q)}}e=!isNaN(parseInt(h.attr("hoffset")))?h.attr("hoffset"):0;s=!isNaN(parseInt(h.attr("voffset")))?h.attr("voffset"):0;g.children(":first").addClass("first-link");g.children(":last").addClass("last-link");g.hover(function(){k=d;clearTimeout(n)},function(){k=0;n=setTimeout(function(){r()},c.closeDelay);c.debug&&
b.log("L2 HOLDER OUT")});f.prepend("<div id='menu-header'><\!-- --\></div>").append("<div id='menu-footer'><\!-- --\></div>").wrapInner("<div id='holder'></div>").css("overflow","hidden").data("hOffset",e).data("vOffset",s);m=f.children();m.children().filter(function(){return b(this).attr("id")=="menu-header"||b(this).attr("id")=="menu-footer"}).hover(function(){k=d;clearTimeout(n)},function(){k=0;n=setTimeout(function(){r()},c.closeDelay)});m.children().filter(function(){return b(this).attr("id")!=
"menu-header"||b(this).attr("id")!="menu-footer"}).filter("div:first").addClass("menufirst");m.children().filter(function(){return b(this).attr("id")!="menu-header"||b(this).attr("id")!="menu-footer"});h.data("hasMenu",!0);A(f)}}B();t=b(".L3Menu"+c.direction);c.direction=="horizontal"&&($obj=b("#"+l.attr("id")+"_"+c.currentL1),$obj.data("hasMenu")&&(a=$obj.data("pageID"),u(a)))}function B(){var a=b("#"+l.attr("id")+" li a");a.each(function(){$obj=b(this);$obj.data("pageID",b(this).attr("id").substring(l.attr("id").length+
1,b(this).attr("id").length))});a.hover(function(){v();c.direction=="horizontal"&&w(c.currentL1);var a=b(this);a.addClass("hover");a.data("hasMenu")&&(k=a=a.data("pageID"),u(a))},function(){var a=b(this);a.data("pageID");a.data("hasMenu")?(k=0,n=setTimeout(function(){r()},c.closeDelay)):a.removeClass("hover");c.direction=="horizontal"&&!a.data("hasMenu")&&(n=setTimeout(function(){r()},c.closeDelay))});c.debug&&b.log("Menu Actions Built")}function r(){v();b("#"+l.attr("id")+" li a").each(function(){var a=
b(this).attr("id").split("_")[1];a!=k&&w(a);c.direction=="horizontal"&&c.currentL1==a&&k==0&&u(c.currentL1)})}function v(){$L3s=t;$L3s.each(function(){var a=b(this).attr("id").split("_")[1];x(a,!1)})}function y(a){$L3s=t;$L3s.each(function(){var c=b(this).attr("id").split("_")[1];c!=a&&x(c)})}function A(a){var b=0,d=0;switch(c.direction){case "up":b=a.height();d=0;break;case "down":b=a.height()*-1;d=0;break;case "right":b=0;d=0-a.width();break;case "left":b=0;d=a.width();break;case "horizontal":b=
a.height()*-1;d=0;break;default:b=a.height()*-1,d=0}a.children("#holder").css("top",b).css("left",d).css("position","relative")}function u(a){c.debug&&b.log("animate menu");var h=b("#"+l.attr("id")+"_"+a),d=b("#L2"+j+"_"+a),a=b("#L2"+j+"_"+a+" div:first");c.debug&&b.txt(a);var f=h.getTopLeft(),g=0,e=0;switch(c.direction){case "up":g=parseInt(f.top)-parseInt(d.height())+parseInt(d.data("vOffset"));e=parseInt(f.left)+parseInt(d.data("hOffset"));break;case "down":g=parseInt(f.top)+h.height()+parseInt(d.data("vOffset"));
e=parseInt(f.left)+parseInt(d.data("hOffset"));break;case "left":g=parseInt(f.top)+parseInt(d.data("vOffset"));e=parseInt(f.left)-d.width()+parseInt(d.data("hOffset"));break;case "right":g=parseInt(f.top)+parseInt(d.data("vOffset"));e=parseInt(f.left)+h.width()+parseInt(d.data("hOffset"));break;case "horizontal":f=l.getTopLeft();g=parseInt(f.top)+l.height()+parseInt(d.data("vOffset"));e=parseInt(f.left)+parseInt(d.data("hOffset"));break;default:g=parseInt(f.top)+h.height()+parseInt(d.data("vOffset")),
e=parseInt(f.left)+parseInt(d.data("hOffset"))}d.css("top",g+"px");d.css("left",e+"px");h.addClass("hover");a.queue("fx",[]).stop();d.show().css("z-index",1E3);c.debug&&b.log("SPEED:"+c.inSpeed);switch(c.direction){case "up":a.animate({top:0},c.inSpeed);break;case "down":a.animate({top:0},c.inSpeed);break;case "left":a.animate({left:0},c.inSpeed);break;case "right":a.animate({left:0},c.inSpeed);break;case "horizontal":a.animate({top:0},c.inSpeed);break;default:a.animate({top:0},c.inSpeed)}}function w(a){var h=
b("#"+l.attr("id")+"_"+a),d=b("#L2"+j+"_"+a),a=b("#L2"+j+"_"+a+" div:first"),f=0,f=0;h.removeClass("hover");d.css("z-index",c.outSpeed);a.queue("fx",[]).stop();switch(c.direction){case "up":f=d.height();a.animate({top:f},c.outSpeed);break;case "down":f=parseInt(d.height())*-1;a.animate({top:f},c.outSpeed);break;case "right":f=0-parseInt(d.width());a.animate({left:f},c.outSpeed);break;case "left":f=parseInt(d.width())*2;a.animate({left:f},c.outSpeed);break;case "horizontal":f=parseInt(d.height())*
-1;a.animate({top:f},c.outSpeed);break;default:f=parseInt(d.height())*-1,a.animate({top:f},c.outSpeed)}a.queue(function(){b(this).parent().hide();b(this).dequeue()})}function z(a){var b=0,d=0;switch(c.direction){case "up":b=0;d=0-a.width();break;case "down":b=0;d=0-a.width();break;case "right":b=0;d=0-a.width();break;case "left":b=0;d=a.width()*2;break;case "horizontal":b=a.height()*-1;d=0;break;default:b=0,d=0-a.width()}a.children("#holder").css("top",b).css("left",d).css("position","relative")}
function x(a,h){var h=typeof h!="undefined"?h:!0,d=b("#L2Item"+j+"_"+a),f=b("#L3"+j+"_"+a),g=b("#L3"+j+"_"+a+" div:first"),e=0,e=0;d.removeClass("on");f.css("z-index",c.outSpeed);g.queue("fx",[]).stop();switch(c.direction){case "up":e=0-parseInt(f.width());h?g.animate({left:e},c.outSpeed):g.css("left",e+"px");break;case "down":e=0-parseInt(f.width());h?g.animate({left:e},c.outSpeed):g.css("left",e+"px");break;case "right":e=0-parseInt(f.width());h?g.animate({left:e},c.outSpeed):g.css("left",e+"px");
break;case "left":e=parseInt(f.width())*2;g.animate({left:e},c.outSpeed);break;case "horizontal":e=parseInt(f.height())*-1;h?g.animate({top:e},c.outSpeed):g.css("top",e+"px");break;default:e=0-parseInt(f.width()),h?g.animate({left:e},c.outSpeed):g.css("left",e+"px")}g.queue(function(){b(this).parent().hide();b(this).dequeue()})}var j=b.getNextID(),l=b(this);i.length>0?o():c.debug&&b.log("No Data to build the menu with");if(c.outSpeed==0)c.outSpeed=1;if(c.inSpeed==0)c.inSpeed=1})};b.fn.menu.version=
function(){window.console&&console.debug("Menu Plugin, Version: 3.5.1")}})(jQuery);(function(){var b=0;jQuery.getNextID=function(){return b++}})(jQuery);jQuery.txt=function(){return this.each(function(){$.log(this)})};jQuery.log=function(b){if(window.console){var o=b;if(typeof b=="object"){for(var o="&lt;",c=0;c<b.attributes.length;c++)o+=" "+b.attributes[c].nodeName.toLowerCase()+'="'+b.attributes[c].nodeValue+'"';o+="&gt;"}console.debug(o)}};
