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