/*
	DMXzone Navigation Menu
	Version 1.0.0
	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 j=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 k=jQuery(this).attr("style");if(!(/\bwidth\b/.test(k))){if(jQuery(this).hasClass("mega")){jQuery(this).css({width:(a.menuWidth*jQuery(">li",this).length)});jQuery(">li",this).css({width:a.menuWidth})}else{jQuery(this).css({width:a.menuWidth})}}});b.find("li:has(>ul.mega,>ul.sub)>a").each(function(){var k=jQuery(this).addClass("expandable");if(!k.is(":has(span[class^=sub_])")){if(k.closest("ul").hasClass("horizontal")){k.append('<span class="sub_down"></span>')}else{k.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:h,out:h,timeout:a.timeout})}else{b.find("li").click(i);jQuery(document).click(i)}function g(l,k){while(l!=k&&l.parentNode){l=l.parentNode}return(l==k)}function d(r){if(r.target&&!g(r.target,b.get(0))){var q;if(r.which==null){q=(r.button<2)?"left":((r.button==4)?"middle":"right")}else{q=(r.which<2)?"left":((r.which==2)?"middle":"right")}if(q==a.contextButton){var m=jQuery(document).scrollTop();var t=jQuery(document).scrollLeft();var l=jQuery(window).width()-t;var o=jQuery(window).height()-t;var p=jQuery(".contextMenu").width();var k=jQuery(".contextMenu").height();var n=r.pageX+5;if(n+p>l){n=l-p}if(n<t){n=t}var s=r.pageY+5;if(s+k>o){s=o-k}if(s<m){s=m}jQuery(".contextMenu").css({left:n,top:s}).show();return false}}}function e(k){if(k.which==1&&k.target&&!g(k.target,b.get(0))){jQuery(".contextMenu").hide().find(".active").each(function(){jQuery(this).removeClass("active");jQuery(">ul",this).stop(true,true).hide()})}}function i(q){if(q.originalTarget&&!g(q.originalTarget,q.currentTarget)){return}q.stopPropagation();var l,p,r;var m=jQuery(q.currentTarget);var o=m.find(">ul.sub,>ul.mega");var n=o.length>0?true:false;var k=!m.hasClass("active");if(q.currentTarget!=document){m.siblings(".active").each(function(){jQuery(this).trigger("click")})}else{b.find(">li.active").each(function(){jQuery(this).trigger("click")})}if(!n){return}if(k){m.addClass("active")}else{m.removeClass("active");m.find(".active").each(function(){jQuery(this).removeClass("active");jQuery(">ul",this).stop(true,true).hide()})}if(m.hasClass("main")){l=a.mainShowEffect;p=a.mainShowDuration;r=a.mainShowEasing}else{l=a.subShowEffect;p=a.subShowDuration;r=a.subShowEasing}if(jQuery.dmxNavigationMenu.effects[l]){jQuery.dmxNavigationMenu.effects[l](o,k,p,r)}else{if(k){o.show()}else{o.hide()}}return false}function h(q){var l,p,r;var m=jQuery(q.currentTarget);var o=m.find(">ul.sub,>ul.mega");var n=o.length>0?true:false;var k=q.type=="mouseover"?true:false;if(k){m.siblings(".active").each(function(){this.hoverIntent_t=clearTimeout(this.hoverIntent_t);this.hoverIntent_s=0;var s=new jQuery.Event("mouseout");s.currentTarget=this;h(s)})}if(!n){return}if(k){m.addClass("active")}else{m.removeClass("active");m.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()})}if(m.hasClass("main")){l=a.mainShowEffect;p=a.mainShowDuration;r=a.mainShowEasing}else{l=a.subShowEffect;p=a.subShowDuration;r=a.subShowEasing}if(jQuery.dmxNavigationMenu.effects[l]){jQuery.dmxNavigationMenu.effects[l](o,k,p,r)}else{if(k){o.show()}else{o.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(c,a,b,d){if(c.parents("ul:first").hasClass("horizontal")){c.stop(true,true).animate({height:a?"show":"hide",marginTop:a?"show":"hide",marginBottom:a?"show":"hide",paddingTop:a?"show":"hide",paddingBottom:a?"show":"hide"},{duration:b,easing:d})}else{c.stop(true,true).animate({width:a?"show":"hide",marginLeft:a?"show":"hide",marginRight:a?"show":"hide",paddingLeft:a?"show":"hide",paddingRight:a?"show":"hide"},{duration:b,easing:d})}},jump:function(e,a,d,f){e.stop(true,true);if(e.parents("ul:first").hasClass("horizontal")){if(a){e.show()}var c=e.offsetParent().outerHeight();if(a){e.hide()}e.css({top:a?c+100:c}).animate({top:a?c:c+100,opacity:a?"show":"hide"},{duration:d,easing:f,complete:function(){$(this).css({top:c})}})}else{if(a){e.show()}var b=e.offsetParent().outerWidth()*0.97;if(a){e.hide()}e.css({left:a?b+100:b}).animate({left:a?b:b+100,opacity:a?"show":"hide"},{duration:d,easing:f,complete:function(){$(this).css({left:b})}})}}};jQuery.dmxNavigationMenu.defaults={menuWidth:150,timeout:500,showOnMouseOver:true,contextTarget:document,contextButton:"right",mainShowEffect:"show",mainShowDuration:"",mainShowEasing:"swing",mainHideEffect:"hide",mainHideDuration:"",mainHideEasing:"swing",subShowEffect:"show",subShowDuration:"",subShowEasing:"swing",subHideEffect:"hide",subHideDuration:"",dubHideEasing:"swing"};
