<%
	'************************************************************************************
	'*																					*
	'*	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/											*
	'*																					*
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*	Displays the UPS shipping estimate HTML table									*
	'*																					*
	'************************************************************************************
	Function SHIPPING_DispEstimate(sParseText, bDataReturned, bCheckout, pSubTotal)
	
		If ( sOWCurrencyCode <> "" ) Then
			sTempCurrencyCode = "(" & sOWCurrencyCode & ")"
		Else
			sTempCurrencyCode = "(USD)"
		End If
		
		Set objstrTemp = New StrConCatArray
	
		sSQLText = "SELECT * FROM UPSShippingMethods"
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( bCheckout = "T" ) Then
			' if bCheckout is "T" then we are displaying the form to allow customers to actually choose their shipping method - otherwise we are
			'	just displaying an estimate
			objstrTemp.Add "<table width=100" & "%" & " cellpadding=0 cellspacing=0 border=0><TR><TD style='border-bottom: 1px solid #EEEEEE;' colspan=2><b>" & LANG_DT( "ISHIPPING_DESC", "Shipment Description" ) & "</b></TD><TD width=150 style='border-bottom: 1px solid #EEEEEE;' align=center><b>" & LANG_DT( "ISHIPPING_COST", "Shipment Cost" ) & "</b>&nbsp;" & sTempCurrencyCode & "</TD><td width=50 style='border-bottom: 1px solid #EEEEEE;' align=center><b>" & LANG_DT( "ISHIPPING_SELECT", "Select?" ) & "</td></TR>"
		Else
			objstrTemp.Add "<table width=100" & "%" & " cellpadding=0 cellspacing=0 border=0><TR><TD style='border-bottom: 1px solid #EEEEEE;' colspan=2><b>" & LANG_DT( "ISHIPPING_DESC", "Shipment Description" ) & "</b></TD><TD width=150 style='border-bottom: 1px solid #EEEEEE;' align=center><b>" & LANG_DT( "ISHIPPING_COST", "Shipment Cost" ) & "</b>&nbsp;" & sTempCurrencyCode & "</TD></TR>"
		End If
		do until rsStoreData.eof 
			sHandlingFee			= rsStoreData("HandlingFee")
			sHandlingVisibility		= Trim(UCase(rsStoreData("HandlingVisibility")))
			sUPSInternalIDNum		= rsStoreData("UPSInternalIDNum")
			sUPSName				= rsStoreData("Name")
			sFreeShipping			= Trim(UCase(rsStoreData("FreeShipping")))
			sFreeShippingMinPrice	= CDbl(Trim(rsStoreData("FreeShippingMinPrice")))
	
			shipArray = split(sParseText, VbCrlf)
			for iX = 1 to (Ubound(shipArray))
				shipDetailsArray	= split(shipArray(iX),"|")
				sFreeShippingText	= ""
				tempRate			= ""
				if ubound(shipDetailsArray) > 0 then
					if shipDetailsArray(1) = sUPSInternalIDNum then
						If sHandlingVisibility = "Y" then
							tempRate = shipDetailsArray(2)
						Else
							' if handling is visible then DO NOT add it here to the shipping because they will see
							'	it in the order verify page. If you add it here, it'll get added again in the order verify page
							tempRate = (cDbl(shipDetailsArray(2)) + cDbl(sHandlingFee))
						End If

						' check method -- see if this order and method requirements match up for free shipping
						If ( sFreeShipping = "Y" ) Then
							sFreeShippingText = Replace(LANG_DT( "ISHIPPING_FREEMSG", " &#151; Ship using this method FREE on all orders over 1:" ), "1:", CONVERSION_Currency(sFreeShippingMinPrice))
							If ( CDbl(pSubTotal) > CDbl(sFreeShippingMinPrice) ) Then	' free shipping is enabled for this method and they have reached the price limit required
								tempRate = 0
							End If
						End If

						objstrTemp.Add "<tr><td style='border-bottom: 1px solid #EEEEEE;'>" & sUPSName & sFreeShippingText & "</td>"
						objstrTemp.Add "<td style='border-bottom: 1px solid #EEEEEE;'>&nbsp;"
						If ( shipDetailsArray(3) <> "-1" ) Then
							objstrTemp.Add LANG_DT( "ISHIPPING_ESTDEL", "Estimated delivery by" ) & ": " & shipDetailsArray(3)
						End If
						
						objstrTemp.Add "</td><td align=center style='border-bottom: 1px solid #EEEEEE;'>" & CONVERSION_Currency(tempRate) & "</td>"
						
						If ( bCheckout = "T" ) Then
							objstrTemp.Add "<td width=50 style='border-bottom: 1px solid #EEEEEE;' align=center>"
							
							If ( NOT bDataReturned ) Then 
								objstrTemp.Add "<input type='radio' name='sShipMethod' value='" & tempRate & "|UPS" & sUPSInternalIDNum & "' checked></td>"
							Else
								objstrTemp.Add "<input type='radio' name='sShipMethod' value='" & tempRate & "|UPS" & sUPSInternalIDNum & "' ></td>"
							End If
						End If
						
						objstrTemp.Add "</tr>"
						bDataReturned = True
					end if
				end if
			next
			rsStoreData.movenext
		loop
		objstrTemp.Add "</table>"
		SHIPPING_DispEstimate = objstrTemp.Value
		Set objstrTemp = Nothing
		Call DB_closeRecordset(rsStoreData)
		
	End Function
	'************************************************************************************
%>