<%
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function STRUCTURE_TerritoryLabel(sCountryCode)
		
		Dim rsStoreData
		
		STRUCTURE_TerritoryLabel = LANG_DT( "STATE", "State" )	' set to "State" in case there is nothing else found
		If ( sCountryCode <> "" ) Then
			set rsStoreData	= CreateObject("ADODB.Recordset")
			sSQLText = "SELECT TerritoryLabel FROM CountryCodes WHERE CountryCode = '" & sCountryCode & "'"
			call DB_getFromDatabase(sSQLText, rsStoreData, "")
			If ( NOT rsStoreData.EOF ) Then
				STRUCTURE_TerritoryLabel = rsStoreData("TerritoryLabel")
				If ( IsNull(STRUCTURE_TerritoryLabel) ) Then
					STRUCTURE_TerritoryLabel = LANG_DT( "STATE", "State" )
				End If
			End If
			set rsStoreData	= Nothing
		End If
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function STRUCTURE_PostalCodeLabel(sCountryCode)
		
		Dim rsStoreData
		
		STRUCTURE_PostalCodeLabel = LANG_DT( "POSTAL_CODE", "Postal Code" )
		If ( sCountryCode <> "" ) Then
			set rsStoreData	= CreateObject("ADODB.Recordset")
			sSQLText = "SELECT PostalCodeLabel FROM CountryCodes WHERE CountryCode = '" & sCountryCode & "'"
			call DB_getFromDatabase(sSQLText, rsStoreData, "")
			If ( NOT rsStoreData.EOF ) Then
				STRUCTURE_PostalCodeLabel = rsStoreData("PostalCodeLabel")
				If ( IsNull(STRUCTURE_PostalCodeLabel) ) Then
					STRUCTURE_PostalCodeLabel = LANG_DT( "POSTAL_CODE", "Postal Code" )
				End If
			End If
			set rsStoreData	= Nothing
		End If
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	sub VALIDATE_textbox(byVal fieldName , byVal sFieldValue, byVal fieldSize, byVal fieldType, sAltTagValidation) 
	
		Dim sTemp
		
		If ( Trim(sFieldValue) <> "" ) Then
			sTemp = sFieldValue
		else
			sTemp = Server.HTMLEncode(Trim(Request(fieldName)))    
		end if
	
		Select Case fieldType
			Case "textbox" 
				%><input name="<%=fieldName%>" size="<%=fieldSize%>" value="<%=Server.HTMLEncode(sTemp)%>" alt="<%=sAltTagValidation%>"><%
			
			Case "password" 
				%><input name="<%=fieldName%>" type="password" size="<%=fieldSize%>" value="<%=Server.HTMLEncode(sTemp)%>" alt="<%=sAltTagValidation%>"><%
			
			Case "textarea" 
				%><textarea name="<%=fieldName%>" rows="5" cols="<%=fieldSize%>" alt="<%=sAltTagValidation%>"><%=sTemp%></textarea><%
		
		End Select 
	
	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	Displays a message. The sType determines if it's an "error" or "success" 		*
	'*		message. C_SUCCESS or C_ERROR are the two types.							*
	'*																					*
	'************************************************************************************
	Sub owMessage(sText, sType)
	
		Dim sColorType
		
		If ( sType = C_ERROR ) Then
			sColorType = "660000"
		Else
			sColorType = "000066"
		End If
		%>
		<table width=<%=sOWStoreTableWidth%> border=0 style='border: 1px solid #000000;' cellspacing=0 cellpadding=5>
			<tr>
				<td align=center>
					<br>
					<table><tr><td><b><%=sText%></b></td></tr></table>
					<br>
				</td>
			</tr>
		</table>
		<%
		
	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub STRUCTURE_RecurseCategories(sIDParentCat, iLevel, sDisplay, sSearchCatID)
		
		Dim rsStoreData
		Set rsStoreData	= CreateObject("ADODB.Recordset")
		
		sSQLText = "SELECT * FROM Categories WHERE Active = -1 AND idParentCategory = " & sIDParentCat & " ORDER BY DisplayOrder, CategoryDesc"
		Call DB_getFromDatabase (sSQLText, rsStoreData, "")
		While ( NOT rsStoreData.EOF )
			Select Case sDisplay
				Case "SELECT"
					If ( CInt(sSearchCatID) = CInt(rsStoreData("idCategory")) ) Then
						Response.Write "<option value='" & rsStoreData("idCategory") & "' SELECTED>" & String(iLevel*2, "-") & rsStoreData("CategoryDesc") & "</option>"
					Else
						Response.Write "<option value='" & rsStoreData("idCategory") & "'>" & String(iLevel*2, "-") & rsStoreData("CategoryDesc") & "</option>"
					End If
				Case "BREADCRUMB"
					Response.Write "<a href='owListProduct.asp?idCategory=" &arrCategories(f,1) & "'>" & arrCategories(f,0) &"</a>" & "&nbsp;&#151;&nbsp;"
			End Select
			iLevel = iLevel + 1
			Call STRUCTURE_RecurseCategories(rsStoreData("idCategory"), iLevel, sDisplay, sSearchCatID)
			iLevel = iLevel - 1
			rsStoreData.MoveNext
		Wend
		Call DB_closeRecordset(rsStoreData)
		Set rsStoreData	= Nothing
		
	End Sub
	'************************************************************************************
	
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub STRUCTURE_Breadcrumbs(sBreadCrumb, iParentUnq)
	
		Dim rsStoreData

		If ( iParentUnq = "" ) Then
			iParentUnq = 0
		Else
			If ( IsNumeric(iParentUnq) ) Then
				iParentUnq = CDbl(iParentUnq)
			Else
				iParentUnq = 0
			End If
		End If

		Set rsStoreData = CreateObject("ADODB.Recordset")
		sSQLText = "SELECT categoryDesc, idParentcategory FROM categories WHERE idCategory=" & iParentUnq
		Call DB_getFromDatabase (sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			if sBreadCrumb = "" then
				' this is the last entry, so end with two <br> tags
				sBreadCrumb = "<B>" & rsStoreData("categoryDesc") & "</b>"
			else
				If ( rsStoreData("idParentcategory") <> 0 ) Then	' don't display "Root"
					sBreadCrumb = "<a href='owListProduct.asp?idCategory=" & iParentUnq & "'>" & rsStoreData("categoryDesc") & "</a>&nbsp;--&nbsp;" & sBreadCrumb
				End If
			end if
			Call STRUCTURE_Breadcrumbs(sBreadCrumb, rsStoreData("idParentcategory"))
		End If
		Call DB_closeRecordset(rsStoreData)
		Set rsStoreData = Nothing
		
	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function STRUCTURE_ReturnCity(sCountryCode, sZip, sState)
	
		Dim rsStoreData
	
		Select Case UCase(Trim(sCountryCode))
			Case "US"
				sSQLText = "SELECT CZ.City AS City, SC.StateName AS State FROM CountryUSZipCode CZ LEFT OUTER JOIN StateCodes SC ON CZ.StateCode = SC.StateCode WHERE CountryUSZipCode = '" & SQLEncode(sZip) & "'"
			Case "CA"
				sSQLText = "SELECT CZ.City AS City, SC.StateName AS State FROM countryCAPostalCodes CZ LEFT OUTER JOIN StateCodes SC ON CZ.ProvinceCode = SC.StateCode WHERE CZ.CountryCAPostalCodes = '" & SQLEncode(sZip) & "'"
			Case "DK"
				sSQLText = "SELECT City, '' AS State FROM countryDKPostalCodes WHERE DKPostalCode = '" & SQLEncode(sZip) & "'"
		End Select
		
		If ( sSQLText <> "" ) Then
			Set rsStoreData = CreateObject("ADODB.Recordset")
			Call DB_getFromDatabase (sSQLText, rsStoreData, "")
			If ( NOT rsStoreData.EOF ) Then
				STRUCTURE_ReturnCity	= rsStoreData("City")
				sState					= rsStoreData("State")
			End If
			Call DB_closeRecordset(rsStoreData)
			Set rsStoreData = Nothing
		End If
	
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function STRUCTURE_ReturnState(sCountryCode, sZip)
	
		Dim rsStoreData
	
		Select Case UCase(Trim(sCountryCode))
			Case "US"
				sSQLText = "SELECT StateCode AS State FROM CountryUSZipCode WHERE CountryUSZipCode = '" & SQLEncode(sZip) & "'"
			Case "CA"
				sSQLText = "SELECT ProvinceCode AS State FROM countryCAPostalCodes WHERE CountryCAPostalCodes = '" & SQLEncode(sZip) & "'"
			Case "DK"
				sSQLText = "SELECT '' AS State FROM countryDKPostalCodes WHERE DKPostalCode = '" & SQLEncode(sZip) & "'"
		End Select
		
		If ( sSQLText <> "" ) Then
			Set rsStoreData = CreateObject("ADODB.Recordset")
			Call DB_getFromDatabase (sSQLText, rsStoreData, "")
			If ( NOT rsStoreData.EOF ) Then
				STRUCTURE_ReturnState	= rsStoreData("State")
			End If
			Call DB_closeRecordset(rsStoreData)
			Set rsStoreData = Nothing
		End If
	
	End Function
	'************************************************************************************
%>