﻿function initEventHandlerSub() {
	//Best Seller 탭 처리
	$(".mainBest .title ul li a").each(function() {
		$(this).bind("mouseover", function(e) {
			if ($(this).attr("class") == "selected") {
				$(this).addClass("selected");
			} else {
				$(".mainBest .title ul li a").removeClass("selected");
				$(this).addClass("selected");
			}

			var max_idx = $("a[name=" + $(this).attr("valList") + "]").eq(0).attr("max_idx")
			var idx = Math.floor(max_idx * Math.random());

			for (var i = 0; i < 4; i++) {
				$(".bestGoods dl dt a").eq(i).attr({ "href": $("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("link") });
				$(".bestGoods dl dd a").eq(i).attr({ "href": $("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("link") });
				$("#bestGoods" + (i + 1) + "Img").attr({ "src": $("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("image"), "alt": $("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("title") });
				$(".bestGoods dl dd a").eq(i).html($("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("gd_nm"));
				$(".bestGoods .price").eq(i).html($("a[name=" + $(this).attr("valList") + "]").eq(idx).attr("d_price"));

				if (idx == max_idx)
					idx = 0;
				else
					idx++;
			}

			return false;
		});
	});

	//Today's Deal Rolling
	$(".todayDeal .mainTitle a").click(function() {

		var idx;
		if ($(this).attr("class") == "left") {
			if ($(this).attr("idx") == 0)
				idx = $(this).attr("max");
			else
				idx = $(this).attr("idx") - 1;
		} else {
			if ($(this).attr("idx") == $(this).attr("max"))
				idx = 0;
			else
				idx = parseInt($(this).attr("idx")) + 1;
		}

		$("#todaysDealOffRate").html($("a[name=TodaysDealList]").eq(idx).attr("offrate"));
		$(".todayDeal .mainTitle a").attr({ "idx": idx });
		$("#TodaysDealImg").attr({ "src": $("a[name=TodaysDealList]").eq(idx).attr("image"), "alt": $("a[name=TodaysDealList]").eq(idx).attr("gd_f_nm") });
		$(".dealDetail .thum a").attr({ "href": $("a[name=TodaysDealList]").eq(idx).attr("link") });
		$("#todaysDealDel").html($("a[name=TodaysDealList]").eq(idx).attr("s_price"));
		$("#todaysDealStrong").html($("a[name=TodaysDealList]").eq(idx).attr("d_price"));
		$("#todaysDealFree").html($("a[name=TodaysDealList]").eq(idx).attr("d_fee"));
		$(".item strong").html($("a[name=TodaysDealList]").eq(idx).attr("title"));
		$(".item a").attr({ "href": $("a[name=TodaysDealList]").eq(idx).attr("link") });
		$(".item span").html($("a[name=TodaysDealList]").eq(idx).attr("gd_nm"));
		return false;
	});
	
	//카테고리 상세 아이템 마우스 오버 처리
	$(".cateInfo .detail dt").each(function() {
		$(this).bind("mouseover", function(e) {
			$("#" + $(this).attr("off")).removeClass("selected");
			$(this).addClass("selected");
			$("#" + $(this).attr("view")).attr({ "style": "display:;" });
			$("#" + $(this).attr("hide")).attr({ "style": "display:none;" });
			return false;
		});
	});

}