(function($){$.fn.hugeMenu=function(options){var defaults={classParent:'dc-huge',arrow:true,classArrow:'dc-huge-icon',classContainer:'sub-container',classSubMenu:'sub',classhuge:'huge',classSubParent:'huge-hdr',classSubLink:'huge-hdr',classRow:'row',rowItems:3,speed:'fast',effect:'show',direction:'bottom'};var options=$.extend(defaults,options);var $hugeMenuObj=this;return $hugeMenuObj.each(function(options){var $huge=$(this);if(defaults.direction=='bottom'){$huge.addClass('bottom');}else{$huge.addClass('top');}
var hugeHeight=$huge.height();$('> li',$huge).each(function(){var $parent=$(this);var $hugeSub=$('> ul',$parent);if($hugeSub.length>0){$('> a',$parent).addClass(defaults.classParent).append('<span class="'+defaults.classArrow+'"></span>');$hugeSub.addClass(defaults.classSubMenu).wrap('<div class="'+defaults.classContainer+'" />');var $container=$('.'+defaults.classContainer,$parent);if($('ul',$hugeSub).length>0){$parent.addClass(defaults.classParent+'-li');$container.addClass(defaults.classhuge);$('> li',$hugeSub).each(function(){$(this).addClass('huge-unit');if($('> ul',this).length){$(this).addClass(defaults.classSubParent);$('> a',this).addClass(defaults.classSubParent+'-a');}else{$(this).addClass(defaults.classSubLink);$('> a',this).addClass(defaults.classSubLink+'-a');}});var hdrs=$('.huge-unit',$parent);var rowSize=parseInt(defaults.rowItems);for(var i=0;i<hdrs.length;i+=rowSize){hdrs.slice(i,i+rowSize).wrapAll('<div class="'+defaults.classRow+'" />');}
var itemWidth=$('.huge-unit',$hugeSub).outerWidth(true);var rowItems=$('.row:eq(0) .huge-unit',$hugeSub).length;var innerItemWidth=itemWidth*rowItems;var totalItemWidth=innerItemWidth+containerPad;$('.row',this).each(function(){$('.huge-unit:last',this).addClass('last');var maxValue=undefined;$('.huge-unit > a',this).each(function(){var val=parseInt($(this).height());if(maxValue===undefined||maxValue<val){maxValue=val;}});$('.huge-unit > a',this).css('height',maxValue+'px');$(this).css('width',innerItemWidth+'px');});var subWidth=$hugeSub.outerWidth(true);var totalWidth=$container.outerWidth(true);var containerPad=totalWidth-subWidth;$('.row',$hugeSub).each(function(){var rowHeight=$(this).height();$(this).parent('.row').css('height',rowHeight+'px');});$('.row:last',$hugeSub).addClass('last');$('.row:first',$hugeSub).addClass('first');}else{$container.addClass('non-'+defaults.classhuge);}}
var $container=$('.'+defaults.classContainer,$parent);var subHeight=$container.height();var itemHeight=$parent.outerHeight(true);$container.css({height:subHeight+'px',marginTop:-itemHeight+'px',zIndex:'1000',width:subWidth+'px'}).hide();});var config={sensitivity:2,interval:100,over:hugeOver,timeout:300,out:hugeOut};$('li',$hugeMenuObj).hoverIntent(config);function hugeOver(){$(this).addClass('huge-hover');var $link=$('> a',this);var $subNav=$('.sub',this);var $container=$('.sub-container',this);var width=$container.width();var outerHeight=$container.outerHeight(true);var height=$container.height();var itemHeight=$(this).outerHeight(true);var offset=$link.offset();var scrollTop=$(window).scrollTop();offset=offset.top-scrollTop
var bodyHeight=$(window).height();var maxHeight=bodyHeight-offset;var xsHeight=maxHeight-outerHeight-itemHeight;var containerPosition={top:hugeHeight*2};if(defaults.direction=='top'){containerPosition={bottom:hugeHeight-1};}
if(defaults.effect=='fade'){$container.css(containerPosition).fadeIn(defaults.speed);}
if(defaults.effect=='show'){$container.css(containerPosition).show();}
if(defaults.effect=='slide'){$container.css({height:0,opacity:0});if(defaults.direction=='top'){$container.show().css({bottom:hugeHeight});}else{$container.show().css({bottom:hugeHeight});}
$container.animate({height:height,opacity:1},defaults.speed);}}
function hugeOut(){$(this).removeClass('huge-hover');var $container=$('.sub-container',this);$container.hide();}});};})(jQuery);
