//	¸ÞÀÎ»óÇ° ¿¬°á
function main_view(chk_id, code, limit)
{
	var url = 'index.htm?mode=m_view&code='+ code +'&limit='+ limit ;

	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function()	{

		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {

			try {

				eval("var response = ("+ xmlhttp.responseText +")");

				htmls = recommend_html(response);
				document.getElementById('m_view[1]').innerHTML = htmls;

				for(i = 1 ; i <= 7; i++) {

					id = "A"+ i;
					if(chk_id == id) {

						url = 'url(images/design/mm_1.gif)';
						color = '#FF6600';
					}
					else {

						url = 'url(images/design/mm_2.gif)';
						color = '#535353';
					}

					document.getElementById(id).style.color = color;
					document.getElementById(id).style.backgroundImage = url;
				}

			} catch(e) {

				alert(e.message);
			}
		}
	};
	xmlhttp.send(null);
}

function recommend_html(response)
{
	var htmls = "<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\">";
		htmls += "  <tr>";

	if(response == "NULL") {

			htmls += "<td valign='top'>";
			htmls += "<table width=\"524\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
			htmls += "  <tr>";
			htmls += "    <td height=\"260\" align=\"center\"><b>°Ë»öÁ¤º¸°¡ ¾ø½À´Ï´Ù.</b></td>";
			htmls += "  </tr>";
			htmls += "</table>";
			htmls += "</td>";
	}
	else {

		for(i = 0, num = response.length; i < num; i++) {

			if(i % 2 == 0) htmls += "</tr><tr>";

			htmls += "<td height=\"90\" valign='top' style=\"border-style:dotted; border-width:0px 0px 1px 0px; border-color:CCCCCC;\">";
			htmls += "<table width=\"260\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
			htmls += "  <tr>";
			htmls += "    <td width=\"60\" valign=\"top\" align=\"left\"><span style=\"width: 60px; margin-left: 2px; padding: 2px; border: solid 1px #CCCCCC; background: #FFFFFF;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\"><img src=\"/p_img/"+ response[i].img1 +"\" width=\"60\" height=\"60\" border=\"0\"></a></span></td>";
			htmls += "    <td valign=\"top\" align=\"left\">";
			htmls += "<p style=\"line-height: 18px; font-weight: bold;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].artist +"</a></p>";
			htmls += "<p style=\"line-height: 16px; font-size: 11px;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].title +"</a></p>";
			htmls += "<p style=\"line-height: 16px;\">"+ response[i].summary +"</p>";

			if( response[i].sale_fg == "y") {

				htmls += "<p style=\"line-height: 16px; color: #FF6600; font-weight: bold;\">"+ response[i].sale_price +"</p>";
			}
			else {

				htmls += "<p style=\"line-height: 16px; color: #FF6600; font-weight: bold;\">"+ response[i].price +"</p>";
			}
			htmls += "</td>";
			htmls += "  </tr>";
			htmls += "</table>";
			htmls += "</td>";
		}
	}
	htmls += "  </tr>";
	htmls += "</table>";

	return htmls;
}

//	¸ÞÀÎ»óÇ° ¿¬°á
function right_view(chk_id, code, limit)
{
	var url = 'index.htm?mode=m_view&code='+ code +'&limit='+ limit ;

	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function()	{

		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {

			try {

				eval("var response = ("+ xmlhttp.responseText +")");

				htmls = right_html(response);
				document.getElementById('m_view[2]').innerHTML = htmls;

				for(i = 1 ; i <= 5; i++) {

					id = "B"+ i;
					if(chk_id == id) {

						bground	= '#FF6600';
						color	= '#FFFFFF';
					}
					else {

						bground	= '#EEEEEE';
						color	= '#535353';
					}

					document.getElementById(id).style.color = color;
					document.getElementById(id).style.background = bground;
				}

			} catch(e) {

				alert(e.message);
			}
		}
	};
	xmlhttp.send(null);
}

function right_html(response)
{
	var htmls = "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
		htmls += "  <tr>";

	if(response == "NULL") {

			htmls += "<td valign='top'>";
			htmls += "<table width=\"234\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
			htmls += "  <tr>";
			htmls += "    <td height=\"160\" align=\"center\"><b>°Ë»öÁ¤º¸°¡ ¾ø½À´Ï´Ù.</b></td>";
			htmls += "  </tr>";
			htmls += "</table>";
			htmls += "</td>";
	}
	else {

		for(i = 0, num = response.length; i < num; i++) {


			if(response[i].no < 1) {

				htmls += "<tr>";
				htmls += "<td valign='top'>";
				htmls += "<table width=\"234\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\" style=\"border-style:dotted; border-width:0px 0px 1px 0px; border-color:CCCCCC;\">";
				htmls += "  <tr>";
				htmls += "    <td width=\"54\" valign=\"top\" align=\"left\"><span style=\"width: 50px; margin-left: 2px; padding: 2px; border: solid 1px #CCCCCC; background: #FFFFFF;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\"><img src=\"/p_img/"+ response[i].img2 +"\" width=\"50\" height=\"50\" border=\"0\"></a></span></td>";
				htmls += "    <td valign=\"top\" align=\"left\">";
				htmls += "<p style=\"line-height: 18px; font-weight: bold; letter-spacing:-1px;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].artist +"</a></p>";
				htmls += "<p style=\"line-height: 16px; font-size: 11px;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].title +"</a></p>";
				htmls += "<p style=\"line-height: 16px;\">"+ response[i].summary +"</p>";
				htmls += "</td>";
				htmls += "  </tr>";
				htmls += "</table>";
				htmls += "</td>";
				htmls += "</tr>";
			}
			else {

				htmls += "<tr>";
				htmls += "<td valign='top'>";
				htmls += "<table width=\"234\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-style:dotted; border-width:0px 0px 1px 0px; border-color:CCCCCC;\">";
				htmls += "  <tr>";
				htmls += "    <td width=\"20\" valign=\"top\" align=\"center\"><span style=\"width: 20px; margin-left: 2px; border: solid 1px #CCCCCC; background: #FFCC99; font-weight: bold;\">"+ response[i].no +"</span></td>";
				htmls += "    <td valign=\"top\" align=\"left\" style=\"padding-left: 2px;\">";
				htmls += "<span style=\"font-weight: bold; letter-spacing:-1px;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].artist +"</a></span><br>";
				htmls += "<span style=\"font-size: 11px; letter-spacing:-1px;\"><a href=\"/product.htm?mode=goods_view&goods_id="+ response[i].goods_id +"\">"+ response[i].title +"</a></span>";
				htmls += "<p style=\"line-height: 16px;\">"+ response[i].summary +"</p>";
				htmls += "</td>";
				htmls += "  </tr>";
				htmls += "</table>";
				htmls += "</td>";
				htmls += "</tr>";

			}
		}
	}
	htmls += "  </tr>";
	htmls += "</table>";

	return htmls;
}
