/********************************************************************************************************
*
*    SEARCH
*
********************************************************************************************************/
var deSearchFrom = document.getElementById("deSearchFrom");
if (deSearchFrom) {
	deSearchFrom.onsubmit = function () {
		if (this.query.value.length < 2) {
			alert("°Ë»ö¾î¸¦ 2ÀÚ ÀÌ»ó ÀÔ·Â ÇØÁÖ¼¼¿ä!      ");
			this.query.focus();
			this.query.select();
			return false;
		}
	};

	deSearchFrom.searchword.onchange = deSearchFrom.searchword.onclick = function () {
		if (this.checked) {
			this.form.query.focus();
			this.form.query.select();
		}
	};
}

/* SLIDER CATEGORY BEST */
var getFramesArray = function (frame_, distance_, type_) {
		for (var arr = [], i = 0; frame_ > 1; frame_--) {
			arr[i] = Math.round(distance_ / frame_ * 2);
			distance_ -= arr[i++];
		}
		return type_ ? arr.reverse() : arr;
	}; //return Array

var slider = function () {
	var ul = document.getElementById("slider_list");
	if (!ul)
		return false;

	var li = ul.getElementsByTagName("LI"),
		distance;
	if (slider.isMoving || slider.cropItems >= li.length)
		return false;
	slider.isMoving = 1;
	if (this == slider.btns[1]) {
		if (/^-/.test(ul.style.marginLeft))
			ul.appendChild(li[0]);
		ul.style.marginLeft = "0px";
		distance = - li[0].offsetWidth;
	} else {
		if (!/^-/.test(ul.style.marginLeft))
			ul.insertBefore(li[li.length - 1], li[0]);
		ul.style.marginLeft = -li[0].offsetWidth + "px";
		distance = li[0].offsetWidth;
	}

	var i = 0;
		range = getFramesArray(20, distance, 0);

	(function () {
		if (i < range.length) {
			var marginLeft = parseInt(ul.style.marginLeft, 10);
			ul.style.marginLeft = marginLeft + range[i] + "px";
			i++;
			setTimeout(arguments.callee, 10);
		} else {
			slider.isMoving = 0;
			delete range;
		}
	}) ();
	return false;
};

(function () {
	slider.btns = document.getElementsByName("sliderBtn");
	if (!slider.btns || !slider.btns.length)
		return;
	slider.isMoving = 0;
	slider.isOver = 0;
	slider.cropItems = 4;
	var length = document.getElementById("slider_list").getElementsByTagName("LI").length;
	if (length > slider.cropItems) {
		slider.btns[0].onclick = slider;
		slider.btns[1].onclick = slider;
		slider.btns[0].onmouseover = slider.btns[1].onmouseover = function () { slider.isOver = 1; };
		slider.btns[0].onmouseout = slider.btns[1].onmouseout = function () { slider.isOver = 0; };
		var a = document.getElementById("slider_list").getElementsByTagName("A")
		for (var i = 0; i < a.length; i++) {
			a[i].onmouseover = function () { slider.isOver = 1; };
			a[i].onmouseout = function () { slider.isOver = 0; };
		}
	}

	setInterval(function () {
		if (slider.isOver)
			return;
		slider();
	}, 2000);

})();

	(function () {
		var topTab = document.getElementById("top_tab"),
			botTab = document.getElementById("bot_tab"),
			topIndex = 0,
			botIndex = 0,
			isOver = false,
			topLinks, botLinks, i, length;
		if (topTab) {
			var lists = document.getElementById("shopping_top_list");
			lists.onmouseover = topTab.onmouseover = function () { isOver = true; };
			lists.onmouseout = topTab.onmouseout = function () { isOver = false; };
			topLinks = topTab.getElementsByTagName("A");
			length = topLinks.length;
			for (i = 0; i < length; i++) {
				topLinks[i].index = i;
				topLinks[i].onclick = function () {
					if (this.index == topIndex)
						return false;
					var lists = document.getElementById("shopping_top_list");
					lists = lists.getElementsByTagName("UL");
					if (lists[topIndex])
						addClass(lists[topIndex], "outHidden");
					if (lists[this.index])
						removeClass(lists[this.index], "outHidden");

					removeClass(topLinks[topIndex], "on");
					topLinks[topIndex].onmouseout();
					addClass(this, "on");
					topIndex = this.index;
					return false;
				};
				topLinks[i].onmouseover = function () {
					if (hasClass(this, "on"))
						return false;
					var imgs = this.getElementsByTagName("IMG");
					if (imgs.length == 2) {
						addClass(imgs[0], "dsp_none");
						removeClass(imgs[1], "dsp_none");
					}
				};
				topLinks[i].onmouseout = function () {
					if (hasClass(this, "on"))
						return false;
					var imgs = this.getElementsByTagName("IMG");
					if (imgs.length == 2) {
						removeClass(imgs[0], "dsp_none");
						addClass(imgs[1], "dsp_none");
					}
				};
			}
		}
		if (botTab) {
			var lists = document.getElementById("shopping_bot_list");
			lists.onmouseover = botTab.onmouseover = function () { isOver = true;};
			lists.onmouseout = botTab.onmouseout = function () { isOver = false; };
			botLinks = botTab.getElementsByTagName("A");
			length = botLinks.length;
			for (i = 0; i < length; i++) {
				botLinks[i].index = i;
				botLinks[i].onclick = function () {
					if (this.index == botIndex)
						return false;
					var lists = document.getElementById("shopping_bot_list");
					lists = lists.getElementsByTagName("UL");
					if (lists[botIndex])
						addClass(lists[botIndex], "outHidden");
					if (lists[this.index])
						removeClass(lists[this.index], "outHidden");

					removeClass(botLinks[botIndex], "on");
					botLinks[botIndex].onmouseout();
					addClass(this, "on");
					botIndex = this.index;
					return false;
				};
				botLinks[i].onmouseover = function () {
					if (hasClass(this, "on"))
						return false;
					var imgs = this.getElementsByTagName("IMG");
					if (imgs.length == 2) {
						addClass(imgs[0], "dsp_none");
						removeClass(imgs[1], "dsp_none");
					}
				};
				botLinks[i].onmouseout = function () {
					if (hasClass(this, "on"))
						return false;
					var imgs = this.getElementsByTagName("IMG");
					if (imgs.length == 2) {
						removeClass(imgs[0], "dsp_none");
						addClass(imgs[1], "dsp_none");
					}
				};
			}
		}
		var topLength = 1,
			botLength = 0;
		if (topTab || botTab)
			setInterval(function () {
				if (isOver)
					return;

				if (topLinks.length) {
					topLength = topIndex + 1;
					if (topLength >= topLinks.length)
						topLength = 0;
					topLinks[topLength].onmouseover();
					topLinks[topLength].onclick();
				}

				if (botLinks.length) {
					botLength = botIndex + 1;
					if (botLength >= botLinks.length)
						botLength = 0;
					botLinks[botLength].onmouseover();
					botLinks[botLength].onclick();
				}
			}, 2000)
	})();

/*******************************************************************************************************/