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