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