//¹Ù±¸´Ï º¸±â. 
function ViewServiceBasket()
{
	with (document.forms[0])
	{
		action = "TOTWServiceBasket.asp";
		target = self.name;
		submit();
	}
}
//¹Ù±¸´Ï¿¡ ÀúÀå 
function PutServiceBasket()
{
	if (PutBasketContent() == false)
		return;
	with (document.forms[0])
	{
		action = "TOTWServiceBasketPut.asp";
		target = self.name;
	}
	
	DoSubmit(intFormIndex, strCheckBoxName);
}


function SortResultBy(strOrderType)
{
	var objSelectBox = document.forms[0].SelectedSortBy;
	var strCurSelectedSortBy = objSelectBox.options[objSelectBox.options.selectedIndex].value;
	// °Ë»ö °Ç¼ö°¡ 1000°ÇÀÌ ³ÑÀ¸¸é, ÀÏ´ÜÀº Á¤·ÄÀ» ÇÏÁö ¾Ê´Â´Ù.
	if (intTotalResultNo >=30000)
		return;
/*	if (strCurSelectedSortBy == strSelectedSortBy)
		return;
	else
*/
	{
		with (document.forms[0])
		{
			PageNo.value = "";
			var strSysKey = SysKey.value;
			var strSysDiv = SysDiv.value;	
			if (strSysDiv == "TOT")
				var strSysDivKey = "TOT00"
			else
				var strSysDivKey = strSysDiv + strSysKey.substr(strSysKey.length-2, 2);

			// Á¤·ÄÇÒ ¶§, ±âº»ÀûÀÎ °Ë»öÄõ¸®(OriginSearchQuery)¿¡ AND ·Î ´ÙÀ½ÀÇ Äõ¸®°¡ µ¡ºÙ¿©Áø´Ù. 
			// Çü½Ä --> [340,CAT01, 7, 1, 5] (ÃÑ °Ë»ö °Ç¼ö:340°Ç, 7:Á¤·Ä, 1:Disp01·Î Á¤·Ä, 5:asc, 6:desc)
			if (strOrderType == "up")
				strOrderIndex = "5"
			else
				strOrderIndex = "6"
			
			SearchQuery.value = OriginSearchQuery.value + " AND " + "[" + strDefaultMaxResult + "," 
									+ strSysDivKey + ",7," + strCurSelectedSortBy.substr(strCurSelectedSortBy.length-1, 1) 
									+ "," + strOrderIndex + "]";
			action = "TOTWSearchList.asp";
			target = self.name;
			submit();
			//alert(SearchQuery.value);
		}
	}
}


//table header´­·¶À»¶§ Á¤·ÄÇÏ´Â function
//È«¼ºÁø Ãß°¡ 20010602
function ClickSortHeader(strDisp)
{
	var strOrderType; 
	var strClickedDisp;
	var SortUpDown;
	
	strClickedDisp = document.forms[0].ClickedDisp.value;
	SortUpDown = document.forms[0].DispSortUpDown.value;
	if (strClickedDisp == strDisp) { //±Ý¹æ ´­·¶´ø Á¤·ÄÀ» ÇÑ¹ø ´õÇÑ´Ù. Á¤·Ä ¹æÇâÀÌ ¹Ù²ï´Ù
		if(SortUpDown == "up"){
			strOrderType = "down";
			document.forms[0].DispSortUpDown.value = "down";
		}
		else{
			strOrderType = "up";
			document.forms[0].DispSortUpDown.value = "up";
		}
	}
	else{
		document.forms[0].DispSortUpDown.value = "up";
		strOrderType = "up";
	}
	
	document.forms[0].ClickedDisp.value = strDisp;
		
	gstrOrderType = strOrderType;
	gstrDisp = strDisp;
	
	//var objSelectBox = document.forms[0].SelectedSortBy;
	//var strCurSelectedSortBy = objSelectBox.options[objSelectBox.options.selectedIndex].value;
	var strCurSelectedSortBy = strDisp
	// °Ë»ö °Ç¼ö°¡ 1000°ÇÀÌ ³ÑÀ¸¸é, ÀÏ´ÜÀº Á¤·ÄÀ» ÇÏÁö ¾Ê´Â´Ù.
	if (intTotalResultNo >=30000) {
		alert (strSortingOverMsg);
		return;
	}
/*	if (strCurSelectedSortBy == strSelectedSortBy)
		return;
	else
*/
	{
		with (document.forms[0])
		{
			PageNo.value = "";
			var strSysKey = SysKey.value;
			var strSysDiv = SysDiv.value;	
			if (strSysDiv == "TOT")
				var strSysDivKey = "TOT00"
			else
				var strSysDivKey = strSysDiv + strSysKey.substr(strSysKey.length-2, 2);

			// Á¤·ÄÇÒ ¶§, ±âº»ÀûÀÎ °Ë»öÄõ¸®(OriginSearchQuery)¿¡ AND ·Î ´ÙÀ½ÀÇ Äõ¸®°¡ µ¡ºÙ¿©Áø´Ù. 
			// Çü½Ä --> [340,CAT01, 7, 1, 5] (ÃÑ °Ë»ö °Ç¼ö:340°Ç, 7:Á¤·Ä, 1:Disp01·Î Á¤·Ä, 5:asc, 6:desc)
			if (strOrderType == "up")
				strOrderIndex = "5"
			else
				strOrderIndex = "6"
			
			SearchQuery.value = OriginSearchQuery.value + " AND " + "[" + strDefaultMaxResult + "," 
									+ strSysDivKey + ",7," + strCurSelectedSortBy.substr(strCurSelectedSortBy.length-1, 1) 
									+ "," + strOrderIndex + "]";
			//if (CallASPKind)
			findCallASPKind = false;
			for (i=0;i<elements.length;i++)
			{
				if (elements[i].name == "CallASPKind")
				{	
					findCallASPKind = true;
					action = CallASPKind.value;
				}
				else
				{
					if (findCallASPKind == false) 
						action = "/dlsearch/dlsearch/TOTWSearchList.asp";
				}
			}
			//else
			//	action = CallASPKind.value;
			target = self.name;
			//alert(SearchQuery.value);
			submit();
		}
	}
}
/*
function SearchWithSysKey(strSysKey, strSysDiv)
{
	alert(strSysKey+":"+strSysDiv);
	with (document.forms[0])
	{
		if (strSysDiv == "TOT")
			var strSysDivKey = "TOT00"
		else
			var strSysDivKey = strSysDiv + strSysKey.substr(strSysKey.length-2, 2);
			
		var strSearchQuery = SearchQuery.value;
		SearchQuery.value = replaceString(strSearchQuery, strSysDivKey);
		OriginSearchQuery.value = replaceString(OriginSearchQuery.value, strSysDivKey);
		SysKey.value = strSysKey;
		SysDiv.value = strSysDiv;
		PageNo.value = "";
		RetdMaxResultNo.value = "";
		target = self.name;
		action = "TOTWSearchList.asp";
		submit();
	}
}


function replaceString(str1, str2)
{
	var tempIndex1, tempIndex2;
	if ((tempIndex1 = str1.indexOf("[")) != -1)
	{
		tempIndex1 = str1.indexOf(",", tempIndex1)
		tempIndex2 = str1.indexOf(",", tempIndex1+1)
		str1 = str1.substr(0, tempIndex1+1) + str2 +
			replaceString(str1.substr(tempIndex2, str1.length-tempIndex2), str2);
	}
	return str1;
}
// °á°ú³» Àç°Ë»ö¿¡ °üÇÑ ¸µÅ© °É±â 
function SearchPrecisely()
{
	wndWidth = "750";
	wndHeight = "500";
	window.open ("", "PreciseSearch", "toolbar=no,width=" + wndWidth + ",height=" + wndHeight + ",location=no,status=no,directory=no,menubar=no");
	with (document.forms[0])
	{
		target = "PreciseSearch"
		action = "TOTWSearchResult.asp";
		submit();
		target = self.window.name;
	}
	
}

function SearchWithSysKey(strSysKey, strSysDiv)
{
	//alert(strSysKey+":"+strSysDiv);
	with (document.forms[0])
	{
		if (strSysDiv == "TOT")
			var strSysDivKey = "TOT00"
		else
			var strSysDivKey = strSysDiv + strSysKey.substr(strSysKey.length-2, 2);
			
		var strSearchQuery = SearchQuery.value;
		SearchQuery.value = replaceString(strSearchQuery, strSysDivKey);
		OriginSearchQuery.value = replaceString(OriginSearchQuery.value, strSysDivKey);
		SysKey.value = strSysKey;
		SysDiv.value = strSysDiv;
		PageNo.value = "";
		RetdMaxResultNo.value = "";
		target = self.name;
		action = "TOTWSearchList.asp";
		submit();
	}
}
*/
function SearchWithSysKey(strLimitValue)
{
	with (document.forms[0])
	{
		var strSearchQuery = OriginSearchQuery.value;
		if (strLimitValue != "TOTAL")
		{
			strSearchQuery = "(" + strSearchQuery + ") and (";
			var arrLimitValue = strLimitValue.split("");
			for (intIndex=0; intIndex<arrLimitValue.length; intIndex++)
			{
				if (intIndex < arrLimitValue.length-1)
					strSearchQuery = strSearchQuery + "[" + arrLimitValue[intIndex] + ",TOT00,3,1,3] or ";
				else
					strSearchQuery = strSearchQuery + "[" + arrLimitValue[intIndex] + ",TOT00,3,1,3])";
			}
		}
		Limit01Value.value = strLimitValue;
		SearchQuery.value = strSearchQuery;
		if (document.forms[0].SelectedSortBy)
			SelectedSortBy.options.selectedIndex = -1;
		PageNo.value = "";
		RetdMaxResultNo.value = "";
		target = self.name;
		action = "TOTWSearchList.asp";
		submit();
	}
}


function replaceString(str1, str2)
{
	var tempIndex1, tempIndex2;
	if ((tempIndex1 = str1.indexOf("[")) != -1)
	{
		tempIndex1 = str1.indexOf(",", tempIndex1)
		tempIndex2 = str1.indexOf(",", tempIndex1+1)
		str1 = str1.substr(0, tempIndex1+1) + str2 +
			replaceString(str1.substr(tempIndex2, str1.length-tempIndex2), str2);
	}
	return str1;
}
// °á°ú³» Àç°Ë»ö¿¡ °üÇÑ ¸µÅ© °É±â 
function SearchPrecisely()
{
	wndWidth = "750";
	wndHeight = "400";
	window.open ("", "PreciseSearch", "toolbar=no,width=" + wndWidth + ",height=" + wndHeight + ",location=no,status=no,directory=no,menubar=no");
	with (document.forms[0])
	{
		target = "PreciseSearch"
		action = "TOTWSearchResult.asp";
		submit();
		target = self.window.name;
	}
	
}

function RequestBookHope()
{
	self.location.href="/dlsearch/dlservice/bookhope/LegWHopeForm.asp?TitleImageName= &MainMenuNo=236&InformYN=N&InformHTML= &InformTarget= &InformWidth= &InformHeight=";
}

