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