KR.fn.extend({
	gnb : function(lump){
		var GNB = this;
		if(!GNB.length) return false;
		var acTime = lump.timer;
		var subTag = lump.subTag;

		var one = GNB.child();
		var oneBtn = GNB.find(">li>a");
		var twoBtn = GNB.find(">li:has("+subTag+") li>a");
		var anchor = GNB.find("a");

		oneBtn.evt("mouseover focus",function(e,o){
			clear();
			var img = this.first('img');
			img.src = img.src.replace("_off","_on");
			one.nth(this.n).className({add:"on"})
			if(!GNB.chk('className').toString().indexOf(" on"))
				GNB.className({add:"on"});
			if(one[this.n].first(subTag)) one[this.n].first(subTag).style.display = "";
		});
		oneBtn.evt('mouseout blur',function(){
			clearTimeout(GNB.act);
			//GNB.className({remove:"on"});
			start();
		});

		twoBtn.evt("mouseover focus",function(){
			clearTimeout(GNB.act);
			this.img = this.first('img');
			this.img.src = this.img.src.replace('_off','_on');
			if(!GNB.chk('className').toString().indexOf(" on"))
				GNB.className({add:"on"});
		});
		twoBtn.evt("mouseout blur",function(){
			clearTimeout(GNB.act);
			this.img = this.first('img');
			GNB.className({remove:"on"});
			if(this.img.active) return false;
			this.img.src = this.img.src.replace('_on','_off');
			start();
		});

		var clear = function(){
			clearTimeout(GNB.act);
			one.each(function(){
				var img = this.first('img');
				if(this.first(subTag)) this.first(subTag).style.display = "none";
				if(img) img.src = img.src.replace("_on","_off")
			});
		},
		start = function(){
			GNB.act = setTimeout(function(){
				if(!GNB.state) active();
			},acTime);
		},
		active = function(){
			clear();
			if(!one[subNum-1]){alert("'ERROR'=> subNum = " +subNum );return false}
			if(subNum && one[subNum-1]){
				var img = one[subNum-1].first('img'),two = one.child(subTag+":"+(subNum-1));
				img.src = img.src.replace("_off","_on");
				if(pageNum && two){
					two.show();
					var twoIMg = two.find("IMG")[pageNum-1];
					if(!twoIMg){alert("'ERROR'=> pageNum = " +pageNum );return false}
					twoIMg.src = twoIMg.src.replace("_off","_on");
					twoIMg.active = true;
				}
			}
		};
		active();
	},
	tab: function(){
		var box = this,cnt,btns;
		var onFocus = function(btns,cnt,obj){
			btns.each(function(){
				var img = this.first('img');
				if(img) img.src = img.src.replace('_on','_off');
			})
			var img = obj.first('img');
			cnt.hide()
			if(img) img.src = img.src.replace('_off','_on');
			if(obj) cnt.nth(obj.n).show()
		}
		if(box.chk('length')>1)return false;
		if(box.chk('nodeName') == "ul"){
			btns = box.child("li>a");
			cnt = box.child("li>div");
			btns.evt("focus",function(){
				onFocus(btns,cnt,this)
			})
		}else if( box.chk('nodeName') == "div"){
			btns = box.child('even').child('a');
			cnt = box.child('odd');
			btns.evt("focus",function(){
				onFocus(btns,cnt,this)
			})
		}
		cnt.css({position:"absolute"});
		btns[0].focus();
		return false;
	}
})

KR.fn.extend({
	over:function(){
		this.child('a').each(function(){
			this.onmouseover = this.onfocus = function(){
				var img = this.first('img');
				img.src = img.src.replace("_off","_on");
				this.onmouseout = this.onblur = function(){
					img.src = img.src.replace("_on","_off");
				}
			}
		})
	}
})
