// faq
var faq_tab_img = Array();

	faq_tab_img[1] = 'q_web';
    faq_tab_img[2] = 'q_img';
	faq_tab_img[3] = 'q_stream';
	//faq_tab_img[4] = 'q_db';
	//faq_tab_img[5] = 'q_sms';
	faq_tab_img[4] = 'q_elearning';
	faq_tab_img[5] = 'q_ssl';

function getFaqList (seqno, img_num)
{
	//
	$("#faq_list").empty();


	var seqno   = seqno;

	for(tmp=1; tmp < 6; tmp++){

		img_name = faq_tab_img[tmp];
		if( tmp == img_num){
			img_src = '/images/hosting/2010/index/' + tmp + '_on.gif';
		}
		else{
			img_src = '/images/hosting/2010/index/' + tmp + '.gif';
		}

		//document.all[img_name].src = img_src;
		document.getElementsByName(img_name).src = img_src;
	}


	$.ajax({
		type: 'POST',
		url: '/include/ajax_inc/get_index.php',
		data: 'action=getFaqList&category='+seqno,
		dataType: 'json',
		error: function (XMLHttpRequest, textStatus, errorThrown) { alert ("Åë½Å Áß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.");},
		success: showFaqList
	});
}

function showFaqList(json_data)
{
	$("#faq_list").empty();


	if (json_data.total_count == 0)
	{
		var tr_html = "<tr valign='top'><td width='15' style='border-bottom:solid 1px #ebebeb;'><img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'></td><td height='25' style='border-bottom:solid 1px #ebebeb;'>³»¿ëÀÌ ¾ø½À´Ï´Ù.</td></tr><tr valign='top'><td width='15' style='border-bottom:solid 1px #ebebeb;'><img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'></td><td height='25' style='border-bottom:solid 1px #ebebeb;'></td></tr><tr valign='top'><td width='15' style='border-bottom:solid 1px #ebebeb;'><img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'></td><td height='25' style='border-bottom:solid 1px #ebebeb;'></td></tr><tr valign='top'><td width='15' style='border-bottom:solid 1px #ebebeb;'><img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'></td><td height='25' style='border-bottom:solid 1px #ebebeb;'></td></tr><tr valign='top'><td width='15' style='border-bottom:solid 1px #ebebeb;'><img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'></td><td height='25' style='border-bottom:solid 1px #ebebeb;'></td></tr>";

		$("#faq_list").append(tr_html);
	}
	else{

		for (var i=0; i<json_data.data.length; i++)
		{
			//alert(json_data.data[i][0]);
			var seqno       = json_data.data[i][0];
			var view_count  = json_data.data[i][1];
			var subject     = json_data.data[i][2];


			var tr_html = "<tr><td width='15' style='border-bottom:solid 1px #ebebeb;'>"
						+ "<img src='images/hosting/2010/index/icon.gif' width='11' height='11' align='absmiddle' style='margin-bottom:3px'>"
						+ "</td><td height='25' style='border-bottom:solid 1px #ebebeb;'><a href='javascript:viewFaq("+seqno+")' onclick='viewFaq("+seqno+")'>" + subject + "</td></tr>";
			$("#faq_list").append(tr_html);
		}
	}

}

function geHostingNotice ()
{

	$("#notice_list").empty();


	document.getElementsByName('h_notice')[0].src = '/images/hosting/2010/index/n_tab01_on.gif';
	document.getElementsByName('h_news')[0].src = '/images/hosting/2010/index/n_tab02.gif';

	document.getElementsByName('hosting_more')[0].href = '/notice/notice.php';

	$.ajax({
		type: 'POST',
		url: '/include/ajax_inc/get_hosting_index.php',
		data: 'action=getNoticeList',
		dataType: 'json',
		error: function (XMLHttpRequest, textStatus, errorThrown) { alert ("Åë½Å Áß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.");},
		success: showNoticeList
	});
}

function showNoticeList(json_data){
	$("#notice_list").empty();


	var tr_html = '<tr><td colspan="2" style="padding:17px 0px 0px 3px; line-height:19px">';
	for (var i=0; i<json_data.data.length; i++){
		 var seqno       = json_data.data[i][0];
		 var title       = json_data.data[i][1];
		 var view_count  = json_data.data[i][2];
		 var write_date  = json_data.data[i][3];

		 tr_html += '<b>¤ý</b><a href="/notice/notice_view.php?seq_no=' + seqno + '" class="inotice">['+ write_date +'] ' + title + '</a><br>';

	}
	tr_html += '</td></tr>';
	$("#notice_list").append(tr_html);
}



function geHostingNews ()
{
	$("#notice_list").empty();

	document.getElementsByName('h_notice')[0].src = '/images/hosting/2010/index/n_tab01.gif';
	document.getElementsByName('h_news')[0].src = '/images/hosting/2010/index/n_tab02_on.gif';

	document.getElementsByName('hosting_more')[0].href = '/notice/news.php';

	$.ajax({
		type: 'POST',
		url: '/include/ajax_inc/get_hosting_index.php',
		data: 'action=getNewsList',
		dataType: 'json',
		error: function (XMLHttpRequest, textStatus, errorThrown) { alert ("Åë½Å Áß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.");},
		success: showNewsList
	});

}

function showNewsList(json_data){
	$("#notice_list").empty();

	var tr_html = '<tr><td colspan="2" style="padding:17px 0px 0px 3px; line-height:19px">';
	for (var i=0; i<json_data.data.length; i++){
		 var seqno       = json_data.data[i][0];
		 var title       = json_data.data[i][1];
		 var write_date  = json_data.data[i][2];

		 tr_html += '<b>¤ý</b><a href="/notice/news_view.php?seq_no=' + seqno + '" class="inotice">['+ write_date +'] ' + title + '</a><br>';
	}
	tr_html += '</td></tr>';
	$("#notice_list").append(tr_html);
}


// »óÇ°¸®½ºÆ®
function goodsList(category, img_num)
{

	for(tmp=1; tmp < 5; tmp++){
		if( tmp == img_num){
			img_src = 'images/hosting/2010/index/dd_tab0' + tmp + '_on.gif';
		}
		else{
			img_src = 'images/hosting/2010/index/dd_tab0' + tmp + '.gif';
		}

		img_name = 'design_' + tmp;

		//document.all[img_name].src = img_src;
		//document.getElementsByName(img_name).src = img_src;
		document.getElementById(img_name).src = img_src;
	}


	if( category == 'HOME'){
		//document.all.home_etc_id.style.display = 'none';
		//document.all.home_main_id.style.display = 'block';
		$("#designshop_img").empty();
		$("#designshop_img").append("<tr><td><img src='/images/hosting/2010/index/img003_2.gif' border='0' usemap='#homepage'></td></tr>");

	}
	else{
		//document.all.home_etc_id.style.display = 'block';
		//document.all.home_main_id.style.display = 'none';

		var page = 1;

		var addData = "&page="+page+"&category="+category;
		getGoodsList(addData,category);
	}
}

// »óÇ°¸®½ºÆ®
function getGoodsList(addData,category)
{


	$.ajax({
		type: 'POST',
		url: '/include/ajax_inc/get_designshop_index.php',
		data: 'action=getGoodsList'+addData,
		dataType: 'json',
		error: function (XMLHttpRequest, textStatus, errorThrown) { alert ("Åë½Å Áß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.");},
		success: function(msg) {
			showDesignList (msg, category);
		}
	});
}


function showDesignList(json_data, category){
	$("#designshop_img").empty();



	var IMG_HOST = "partner.gabia.com";
	var tr_html = '';
	for (var i=0; i<json_data.data.length; i++)
	{
		var seq       	  = json_data.data[i][0];
		var img_path      = json_data.data[i][1];
		var goods_code    = json_data.data[i][2];
		var goods_name    = json_data.data[i][3];
		var sample_url    = json_data.data[i][4];
		var price 		  = json_data.data[i][5];
		var regist_date   = json_data.data[i][6];
		var view_count 	  = json_data.data[i][7];
		var sale_quantity = json_data.data[i][8];
		var goods_id	  = json_data.data[i][9];
		var partner_id	  = json_data.data[i][10];

		img_url = 'http://'+IMG_HOST+'/data/'+partner_id+'/'+goods_id+'/thumb_'+img_path+'';

		href_url = '/designshop/goods_view.php?seq='+seq+'&category='+category;

		if( i == 0 ){
			tr_html += "<tr>"
                    + "<td rowspan='2' align='center'>"
					+ "<a href='/designshop/goods_view.php?seq="+seq+"&category="+category+"' name='design_big_href'><img src='"+ img_url +"' name='design_big_img' width='126' height='127' border='0' style='border:solid 1px #e0e0e0;'></a>"
					+ "</td>"
					+ "<td align='center' valign='middle'>"
					+ "<a href=\"javascript:img_chg('"+ img_url +"', 'design_big_img','design_big_href','"+href_url+"')\" onmouseover=\"javascript:img_chg('"+ img_url +"', 'design_big_img','design_big_href','"+href_url+"')\"><img src='" + img_url + "' width='84' height='57' border='0' style='border:solid 1px #e0e0e0;'></a>"
					+ "</td>";
		}
		else{

			if( i == 3 ){
				tr_html += "</tr>"
						+  "<tr>";
			}


			tr_html += "<td align='center' valign='middle'>"
					+  "<a href=\"javascript:img_chg('"+ img_url +"', 'design_big_img','design_big_href','"+href_url+"')\" onmouseover=\"javascript:img_chg('"+ img_url +"', 'design_big_img','design_big_href','"+href_url+"')\"><img src='"+ img_url + "' width='84' height='57' border='0' style='border:solid 1px #e0e0e0;'></a>"
					+  "</td>";
		}
	}
	tr_html += "</tr>";


	$("#designshop_img").append(tr_html);

}


function img_chg(img_url, big_img, href_name, href_url){
	document.all[big_img].src = img_url;
	document.all[href_name].href = href_url;
}



// FAQ »ó¼¼º¸±â
function viewFaq (seqno)
{
	//
	$.ajax({
		type: 'POST',
		url: '/include/ajax_inc/get_index.php',
		data: 'action=getFaqInfo&seqno='+seqno,
		dataType: 'xml',
		error: function (XMLHttpRequest, textStatus, errorThrown) { alert ("Åë½Å Áß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.");},
		success: function (xml_data) {
			$(xml_data).find("data").each(function() {
				$('#dialog_subject').html($(this).find("subject").text());
				$('#dialog_category').html($(this).find("category").text());
				$('#dialog_contents').html($(this).find("contents").text());
				var attach_files = $(this).find("attach_files");
				$('#dialog_attach_files').html('');
				if (attach_files.find('file').length == 0)
				{
					$('#dialog_attach_files').append('Ã·ºÎÆÄÀÏ ¾øÀ½.');
				}
				else
				{
					$(attach_files).find("file").each(function() {
						$('#dialog_attach_files').append('<a href="/voc/file_viewer.php?s=' + $(this).attr("seqno") + '&gubun=D">' + $(this).text() + '</a> &nbsp; ');
					});
				}
				$('#dialog').dialog('open');
			});
		}
	});
}

