<!--#include file="../../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../header.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************
	
	Dim iConfGroup
	
	sOWCompanyCountryCode2 = Trim(Request("sOWCompanyCountryCode2"))

	%>
	<body onLoad = 'toForm()' style="font-family: Arial; font-size: 11px;" topmargin="0" leftmargin="0" bgcolor=C3DAF9>
	
	<script language='JavaScript1.2' type='text/javascript'>
	
		function SubmitForm(sAction){
			document.CompanySetting.sAction.value = sAction;
			document.CompanySetting.submit();
		}
		
	</script>

	<form name="CompanySetting" method="post" action="owSettingsModifyExec.asp">
		<input type='hidden' name='sAction' value=''>
		<table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding:5px; FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #808080" bgcolor="#ffffff"><tr><td>
		<table border="0" cellpadding="0" cellspacing="0" width="100%" style="FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #808080" bgcolor="#ffffff">
			<tr>
				<td colspan=4 style='padding-bottom: 2px; padding-top: 6px;'>
					<%iConfGroup = 0%>
					<table width=100% border="0" cellpadding="0" cellspacing="0" style="FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #808080" bgcolor="#FFFFFF">
						<tr>
							<td>
				            	<table border="0" cellpadding="5" cellspacing="0" style="border-left: 1px solid C3DAF9; FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #808080" bgcolor="#EAF1F9">
				            		<tr>
				            			<td align=right style='border-top: 1px solid C3DAF9; border-right: 1px solid C3DAF9;' nowrap><b><%=DisplayHeader(iConfGroup)%></b></td>
				            			<td width=100% bgcolor=FFFFFF style='border-bottom: 1px solid C3DAF9;'>&nbsp;</td>
				             		</tr>
				            	</table>
				            </td>
						</tr>
						<tr bgcolor="#EAF1F9">
							<td>
				            	<table width=100% border="0" cellpadding="5" cellspacing="0" style="border-left: 1px solid C3DAF9; border-right: 1px solid C3DAF9; border-bottom: 1px solid C3DAF9; FONT-WEIGHT: bold; FONT-SIZE: 11px; COLOR: #808080" bgcolor="#EAF1F9">
				            		<%Call DisplaySettings(iConfGroup)%>
				            	</table>
				            </td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</td></tr></table>
	</form>
	<!--#include file="../footer.asp"-->

<%
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function DisplayHeader(sIdSettingGroup)

		sSQLText = "SELECT GroupName FROM SettingsGroupNames WHERE idSettingGroup = " & sIdSettingGroup
		call DB_getFromDatabase(sSQLText, rsStoreData, "") 
		If ( NOT rsStoreData.EOF ) Then
			DisplayHeader = "<font size=+1 color=2A5CB2>" & rsStoreData("GroupName") & "</font>"
		End If
		Call DB_closeRecordset(rsStoreData)
		
	End Function
	'************************************************************************************


	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub DisplaySettings(sIdSettingGroup)
		sSQLText = "SELECT S.idSetting, S.settingKey, S.settingValue, S.comments, S.type, SO.settingoption, SO.optionvalue FROM Settings S LEFT OUTER JOIN SettingsOptions SO ON S.idSetting = SO.idSetting WHERE S.idSettingGroup = " & sIdSettingGroup & " ORDER BY S.idSetting"
		call DB_getFromDatabase(sSQLText, rsStoreData, "") 
		While ( NOT rsStoreData.EOF )
			sIdSetting		= Trim(rsStoreData("idSetting"))
			sSettingKey		= Trim(rsStoreData("settingKey"))
			sSettingValue	= Trim(rsStoreData("settingValue"))
			sComments		= Trim(rsStoreData("comments"))
			sType			= UCase(Trim(rsStoreData("type")))
			
			If ( sComments = "" ) Or ( IsNull(sComments) ) Then
				sComments = sSettingKey
			End If
			
			If ( sSettingKey = "sOWCompanyCountryCode" ) Then

				If ( sOWCompanyCountryCode2 = "" ) then
					sOWCompanyCountryCode2 = sSettingValue
				End If

				sSQLText = "SELECT * FROM CountryCodes ORDER BY Position"
				call DB_getFromDatabase(sSQLText, rsStoreData2, "")
				%>
				<tr>
					<td width=50%>Company Country</td>
					<td width=50%>
						<select name='<%=sSettingKey%>' onChange='SubmitForm("sChangeCountry");'>
							<option value=''>Please Select</option>
							<%
							While ( NOT rsStoreData2.EOF )
								If ( sOWCompanyCountryCode2 = rsStoreData2("CountryCode") ) Then
									Response.Write "<option value='" & rsStoreData2("CountryCode") & "' selected>" & rsStoreData2("CountryName") & "</option>"
								Else
									Response.Write "<option value='" & rsStoreData2("CountryCode") & "'>" & rsStoreData2("CountryName") & "</option>"
								End If
								rsStoreData2.MoveNext
							Wend
							%>
						</select>
					</td>
				</tr>
				<%
				Call DB_closeRecordset(rsStoreData2)
			ElseIf ( sSettingKey = "sOWCompanyStateCode" ) Then
				sSQLText = "SELECT * FROM StateCodes WHERE CountryCode = '" & sOWCompanyCountryCode2 & "' ORDER BY StateName"
				call DB_getFromDatabase(sSQLText, rsStoreData2, "")
				%>
				<tr>
					<td width=50%>Company <%=STRUCTURE_TerritoryLabel(sOWCompanyCountryCode2)%></td>
					<td width=50%>
						<select name='<%=sSettingKey%>'>
							<option value=''>Please Select</option>
							<%
							While ( NOT rsStoreData2.EOF )
								If ( sSettingValue = rsStoreData2("StateCode") ) Then
									Response.Write "<option value='" & rsStoreData2("StateCode") & "' selected>" & rsStoreData2("StateName") & "</option>"
								Else
									Response.Write "<option value='" & rsStoreData2("StateCode") & "'>" & rsStoreData2("StateName") & "</option>"
								End If
								rsStoreData2.MoveNext
							Wend
							%>
						</select>
					</td>
				</tr>
				<%
				Call DB_closeRecordset(rsStoreData2)
			Else			
				Select Case sType
					Case "MULTIPICK"
						%>
		        		<tr>
							<td width=50%><%=sComments%></td>
							<td width=50%>
								<select name='<%=sSettingKey%>' size=4 multiple>
									<%
									Do While ( NOT rsStoreData.EOF )
										If ( sIdSetting = Trim(rsStoreData("idSetting")) ) Then
											sSettingOption	= Trim(rsStoreData("settingoption"))
											sOptionValue	= Trim(rsStoreData("optionvalue"))
											If ( Trim(UCase(CStr(sSettingValue))) = Trim(UCase(CStr(sOptionValue))) ) Then
												Response.Write "<option value='" & sOptionValue & "' selected>" & sSettingOption & "</option>"
											Else
												Response.Write "<option value='" & sOptionValue & "'>" & sSettingOption & "</option>"
											End If
										Else
											Exit Do
										End If
										rsStoreData.MoveNext
									Loop
									%>
								</select>
							</td>
		         		</tr>
						<%
					Case "SELECT"
						%>
		        		<tr>
							<td width=50%><%=sComments%></td>
							<td width=50%>
								<select name='<%=sSettingKey%>'>
									<%
									Do While ( NOT rsStoreData.EOF )
										If ( sIdSetting = Trim(rsStoreData("idSetting")) ) Then
											sSettingOption	= Trim(rsStoreData("settingoption"))
											sOptionValue	= Trim(rsStoreData("optionvalue"))
											If ( Trim(UCase(CStr(sSettingValue))) = Trim(UCase(CStr(sOptionValue))) ) Then
												Response.Write "<option value='" & sOptionValue & "' selected>" & sSettingOption & "</option>"
											Else
												Response.Write "<option value='" & sOptionValue & "'>" & sSettingOption & "</option>"
											End If
										Else
											Exit Do
										End If
										rsStoreData.MoveNext
									Loop
									%>
								</select>
							</td>
		         		</tr>
						<%
					Case "TEXT"
						%>
		        		<tr>
		        			<td width=50%><%=sComments%></td>
							<td width=50%><%VALIDATE_textbox sSettingKey, sSettingValue, 50, "textbox", ""%></td>
		         		</tr>
						<%
					Case "BOOLEAN"
						%>
		        		<tr>
		        			<td width=50%><%=sComments%></td>
							<td width=50%>
								<select name='<%=sSettingKey%>'>
									<option value=0 <%If ( Trim(UCase(CStr(sSettingValue))) = "0" ) Then Response.Write "selected" End If%>>No</option>
									<option value=-1 <%If ( Trim(UCase(CStr(sSettingValue))) = "-1" ) Then Response.Write "selected" End If%>>Yes</option>
								</select>
							</td>
		         		</tr>
						<%
				End Select
			End If
			If ( NOT rsStoreData.EOF ) Then
				rsStoreData.MoveNext		' has the possibility with SELECT types
			End If
		Wend
		Call DB_closeRecordset(rsStoreData)
	End Sub
	'************************************************************************************
%>