(function($){
	$.fn.navitation = function(settings){
		//강제추가임 이부분 플러그인 fixinit로 돌릴것
		if($('body').css('background-color') !== "transparent"){
			$("#navigation ul li .list_2depth").addClass("hide");
		}

		var config = {
			place		: 'horizon',		//수직 수평 구분 vertical OR horizon
			local		: 'fix',			//페이지 로케이션에 따른 네비게이션 고정 fix or none
			depth		: '0-0-0',			//뎁스표기
			event		: 'click',			//수직네비게이션의 이벤트 타입  click OR mouseover
			b_suffix	: '_off',			//기본 접미사
			c_suffix	: '_on',			//변경 접미사
			c_class		: 'ui_navi_change',	//변경클래스
			clickover	: true,				//클릭시 마우스오버체크
			easing		: ''
		};
		
		if (config) $.extend(config, settings);

		$.fn.fixinit = function(val_fix, val_depth){
			if(val_fix == "fix"){
				$cont		= $(this);
				$depth		= val_depth.split("-");
				$.each($depth, function(){
					$cont = $cont.children("li").eq(this).addClass("ui_navi_change");
					if($cont.length > 0){
						$target = $cont.find("a:eq(0)").find("img");
						if($target.length > 0){
							$target.attr("src", $target.attr("src").replace(config.b_suffix, config.c_suffix));
						}
					}
					$cont = $cont.find("ul:eq(0)").show();
				});
			}
		};

		$.fn.eventstart = function(eventype, pos){
			$(this).bind(eventype, function(){
				if(eventype === "mouseover"){
					$n_other = $(this).siblings();
					$n_other.each(function(){
						$(this).removeClass("ui_navi_change");
						$(this).find("li").removeClass("ui_navi_change");
						$(this).find("img").each(function(){
							if($(this).length > 0){
								$(this).attr("src", $(this).attr("src").replace(config.c_suffix, config.b_suffix));
							}
						});
						pos == "horizon" ? $(this).find("ul").hide() : '';
					});

					$n_this = $(this).addClass("ui_navi_change").children(":eq(0)").find("img");
					if($n_this.length > 0){
						$n_this.attr("src", $n_this.attr("src").replace(config.b_suffix, config.c_suffix));
					}
					pos == "horizon" ? $(this).find("ul:eq(0)").show() : '';

				}else if(eventype === "click"){
					$n_other		= null;
					$n_other_check	= null;

					$n_other = ($(this).parent().get(0).tagName == "LI") ? $(this).parent() : $(this).parent().parent();
					$n_other_check = ($(this).parent().get(0).tagName == "LI") ? $(this).next("ul") : $(this).parent().next("ul");

					if($n_other_check.length > 0){
						$n_other.siblings().each(function(){
							$(this).removeClass("ui_navi_change");
							$(this).find("li").removeClass("ui_navi_change");
							$(this).find("ul").hide();
							$(this).find("a img").each(function(){
								if($(this).length > 0){
									$(this).attr("src", $(this).attr("src").replace(config.c_suffix, config.b_suffix));
								}
							});
						});

						$n_this = $(this).find("img");
						if($n_this.length > 0){
							$n_this.attr("src", $n_this.attr("src").replace(config.b_suffix, config.c_suffix));
						}
						$n_other.addClass("ui_navi_change");

						$n_other_check.show();

						return false;
					}
				}
			});
		};

		$(this).children("ul").fixinit(config.local, config.depth);
		config.event == "mouseover" && config.place == "vertical" ? $(this).find("ul").show() : '';
		config.event == "mouseover" ? $(this).find("li").eventstart(config.event, config.place) : $(this).find("li a").eventstart(config.event, config.place);
	};
})(jQuery);
