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