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