var _sn = new Array();
var _pclubname = new Array();
var _promotion = new Array();
var _pclub_title = new Array();
var _cntIndex = 0;
	
function getPclubMainPromotionHTML()
{
	var pars = $H({ran:Math.random()*999999}).toQueryString();
	new Ajax.Request('/include/pclub_main_promotion.xml', {method:'get', parameters:pars, onComplete:mainInfoXML});
}

function mainInfoXML(req)
{
	var xmlDoc = req.responseXML;
	var eRoot = xmlDoc.documentElement;

	var popups = eRoot.childNodes;
	
	_cntIndex = popups.length;
			
	if(popups.length > 0)
	{
		var htmlText = "";
		for(var i = 0; i < popups.length; i ++)
		{					
			_sn[i] = popups[i].firstChild.firstChild.nodeValue;
			_promotion[i] = popups[i].firstChild.nextSibling.firstChild.nodeValue;
			_pclubname[i] = popups[i].firstChild.nextSibling.nextSibling.firstChild.nodeValue;
			_pclub_title[i] = popups[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;						
					
		htmlText += "<div id='_btn"+i+"' style='display:"+(i==0 ? "block" : "none")+";'>";	
		htmlText += "<table width='220' border='0' cellpadding='0' cellspacing='0' background='http://img.thinkpool.com/pclub/prom/0809_left_box_bg.gif'>";
		htmlText += "<tr>";
		htmlText += "	<td><img src='http://img.thinkpool.com/pclub/prom/0809_left_box_top.gif' width='220' height='5'></td>";
		htmlText += "</tr>";
		htmlText += "<tr>";
		htmlText += "	<td align='center'>";			
		htmlText += "		<table width='205' border='0' align='center' cellpadding='0' cellspacing='0'>";
		htmlText += "		<tr> ";
		htmlText += "			<td height='20'> ";
		htmlText += "				<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
		htmlText += "				<tr> ";
		htmlText += "					<td height='24' class='text_indigo'><strong><img src='http://img.thinkpool.com/pclub/prom/icon_hot.gif' width='30' height='11'> ÇÁ¸®¹Ì¾öÅ¬·´</strong></td>";
		htmlText += "					<td align='right'>";
		htmlText += "						<table border='0'>";
		htmlText += "						<tr> ";
								for(var j = 0; j < popups.length; j ++){
		htmlText += "							<td><img src='http://img.thinkpool.com/pclub/prom/icon_"+(j+1)+(i==j ? "_on" : "") + ".gif' width='14' height='13' border='0' onClick=\"chagePclubClick("+j+")\" style='cursor:Pointer;'></td> ";
								}
		htmlText += "						</tr>";
		htmlText += "						</table>";
		htmlText += "					</td>";
		htmlText += "				</tr>";
		htmlText += "				</table>";
		htmlText += "			</td>";
		htmlText += "		</tr>";
		htmlText += "		<tr> ";
		htmlText += "			<td height='1' bgcolor='DFE6F0'></td>";
		htmlText += "		</tr>";
		htmlText += "		<tr> ";
		htmlText += "			<td height='60'>";		
		htmlText += "				<div style=margin-top:3px></div>";							
		htmlText += "				<table width='205' border='0' cellpadding='0' cellspacing='0'>";
		htmlText += "				<tr> ";
		htmlText += "					<td width='93'><a href='/pclub/" + _pclubname[i] + ".jsp?Gcode=000_013''><img src='http://img.thinkpool.com/pclub/prom/" + _pclubname[i] + ".gif' width='83' height='50' border='0'></a></td>";
		htmlText += "					<td width='112'><strong><a href='/pclub/" + _pclubname[i] + ".jsp?Gcode=000_013'>" + _pclub_title[i] + "</a></strong><br><a href='/pclub/" + _pclubname[i] + ".jsp?Gcode=000_013'>" + _promotion[i] + "</a>";
		htmlText += "					</td>";
		htmlText += "				</tr>";
		htmlText += "				</table>";				
		htmlText += "			</td>";
		htmlText += "		</tr>";
		htmlText += "		</table>";		
		htmlText += "	</td>";
		htmlText += "</tr>";
		htmlText += "<tr>";
		htmlText += "	<td><img src='http://img.thinkpool.com/pclub/prom/0809_left_box_bottom.gif' width='220' height='5'></td>";
		htmlText += "</tr>";
		htmlText += "</table>";
		htmlText += "</div>";
		}
							
		$('pclubmainprom').innerHTML = htmlText;
		

	}
}

function chagePclubClick(n)
{
	for(var j = 0; j < _cntIndex; j ++){
		document.getElementById("_btn"+j).style.display = "none";
	}
	
      document.getElementById("_btn"+n).style.display = "block";
}	
