// Æ¯Á¤ °á°ú¸¦ Å¬¸¯ÇÏ¸é, »ó¼¼ Á¤º¸¸¦ º¸¿©ÁØ´Ù. 
function FullViewResult(intDataNo)
{
	with (document.forms[1])
	{
		var objFullViewPageNo = document.getElementById("FullViewPageNo");		
		if (objFullViewPageNo == null)
			FullViewDataNo.value = intDataNo;	
		else
		{
			intFullViewPageNo = parseInt(FullViewPageNo.value, 10);
			FullViewDataNo.value = parseInt(intDataNo, 10) + (intFullViewPageNo - 1) * parseInt(ResultPerPage.value, 10);	
		}
			
		target = self.name;
		submit();
	}
}
// ¸µÅ©¸¦ Ã³¸®ÇÑ´Ù. 
function handleLink(intDRowIndex, intElementIndex, strLinkType, strTDID)
{
	if (strLinkType == "FullView" || strLinkType == "FullView_NB")
	{
		setOriginSysDivCtrlNo();
		FullViewResult(intDRowIndex);
	}
	else if (strLinkType == "FullView_VOD")
	{
		var objAbbrTD = eval(strTDID + intDRowIndex + "_" + intElementIndex);
		var strSysDiv = objAbbrTD.getAttribute("SysDiv");
		var strControlNo = objAbbrTD.getAttribute("ControlNo");
		self.location.href = "TOTWServiceVODRedirect.asp?SysDiv=" + strSysDiv + "&ControlNo=" + strControlNo + "&Gubun=VOD";
	}
	// URL/¿ø¹®/VOD/°í¼­/ºñÆò/¼­Æò/ÃÊ·Ï/¸ñÂ÷ ÀÏ ¶§
	else if (strLinkType == "URL" || strLinkType == "IMG" || strLinkType == "VOD" || 
						strLinkType == "OLD" || strLinkType == "CRI" || strLinkType == "REV" ||
						strLinkType == "EXC" || strLinkType == "CON")
		showService(intDRowIndex, intElementIndex, strLinkType, strTDID);
}
// ¿ø¹®, VOD µîÀ» º¸¿©ÁØ´Ù. 
// ¿¬µ¿µÈ Á¤º¸°¡ ¸Å´Þ·Á ÀÖÀ» ¼ö ÀÖÀ¸¹Ç·Î µ¿ÀÏÇÑ ASP page·Î Redirect½ÃÅ²´Ù. (»õ·Î¿î SysDiv, ControlNoÁ¤º¸¸¦ ¾ò´Â´Ù.)
function showService(intDRowIndex, intElementIndex, strService, strTDID)
{
	var strHref;
	var objAbbrTD = eval(strTDID + intDRowIndex + "_" + intElementIndex);
	var strSysDiv = objAbbrTD.getAttribute("SysDiv");
	var strControlNo = objAbbrTD.getAttribute("ControlNo");
	var strIdentifier = objAbbrTD.getAttribute("GuBun");
	if (strIdentifier == null)
		strIdentifier = strService;
	strHref = getServiceASPName(strService) + "?SysDiv=" + strSysDiv + "&ControlNo=" + strControlNo + "&Gubun=" + strIdentifier;

	if (strService == "URL")
	{
		strHref = objAbbrTD.getAttribute("URL");
		window.open(strHref, strService);
		return;
	}
	
	if (strService == "MARC" || strService == "XML")
	{
		wndWidth = "550";
		wndHeight = "600";
	}
	else if (strService == "IMG" || strService == "OLD")
	{
		wndWidth = "800";
		wndHeight = "700";
	}
	else if (strService == "VOD")
	{
		wndWidth = "640";
		wndHeight = "470";
	}
	else
	{
		wndWidth = "600";
		wndHeight = "500";
	}
	window.open (strHref, strService, "toolbar=no,width=" + wndWidth + ",height=" + wndHeight + ",resizable=yes,scrollbars=yes,location=no,status=no,directory=no,menubar=no");

	//window.open(strHref, "Service");
	//self.location.href = strHref;
	//alert(strHref);
}
// ¿ø¹®, VODµîÀ» º¸¿©ÁÙ ASP ÆÄÀÏ ¸íÀ» °¡Á®¿Â´Ù. 
function getServiceASPName(strService)
{
	switch (strService)
	{
		case "MARC"	: return "TOTWServiceMARC.asp";
		case "XML"	: return "TOTWServiceXML.asp";
		case "IMG"	: return "TOTWServiceIMG.asp";				
		case "VOD"	: return "TOTWServiceVODRedirect.asp";
		case "OLD"	: return "TOTWServiceIMG.asp";
		case "Crit"	: return "TOTWServiceCriticism.asp";
		case "CRI"	: return "TOTWServiceCriticism.asp";
		case "REV"	: return "TOTWServiceREV.asp";
		case "EXC"	: return "TOTWServiceExcerpt.asp";
		case "CON"	: return "TOTWServiceContent.asp";

		default		: return "TOTWServiceRedirect.asp";
	}
}

//¹Ù±¸´Ï¿¡ ÀúÀåµÉ Á¤º¸¸¦ ¸¸µç´Ù.  
function PutBasketContent()
{
	if (CountCheckBoxNo(intFormIndex, strCheckBoxName) == 0)
		return false;
	else if(CheckSelectNothing(intFormIndex, strCheckBoxName) == true)
	{
		alert(lngCheckAlert);
		return false;
	}
	else 
	{
		var objCheckBox = eval("document.forms[0]." + strCheckBoxName);
		var objDataTR;
		var strSysDiv, strControlNo;
		var strChkBoxValue;
		var objDispTR = eval("DispTR");
		var chkBxLength = objCheckBox.length ? objCheckBox.length : 1;

		for (chkIndex=0;chkIndex<chkBxLength;chkIndex++)
		{
			objEachChkBx = (chkBxLength==1) ? objCheckBox : objCheckBox[chkIndex];
			if (objEachChkBx.checked == true)
			{
				//Ã¼Å©µÈ µ¥ÀÌÅÍ Áß ÅëÇÕ °Ë»ö Disp Ç×¸ñ¸¸(¸Å´Þ¸° ¸ÅÃ¼°¡ ÀÖÀ¸¸é ¸ðµÎ ÀúÀå) ÀúÀåÇÏ¿© ¹Ù±¸´Ï¿¡ ³Ö´Â´Ù.   
				objDataTR = eval("DataTR" + (chkIndex+1));
				with (document.forms[1])
				{
					strSysDiv = OriginFullViewSysDiv.value.split("")[chkIndex];
					strControlNo = OriginFullViewControlNo.value.split("")[chkIndex];
				}
				strChkBoxValue = "SysDiv¢º" + strSysDiv + "" + "ControlNo¢º" + strControlNo;
				
				// ¼±ÅÃ, ¹øÈ£¿¡ ÇØ´çµÇ´Â ColumnÀº »ý°¢ÇÏÁö ¸»¾Æ¾ß ÇÑ´Ù. 
				for(trIndex=2;trIndex<DispTR.childNodes.length;trIndex++)
					// DispÇ×¸ñÀº intTotSysDispNo°³¼ö ¸¸Å­ ÀúÀåÇÏ°í ³ª¸ÓÁö ¿ø¹®, VODµîÀÇ Á¤º¸¸¦ ÀúÀåÇÑ´Ù. 
					if (trIndex<=intTotSysDispNo+1 || objDispTR.childNodes[trIndex].LinkType.length > 0) 
					{
						// IMGÀÏ¶§, ¿ø¹®°ú °í¼­ÀÇ ±¸ºÐÀÚ¸¦ ³Ñ°Ü ÁÖ¾î¾ß ÇÑ´Ù. 
						if (objDispTR.childNodes[trIndex].LinkType == "IMG" && 
								(strGubunValue = objDataTR.childNodes[trIndex].getAttribute("GuBun")) != null)
							strGubun = "¢º" + strGubunValue;
						else
							strGubun = "";
							
						strChkBoxValue = strChkBoxValue + "" + DispTR.childNodes[trIndex].LinkType 
								+ "¢º" + objDataTR.childNodes[trIndex].data + strGubun;
					}
				objEachChkBx.value = strChkBoxValue;
				//alert(objEachChkBx.value);
				//document.write(objEachChkBx.value);

			}			
		}
		return true;
	}
}

// My °Ë»ö Á¤º¸¿¡ ÀúÀåÇÏ±â 
function Add2MySearch()
{
	if (PutBasketContent() == false)
		return;

	wndWidth = "600";
	wndHeight = "500";
	window.open ("", "ListFolder", "toolbar=no,width=" + wndWidth + ",height=" + wndHeight + ",scrollbars=yes,location=no,status=no,directory=no,menubar=no");
	
	with (document.forms[0])
	{
		Mode.value = "AddMyCol";
		target = "ListFolder";	
		action = "./TOTWServiceMyCol.asp";
		submit();
	}	
}

// Ã¼Å© ¹Ú½º¿¡ Ã¼Å©µÈ °á°úµé¿¡ ´ëÇÑ DispÇ×¸ñº°·Î Á¤º¸µéÀ» °¡Á®¿Â´Ù. (´ÙÀ½ ÆäÀÌÁö¿¡¼­ °£·« ¸®½ºÆ®¸¦ º¸¿©ÁÙ ¶§ »ç¿ë)
function getResultsInformation()
{
	if (CountCheckBoxNo(intFormIndex, strCheckBoxName) == 0)
		return false;	//Ã¼Å©ÇÑ °ÍÀÌ ¾øÀ¸¸é false¸¦ ¸®ÅÏ 
	else if(CheckSelectNothing(intFormIndex, strCheckBoxName) == true)
	{
		alert(lngCheckAlert);
		return false;	//Ã¼Å©ÇÑ °ÍÀÌ ¾øÀ¸¸é false¸¦ ¸®ÅÏ 
	}
	else
	{
		setOriginSysDivCtrlNo();
		var objCheckBox = eval("document.forms[0]." + strCheckBoxName);
		var arrSysDiv, arrControlNo, strSysDiv, strControlNo;
		var chkBxLength = objCheckBox.length ? objCheckBox.length : 1;
		if (chkBxLength > 1)
		{
			strSysDiv = "";
			strControlNo = "";
			with (document.forms[1])
			{
				arrSysDiv = OriginFullViewSysDiv.value.split("");
				arrControlNo = OriginFullViewControlNo.value.split("");
			}
			for (chkIndex=0;chkIndex<chkBxLength;chkIndex++)
			{
				if (objCheckBox[chkIndex].checked == true)
				{
					strSysDiv = strSysDiv + arrSysDiv[chkIndex] + "";
					strControlNo = strControlNo + arrControlNo[chkIndex] + "";
				}
			}
			with (document.forms[1])
			{
				FullViewSysDiv.value = strSysDiv.substr(0, strSysDiv.length-1);
				FullViewControlNo.value = strControlNo.substr(0, strControlNo.length-1);
			}
		}
		return true;	//±âº»ÀûÀÎ SysDiv, SysControlNo¸¦ ÀúÀåÇÏ°í true¸¦ ¸®ÅÏ
	}


}
// Ã¼Å©µÈ °á°úµéÀ» »ó¼¼ Á¤º¸ È­¸é¿¡¼­ º¸¿©ÁØ´Ù. 
function SearchFullView()
{
	if (getResultsInformation() == true)
		FullViewResult(1);
}

function setOriginSysDivCtrlNo()
{
	with (document.forms[1])
	{
		FullViewSysDiv.value = OriginFullViewSysDiv.value;
		FullViewControlNo.value = OriginFullViewControlNo.value;
	}
}
// ÀúÀå, ¸ÞÀÏ, Ãâ·Â µî¿¡ ´ëÇÑ ¸µÅ©¸¦ Ã³¸®ÇÑ´Ù. 
function handleSaving(strServiceType)
{
	if (PutBasketContent() == false)
		return;
	with (document.forms[0])
	{
		ServiceType.value = strServiceType;
		target = self.name;
		action = "TOTWServiceSave.asp";
		submit();
	}
}


//added by syjung :20010228
// My °­ÀÇÁ¤º¸¿¡ ÀúÀåÇÏ±â 
function Add2MyLecture()
{
	if (PutBasketContent() == false)
		return;

	wndWidth = "600";
	wndHeight = "500";
	window.open ("", "Add2MyLecture", "toolbar=no,width=" + wndWidth + ",height=" + wndHeight + ",scrollbars=yes,location=no,status=no,directory=no,menubar=no");
	
	with (document.forms[0])
	{
		target = "Add2MyLecture";	
		//action = "./TOTWServiceAdd2MyLecture.asp";
		action = "./TOTWServiceAdd2MyLecture.asp?FullViewSysDiv="+document.forms[1].FullViewSysDiv.value+"&FullViewControlNo="+document.forms[1].FullViewControlNo.value;
		submit();
	}	
}


