// HTTP Requester[Notice ¿äÃ» ¿ë]
var oTotorosaNoticeHttpRequest = null;
// HTTP Requester[Notice ¿äÃ» ¿ë]
var oTotochatNoticeHttpRequest = null;
// HTTP Requester[Notice ¿äÃ» ¿ë]
var oTotodiskNoticeHttpRequest = null;
// HTTP Requester[Notice ¿äÃ» ¿ë]
var oCopyrightNoticeHttpRequest = null;
// HTTP Requester[Notice ¿äÃ» ¿ë]
var oMailNoticeHttpRequest = null;
// HTTP Requester[Notice ¿äÃ» ¿ë]
var oClubNoticeHttpRequest = null;

/** ÅäÅä·Î»ç °øÁö»çÇ× **/
function requestTotorosaNotice(){

	var oCmnHttpFrm = createFormElementForHttp();

	oTotorosaNoticeHttpRequest = new ClsHttpRequest();

	var body = oTotorosaNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120001&listSize=5", callBack_GetTotorosaNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÅäÅäÃ¤ÆÃ °øÁö»çÇ× **/
function requestTotochatNotice(){

	var oCmnHttpFrm = createFormElementForHttp();

	oTotochatNoticeHttpRequest = new ClsHttpRequest();
	var body = oTotochatNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120004&listSize=4", callBack_GetTotochatNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÅäÅäµð½ºÅ© °øÁö»çÇ× **/
function requestTotodiskNotice(){

	var oCmnHttpFrm = document.frmCmnAjaxForm;

	oTotodiskNoticeHttpRequest = new ClsHttpRequest();

	var body = oTotodiskNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120002&listSize=5", callBack_GetTotodiskNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÅäÅäµð½ºÅ© ÀúÀÛ±Ç °øÁö»çÇ× **/
function requestCopyrightNotice(){

	var oCmnHttpFrm = document.frmCmnAjaxForm;

	oCopyrightNoticeHttpRequest = new ClsHttpRequest();

	var body = oCopyrightNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120011&listSize=4", callBack_GetCopyrightNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÅäÅä¸ÞÀÏ °øÁö»çÇ× **/
function requestMailNotice(){

	var oCmnHttpFrm = createFormElementForHttp();
	
	oMailNoticeHttpRequest = new ClsHttpRequest();

	var body = oMailNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120005&listSize=4", callBack_GetMailNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÅäÅäÅ¬·´ °øÁö»çÇ× **/
function requestClubNotice(){

	var oCmnHttpFrm = document.frmNoticeCmn;
	
	oClubNoticeHttpRequest = new ClsHttpRequest();

	var body = oClubNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120003&listSize=4", callBack_GetClubNoticeList, oCmnHttpFrm, "POST", false);

}

/** ÀüÃ¼ °øÁö»çÇ× ( °í°´¼¾ÅÍ ) : 20080616 ÀÌÈÄ °í°´¼¾ÅÍ ºÐ¸® : Á¶À±Á¤ **/
function requestHelpNotice(){

	var oCmnHttpFrm = createFormElementForHttp();

	oClubNoticeHttpRequest = new ClsHttpRequest();

	var body = oClubNoticeHttpRequest.request("/common/dataset/cmn/notice/list/?serviceCode=120014&listSize=5", callBack_GetHelpNoticeList, oCmnHttpFrm, "POST", false);

}

function printNoticeList(oCmnNoticeHttpRequest, oNoticeTb){

	if (oCmnNoticeHttpRequest.readyState() != 4) {
		return;
	}
	
	if (oCmnNoticeHttpRequest.status() != 200) {
		return;
	}

	var serviceCode = "";
	var args = printNoticeList.arguments;
	if ( args.length > 2 )
	{
		serviceCode = args[2];
	}

	var html = "";
	var oRs = new ClsDataSet();

	oRs.setXmlDom(oCmnNoticeHttpRequest.responseXML());	

	for ( var i=0; i<oRs.count(); i++ ){
		
		var cmnNoticeId = oRs.field("cmn_notice_id");
		var cmnNoticeTitle = oRs.field("cmn_notice_title");
		var cmnNoticeRegDate = oRs.field("cmn_notice_reg_date");
		var cmnNoticeServiceCode = oRs.field("service_code");
		var serviceUrl = "";
		var cutStrCnt = 29;

		if ( serviceCode == "" )
		{
			serviceCode = cmnNoticeServiceCode;
		}
		// ÅäÅäµð½ºÅ© ¸ÞÀÎ°øÁö
		if ( serviceCode == "120002" ){
			cutStrCnt = 24;	
			serviceUrl = "/intro/notice/";
			serviceUrl = "http://help.totorosa.com/notice/";
		}
		// ÅäÅäµð½ºÅ© ÀúÀÛ±Ç ¸ÞÀÎ°øÁö		
		else if ( serviceCode == "120011" ){
			cutStrCnt = 23;
			serviceUrl = "http://help.totorosa.com/totodisk/intro/copyright/";
			
		}		
		else if ( serviceCode == "120005" ){
			cutStrCnt = 50;			
			serviceUrl = "/info/notice/";
			serviceUrl = "http://help.totorosa.com/notice/";
		}
		else if ( serviceCode == "120003" ){
			cutStrCnt = 24;
			serviceUrl = "/club/notice/";
			serviceUrl = "http://help.totorosa.com/notice/";
		}
		else if ( serviceCode == "120004" )
		{
			cutStrCnt = 24;
			serviceUrl = "/notice/";
			serviceUrl = "http://help.totorosa.com/notice/";
		}
		// °í°´ ¼¾ÅÍ ¸ÞÀÎ °øÁö
		else if ( serviceCode == "120006" )
		{
            cutStrCnt = 50;
			serviceUrl = "notice/";
			serviceUrl = "http://help.totorosa.com/notice/";
		}
		// ÅäÅä·Î»ç ¸ÞÀÎ °øÁö
		else if ( serviceCode == "120001" )
		{
			cutStrCnt = 23;
			serviceUrl = "http://help.totorosa.com/notice/";
			cmnNoticeServiceCode = "";
		}
		else{
			serviceUrl = "/notice/";
		}
		oRs.next();

		var oNewRow = oNoticeTb.insertRow(oNoticeTb.rows.length);
		var iNewRowIndex = oNewRow.rowIndex;

		// tr collection
		var aRows = oNoticeTb.rows;

		// »õ·Î »ý¼ºÇÑ trÀÇ td collection
		var aCells = oNewRow.cells;

		var oCell_1 = aRows(iNewRowIndex).insertCell(aCells.length);
		var oCell_2 = aRows(iNewRowIndex).insertCell(aCells.length);
		// ¾ÆÀÌÄÜ
		oCell_1.innerHTML = "<img src=http://img.totorosa.com/com/com_dot05.gif style='margin:3 0 3 0 '>";
		oCell_1.style.width = "4px";

		// Á¦¸ñ
		oCell_2.innerHTML = "<span style=\"overflow:hidden\"><a href='" + serviceUrl + "?serviceCode=" + cmnNoticeServiceCode + "&noticeId=" + cmnNoticeId + "' class=linktxt02d1_line>" + cut_str(cmnNoticeTitle, cutStrCnt) + "..</a></span>";
		if ( serviceCode == "120005" ){
			// ¸ÞÀÏ °øÁö¶ó¸é...
			var oCell_3 = aRows(iNewRowIndex).insertCell(aCells.length);
			oCell_3.align = "right";
			oCell_3.innerHTML = cmnNoticeRegDate.substr(0, 10);
		}
		if ( serviceCode == "120006" ){
			// ¸ÞÀÏ °øÁö¶ó¸é...
			var oCell_3 = aRows(iNewRowIndex).insertCell(aCells.length);
			oCell_3.align = "right";
			
		}

		// ¶óÀÎ ÁÙ ROW Ãß°¡
		oNewRow = oNoticeTb.insertRow(oNoticeTb.rows.length);
		iNewRowIndex = oNewRow.rowIndex;

		// tr collection
		aRows = oNoticeTb.rows;

		// »õ·Î »ý¼ºÇÑ trÀÇ td collection
		aCells = oNewRow.cells;

		oCell_1 = aRows(iNewRowIndex).insertCell(aCells.length);
		oCell_1.className = "dot_ling01";
		oCell_1.colspan = 3;
	}

}

/** ÅäÅä·Î»ç °øÁö»çÇ× **/
function callBack_GetTotorosaNoticeList(){

	printNoticeList(oTotorosaNoticeHttpRequest, getObject("oNoticeTbRosa"));

}

/** ÅäÅäÃ¤ÆÃ °øÁö»çÇ× **/
function callBack_GetTotochatNoticeList(){

	optChatNotice(); //Ã¤ÆÃ°øÁö ¶ç¿ì±â
	printNoticeList(oTotochatNoticeHttpRequest, getObject("oNoticeTbChat"));

}

/** ÅäÅäµð½ºÅ© °øÁö»çÇ× **/
function callBack_GetTotodiskNoticeList(){

	printNoticeList(oTotodiskNoticeHttpRequest, getObject("oNoticeTb"));

}

/** ÀúÀÛ±Ç ¸ñ·Ï **/
function callBack_GetCopyrightNoticeList(){

	printNoticeList(oCopyrightNoticeHttpRequest, getObject("oNoticeTbCopyright"));

}

/** ¸ÞÀÏ ¸ñ·Ï **/
function callBack_GetMailNoticeList(){

	printNoticeList(oMailNoticeHttpRequest, getObject("oNoticeTbMail"));

}

/** Å¬·´ ¸ñ·Ï **/
function callBack_GetClubNoticeList(){

	printNoticeList(oClubNoticeHttpRequest, getObject("oNoticeTbClub"));

}

/** °í°´¼¾ÅÍ ¸ñ·Ï ( ÀüÃ¼ °øÁö»çÇ× **/
function callBack_GetHelpNoticeList(){

	printNoticeList(oClubNoticeHttpRequest, getObject("oNoticeTbHelp"), "120006");

}