(function($){
	$.fn.navi = function(args){

		var elkha = jQuery.extend({
			show : { height: "show" },
			hide : { opacity: "hide" },
			speed: "fast",
			delay: 0,
			click: false
		}, args);

		// ieSelect
		var ieSelect = false;
		if($.browser.msie == true) ieSelect = parseInt($.browser.version);

		this.each(function(){
			var gnb = $(this);

			gnb.find("li:has(ul)").hover(function(){
				$(this).addClass("hover");
				if(elkha.click && $(this).children("a").attr("href")=="#") return;
				if(elkha.speed==0 || (ieSelect && ieSelect <= 6)) $(this).children("ul").show();
				else $(this).children("ul:not(:animated)").animate(elkha.show, elkha.speed); 
			}, function(){
				$(this).removeClass("hover");
				if(elkha.click && $(this).children("a").attr("href")=="#") return;
				var hover = $(this);
				setTimeout(function(){
					if(hover.hasClass("hover")) return;
					if(elkha.speed==0 || (ieSelect && ieSelect <= 6)) hover.children("ul").hide();
					else hover.children("ul").animate(elkha.hide, elkha.speed);
				}, elkha.delay);
			});
			gnb.find("a").focus(function(){
				$(this).parent("li").prev("li").find("ul").hide();
				$(this).parent("li").next("li").find("ul").hide();
				if(elkha.click && $(this).attr("href")=="#") return;
				$(this).next("ul").show();
			});

			gnb.find("a").click(function(){
				if($(this).attr("href")=="#") {
					if(elkha.click) {
						if( $(this).next("ul").css("display")=="block" ) $(this).next("ul").hide();
						else $(this).next("ul").show();
					}
					return false;
				}
			});

		});

		return this;
	};
})(jQuery);

