<!--#include file="../../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../../owFunctions/I_Cart.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 sOrderFName, sOrderLName, sOrderEmail, sOrderPhone, dOrderDate, sTotal, sPaymentMethod
	Dim sPaymentMethodFee, sShipmentDetails, sShippingFee, sTaxAmount, sAddress
	Dim sZip, sState, sStateCode, sCity, sCountryCode, sShippingAddress, sShippingZip
	Dim sShippingState, sShippingStateCode, sShippingCity, sShippingCountryCode
	Dim sShippingName, sShippingLastName
	Dim sOrderStatus, pViewed, sBrowserIP, sTrackingNumber, sVatNumber, sCustomerComments
	Dim sCustomField1, sCustomField2, sCustomField3, sTtlLength, sTtlHeight, sTtlWidth
	Dim sTtlWeight, sIDOrder, sHandlingVisibility, sHandlingFee
	Dim sCardType, sCardNumber, sExpiration, sSeqCode, sComments, sInternalComments
	Dim sCustomerFName, sCustomerLName, sCustomerEmail, sCustomerPhone, bStatusEmail
	Dim sOriginalStatus, sSubTotal, sMessage, sTextDetail
	Dim sDigitalDownload, sExpireDays, sAllowedDownloads, sNumDownloads, sAffiliate
	Dim bHasDist, bDropShipEmail
	Dim sAccountUnq, sDiscountCode, sDiscountAmount

	Call Main()
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub Main()
		
		Dim sAction
		
		sAction		= Trim(Request("sAction"))
		sIDOrder	= Trim(Request("idOrder"))
		
		Select Case sAction
			Case "ModifyOrder"
				bStatusEmail	= Trim(Request("bStatusEmail"))
				sOrderStatus	= Trim(Request("sOrderStatus"))
				sOriginalStatus	= Trim(Request("sOriginalStatus"))
				If ( sOrderStatus <> "" ) Then
					If ( IsNumeric(sOrderStatus) ) Then
						sOrderStatus = CInt(sOrderStatus)
					Else
						sOrderStatus = 0
					End If
				End If
				x = CheckIfSendEmail()
				Call DB_updateDatabase("UPDATE Orders SET orderStatus = " & sOrderStatus & " WHERE idOrder = " & sIDOrder)
			
			Case "UpdateCountry"
			Case "UpdateShippingCountry"
			
			Case Else
				If ( Trim(sIDOrder) = "" ) Then
					sMessage = LANG_DT( "ORDERS_CHOOSEORDER", "** Please choose an order **" )
				Else
					If ( RetrieveData() ) Then
						Call DB_updateDatabase("UPDATE orders SET viewed=" & (CInt(pViewed)+1) & " WHERE idOrder=" & sIDOrder) 
					Else
						sMessage = LANG_DT( "ORDERS_NOTINDB", "** Order missing from database **" )
					End If
				End If
		End Select

		Call WriteForm()
		
	End Sub
	'************************************************************************************
	
	
	
	'************************************************************************************
	'*																					*
	'*	This is the function to write out the form.										*
	'*																					*
	'************************************************************************************
	Sub WriteForm()

		%>
		<script language = "javascript">
		
			parent.owBodyTopNav.location="owBodyTopNav.asp?sIDOrder=<%=sIDOrder%>&sPage=ModifyOrder&sMessage=<%=Server.URLEncode(sMessage)%>"
			parent.owBodyFooter.location="owBodyFooter.asp?sAction=Null"
			
		</script>
		
		<script type="text/javascript" src="../Script/fValConfig.js"></script>
		<script type="text/javascript" src="../Script/fValidate.js"></script>
		
		<style>
			input.owDisabled, select.owDisabled, textarea.owDisabled {
				border: 2px inset #FFFFFF;
				background-color: #BBBBBB;
			}
			.owDisabledContainer {
				font-family: verdana, arial, helvetica, sans-serif;
				font-size: 10px;
				position: relative; left: 1px; top: 1px; color: #FFFFFF;
			}
			.owDisabledText {
				font-family: verdana, arial, helvetica, sans-serif;
				font-size: 10px;
				position: absolute; left: -1px; top: -1px; color: #BBBBBB;
			} 
			
			.owDisabledContainerW {
				font-family: verdana, arial, helvetica, sans-serif;
				font-size: 10px;
				position: relative; left: 1px; top: 1px; color: #777777;
			}
			.owDisabledTextW {
				font-family: verdana, arial, helvetica, sans-serif;
				font-size: 10px;
				position: absolute; left: -1px; top: -1px; color: #DDDDDD;
			} 
		</style>
					
		<table border="0" cellpadding="0" cellspacing="0" width="100%" style="FONT-SIZE: 11px; COLOR: #808080" bgcolor="#ffffff">
			<tr>
				<td><b><font size=+1><%=LANG_DT( "ORDERS_HEAD", "OneWorldStore eCommerce" )%></font></b></td>
				<td align=right>
					<b><%=LANG_DT( "ORDERS_INVOICE", "Invoice: " )%><%=sOWOrderPrefix&sIDOrder%><br>
				</td>
			</tr>
		</table>

		<table border=0 cellpadding="5" cellspacing="0" width="100%" style="FONT-SIZE: 11px; COLOR: #808080" bgcolor="#ffffff">
		<form action='owModifyOrder.asp' method='post' name='ModifyOrder'>
		<input type='hidden' name='sAction' value='ModifyOrder'>
		<input type='hidden' name='idOrder' value='<%=sIDOrder%>'>
		<input type='hidden' name='sOriginalStatus' value='<%=sOrderStatus%>'>
			<tr>
				<td colspan=3 align=right style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<table border=0 cellpadding="0" cellspacing="0" width="100%" style="FONT-SIZE: 11px; COLOR: #808080" bgcolor="#ffffff">
						<tr>
							<td valign=bottom>
								<%If ( sAffiliate <> "" ) Then%>
								<b>Sold through Affiliate:</b> <%=sAffiliate%>
								<%End If%>
							</td>
							<td align=right valign=bottom>
								<b><%=LANG_DT( "ORDERS_CHANGESTATUS", "Change Order Status:" )%></b>
								<select name='sOrderStatus'>
									<option value='<%=C_PENDING%>' <%If ( sOrderStatus = C_PENDING ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_PEND", "Pending" )%></option>
									<option value='<%=C_DELIVERED%>' <%If ( sOrderStatus = C_DELIVERED ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_DEL", "Delivered" )%></option>
									<option value='<%=C_CANCELLED%>' <%If ( sOrderStatus = C_CANCELLED ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_CANCEL", "Cancelled" )%></option>
									<option value='<%=C_PAID%>' <%If ( sOrderStatus = C_PAID ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_PAID", "Paid" )%></option>
									<option value='<%=C_CHARGEBACK%>' <%If ( sOrderStatus = C_CHARGEBACK ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_CHARGEBACK", "Chargeback" )%></option>
									<option value='<%=C_REFUNDED%>' <%If ( sOrderStatus = C_REFUNDED ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_REFUNDED", "Refunded" )%></option>
									<option value='<%=C_UNFINALIZED%>' <%If ( sOrderStatus = C_UNFINALIZED ) Then Response.Write "selected" End If %>><%=LANG_DT( "ORDERS_UNFINALIZED", "Unfinalized" )%></option>
							    </select>
							    <br>
							    <%=LANG_DT( "ORDERS_SENDSTATUSEMAIL", "Send email to customer upon status change?" )%>
							    <input type='checkbox' name='bStatusEmail' value='Y' <%If ( bStatusEmail = "Y" ) Then Response.Write "checked" End If%>>
							    <%If ( bHasDist ) And ( sOrderStatus <> C_PAID ) Then%>
							    <br>
							    <span class="owDisabledContainer"><%=LANG_DT( "ORDERS_SENDTODROPSHIP", "Send email to drop-shipper upon status change to Paid?" )%><font color="#FFFFFF" class="owDisabledText"><%=LANG_DT( "ORDERS_SENDTODROPSHIP", "Send email to drop-shipper upon status change to Paid?" )%></font></span>
							    <input type='checkbox' name='' value='Y' class='owDisabled'>
							    <%End If%>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_DATE", "Order Date:" )%></td>
				<td colspan=2 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%=dOrderDate%></td>
			</tr>
			<tr>
				<td style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><font color=aa0000><%=LANG_DT( "ORDERS_CUSTIP", "Customer IP" )%></td>
				<td colspan=2 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><font color=aa0000><%=sBrowserIP%></td>
			</tr>
			<%if bOWUseVatNumber then%>
			<tr>
				<td style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDERS_VATNUMBER", "Vat Number:" )%></td>
				<td colspan=2 style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%
					if sVatNumber<>"" then 
						Call VALIDATE_textbox ( "sVatNumber", sVatNumber, 5, "textbox", "" )
					else
						response.write LANG_DT( "ORDERS_NA", "N/A" )
					end if
					%>
				</td>
			</tr>
			<%end if%>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_EMAIL", "Email" )%></td>
				<td colspan=2 style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sOrderEmail", sOrderEmail, 50, "textbox", "blank"%>
					<%If ( sOrderEmail <> sCustomerEmail ) Then%>
					<br>
					*<%=LANG_DT( "ORDERS_ORIGINALEMAILDIF", "Email under which this order was placed is different from this customers current email address of" )%>: <b><%=sCustomerEmail%></b>.
					<%End If%>
				</td>
			</tr>
		</table>
		<br>
		<table border=0 cellpadding="5" cellspacing="0" width="100%" style="FONT-SIZE: 11px; COLOR: #808080" bgcolor="#EAF1F9">
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
				<td width=50% style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_BILLINGADDRESS", "Billing Address" )%></td>
				<td width=50% style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_SHIPPINGADDRESS", "Shipping Address" )%></td>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_FIRSTNAME", "First Name" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sOrderFName", sOrderFName, 25, "textbox", "blank"%>
					<%If ( sOrderFName <> sCustomerFName ) Then%>
					<br>*<%=LANG_DT( "ORDER_ORIGINALNAMEDIF", "First name under which this order was placed is different from this customers current first name of" )%>: <b><%=sCustomerFName%></b>.
					<%End If%>
				</td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sShippingName", sShippingName, 25, "textbox", ""%></td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_LASTNAME", "Last Name" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sOrderLName", sOrderLName, 25, "textbox", "blank"%>
					<%If ( sOrderLName <> sCustomerLName ) Then%>
					<br>*<%=LANG_DT( "ORDER_ORIGINALLASTNAMEDIF", "Last name under which this order was placed is different from this customers current last name of" )%>: <b><%=sCustomerLName%></b>.
					<%End If%>
				</td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sShippingLastName", sShippingLastName, 25, "textbox", ""%></td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_ADDRESS", "Address" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sAddress", sAddress, 50, "textbox", "blank"%></td>
				<%
				If ( sShippingAddress = "" ) Then
					Response.Write "<td rowspan=5 valign=center align=center bgcolor=FFFFFF style='BORDER-BOTTOM: #C3DAF9 1px solid;'>"
					Response.Write LANG_DT( "ORDER_SAMEASBILLING", "(Same as billing address)" )
					Response.Write "</td>"
				Else
					Response.Write "<td bgcolor=FFFFFF style='BORDER-BOTTOM: #C3DAF9 1px solid;'>"
					Call VALIDATE_textbox ( "sShippingAddress", sShippingAddress, 50, "textbox", "blank" )
					Response.Write "</td>"
				End If
				%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_CITY", "City" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sCity", sCity, 25, "textbox", ""%></td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sShippingCity", sShippingCity, 25, "textbox", ""%></td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=STRUCTURE_PostalCodeLabel(sCountryCode)%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sZip", sZip, 15, "textbox", ""%></td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sShippingZip", sShippingZip, 15, "textbox", ""%></td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=STRUCTURE_TerritoryLabel(sCountryCode)%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%
					sSQLText = "SELECT * FROM stateCodes WHERE Active='Y' AND CountryCode = '" & sCountryCode & "'"
					Call DB_getFromDatabase(sSQLText, rsStoreData, "") 
					If ( NOT rsStoreData.EOF ) Then
						%>
						<SELECT name=sStateCode size=1 align=top>
							<%
							do while not rsStoreData.eof
								sStateCode2 = rsStoreData("stateCode")
								%><option value="<%=sStateCode2%>" <%if sStateCode2=sStateCode then response.write "selected" end if%>><%=rsStoreData("stateName")%></OPTION><%
								rsStoreData.movenext
							loop
							%>
						</SELECT>
					<%
					Else
						Response.Write LANG_DT( "CUSTOMER_STATE_EMPTY", "State/Provence database is empty." )
					End If
					Call DB_closeRecordset(rsStoreData)
					%>
					<%VALIDATE_textbox "sState", sState, 5, "textbox", ""%>
				</td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%
					sSQLText = "SELECT * FROM stateCodes WHERE Active='Y' AND CountryCode = '" & sShippingCountryCode & "'"
					Call DB_getFromDatabase(sSQLText, rsStoreData, "") 
					If ( NOT rsStoreData.EOF ) Then
						%>
						<SELECT name=sShippingStateCode size=1 align=top>
							<%
							do while not rsStoreData.eof
								sStateCode2 = rsStoreData("stateCode")
								%><option value="<%=sStateCode2%>" <%if sStateCode2=sShippingStateCode then response.write "selected" end if%>><%=rsStoreData("stateName")%></OPTION><%
								rsStoreData.movenext
							loop
							%>
						</SELECT>
					<%
					Else
						Response.Write LANG_DT( "CUSTOMER_STATE_EMPTY", "State/Provence database is empty." )
					End If
					Call DB_closeRecordset(rsStoreData)
					%>
					<%VALIDATE_textbox "sShippingState", sShippingState, 5, "textbox", ""%>
				</td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_COUNTRY", "Country" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%
					sSQLText = "SELECT * FROM countryCodes WHERE Active = 'Y' ORDER BY Position"
					Call DB_getFromDatabase(sSQLText, rsStoreData2, "")
					If ( NOT rsStoreData2.EOF ) Then
						%>
						<SELECT onChange='ModifyOrder.sAction.value="UpdateCountry"; ModifyOrder.submit();' name=sCountryCode style="BORDER-RIGHT: #C3DAF9 1px solid; BORDER-TOP: #C3DAF9 1px solid; FONT-SIZE: 9px; BORDER-LEFT: #C3DAF9 1px solid; BORDER-BOTTOM: #C3DAF9 1px solid">
							<%
							do while not rsStoreData2.eof
								sCountryCode2 = rsStoreData2("countryCode")
								%><option value="<%=sCountryCode2%>" <%if sCountryCode=sCountryCode2 then response.write "selected" end if%>><%=LCase(rsStoreData2("countryName"))%></OPTION><%
								rsStoreData2.movenext
							loop
							%>
						</SELECT>
						<%
					Else
						Response.Write LANG_DT( "CUSTOMER_COUNTRY_EMPTY", "Country Database is empty." )
					End If
					Call DB_closeRecordset(rsStoreData2)
					%>
				</td>
				<%If ( sShippingAddress <> "" ) Then%>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%
					sSQLText = "SELECT * FROM countryCodes WHERE Active = 'Y' ORDER BY Position"
					Call DB_getFromDatabase(sSQLText, rsStoreData2, "")
					If ( NOT rsStoreData2.EOF ) Then
						%>
						<SELECT onChange='ModifyOrder.sAction.value="UpdateShippingCountry"; ModifyOrder.submit();' name=sShippingCountryCode style="BORDER-RIGHT: #C3DAF9 1px solid; BORDER-TOP: #C3DAF9 1px solid; FONT-SIZE: 9px; BORDER-LEFT: #C3DAF9 1px solid; BORDER-BOTTOM: #C3DAF9 1px solid">
							<%
							do while not rsStoreData2.eof
								sCountryCode2 = rsStoreData2("countryCode")
								%><option value="<%=sCountryCode2%>" <%if sShippingCountryCode=sCountryCode2 then response.write "selected" end if%>><%=LCase(rsStoreData2("countryName"))%></OPTION><%
								rsStoreData2.movenext
							loop
							%>
						</SELECT>
						<%
					Else
						Response.Write LANG_DT( "CUSTOMER_COUNTRY_EMPTY", "Country Database is empty." )
					End If
					Call DB_closeRecordset(rsStoreData2)
					%>
				</td>
				<%End If%>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_PHONE", "Phone" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sOrderPhone", sOrderPhone, 15, "textbox", ""%>
					<%If ( sOrderPhone <> sCustomerPhone ) Then%>
					<br>*<%=LANG_DT( "ORDER_ORIGPHONEDIF", "Phone number under which this order was placed is different from this customers current phone number of" )%>: <b><%=sCustomerPhone%></b>.
					<%End If%>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<%If ( sCustomField1 <> "" ) Then%>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_ADDITIONALINFO", "Additional Information" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sCustomField1", sCustomField1, 25, "textbox", ""%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<%End If%>
			<%If ( sCustomField2 <> "" ) Then%>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b>...</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sCustomField2", sCustomField2, 25, "textbox", ""%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<%End If%>
			<%If ( sCustomField3 <> "" ) Then%>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b>...</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sCustomField3", sCustomField3, 25, "textbox", ""%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<%End If%>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_PAYMENT", "Payment Method" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;"><%VALIDATE_textbox "sPaymentMethod", sPaymentMethod, 25, "textbox", ""%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><font color=aa0000><b><%=LANG_DT( "ORDER_CARDTYPE", "Card Type" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<select name='sCardType'>
						<option value='VI' <%If ( sCardType = "VI" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_VISA", "Visa" )%></option>
						<option value='MA' <%If ( sCardType = "MA" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_MC", "MasterCard" )%></option>
						<option value='AM' <%If ( sCardType = "AM" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_AM", "American Express" )%></option>
						<option value='DIN' <%If ( sCardType = "DIN" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_DIN", "Diners Club" )%></option>
						<option value='DIS' <%If ( sCardType = "DIS" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_DIS", "Discover" )%></option>
						<option value='JC' <%If ( sCardType = "JC" ) Then Response.Write "Selected" End If%>><%=LANG_DT( "OFFLINEPAYMENT_JCB", "JCB" )%></option>
					</select>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><font color=aa0000><%=LANG_DT( "ORDER_CARDNUM", "Card Number" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sCardNumber", sCardNumber, 25, "textbox", ""%>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><font color=aa0000><%=LANG_DT( "ORDER_CARDEXP", "Expiration" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sExpiration", sExpiration, 25, "textbox", ""%>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><font color=aa0000><%=LANG_DT( "ORDER_CARDSEQ", "Sequence Code" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sSeqCode", sSeqCode, 5, "textbox", ""%>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><font color=aa0000><%=LANG_DT( "ORDER_CARDDETAILS", "Charge Details" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<%VALIDATE_textbox "sComments", sComments, 50, "textbox", ""%>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			
			<tr>
				<td width=130 style="BORDER-BOTTOM: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_COMMENTS", "Customer Comments" )%></td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<textarea name='sCustomerComments' cols=50 rows=4><%=sCustomerComments%></textarea>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>
			<tr>
				<td style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<span class="owDisabledContainer">Internal<font color="#FFFFFF" class="owDisabledText">Internal</font></span>
					<br>
					<span class="owDisabledContainer">Comments<font color="#FFFFFF" class="owDisabledText">Comments</font></span>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">
					<textarea name='' cols=50 rows=4 class='owDisabled' readonly></textarea>
				</td>
				<td bgcolor=FFFFFF style="BORDER-BOTTOM: #C3DAF9 1px solid;">&nbsp;</td>
			</tr>

			<tr>
				<td width=130><span class="owDisabledContainer"><%=LANG_DT( "ORDER_TRACKINGNUM", "Tracking Number" )%><font color="#FFFFFF" class="owDisabledText"><%=LANG_DT( "ORDER_TRACKINGNUM", "Tracking Number" )%></font></span></td>
				<td bgcolor=FFFFFF><input type='text' name='' value='' class='owDisabled' size=25 readonly></td>
				<td bgcolor=FFFFFF>&nbsp;</td>
			</tr>
			<tr>
				<td width=130 valign=top style="BORDER-TOP: #C3DAF9 1px solid;"><b><%=LANG_DT( "ORDER_ITEMDESC", "Item&nbsp;Description" )%></td>
				<td colspan=2 width=100% bgcolor=FFFFFF style="BORDER-TOP: #C3DAF9 1px solid;">
					<table border=0 cellpadding="0" cellspacing="0" width="100%" style="FONT-SIZE: 11px; COLOR: #808080">
						<tr>
							<td valign=top>
								<%
								' get order details (products and their options)
								sSQLText = "SELECT * FROM OrdersProdRef WHERE idOrder = " & sIDOrder
								Call DB_getFromDatabase(sSQLText, rsStoreData, "")
								If ( NOT rsStoreData.EOF ) Then
									Response.Write "<table cellspacing=5 style='FONT-SIZE: 11px; COLOR: #808080'><tr><td><b>" & LANG_DT( "ORDERS_QTY", "Qty" ) & "</b></td><td width=100" & "%" & "><b>" & LANG_DT( "ORDERS_PRODUCT", "Product" ) & "</b></td><td><b>" & LANG_DT( "ORDERS_PRICE", "Price" ) & "</td></tr>"
									While ( NOT rsStoreData.EOF )
										sDigitalDownload	= Trim(rsStoreData("DigitalDownload"))
										sExpireDays			= Trim(rsStoreData("ExpireDays"))
										sAllowedDownloads	= Trim(rsStoreData("AllowedDownloads"))
										sNumDownloads		= Trim(rsStoreData("NumDownloads"))
										sIDOrderProd		= Trim(rsStoreData("IDOrderProd"))
										sUnitDealerPrice	= Trim(rsStoreData("UnitDealerPrice"))
										sUnitBtoBPrice		= Trim(rsStoreData("unitBtoBPrice"))
										sUnitPrice			= Trim(rsStoreData("unitPrice"))
										sTaxExempt			= Trim(rsStoreData("TaxExempt"))
										Response.Write "<tr><td align=center valign=top>" & rsStoreData("Quantity") & "</td>"
										Response.Write "<td valign=top>"
										Response.Write rsStoreData("Description")
										If ( sTaxExempt = "Y" ) Then
											Response.Write "<BR>(" & LANG_DT( "ORDERS_TAXEXEMPT", "Tax Exempt Product" ) & ")"
										End If
										Response.Write "</td><td>"
										
										If ( sUnitDealerPrice > 0 ) Then
											Response.Write CONVERSION_Currency(sUnitDealerPrice)
										Else
											If ACCNT_InGroup(sAccountUnq, C_GROUP_WHOLESALE) and sUnitBtoBPrice>0 Then
												Response.Write CONVERSION_Currency(sUnitBtoBPrice)
											Else
												Response.Write CONVERSION_Currency(sUnitPrice)
											End If 
										End If
										

										Response.Write "</td></tr>"
										sSQLText = "SELECT * FROM OrdersProdOptions WHERE idProduct = " & rsStoreData("idProduct") & " AND idOrder = "& sIDOrder
										Call DB_getFromDatabase(sSQLText, rsStoreData2, "")
										If ( NOT rsStoreData2.EOF ) Then
											Response.Write "<tr><td colspan=3><table cellpadding=0 cellspacing=0 border=0 style='FONT-SIZE: 11px; COLOR: #808080'>"
											While ( NOT rsStoreData2.EOF )
												sTextDetail	= Trim(rsStoreData2("TextDetail"))
												%>
												<tr>
													<td><img src='../../owTemplates/images/Blank.gif' width=20 height=1></td>
													<td><%=rsStoreData2("OptionGroupDescription")%>: </td>
													<td>&nbsp;&nbsp;&nbsp;</td>
													<td>
														<%=rsStoreData2("OptionDescription")%>
														<%If ( sTextDetail <> "" ) Then%>
														<bR><input type='text' name='' value="<%=Server.HTMLEncode(sTextDetail)%>" readonly>
														<%End If%>
													</td>
												</tr>
												<%
												rsStoreData2.MoveNext
											Wend
											Response.Write "</table></td></tr>"
										End If
										Call DB_closeRecordset(rsStoreData2)
										
										If ( sDigitalDownload <> "" ) Then%>
										<tr>
											<td colspan=3>
												<table cellspacing=5 style='FONT-SIZE: 11px; COLOR: #808080'>
													<tr><td><%=LANG_DT( "ORDERDETAILS_DDLFILE", "Downloadable File" )%></td><td><%VALIDATE_textbox "sDigitalDownload_" & sIDOrderProd, sDigitalDownload, 25, "textbox", ""%></td></tr>
													<tr><td><%=LANG_DT( "ORDERDETAILS_DDLDAYS", "Days to Expire (from order date)" )%></td><td><%VALIDATE_textbox "sExpireDays_" & sIDOrderProd, sExpireDays, 5, "textbox", "number"%></td></tr>
													<tr><td><%=LANG_DT( "ORDERDETAILS_DDLNUM", "Number of allowed downloads" )%></td><td><%VALIDATE_textbox "sAllowedDownloads_" & sIDOrderProd, sAllowedDownloads, 5, "textbox", "number"%></td></tr>
													<tr><td><%=LANG_DT( "ORDERDETAILS_DDLSOFAR", "Downloaded so far" )%></td><td><%VALIDATE_textbox "sNumDownloads_" & sIDOrderProd, sNumDownloads, 5, "textbox", "number"%></td></tr>
												</table>
											</td>
										</tr>
										<%End If
										
										rsStoreData.MoveNext
									Wend
									Response.Write "</tr></table>"
								End If
								Call DB_closeRecordset(rsStoreData)
								%>
								<%If ( ( sTtlLength <> "" ) Or ( sTtlHeight <> "" ) Or ( sTtlWidth <> "" ) ) And ( ( sTtlLength <> "0" ) And ( sTtlHeight <> "0" ) And ( sTtlWidth <> "0" ) ) Then%>
								<br>
								<%=LANG_DT( "ORDER_VOLUME", "Package volume: " )%><%=sTtlLength%>x<%=sTtlHeight%>x<%=sTtlWidth%>
								<%End If%>
								<%If ( sTtlWeight <> "" ) Then%>
								<br>
								<%=LANG_DT( "ORDER_WEIGHT", "Total Weight " )%>: <%=sTtlWeight%><%=LCase(owCONFIG_ReturnConfigValue("sOWShipWeightType"))%>
								<%End If%>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td></td>
				<td valign=top colspan=2 align=right>
					<table style='FONT-SIZE: 11px; COLOR: #808080'>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERDETAILS_SUBTOTAL", "Subtotal" )%>: 
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sSubTotal", sSubTotal, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
						<tr>
							<td align=right>
								<b><b><%=LANG_DT( "ORDERDETAILS_SHIPPING", "Shipping" )%>:
							</td>
							<td>
								<table cellpadding=0 cellspacing=0 border=0 style="FONT-SIZE: 11px; COLOR: #808080">
									<tr>
										<td>
											<%VALIDATE_textbox "sShipmentDetails", sShipmentDetails, 25, "textbox", ""%>
										</td>
										<td>
											<%=sOWCurrencySymbol%><%VALIDATE_textbox "sShippingFee", sShippingFee, 10, "textbox", "decimalr|bok"%>
										</td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td align=right>
								<%If ( sHandlingVisibility = "Y" ) Then%>
								<b><%=LANG_DT( "ORDERVERIFY_HANDLING", "Handling" )%>:
								<%Else%>
								<font color=aa0000>
								<b><%=LANG_DT( "ORDERVERIFY_HANDLING", "Handling" )%>:
								</font>
								<%End If%>
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sHandlingFee", sHandlingFee, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERS_PMTFEE", "Payment Method Fee" )%>:
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sPaymentMethodFee", sPaymentMethodFee, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
						<%
						sSQLText = "SELECT * FROM OrdersTaxes WHERE idOrder = " & sIDOrder
						Call DB_getFromDatabase(sSQLText, rsStoreData, "")
						If ( NOT rsStoreData.EOF ) Then
						%>
						<tr>
							<td align=right valign=top>
								<b><%=LANG_DT( "ORDERS_TAXDETAIL", "Tax Detail" )%>: 
							</td>
							<td>
								<table cellpadding=0 cellspacing=0 border=0 style="FONT-SIZE: 11px; COLOR: #808080">
									<%While ( NOT rsStoreData.EOF )%>
										<tr>
											<td>
												<%'VALIDATE_textbox "sTaxName_" & rsStoreData("idOrderTax"), rsStoreData("TaxName"), 25, "textbox", ""%>
												<%=rsStoreData("TaxName")%>
											</td>
											<td>&nbsp;&nbsp;&nbsp;</td>
											<td>
												<%'VALIDATE_textbox "sPercentage_" & rsStoreData("idOrderTax"), rsStoreData("Percentage"), 5, "textbox", ""%>
												<%=rsStoreData("Percentage")%>%
											</td>
										</tR>
										<%
										rsStoreData.MoveNext
									Wend%>
								</table>
							</td>
						</tr>
						<%
						End If
						Call DB_closeRecordset(rsStoreData)
						%>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERS_TTLTAX", "Total Tax" )%>: 
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sTaxAmount", sTaxAmount, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
						<%If ( sDiscountCode <> "" ) Then%>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERDETAILS_DISCAMT", "Discount Amount" )%>: 
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sDiscountAmount", sDiscountAmount, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERDETAILS_DISCCODE", "Discount Code" )%>: 
							</td>
							<td>
								<%VALIDATE_textbox "sDiscountCode", sDiscountCode, 25, "textbox", ""%>
							</td>
						</tr>
						<%End If%>
						<tr>
							<td align=right>
								<b><%=LANG_DT( "ORDERDETAILS_TOTAL", "Total" )%>: 
							</td>
							<td>
								<%=sOWCurrencySymbol%><%VALIDATE_textbox "sTotal", sTotal, 10, "textbox", "decimalr|bok"%>
							</td>
						</tr>
					</table>												
				</td>
			</tr>
			<tr>
				<td colspan=3 style="BORDER-top: #C3DAF9 1px solid;">
					<font color=aa0000>* <%=LANG_DT( "ORDERS_REDTEXT", "Red text is hidden from customer view." )%></font>
				</td>
			</tr>
		</table>
		</form>
		<form action='owListOrders.asp' method='post' name='OrderList'>
			<input type='hidden' name='sAction' value='Delete'>
			<input type='hidden' name='sDelete<%=sIDOrder%>' value=''>
		</form>
		<%
	End Sub
	'************************************************************************************
	
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function RetrieveData()
	
		RetrieveData = False
	
		sSQLText = "SELECT * FROM Orders WHERE idorder = " & sIDOrder
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			sAccountUnq			= CONVERSION_Trim(rsStoreData("AccountUnq"))
			sCustomerFName		= ACCNT_ReturnADV("OW_CUSTFNAME", "V", sAccountUnq, C_OVERRIDE_ADV)
			sCustomerLName		= ACCNT_ReturnADV("OW_CUSTLNAME", "V", sAccountUnq, C_OVERRIDE_ADV)
			sCustomerEmail		= ACCNT_ReturnADV("OW_CUSTEMAIL", "V", sAccountUnq, C_OVERRIDE_ADV)
			sCustomerPhone		= ACCNT_ReturnADV("OW_CUSTPHONE", "V", sAccountUnq, C_OVERRIDE_ADV)
			sOrderFName			= CONVERSION_Trim(rsStoreData("FName"))
			sOrderLName			= CONVERSION_Trim(rsStoreData("LName"))
			sOrderEmail			= CONVERSION_Trim(rsStoreData("email"))
			sOrderPhone			= CONVERSION_Trim(rsStoreData("phone"))
			dOrderDate			= CONVERSION_Trim(rsStoreData("orderDate"))
			sTotal				= CONVERSION_Trim(rsStoreData("total"))
			sPaymentMethod		= CONVERSION_Trim(rsStoreData("PaymentMethod"))
			sPaymentMethodFee	= CONVERSION_Trim(rsStoreData("PaymentMethodFee"))
			sShipmentDetails	= CONVERSION_Trim(rsStoreData("ShipmentDetails"))
			sShippingFee		= CONVERSION_Trim(rsStoreData("ShippingFee"))
			sTaxAmount			= CONVERSION_Trim(rsStoreData("taxAmount"))
			sAddress			= CONVERSION_Trim(rsStoreData("address"))
			sZip				= CONVERSION_Trim(rsStoreData("zip"))
			sState				= CONVERSION_Trim(rsStoreData("state"))
			sStateCode			= CONVERSION_Trim(rsStoreData("StateCode"))
			sCity				= CONVERSION_Trim(rsStoreData("city"))
			sCountryCode		= CONVERSION_Trim(rsStoreData("CountryCode"))
			sShippingName		= CONVERSION_Trim(rsStoreData("ShippingName"))
			sShippingLastName	= CONVERSION_Trim(rsStoreData("ShippingLastName"))
			sShippingAddress	= CONVERSION_Trim(rsStoreData("shippingAddress"))
			sShippingZip		= CONVERSION_Trim(rsStoreData("shippingzip"))
			sShippingState		= CONVERSION_Trim(rsStoreData("shippingstate"))
			sShippingStateCode	= CONVERSION_Trim(rsStoreData("shippingstateCode"))
			sShippingCity		= CONVERSION_Trim(rsStoreData("shippingcity"))
			sShippingCountryCode= CONVERSION_Trim(rsStoreData("shippingCountryCode"))
			sOrderStatus		= CInt(CONVERSION_Trim(rsStoreData("orderstatus")))
			pViewed				= CONVERSION_Trim(rsStoreData("viewed"))
			sBrowserIP			= CONVERSION_Trim(rsStoreData("browserIp"))
			sTrackingNumber		= CONVERSION_Trim(rsStoreData("TrackingNumber"))
			sVatNumber			= CONVERSION_Trim(rsStoreData("vatNumber"))
			sCustomerComments	= CONVERSION_Trim(rsStoreData("CustomerComments"))
			sCustomField1		= CONVERSION_Trim(rsStoreData("user1"))
			sCustomField2		= CONVERSION_Trim(rsStoreData("user2"))
			sCustomField3		= CONVERSION_Trim(rsStoreData("user3"))
			sTtlLength			= CONVERSION_Trim(rsStoreData("TtlLength"))
			sTtlHeight			= CONVERSION_Trim(rsStoreData("TtlHeight"))
			sTtlWidth			= CONVERSION_Trim(rsStoreData("TtlWidth"))
			sTtlWeight			= CONVERSION_Trim(rsStoreData("TtlWeight"))
			sHandlingVisibility	= CONVERSION_Trim(rsStoreData("HandlingVisibility"))
			sHandlingFee		= CONVERSION_Trim(rsStoreData("HandlingFee"))
			sInternalComments	= CONVERSION_Trim(rsStoreData("InternalComments"))
			sSubTotal			= CONVERSION_Trim(rsStoreData("SubTotal"))
			sIDAffiliate		= CONVERSION_Trim(rsStoreData("IDAffiliate"))
			sDiscountCode		= CONVERSION_Trim(rsStoreData("DiscountCode"))
			sDiscountAmount		= CDbl(CONVERSION_Trim(rsStoreData("DiscountAmount")))
			RetrieveData		= True
		End If
		Call DB_closeRecordset(rsStoreData)
		
		sSQLText = "SELECT * FROM OrdersCreditCards WHERE idOrder = " & sIDOrder
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			sCardType			= CONVERSION_Trim(rsStoreData("CardType"))
			sCardNumber			= decrypt(CONVERSION_Trim(rsStoreData("CardNumber")), sOWEncryptionPassword)
			sExpiration			= CONVERSION_Trim(rsStoreData("Expiration"))
			sSeqCode			= CONVERSION_Trim(rsStoreData("SeqCode"))
			sComments			= CONVERSION_Trim(rsStoreData("Comments"))
		End If
		Call DB_closeRecordset(rsStoreData)
		
		If ( sIDAffiliate <> "" ) Then
			sAffiliate = ACCNT_ReturnADV("OW_CUSTCOMPANY", "V", sIDAffiliate, C_OVERRIDE_ADV)
		End If
		
		' check to see if there are any distributors for any of the products - this just sets a boolean to disp the send email checkbox or not
		bHasDist = False
		sSQLText = "SELECT P.DistributorUnq FROM Products P, OrdersProdRef OPR WHERE P.idProduct = OPR.idProduct AND OPR.idOrder = " & sIDOrder
		' (allow for digital downloads because you can sell, say, a computer w/ a downloadable manual and the computer needs to be drop-shipped)
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			bHasDist = True
		End If
		Call DB_closeRecordset(rsStoreData)
	
	End Function
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Function CheckIfSendEmail()
	
		Dim sSubject, sEmailBody

		CheckIfSendEmail = False
		
		If ( sOrderStatus <> sOriginalStatus ) And ( bStatusEmail = "Y" ) Then	
			sEmailBody = LANG_DT( "CHANGE_STATUS_EMAIL_TO_CUSTOMER", "" )
			sEmailBody = Replace(sEmailBody, "#NAME#", sCustomerFName & " " & sCustomerLName)
			
			Select Case sOrderStatus
				Case C_PENDING
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_PEND", "Pending" ))
				Case C_DELIVERED
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_DEL", "Delivered" ))
				Case C_CANCELLED
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_CANCEL", "Cancelled" ))
				Case C_PAID
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_PAID", "Paid" ))
				Case C_CHARGEBACK
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_CHARGEBACK", "Chargeback" ))
				Case C_REFUNDED
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_REFUNDED", "Refunded" ))
				Case C_UNFINALIZED
					sEmailBody = Replace(sEmailBody, "#STATUS#", LANG_DT( "ORDERS_UNFINALIZED", "Unfinalized" ))
			End Select
			
			sEmailBody = Replace(sEmailBody, "#ORDER#", sOWOrderPrefix & sIDOrder)
			sEmailBody = Replace(sEmailBody, "#DATE#", dOrderDate)
			sEmailBody = Replace(sEmailBody, "#TOTAL#", sTotal)
			sEmailBody = Replace(sEmailBody, "#COMPANY#", sOWCompany)
			'Dear #NAME#,
			'
			'Your Order Status was updated to : #STATUS#
			'
			'-----------------------------------------------------
			'Name : #NAME#
			'Order	Number	: #ORDER#
			'		Date	: #DATE#
			'		Total	: #TOTAL#
			'-----------------------------------------------------
			'
			'Thank you for shopping with us!
			'
			'#COMPANY#
			'
			'Powered by OneWorldStore
			'http://www.OneWorldStore.com
			
			sSubject = Replace(LANG_DT( "CHANGE_STATUS_EMAIL_TO_CUSTOMER_SUBJECT", "Order Status Update from #COMPANY#" ), "#COMPANY#", sOWCompany)
		
			Call sendMail(sOWCompany, sOWEmailSender, sCustomerEmail, sSubject, sEmailBody)
			CheckIfSendEmail = True
		End If
		
	End Function
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	This returns the order subtotal by adding up all the individual product amounts	*
	'*		and any additional fees associated with options for those products			*
	'*																					*
	'************************************************************************************
	function CalcIndProdTotal()       
	
		Dim sOptionsTotal, rsStoreData, rsStoreData2

		Set rsStoreData		= CreateObject("ADODB.Recordset")
		Set rsStoreData2	= CreateObject("ADODB.Recordset")
		sOptionsTotal		= 0
		CalcIndProdTotal	= 0

		If ( sIDCart <> "" ) Then
			sSQLText = "SELECT idProduct, quantity, unitPrice, unitBtoBPrice FROM OrdersProdRef WHERE idOrder = " & sIDOrder
			call DB_getFromDatabase(sSQLText, rsStoreData, "")  
			While ( NOT rsStoreData.EOF )
				sUnitPrice		= Cdbl(rsStoreData("unitPrice"))
				sUnitBtoBPrice	= Cdbl(rsStoreData("unitBtoBPrice"))
				sQuantity		= rsStoreData("quantity")
				sIDProduct		= rsStoreData("idProduct")    
				sOptionsTotal	= 0
				
				' get Optionals value for that row    
				sSQLText = "SELECT Sum(PriceToAdd) AS OptionsTotal FROM OrdersProdOptions WHERE idOrder = " & sIDOrder & " AND idProduct = " & sIDProduct
				call DB_getFromDatabase(sSQLText, rsStoreData2, "cartFunctions")  
				If ( NOT rsStoreData2.EOF ) Then
					If ( NOT IsNull(rsStoreData2("OptionsTotal")) ) Then
						sOptionsTotal = Cdbl(rsStoreData2("OptionsTotal"))
					End If
				End If                
				Call DB_closeRecordset(rsStoreData2)
	
				if ACCNT_InGroup(sAccountUnq, C_GROUP_WHOLESALE) and sUnitBtoBPrice>0 then 
					CalcIndProdTotal = CDbl(CalcIndProdTotal + sQuantity * (sUnitBtoBPrice + sOptionsTotal))
				else
					CalcIndProdTotal = CDbl(CalcIndProdTotal + sQuantity * (sUnitPrice + sOptionsTotal))
				End If       
				
				rsStoreData.movenext
			Wend
			Call DB_closeRecordset(rsStoreData)
		End If
		
		Set rsStoreData		= Nothing
		Set rsStoreData2	= Nothing
	
	End Function
	'************************************************************************************
	%>
<!--#include file="../footer.asp"-->