// Dependency javascript file : util.js

var Navi = (function() {
	return {
		initGNB : function(offset) {
			var keepFlag = false;

			// bind depth1 mouse hover
			$("#gnb .dep1 > li").mouseenter(function() {
				keepFlag = false;
				
				$("> li", $(this).parent()).each(function(){
					$("a:first img.on", this).hide();
					$("a:first img.off", this).show();
				});
				
				$("a:first img.on", this).show();
				$("a:first img.off", this).hide();
				
				$("ul.dep2", $(this).parent()).hide();
				$("ul.dep2", this).show();
			});
			
			// bind depth2 link mouse hover
			$("#gnb .dep2 li").mouseenter(function() {
				keepFlag = false;
				
				$("#gnb .dep2 > li img.on").hide().siblings().show();
				$("a:first img.on", this).show();
				$("a:first img.off", this).hide();
			});
			
			// bind depth2 mouse leave
			$("#header").mouseleave(function() {
				if (!keepFlag) {
					$("#gnb .dep1 > li img.on").hide().siblings().show();
					$("#gnb .dep2").hide();
				}
			});
			
			var urlPaths = URL.getPathArray();
			var depth1Url = urlPaths[offset + 0]; 
			
			$("#gnb .dep1 > li").each(function(){
				var curUrlPaths = $("a:first", $(this)).attr("href").split("/");
				var curDepth1Url = curUrlPaths[offset + 1];
				
				if (depth1Url != undefined && depth1Url == curDepth1Url) {
					$(this).trigger("mouseenter");
					keepFlag = true;
				}
			});
			
		},
		
		initSNB : function(offset) {
			// Find 1depth, 2depth url value
			var urlPaths = URL.getPathArray();
			var depth2Url = urlPaths[offset + 1]; 
			var depth3Url = urlPaths[offset + 2];
			
			// loop 1depth
			$("#snb > li").each(function() {
				var curUrlPaths = $("a:first", $(this)).attr("href").split("/");
				var curDepth2Url = curUrlPaths[offset + 2];
				
				// 1depth highlight and 2depth open
				if(depth2Url == curDepth2Url) {
					$("a:first > img.on", $(this)).show().siblings().hide();
					$("ul.snb_sub", $(this)).show();
					
					// loop 2depth
					$("ul:first > li", $(this)).each(function() {
						var curUrlPaths = $("a:first", $(this)).attr("href").split("/");
						var curDepth3Url = curUrlPaths[offset + 3];
						
						//2depth highlight
						if(depth3Url == curDepth3Url) {
							$(this).addClass("snb_on");
							return;
						}
					});
					return;
				}
			});
		}
	};
})();







	
	
	


