var timeout_id =null;

//Main Banner
function writeMainBan()
{

	  	var m_banner = Math.floor(Math.random() * arrMainBan.length) + 1;
		document.getElementById("main_banner").innerHTML = "<a href='"+ arrMainBan[m_banner-1][1]+"'><img src='"+arrMainBan[m_banner-1][0]+"' width=400 height=200 border=0></a>";
	  	document.getElementById("ico_"+m_banner).src = "http://image.gmarket.co.jp/challenge_jp/neo_image/new_main_img12/new_ca/n"+ m_banner + "_r.gif";

		//var timeout_id =null;
		//timeout_id = window.setTimeout("flickerMainB("+m_banner+")",3000);
}

function writeLayerImg()
{
	for (var i=1 ; i<=arrMainBan.length ; i++)
	{
		//document.write("<tr><td><a href=" + arrMainBan[i-1][1]+ " onMouseOver='swapBanner("+ i + ");' onMouseOut='flickerMainB("+ i + ");'><img id='ico_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/neo_image/new_main_img12/new_ca/n"+i+".gif' width='16' height='13' border='0'></a></td></tr>");
		document.write("<tr><td><a href=" + arrMainBan[i-1][1]+ " onMouseOver='swapBanner("+ i + ");' ><img id='ico_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/neo_image/new_main_img12/new_ca/n"+i+".gif' width='16' height='13' border='0'></a></td></tr>");
	}
}

function flickerMainB(i)
{
	if (i == (arrMainBan.length+1))
		i = i - arrMainBan.length;
	swapBanner(i++);
	timeout_id = window.setTimeout("flickerMainB("+i+")",3000);
}

function swapBanner(i)
{

	document.getElementById("main_banner").innerHTML = "<a href='"+ arrMainBan[i-1][1]+"'><img src='"+arrMainBan[i-1][0]+"' width=400 height=200 border=0></a>";

	for (var idx = 1; idx <= arrMainBan.length ; idx++)
	{
		if (i == idx)
			document.getElementById("ico_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/neo_image/new_main_img12/new_ca/n"+i+"_r.gif";
		else
			document.getElementById("ico_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/neo_image/new_main_img12/new_ca/n"+idx+".gif";
	}

	clearTimeout(timeout_id);
}


//BestReview
function writeBestReview()
{
		var rdm

	  	rdm = Math.floor(Math.random() * arrBestReview.length) + 1;
		document.getElementById("img_BestRV").src = arrBestReview[rdm-1][5];
		document.getElementById("span_BestRV_tit").innerHTML = "<font color='"+ arrBestReview[rdm-1][2]+"'>"+arrBestReview[rdm-1][0]+"</font>";
		document.getElementById("span_BestRV_cts").innerHTML = "<font color='"+ arrBestReview[rdm-1][3]+"'>"+arrBestReview[rdm-1][1]+"</font>";
		document.getElementById("BestRV_url").href = arrBestReview[rdm-1][4];
		document.getElementById("btnRv_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index_new/no_"+ rdm + "g.gif";
}


function writeBestRVLayer()
{
	for (var i=1 ; i<=arrBestReview.length ; i++)
	{
		document.write("<td><a href=" + arrBestReview[i-1][4]+ " onMouseOver='swapBestRV("+ i + ");'><img id='btnRv_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index_new/no_"+i+".gif' width='11' height='11' border='0'></a></td>");
	}
}


function swapBestRV(i)
{

	document.getElementById("img_BestRV").src = arrBestReview[i-1][5];
	document.getElementById("span_BestRV_tit").innerHTML = "<font color='"+ arrBestReview[i-1][2]+"'>"+arrBestReview[i-1][0]+"</font>";
	document.getElementById("span_BestRV_cts").innerHTML = "<font color='"+ arrBestReview[i-1][3]+"'>"+arrBestReview[i-1][1]+"</font>";
	document.getElementById("BestRV_url").href = arrBestReview[i-1][4];

	for (var idx = 1; idx <= arrBestReview.length ; idx++)
	{
		if (i == idx)
			document.getElementById("btnRv_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index_new/no_"+i+"g.gif";
		else
			document.getElementById("btnRv_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index_new/no_"+idx+".gif";
	}

}

//middle categories
function writeMiddleCate()
{
	var rdm
	//rdm = Math.floor(Math.random()*2);
	var arrcnt = arrBrand_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrBrand_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrBrand_Goods[(rdm+i)][1] = arrBrand_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrBrand_Goods[(rdm+i)][1] = arrBrand_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("Brand_goods"+i+"_img_url").href = arrBrand_Goods[(rdm+i)][1];
		document.getElementById("Brand_goods"+i+"_img").src = arrBrand_Goods[(rdm+i)][0];
		document.getElementById("Brand_goods"+i+"_tit_url").href = arrBrand_Goods[(rdm+i)][1];
		document.getElementById("Brand_goods"+i+"_tit").innerHTML = arrBrand_Goods[(rdm+i)][2];
		document.getElementById("Brand_goods"+i+"_price").innerHTML = arrBrand_Goods[(rdm+i)][3];

	}

	arrcnt = arrFashion_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrFashion_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrFashion_Goods[(rdm+i)][1] = arrFashion_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrFashion_Goods[(rdm+i)][1] = arrFashion_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("Fashion_Goods"+i+"_img_url").href = arrFashion_Goods[(rdm+i)][1];
		document.getElementById("Fashion_Goods"+i+"_img").src = arrFashion_Goods[(rdm+i)][0];
		document.getElementById("Fashion_Goods"+i+"_tit_url").href = arrFashion_Goods[(rdm+i)][1];
		document.getElementById("Fashion_Goods"+i+"_tit").innerHTML = arrFashion_Goods[(rdm+i)][2];
		document.getElementById("Fashion_Goods"+i+"_price").innerHTML = arrFashion_Goods[(rdm+i)][3];

	}

	arrcnt = arrCdDvdBook_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrCdDvdBook_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrCdDvdBook_Goods[(rdm+i)][1] = arrCdDvdBook_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrCdDvdBook_Goods[(rdm+i)][1] = arrCdDvdBook_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("CdDvdBook_Goods"+i+"_img_url").href = arrCdDvdBook_Goods[(rdm+i)][1];
		document.getElementById("CdDvdBook_Goods"+i+"_img").src = arrCdDvdBook_Goods[(rdm+i)][0];
		document.getElementById("CdDvdBook_Goods"+i+"_tit_url").href = arrCdDvdBook_Goods[(rdm+i)][1];
		document.getElementById("CdDvdBook_Goods"+i+"_tit").innerHTML = arrCdDvdBook_Goods[(rdm+i)][2];
		document.getElementById("CdDvdBook_Goods"+i+"_price").innerHTML = arrCdDvdBook_Goods[(rdm+i)][3];

	}

	arrcnt = arrFoodDrink_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrFoodDrink_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrFoodDrink_Goods[(rdm+i)][1] = arrFoodDrink_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrFoodDrink_Goods[(rdm+i)][1] = arrFoodDrink_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("FoodDrink_Goods"+i+"_img_url").href = arrFoodDrink_Goods[(rdm+i)][1];
		document.getElementById("FoodDrink_Goods"+i+"_img").src = arrFoodDrink_Goods[(rdm+i)][0];
		document.getElementById("FoodDrink_Goods"+i+"_tit_url").href = arrFoodDrink_Goods[(rdm+i)][1];
		document.getElementById("FoodDrink_Goods"+i+"_tit").innerHTML = arrFoodDrink_Goods[(rdm+i)][2];
		document.getElementById("FoodDrink_Goods"+i+"_price").innerHTML = arrFoodDrink_Goods[(rdm+i)][3];

	}

	arrcnt = arrBeautyBest_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrBeautyBest_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrBeautyBest_Goods[(rdm+i)][1] = arrBeautyBest_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrBeautyBest_Goods[(rdm+i)][1] = arrBeautyBest_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("BeautyBest_Goods"+i+"_img_url").href = arrBeautyBest_Goods[(rdm+i)][1];
		document.getElementById("BeautyBest_Goods"+i+"_img").src = arrBeautyBest_Goods[(rdm+i)][0];
		document.getElementById("BeautyBest_Goods"+i+"_tit_url").href = arrBeautyBest_Goods[(rdm+i)][1];
		document.getElementById("BeautyBest_Goods"+i+"_tit").innerHTML = arrBeautyBest_Goods[(rdm+i)][2];
		document.getElementById("BeautyBest_Goods"+i+"_price").innerHTML = arrBeautyBest_Goods[(rdm+i)][3];

	}

	arrcnt = arrDigitalBest_Goods.length -1
	rdm = Math.floor(Math.random() * arrcnt);

	for (var i=0 ; i<2 ; i++)
	{
		if(arrDigitalBest_Goods[(rdm+i)][1].indexOf("?") !=  -1){
			arrDigitalBest_Goods[(rdm+i)][1] = arrDigitalBest_Goods[(rdm+i)][1] + "&pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrDigitalBest_Goods[(rdm+i)][1] = arrDigitalBest_Goods[(rdm+i)][1] + "?pos_shop_cd=M_LO&pos_class_cd=111111111&pos_class_kind=T";
		}
		document.getElementById("DigitalBest_Goods"+i+"_img_url").href = arrDigitalBest_Goods[(rdm+i)][1];
		document.getElementById("DigitalBest_Goods"+i+"_img").src = arrDigitalBest_Goods[(rdm+i)][0];
		document.getElementById("DigitalBest_Goods"+i+"_tit_url").href = arrDigitalBest_Goods[(rdm+i)][1];
		document.getElementById("DigitalBest_Goods"+i+"_tit").innerHTML = arrDigitalBest_Goods[(rdm+i)][2];
		document.getElementById("DigitalBest_Goods"+i+"_price").innerHTML = arrDigitalBest_Goods[(rdm+i)][3];

	}
}


//left
function writeToday()
{
	var rdm

	rdm = Math.floor(Math.random()* (CgdsCnt_ATTENTION));

	document.getElementById("ATTENTION_Url").href = arrATTENTION[(rdm)]['URL1'];
	document.getElementById("ATTENTION_Img").src = arrATTENTION[(rdm)]['IMG1'];
	document.getElementById("ATTENTION_Url1").href = arrATTENTION[(rdm)]['URL1'];
	document.getElementById("ATTENTION_Txt1").innerHTML = "<strong><font color='"+ arrATTENTION[(rdm)]['TAG1']+"'>"+arrATTENTION[(rdm)]['TXT1']+"</font></strong>";
	//document.getElementById("ATTENTION_Txt1").innerHTML = arrATTENTION[(rdm)]['TXT1'];
	document.getElementById("ATTENTION_Url2").href = arrATTENTION[(rdm)]['URL1'];
	document.getElementById("ATTENTION_Txt2").innerHTML = arrATTENTION[(rdm)]['TXT2'];

	rdm = Math.floor(Math.random()* (CgdsCnt_AUCTION));

	document.getElementById("AUCTION_Url").href = arrAUCTION[(rdm)]['URL1'];
	document.getElementById("AUCTION_Img").src = arrAUCTION[(rdm)]['IMG1'];
	document.getElementById("AUCTION_Url1").href = arrAUCTION[(rdm)]['URL1'];
	document.getElementById("AUCTION_Txt1").innerHTML = arrAUCTION[(rdm)]['TXT1'];
	document.getElementById("AUCTION_Txt2").innerHTML = arrAUCTION[(rdm)]['TXT2'];
	document.getElementById("AUCTION_Txt3").innerHTML = arrAUCTION[(rdm)]['TXT3'];

	rdm = Math.floor(Math.random()* (CgdsCnt_EVENTLEFT));

	document.getElementById("EVENTLEFT_Url").href = arrEVENTLEFT[(rdm)]['URL1'];
	document.getElementById("EVENTLEFT_Img").src = arrEVENTLEFT[(rdm)]['IMG1'];

}


//Right
function writeLuckyAuction()
{
	document.getElementById("LuckyAuction_img_url").href = arrLuckyAuction[0][1];
	document.getElementById("LuckyAuction_img").src = arrLuckyAuction[0][0];
	document.getElementById("LuckyAuction_tit_url").href = arrLuckyAuction[0][1];
	document.getElementById("LuckyAuction_tit").innerHTML = "<strong><font color='"+ arrLuckyAuction[0][4]+"'>"+arrLuckyAuction[0][2]+"</font></strong>";
	document.getElementById("LuckyAuction_con_url").href = arrLuckyAuction[0][1];
	document.getElementById("LuckyAuction_con").innerHTML = "<font color='"+ arrLuckyAuction[0][5]+"'>"+arrLuckyAuction[0][3]+"</font>";

}


//Notice
function writeNotice()
{
	for (var i=0 ; i<=1 ; i++)
	{
		if (arrNotice[i][2] == 'N')
		{
			document.getElementById("notice"+i+"").innerHTML = "<a href='"+ arrNotice[i][0]+"' class='auc11dk' target='_blank'>"+arrNotice[i][1]+"</a>";
		}
		else if (arrNotice[i][2] == 'P')
		{
			document.getElementById("notice"+i+"").innerHTML = "<a href='javascript: var notice = window.open(\""+ arrNotice[i][0]+"\",430,400)' class='auc11dk'>"+arrNotice[i][1]+"</a>";

		}
		else
		{
			document.getElementById("notice"+i+"").innerHTML = "<a href='"+ arrNotice[i][0]+"' class='auc11dk' target='_blank'>"+arrNotice[i][1]+"</a>";
		}
	}


}


// Bestsellers
function writeBestsellers()
{
	var rdm = Math.floor(Math.random() * (arrTodayBest_Goods.length-2));

	document.getElementById("TodayBest_Goods0_img_url").href = arrTodayBest_Goods[rdm][1];
	document.getElementById("TodayBest_Goods0_img").src = arrTodayBest_Goods[rdm][0];
	document.getElementById("TodayBest_Goods0_tit_url").href = arrTodayBest_Goods[rdm][1];
	document.getElementById("TodayBest_Goods0_tit").innerHTML = arrTodayBest_Goods[rdm][2];
	document.getElementById("TodayBest_Goods0_price_url").href = arrTodayBest_Goods[rdm][1];
	document.getElementById("TodayBest_Goods0_price").innerHTML = arrTodayBest_Goods[rdm][3];

	document.getElementById("TodayBest_Goods1_img_url").href = arrTodayBest_Goods[rdm+1][1];
	document.getElementById("TodayBest_Goods1_img").src = arrTodayBest_Goods[rdm+1][0];
	document.getElementById("TodayBest_Goods1_tit_url").href = arrTodayBest_Goods[rdm+1][1];
	document.getElementById("TodayBest_Goods1_tit").innerHTML = arrTodayBest_Goods[rdm+1][2];
	document.getElementById("TodayBest_Goods1_price_url").href = arrTodayBest_Goods[rdm+1][1];
	document.getElementById("TodayBest_Goods1_price").innerHTML = arrTodayBest_Goods[rdm+1][3];

	document.getElementById("TodayBest_Goods2_img_url").href = arrTodayBest_Goods[rdm+2][1];
	document.getElementById("TodayBest_Goods2_img").src = arrTodayBest_Goods[rdm+2][0];
	document.getElementById("TodayBest_Goods2_tit_url").href = arrTodayBest_Goods[rdm+2][1];
	document.getElementById("TodayBest_Goods2_tit").innerHTML = arrTodayBest_Goods[rdm+2][2];
	document.getElementById("TodayBest_Goods2_price_url").href = arrTodayBest_Goods[rdm+2][1];
	document.getElementById("TodayBest_Goods2_price").innerHTML = arrTodayBest_Goods[rdm+2][3];
}

function writeMiddleCateBn()
{
		var rdm

		rdm = Math.floor(Math.random() * arrBrandBn.length) + 1;
		if(arrBrandBn[rdm-1][1].indexOf("?") !=  -1){
			arrBrandBn[rdm-1][1] = arrBrandBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrBrandBn[rdm-1][1] = arrBrandBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrFashionBn.length) + 1;
		if(arrFashionBn[rdm-1][1].indexOf("?") !=  -1){
			arrFashionBn[rdm-1][1] = arrFashionBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrFashionBn[rdm-1][1] = arrFashionBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrCdDvdBookBn.length) + 1;
		if(arrCdDvdBookBn[rdm-1][1].indexOf("?") !=  -1){
			arrCdDvdBookBn[rdm-1][1] = arrCdDvdBookBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrCdDvdBookBn[rdm-1][1] = arrCdDvdBookBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrFoodDrinkBn.length) + 1;

		if(arrFoodDrinkBn[rdm-1][1].indexOf("?") !=  -1){
			arrFoodDrinkBn[rdm-1][1] = arrFoodDrinkBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrFoodDrinkBn[rdm-1][1] = arrFoodDrinkBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrBeautyBestBn.length) + 1;

		if(arrBeautyBestBn[rdm-1][1].indexOf("?") !=  -1){
			arrBeautyBestBn[rdm-1][1] = arrBeautyBestBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrBeautyBestBn[rdm-1][1] = arrBeautyBestBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrDigitalBestBn.length) + 1;
		if(arrDigitalBestBn[rdm-1][1].indexOf("?") !=  -1){
			arrDigitalBestBn[rdm-1][1] = arrDigitalBestBn[rdm-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}else{
			arrDigitalBestBn[rdm-1][1] = arrDigitalBestBn[rdm-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
		}

		rdm = Math.floor(Math.random() * arrBrandBn.length) + 1;

		document.getElementById("Brand_goodsBn").innerHTML = "<a href='"+ arrBrandBn[rdm-1][1]+"'><img src='"+arrBrandBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn1_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

		rdm = Math.floor(Math.random() * arrFashionBn.length) + 1;

		document.getElementById("Fashion_GoodsBn").innerHTML = "<a href='"+ arrFashionBn[rdm-1][1]+"'><img src='"+arrFashionBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn2_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

		rdm = Math.floor(Math.random() * arrCdDvdBookBn.length) + 1;

		document.getElementById("CdDvdBook_goodsBn").innerHTML = "<a href='"+ arrCdDvdBookBn[rdm-1][1]+"'><img src='"+arrCdDvdBookBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn3_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

		rdm = Math.floor(Math.random() * arrFoodDrinkBn.length) + 1;

		document.getElementById("FoodDrink_goodsBn").innerHTML = "<a href='"+ arrFoodDrinkBn[rdm-1][1]+"'><img src='"+arrFoodDrinkBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn4_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

		rdm = Math.floor(Math.random() * arrBeautyBestBn.length) + 1;

		document.getElementById("BeautyBest_goodsBn").innerHTML = "<a href='"+ arrBeautyBestBn[rdm-1][1]+"'><img src='"+arrBeautyBestBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn5_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

		rdm = Math.floor(Math.random() * arrDigitalBestBn.length) + 1;

		document.getElementById("DigitalBest_goodsBn").innerHTML = "<a href='"+ arrDigitalBestBn[rdm-1][1]+"'><img src='"+arrDigitalBestBn[rdm-1][0]+"' width=179 height=155 border=0></a>";
	  	document.getElementById("btn6_"+rdm).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+ rdm + "g.gif";

}

function writeLayer(CategoryBn)
{
	if (CategoryBn == "BrandBn")
	{
			
		for (var i=1 ; i<=arrBrandBn.length ; i++){
			if(arrBrandBn[i-1][1].indexOf("?") !=  -1){
				arrBrandBn[i-1][1] = arrBrandBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrBrandBn[i-1][1] = arrBrandBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrBrandBn[i-1][1]+ " onMouseOver='swapCateBanner(1,"+ i + ");'><img id='btn1_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
	else if ( CategoryBn == "FashionBn")
	{
		for (var i=1 ; i<=arrFashionBn.length ; i++){
			if(arrFashionBn[i-1][1].indexOf("?") !=  -1){
				arrFashionBn[i-1][1] = arrFashionBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrFashionBn[i-1][1] = arrFashionBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrFashionBn[i-1][1]+ " onMouseOver='swapCateBanner(2,"+ i + ");'><img id='btn2_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
	else if ( CategoryBn == "CdDvdBookBn")
	{
		for (var i=1 ; i<=arrCdDvdBookBn.length ; i++){
			if(arrCdDvdBookBn[i-1][1].indexOf("?") !=  -1){
				arrCdDvdBookBn[i-1][1] = arrCdDvdBookBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrCdDvdBookBn[i-1][1] = arrCdDvdBookBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrCdDvdBookBn[i-1][1]+ " onMouseOver='swapCateBanner(3,"+ i + ");'><img id='btn3_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
	else if ( CategoryBn == "FoodDrinkBn")
	{
		for (var i=1 ; i<=arrFoodDrinkBn.length ; i++){
			if(arrFoodDrinkBn[i-1][1].indexOf("?") !=  -1){
				arrFoodDrinkBn[i-1][1] = arrFoodDrinkBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrFoodDrinkBn[i-1][1] = arrFoodDrinkBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrFoodDrinkBn[i-1][1]+ " onMouseOver='swapCateBanner(4,"+ i + ");'><img id='btn4_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
	else if ( CategoryBn == "BeautyBestBn")
	{
		for (var i=1 ; i<=arrBeautyBestBn.length ; i++){
			if(arrBeautyBestBn[i-1][1].indexOf("?") !=  -1){
				arrBeautyBestBn[i-1][1] = arrBeautyBestBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrBeautyBestBn[i-1][1] = arrBeautyBestBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrBeautyBestBn[i-1][1]+ " onMouseOver='swapCateBanner(5,"+ i + ");'><img id='btn5_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
	else if ( CategoryBn == "DigitalBestBn")
	{
		for (var i=1 ; i<=arrDigitalBestBn.length ; i++){
			if(arrDigitalBestBn[i-1][1].indexOf("?") !=  -1){
				arrDigitalBestBn[i-1][1] = arrDigitalBestBn[i-1][1] + "&pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}else{
				arrDigitalBestBn[i-1][1] = arrDigitalBestBn[i-1][1] + "?pos_shop_cd=M_LB&pos_class_cd=111111111&pos_class_kind=T";
			}
			document.write("<td><a href=" + arrDigitalBestBn[i-1][1]+ " onMouseOver='swapCateBanner(6,"+ i + ");'><img id='btn6_"+ i +"' src='http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+".gif' border='0'></a></td><td width='2'></td>");
		}
	}
}


function swapCateBanner(CategoryBn,i)
{

	if (CategoryBn == 1)
	{
		for (var idx = 1; idx <= arrBrandBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn1_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn1_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("Brand_goodsBn").innerHTML = "<a href='"+ arrBrandBn[i-1][1]+"'><img src='"+arrBrandBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}
	else if ( CategoryBn == 2)
	{
		for (var idx = 1; idx <= arrFashionBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn2_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn2_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("Fashion_GoodsBn").innerHTML = "<a href='"+ arrFashionBn[i-1][1]+"'><img src='"+arrFashionBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}
	else if ( CategoryBn == 3)
	{
		for (var idx = 1; idx <= arrCdDvdBookBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn3_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn3_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("CdDvdBook_goodsBn").innerHTML = "<a href='"+ arrCdDvdBookBn[i-1][1]+"'><img src='"+arrCdDvdBookBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}

	else if ( CategoryBn == 4)
	{
		for (var idx = 1; idx <= arrFoodDrinkBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn4_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn4_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("FoodDrink_goodsBn").innerHTML = "<a href='"+ arrFoodDrinkBn[i-1][1]+"'><img src='"+arrFoodDrinkBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}

	else if ( CategoryBn == 5)
	{
		for (var idx = 1; idx <= arrBeautyBestBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn5_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn5_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("BeautyBest_goodsBn").innerHTML = "<a href='"+ arrBeautyBestBn[i-1][1]+"'><img src='"+arrBeautyBestBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}

	else if ( CategoryBn == 6)
	{
		for (var idx = 1; idx <= arrDigitalBestBn.length ; idx++)
		{
			if (i == idx)
				document.getElementById("btn6_"+ i).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+i+"g.gif";
			else
				document.getElementById("btn6_"+ idx).src = "http://image.gmarket.co.jp/challenge_jp/index/cate_num"+idx+".gif";
		}
		document.getElementById("DigitalBest_goodsBn").innerHTML = "<a href='"+ arrDigitalBestBn[i-1][1]+"'><img src='"+arrDigitalBestBn[i-1][0]+"' width=179 height=155 border=0></a>";
	}
}