// gnb
menustart = function(DivName, menuseq) {
	$("#" + DivName + ">ul>li").each(function(idx, item) {
		item = $(item);
		item.find(">div").hide();

		if(idx == menuseq) {
			var img = $(item).find("img");
			if(img.attr("src").indexOf("_on.gif") == -1)
				img.attr("src", img.attr("src").replace(".gif", "_on.gif"));
			
			img.attr("isSelected", 1);
			item.attr("isSelected", 1);
			item.find(">div").show();
		}
	});

	$("#" + DivName + ">ul>li").hover(
		function(event) {
			onHover(event.currentTarget);
		},
		function(event) {
			onOut(event.currentTarget);
		}
	);

	$("#" + DivName + ">ul>li>a").focus(
		function(event) {
			onHover(event.currentTarget);
		}
	);
};

function onHover(item) {
	if(item.tagName == 'A')
		item = item.parentNode;

	item = $(item);

	item.parent().find(">li>div").hide();
	item.parent().find(">li>a>img").each(
		function(idx, item) {
			item = $(item);
			item.attr("src", item.attr("src").replace("_on.gif", ".gif"));
		}
	);


	item.find(">div").show();
	item.attr("isSelected", 1);
	var img = item.find(">a>img");

	if(img.attr("src").indexOf("_on.gif") == -1)
		img.attr("src", img.attr("src").replace(".gif", "_on.gif"));
}

function onOut(item) {
	item = $(item);

	item.parent().find(">li>a>img").each(
		function(idx, item) {
			item = $(item);
			if(item.attr("isSelected") == 1) {
				if(item.attr("src").indexOf("_on.gif") == -1)
					item.attr("src", item.attr("src").replace(".gif", "_on.gif"));
				item.parent().parent().find(">div").show();
			} else {
				item.attr("src", item.attr("src").replace("_on.gif", ".gif"));
				item.parent().parent().find(">div").hide();
			}
		}
	);
}


// quick
function scrollquick(name,bottomlimit){
	var topdis=1;
	if(!document.getElementById(name)){
		return;
	}
	var obj = $("#"+name);
	var btmlimit=parseInt(document.documentElement.scrollHeight-obj.height()-bottomlimit);
	var menuYloc = parseInt(obj.css("top").substring(0, obj.css("top").indexOf("px")));
	$(window).scroll(function() {
		if(menuYloc<$(document).scrollTop()){
			
		}else{
			topdis = menuYloc;
		}
		offset = topdis+parseInt($(document).scrollTop()) + "px";
		if(parseInt(offset)>btmlimit||menuYloc>btmlimit){
			return;
		}
		obj.animate({ top: offset }, { duration: 500, queue: false });
	});
}


