/*
	DMXzone Navigation Menu
	Version 1.0.2
	Copyright (c) 2009-2010
*/
(function(b){b.fn.extend({dmxNavigationMenu:function(c){return this.each(function(){b.extend(this,new b.dmxNavigationMenu(this,c))})}});b.fn.hoverIntent=function(l,k){var m={sensitivity:7,interval:100,timeout:0};m=b.extend(m,k?{over:l,out:k}:l);var o,n,i,e;var h=function(f){o=f.pageX;n=f.pageY};var d=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(i-o)+Math.abs(e-n))<m.sensitivity){b(f).unbind("mousemove",h);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{i=o;e=n;f.hoverIntent_t=setTimeout(function(){d(g,f)},m.interval)}};var j=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var c=function(r){var q=(r.type=="mouseover"?r.fromElement:r.toElement)||r.relatedTarget;while(q&&q!=this){try{q=q.parentNode}catch(r){q=this}}if(q==this){return false}var g=b.extend({},r);var f=this;if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(r.type=="mouseover"){i=g.pageX;e=g.pageY;b(f).bind("mousemove",h);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){d(g,f)},m.interval)}}else{b(f).unbind("mousemove",h);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){j(g,f)},m.timeout)}}};return this.mouseover(c).mouseout(c)};b.fn.extend({fixPNG:function(){if((window.XMLHttpRequest==undefined)&&(ActiveXObject!=undefined)){return this.each(function(){if(this.nodeName!="IMG"){return}var g=b(this);var i=g.attr("src");if(/\.png$/i.test(i)){var e=(g.attr("id"))?'id="'+g.attr("id")+'" ':"";var f=(this.className)?'class="'+this.className+'" ':"";var h=(g.attr("title"))?'title="'+g.attr("title")+'" ':'title="'+g.attr("alt")+'" ';var d=this.style.cssText+";display:inline-block;";if(this.align=="left"){d+="float:left;"}if(this.align=="right"){d+="float:right"}if(this.parentElement.href){d+="cursor:hand;"}var c="<span "+e+f+h+' style="width:'+this.getAttribute("width",2)+"px;height:"+this.getAttribute("height",2)+"px;"+d+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"', sizingMethod='scale');\"></span>";this.outerHTML=c}})}else{return this}}});b.dmxNavigationMenu=function(e,n){n=b.extend({},b.dmxNavigationMenu.defaults,n);var r=this;b(e).addClass("dmxNavigationMenu");b("img",e).fixPNG();if(b(e).hasClass("contextMenu")){if(n.contextButton=="right"){document.oncontextmenu=function(){return false}}b(n.contextTarget).bind("mousedown",t);b(document).bind("mousedown",l);b(e).appendTo("body").css({position:"absolute"}).hide()}var g=b(">ul",e);var F=g.children("li");b("ul.icon-top>li>a:not(.icon-left)",e).addClass("icon-top");b("li:not([class],:has(>a))",e).addClass("label");F.addClass("main");if(n.showSelected){var w=b("a",e);var d=[];for(var z=0;z<w.length;++z){var m=w.eq(z);var A=m.attr("href");if(!A||A.length<2){continue}var u=window.location;var D=new a(A);if(u.toString()===D.toString()){d=[];m.addClass("selected");break}if(A.indexOf("://")>-1&&u.hostname!==D.hostName){continue}if(u.pathname===D.pathname){var s=0,B=0;var v=u.search.substring(1).replace("&amp;","&").split("&");var E=D.search.substring(1).replace("&amp;","&").split("&");if(!C(E,v)){continue}s=E.length;if(D.hash.length>0&&D.hash===u.hash){B=1}d.push({j:m,q:s,h:B})}}if(d.length>0){d.sort(function(i,h){if(i.q==h.q){return(i.h==h.h)?0:(i.h<h.h)?1:-1}else{return(i.q<h.q)?1:-1}});d[0].j.addClass("selected")}g.find("a.selected").parents("ul").parent().find(">a").addClass("selected");w.bind("click.menu",y)}g.find("ul").each(function(){var h=b(this).attr("style");if(!(/\bwidth\b/i.test(h))){b(this).css({width:n.menuWidth})}});g.find("ul.mega").each(function(){var M=b(">li",this);var q=b(this).attr("class").match(/\bcols-(\d+)\b/);var K=q&&q.length>1?parseInt(q[1]):M.index(M.filter(function(){return this.style.clear=="left"}));if(K==-1){K=M.length}else{M.css({clear:""}).filter(":nth-child("+K+"n)+li").css({clear:"left"})}var I=[];for(var H=0;H<K;++H){I[H]=0}var h=M.eq(0).find(">ul").eq(0);var L=parseFloat(h.css("paddingLeft"))||0;L+=parseFloat(h.css("paddingRight"))||0;L+=parseFloat(h.css("borderLeftWidth"))||0;L+=parseFloat(h.css("borderRightWidth"))||0;L+=parseFloat(h.css("marginLeft"))||0;L+=parseFloat(h.css("marginRight"))||0;M.each(function(N){var i=parseFloat(b(">ul",this).css("width"))||n.menuWidth;if(I[N%K]<i){I[N%K]=i}}).each(function(i){b(this).width(I[i%K]+L)});var J=K*L;b.each(I,function(){J+=this});b(this).css({width:J})});g.find("li:has(>ul.mega,>ul.sub)>a").each(function(){var h=b(this).addClass("expandable");if(!h.is(":has(span[class^=sub_])")){if(h.closest("ul").hasClass("horizontal")){h.append('<span class="sub_down"></span>')}else{h.append('<span class="sub_right"></span>')}}});b("ul.sub,ul.mega",e).hide();g.find("li.active>ul").show();if(n.showOnMouseOver){g.find("li").hoverIntent({over:p,out:p,timeout:n.timeout})}else{g.find("li").click(f);b(document).click(f)}if(n.keyboard){g.find("li>a").mouseover(function(h){b(this).focus()});g.find("li>a").focus(c);g.bind("keydown",k)}function C(q,H){if(b.isArray(q)){for(var h=0;h<q.length;++h){if(!C(q[h],H)){return false}}return true}else{for(var h=0;h<H.length;++h){if(H[h]===q){return true}}}return false}function x(i,h){while(i!=h&&i.parentNode){i=i.parentNode}return(i==h)}function t(J){if(J.target&&!x(J.target,g.get(0))){var H={left:1,middle:2,right:3};if(J.which==H[n.contextButton]){var L,h;var i=b(window).width();var K=b(window).height();var q=b(J.target).offset();var I=q.top-b(document).scrollTop();var O=K-(I+b(J.target).outerHeight());var M=q.left-b(document).scrollLeft();var N=i-(M+b(J.target).outerWidth());switch(n.contextPosition){case"top":L=q.top-b(e).outerHeight();h=q.left;if(I<b(e).outerHeight(true)&&O>I){L=q.top+b(J.target).outerHeight()}if(i-M<b(e).outerWidth(true)){h=q.left-(M-(i-b(e).outerWidth(true)))}break;case"bottom":L=q.top+b(J.target).outerHeight();h=q.left;if(O<b(e).outerHeight(true)&&I>O){L=q.top-b(e).outerHeight(true)}if(i-M<b(e).outerWidth(true)){h=q.left-(M-(i-b(e).outerWidth(true)))}break;case"left":L=q.top;h=q.left-b(e).outerWidth();if(K-I<b(e).outerHeight(true)){L=q.top-(I-(K-b(e).outerHeight(true)))}if(N<b(e).outerWidth(true)&&N>M){h=q.left+b(J.target).outerWidth()}break;case"right":L=q.top;h=q.left+b(J.target).outerWidth();if(K-I<b(e).outerHeight(true)){L=q.top-(I-(K-b(e).outerHeight(true)))}if(N<b(e).outerWidth(true)&&M>N){h=q.left-b(e).outerWidth(true)}break;default:L=J.pageY;h=J.pageX;break}b(e).css({top:L,left:h}).show();return false}}}function l(h){if(h.which==1&&h.target&&!x(h.target,g.get(0))){b(".contextMenu").hide().find(".active").each(function(){b(this).removeClass("active");b(">ul",this).stop(true,true).hide()})}}function c(h){g.find("li.focus").removeClass("focus");b(this).parent("li").addClass("focus")}function j(h){}function k(J){var I=g.find("li.focus");if(J.which==27){I.removeClass("focus");g.find("li.active").each(function(){G(b(this))})}if(I.hasClass("main")&&g.hasClass("horizontal")){switch(J.which){case 37:var K=I.parent().children(":has(>a)");var H=K.index(I)-1;if(H<0){H=K.length-1}K.eq(H).find(">a").trigger("focus");break;case 39:var K=I.parent().children(":has(>a)");var H=K.index(I)+1;if(H>=K.length){H=0}K.eq(H).find(">a").trigger("focus");break}var h=40;if(g.hasClass("main_up")){h=38}if(J.which==h){if(b(">ul",I).length===1){I.siblings(".active").each(function(){b(this).removeClass("active");b(">ul",this).stop(true,true).hide()});I.addClass("active");o(I);I.find(">ul>li>a:first").trigger("focus")}}}else{switch(J.which){case 38:var K=I.parent().children(":has(>a)");var H=K.index(I)-1;if(H<0){H=K.length-1}K.eq(H).find(">a").trigger("focus");break;case 40:var K=I.parent().children(":has(>a)");var H=K.index(I)+1;if(H>=K.length){H=0}K.eq(H).find(">a").trigger("focus");break}var h=39;if(g.hasClass("sub_left")){h=37}if(J.which==h){if(b(">ul",I).length===1){I.siblings(".active").each(function(){b(this).removeClass("active");b(">ul",this).stop(true,true).hide()});I.addClass("active");o(I);I.find(">ul>li>a:first").trigger("focus")}}if(J.which==37){var q=I.parents("li").eq(0);q.find(">a").trigger("focus");G(q)}}}function y(h){g.find("a.selected").removeClass("selected");b(this).addClass("selected");g.find("a.selected").parents("ul").parent().find(">a").addClass("selected")}function f(K){if(K.originalTarget&&!x(K.originalTarget,K.currentTarget)){return}K.stopPropagation();var i,J,L;var q=b(K.currentTarget);var I=q.find(">ul.sub,>ul.mega");var H=I.length>0?true:false;var h=!q.hasClass("active");if(K.currentTarget!=document){q.siblings(".active").each(function(){b(this).trigger("click")})}else{g.find(">li.active").each(function(){b(this).trigger("click")})}if(!H){return}if(h){q.addClass("active");o(q)}else{q.removeClass("active");q.find(".active").each(function(){b(this).removeClass("active");b(">ul",this).stop(true,true).hide()});G(q)}return false}function p(K){var i,J,L;var q=b(K.currentTarget);var I=q.find(">ul.sub,>ul.mega");var H=I.length>0?true:false;var h=K.type=="mouseover"?true:false;if(h){q.siblings(".active").each(function(){this.hoverIntent_t=clearTimeout(this.hoverIntent_t);this.hoverIntent_s=0;var M=new b.Event("mouseout");M.currentTarget=this;p(M)})}if(!H){return}if(h){q.addClass("active");o(q)}else{q.removeClass("active");q.find(".active").each(function(){this.hoverIntent_t=clearTimeout(this.hoverIntent_t);this.hoverIntent_s=0;b(this).removeClass("active");b(">ul",this).stop(true,true).hide()});G(q)}}function o(N){var i=N.find(">ul.sub,>ul.mega");var L,h;var q=b(window).width();var K=b(window).height();if(o){i.show()}var I=i.offsetParent();if(o){i.hide()}var H=I.offset();var J=H.top-b(document).scrollTop();var P=K-(J+I.outerHeight());var M=H.left-b(document).scrollLeft();var O=q-(M+I.outerWidth());if(i.parents("ul:first").hasClass("horizontal")){if(g.hasClass("main_up")){i.data("direction","up");L="-"+i.outerHeight(true)+"px";if(J<i.outerHeight(true)&&P>J){L=I.outerHeight()+"px";i.data("direction","down")}}else{i.data("direction","down");L=I.outerHeight()+"px";if(P<i.outerHeight(true)&&J>P){L="-"+i.outerHeight(true)+"px";i.data("direction","up")}}if(g.hasClass("sub_left")){h=(I.outerWidth()-i.outerWidth(true))+"px";if(q-O<i.outerWidth(true)){h="-"+M+"px"}}else{h="0px";if(q-M<i.outerWidth(true)){h="-"+(M-(q-i.outerWidth(true)))+"px"}}}else{if(g.hasClass("main_up")){L="-"+(i.outerHeight(true)-I.outerHeight())+"px";if(J-(i.outerHeight(true)-I.outerHeight())<0){L="-"+J+"px"}}else{L="0px";if(K-J<i.outerHeight(true)){L="-"+(J-(K-i.outerHeight(true)))+"px"}}if(g.hasClass("sub_left")){i.data("direction","left");h="-"+(i.outerWidth()-5)+"px";if(M<i.outerWidth(true)-5&&O>M){h=(I.outerWidth()-5)+"px";i.data("direction","right")}}else{i.data("direction","right");h=(I.outerWidth()-5)+"px";if(O<i.outerWidth(true)-5&&M>O){h="-"+(i.outerWidth(true)-5)+"px";i.data("direction","left")}}}i.css({top:L,left:h,bottom:"auto",right:"auto"});if(N.hasClass("main")){effect=n.mainShowEffect;duration=n.mainShowDuration;easing=n.mainShowEasing}else{effect=n.subShowEffect;duration=n.subShowDuration;easing=n.subShowEasing}if(b.dmxNavigationMenu.effects[effect]){b.dmxNavigationMenu.effects[effect](i,true,duration,easing)}else{i.show()}}function G(h){var i=h.find(">ul.sub,>ul.mega");if(h.hasClass("main")){effect=n.mainHideEffect;duration=n.mainHideDuration;easing=n.mainHideEasing}else{effect=n.subHideEffect;duration=n.subHideDuration;easing=n.subHideEasing}if(b.dmxNavigationMenu.effects[effect]){b.dmxNavigationMenu.effects[effect](i,false,duration,easing)}else{i.hide()}}};b.dmxNavigationMenu.effects={fade:function(e,c,d,f){e.stop(true,true).animate({opacity:c?"show":"hide"},{duration:d,easing:f})},slide:function(d,k,e,g){d.stop(true,true);var i=d.data("direction")=="down"||d.data("direction")=="right";var j=parseFloat(d.css("top"));var c=parseFloat(d.css("left"));var l=d.outerWidth(true);var f=d.outerHeight(true);if(d.parents("ul:first").hasClass("horizontal")){if(k&&!i){d.css({top:j+f})}d.animate({height:k?"show":"hide",marginTop:k?"show":"hide",marginBottom:k?"show":"hide",paddingTop:k?"show":"hide",paddingBottom:k?"show":"hide",top:(i)?j:(k?"-=":"+=")+f+"px"},{duration:e,easing:g})}else{if(k&&!i){d.css({left:c+l})}d.animate({width:k?"show":"hide",marginLeft:k?"show":"hide",marginRight:k?"show":"hide",paddingLeft:k?"show":"hide",paddingRight:k?"show":"hide",left:(i)?c:(k?"-=":"+=")+l+"px"},{duration:e,easing:g})}},jump:function(h,c,g,j){h.stop(true,true);var i=h.data("direction")=="down"||h.data("direction")=="right";var d=i?"+=100px":"-=100px";if(h.parents("ul:first").hasClass("horizontal")){var f=parseFloat(h.css("top"));if(c){h.css({top:i?f+100:f-100})}h.animate({top:c?f:d,opacity:c?"show":"hide"},{duration:g,easing:j})}else{var e=parseFloat(h.css("left"));if(c){h.css({left:i?e+100:e-100})}h.animate({left:c?e:d,opacity:c?"show":"hide"},{duration:g,easing:j})}}};b.dmxNavigationMenu.defaults={menuWidth:150,timeout:500,showSelected:true,showOnMouseOver:true,keyboard:false,contextTarget:document,contextPosition:"mouse",contextButton:"right",mainShowEffect:"show",mainShowDuration:"",mainShowEasing:"swing",mainHideEffect:"hide",mainHideDuration:"",mainHideEasing:"swing",subShowEffect:"show",subShowDuration:"",subShowEasing:"swing",subHideEffect:"hide",subHideDuration:"",dubHideEasing:"swing"};function a(d){var c=d;var l=window.location;if(c.indexOf("://")===-1){if(c.charAt(0)==="/"){c=l.protocol+"//"+l.host+c}else{if(c.charAt(0)==="#"){c=l.protocol+"//"+l.host+l.pathname+l.search+c}else{var k=l.pathname.substring(0,l.pathname.lastIndexOf("/")+1)+c;var j=k.split("/");for(var e=j.length-1;e>0;--e){if(j[e]===".."){j.splice(e-1,2)}}c=l.protocol+"//"+l.host+j.join("/")}}}this.href=c;this.protocol="";this.hostname="";this.port="";this.host="";this.pathname="";this.search="";this.hash="";var g=c.indexOf("//");if(g>-1){this.protocol=c.substring(0,g);c=c.substring(g+2);g=c.indexOf("/");if(g===-1){g=c.length}this.host=c.substring(0,g);c=c.substring(g);var f=this.host.split(":");this.hostname=f[0];if(f.length>1){this.port=f[1]}}g=c.indexOf("?");if(g>-1){this.pathname=c.substring(0,g);this.search=c.substring(g);g=this.search.indexOf("#");if(g>-1){this.hash=this.search.substring(g);this.search=this.search.substring(0,g)}if(this.search.length===1){this.search=""}if(this.hash.length===1){this.hash=""}}else{this.pathname=c;g=c.indexOf("#");if(g>-1){this.hash=c.substring(g);this.pathname=c.substring(0,g);if(this.hash.length===1){this.hash=""}}}this.toString=function(){return this.href}}})(jQuery);
