<MvCOMMENT>
|
| Miva Merchant v4.x
|
| This file and the source codes contained herein are the property 
| of Miva Corporation.  Use of this file is restricted to the specific 
| terms and conditions in the License Agreement associated with this 
| file.  Distribution of this file or portions of this file for uses
| not covered by the License Agreement is not allowed without a written 
| agreement signed by an officer of Miva Corporation.
| 
| Copyright 1998-2001 Miva Corporation.  All rights reserved.
| http://www.miva.com/
|
| Utility Functions
| $Source: /home/cvs/merchant/Merchant/lib/util.mv,v $
|
| Prefix         : MER-UTL-
| Next Error Code: 4    
| Next Text ID   : 7    
|
</MvCOMMENT>

<MvFUNCTION NAME = "Installed" STANDARDOUTPUTLEVEL = "">
	<MvFUNCTIONRETURN VALUE = "{ fexists( g.MerchantPath $ 'domain.dbf' ) }">
</MvFUNCTION>

<MvFUNCTION NAME = "OrderMinimumsMet" PARAMETERS = "basket_id" STANDARDOUTPUTLEVEL = "">
	
	<MvIF EXPR = "{ ( Stores.d.omin_quant EQ 0 ) AND ( Stores.d.omin_price EQ 0 ) }">
		<MvASSIGN NAME = "l.minimum_met" VALUE = "1">
	<MvELSE>
		<MvIF EXPR = "{ Stores.d.omin_all }">
			<MvASSIGN NAME = "l.minimum_met" VALUE = "1">
			<MvIF EXPR = "{ Stores.d.omin_quant }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.basketquantity" VALUE = "{ Basket_TotalQuantity( g.Session_ID ) }">
				<MvASSIGN NAME = "l.minimum_met" VALUE = "{ ( l.basketquantity GE Stores.d.omin_quant ) AND l.minimum_met }">
			</MvIF>

			<MvIF EXPR = "{ Stores.d.omin_price }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.basketprice" VALUE = "{ Basket_Total( g.Session_ID ) }">
				<MvASSIGN NAME = "l.minimum_met" VALUE = "{ ( l.basketprice GE Stores.d.omin_price ) AND l.minimum_met }">
			</MvIF>
		<MvELSE>
			<MvASSIGN NAME = "l.minimum_met" VALUE = "0">
			<MvIF EXPR = "{ Stores.d.omin_quant }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.basketquantity" VALUE = "{ Basket_TotalQuantity( g.Session_ID ) }">
				<MvASSIGN NAME = "l.minimum_met" VALUE = "{ ( l.basketquantity GE Stores.d.omin_quant ) OR l.minimum_met }">
			</MvIF>

			<MvIF EXPR = "{ Stores.d.omin_price }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.basketprice" VALUE = "{ Basket_Total( g.Session_ID ) }">
				<MvASSIGN NAME = "l.minimum_met" VALUE = "{ ( l.basketprice GE Stores.d.omin_price ) OR l.minimum_met }">
			</MvIF>
		</MvIF>
	</MvIF>
	
	<MvFUNCTIONRETURN VALUE = "{ l.minimum_met }">
</MvFUNCTION>

<MvFUNCTION NAME = "DetermineSessionID" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ 'https://' IN s.documenturl }">
		<MvASSIGN NAME = "g.Secure" VALUE = 1>
	<MvELSE>
		<MvASSIGN NAME = "g.Secure" VALUE = 0>
	</MvIF>
	<MvIF EXPR = "{ ( NOT g.Session_ID ) AND s.callerid }">
		<MvASSIGN NAME = "l.sessionid" VALUE = "{ s.callerid }">
	<MvELSE>
		<MvASSIGN NAME = "l.sessionid" VALUE = "{ g.Session_ID }">
	</MvIF>
	<MvIF EXPR = "{ l.sessionid EQ '' }">
		<MvASSIGN NAME = "l.sessionid" VALUE = "{ MakeSessionID() }">
	</MvIF>
	<MvIF EXPR = "{ s.callerid EQ '' }">
		<MvASSIGN NAME = "g.sessionurl" VALUE = "{ Domain.d.mm_url $ 'Session_ID=' $ encodeentities( l.sessionid ) $ '&' }">
	<MvELSE>
		<MvASSIGN NAME = "g.sessionurl" VALUE = "{ Domain.d.mm_url }">
	</MvIF>

	<MvIF EXPR = "{ Domain.d.mm_surl }">
		<MvASSIGN NAME = "g.secure_sessionurl" VALUE = "{ Domain.d.mm_surl $ 'Session_ID=' $ encodeentities( l.sessionid ) $ '&' }">
	<MvELSE>
		<MvASSIGN NAME = "g.secure_sessionurl" VALUE = "{ g.sessionurl }">
	</MvIF>

	<MvASSIGN NAME = "g.baseurl" VALUE = "{ Domain.d.base_url }">
	<MvIF EXPR = "{ Domain.d.base_surl }">
		<MvASSIGN NAME = "g.secure_baseurl" VALUE = "{ Domain.d.base_surl }">
	<MvELSE>
		<MvASSIGN NAME = "g.secure_baseurl" VALUE = "{ g.baseurl }">
	</MvIF>

	<MvASSIGN NAME = "g.sessionurl_nosep" VALUE = "{ substring( g.sessionurl, 1, len( g.sessionurl ) - 1 ) }">
	<MvASSIGN NAME = "g.secure_sessionurl_nosep" VALUE = "{ substring( g.secure_sessionurl, 1, len( g.secure_sessionurl ) - 1 ) }">

	<MvIF EXPR = "{ g.Secure }">
		<MvASSIGN NAME = "g.Module_Root_Versionless" VALUE = "{ Domain.d.mod_sroot }">
	<MvELSE>
		<MvASSIGN NAME = "g.Module_Root_Versionless" VALUE = "{ Domain.d.mod_root }">
	</MvIF>
	<MvASSIGN NAME = "g.Module_Root" VALUE = "{ g.Module_Root_Versionless $ g.Merchant_Version $ '/' }">

	<MvASSIGN NAME = "l.null" VALUE = "{ SetPaths() }">

	<MvFUNCTIONRETURN VALUE = "{ l.sessionid }">
</MvFUNCTION>

<MvFUNCTION NAME = "DetermineAdminUser" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.user_id" VALUE = 0>

	<MvIF EXPR = "{ 'https://' IN s.documenturl }">
		<MvASSIGN NAME = "g.Secure" VALUE = 1>
	<MvELSE>
		<MvASSIGN NAME = "g.Secure" VALUE = 0>
	</MvIF>

	<MvIF EXPR = "{ g.Session_ID EQ '' }">
		<MvASSIGN NAME = "g.Session_ID" VALUE = "{ MakeSessionID() }">
	</MvIF>

	<MvIF EXPR = "{ g.Secure AND Domain.d.admin_surl }">
		<MvASSIGN NAME = "g.sessionurl" VALUE = "{ Domain.d.admin_surl $ 'Session_ID=' $ encodeentities( g.Session_ID ) $ '&' }">
	<MvELSE>
		<MvASSIGN NAME = "g.sessionurl" VALUE = "{ s.documenturl $ 'Session_ID=' $ encodeentities( g.Session_ID ) $ '&' }">
	</MvIF>

	<MvIF EXPR = "{ Domain.d.admin_surl }">
		<MvASSIGN NAME = "g.secure_sessionurl" VALUE = "{ Domain.d.admin_surl $ 'Session_ID=' $ encodeentities( g.Session_ID ) $ '&' }">
	<MvELSE>
		<MvASSIGN NAME = "g.secure_sessionurl" VALUE = "{ g.sessionurl }">
	</MvIF>

	<MvASSIGN NAME = "g.baseurl" VALUE = "{ Domain.d.base_url }">
	<MvIF EXPR = "{ Domain.d.base_surl }">
		<MvASSIGN NAME = "g.secure_baseurl" VALUE = "{ Domain.d.base_surl }">
	<MvELSE>
		<MvASSIGN NAME = "g.secure_baseurl" VALUE = "{ g.baseurl }">
	</MvIF>

	<MvASSIGN NAME = "g.sessionurl_nosep" VALUE = "{ substring( g.sessionurl, 1, len( g.sessionurl ) - 1 ) }">
	<MvASSIGN NAME = "g.secure_sessionurl_nosep" VALUE = "{ substring( g.secure_sessionurl, 1, len( g.secure_sessionurl ) - 1 ) }">

	<MvIF EXPR = "{ g.Secure }">
		<MvASSIGN NAME = "g.Module_Root_Versionless" VALUE = "{ Domain.d.mod_sroot }">
	<MvELSE>
		<MvASSIGN NAME = "g.Module_Root_Versionless" VALUE = "{ Domain.d.mod_root }">
	</MvIF>

	<MvASSIGN NAME = "g.Module_Root" VALUE = "{ g.Module_Root_Versionless $ g.Merchant_Version $ '/' }">

	<MvASSIGN NAME = "l.null" VALUE = "{ SetPaths() }">

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ AdminSession_Find_Session( g.Session_ID ) }">
	<MvIF EXPR = "{ NOT l.found }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ User_Find_Name( g.UserName ) }">
		<MvIF EXPR = "{ l.found }">
			<MvIF EXPR = "{ Users.d.lo_date GT 0 }">
				<MvIF EXPR = "{ Users.d.lo_date GE s.dyn_time_t }">
					<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
					<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
					<MvASSIGN NAME = "l.lo_date" VALUE = "{ Users.d.lo_date }">
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					<MvFUNCTIONRETURN VALUE = 0>
				<MvELSE>
					<MvASSIGN NAME = "l.c_fails" VALUE = 0>
					<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails }">
					<MvASSIGN NAME = "l.lo_date" VALUE = 0>
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
				</MvIF>
			<MvELSE>
				<MvIF EXPR = "{ ( Users.d.c_fails EQ 0 ) AND ( Users.d.t_fails GT 0 ) }">
					<MvASSIGN NAME = "l.c_fails" VALUE = 0>
					<MvASSIGN NAME = "l.t_fails" VALUE = 0>
					<MvASSIGN NAME = "l.lo_date" VALUE = 0>
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
				</MvIF>
			</MvIF>
			
			<MvIF EXPR = "{ s.version LT 3.9026 }">
				<MvIF EXPR = "{ substring( Users.d.password, 1, 3 ) EQ '$1$' }">
					<MvASSIGN NAME = "l.salt" VALUE = "{ substring( Users.d.password, 4, 2 ) }">
				<MvELSE>
					<MvASSIGN NAME = "l.salt" VALUE = "{ substring( Users.d.password, 1, 2 ) }">
				</MvIF>
			<MvELSE>
				<MvASSIGN NAME = "l.salt" VALUE = "{ Users.d.password }">
			</MvIF>
			
			<MvIF EXPR = "{ ( g.Password CRYPT l.salt ) EQ Users.d.password }">
				<MvASSIGN NAME = "l.user_id" VALUE = "{ Users.d.id }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ AdminSession_Insert( g.Session_ID, Users.d.id, s.dyn_time_t ) }">
				<MvIF EXPR = "{ Users.d.c_fails GT 0 }">
					<MvASSIGN NAME = "l.c_fails" VALUE = 0>
					<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails }">
					<MvASSIGN NAME = "l.lo_date" VALUE = 0>
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
				</MvIF>
			<MvELSE>
				<MvIF EXPR = "{ Users.d.c_fails GE Domain.d.li_trys }">
					<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
					<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
					<MvASSIGN NAME = "l.lo_date" VALUE = "{ s.dyn_time_t + ( Domain.d.lo_time * 60 ) }">
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					<MvFUNCTIONRETURN VALUE = 0>
				<MvELSE>
					<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
					<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
					<MvASSIGN NAME = "l.lo_date" VALUE = "{ Users.d.lo_date }">
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
				</MvIF>
			</MvIF>
		</MvIF>
	<MvELSE>
		<MvIF EXPR = "{ ( s.time_t - AdminSessions.d.lastupdate ) LE ( Domain.d.admexp * 60 ) }">
			<MvASSIGN NAME = "l.user_id" VALUE = "{ AdminSessions.d.user_id }">
			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ AdminSession_Update( g.Session_ID, AdminSessions.d.user_id, s.dyn_time_t ) }">
		<MvELSE>
			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ User_Find_Name( g.UserName ) }">
			<MvIF EXPR = "{ l.found }">
				<MvIF EXPR = "{ Users.d.lo_date GT 0 }">
					<MvIF EXPR = "{ Users.d.lo_date GE s.dyn_time_t }">
						<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
						<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
						<MvASSIGN NAME = "l.lo_date" VALUE = "{ Users.d.lo_date }">
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
						<MvFUNCTIONRETURN VALUE = 0>
					<MvELSE>
						<MvASSIGN NAME = "l.c_fails" VALUE = 0>
						<MvASSIGN NAME = "l.t_fails" VALUE = "{Users.d.t_fails}">
						<MvASSIGN NAME = "l.lo_date" VALUE = 0>
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					</MvIF>
				<MvELSE>
					<MvIF EXPR = "{ ( Users.d.c_fails EQ 0 ) AND ( Users.d.t_fails GT 0 ) }">
						<MvASSIGN NAME = "l.c_fails" VALUE = 0>
						<MvASSIGN NAME = "l.t_fails" VALUE = 0>
						<MvASSIGN NAME = "l.lo_date" VALUE = 0>
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					</MvIF>
				</MvIF>		

				<MvIF EXPR = "{ s.version LT 3.9026 }">
					<MvIF EXPR = "{ substring( Users.d.password, 1, 3 ) EQ '$1$' }">
						<MvASSIGN NAME = "l.salt" VALUE = "{ substring( Users.d.password, 4, 2 ) }">
					<MvELSE>
						<MvASSIGN NAME = "l.salt" VALUE = "{ substring( Users.d.password, 1, 2 ) }">
					</MvIF>
				<MvELSE>
					<MvASSIGN NAME = "l.salt" VALUE = "{ Users.d.password }">
				</MvIF>

				<MvIF EXPR = "{ ( g.Password CRYPT l.salt ) EQ Users.d.password }">
					<MvASSIGN NAME = "l.user_id" VALUE = "{ Users.d.id }">
					<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ AdminSession_Update( g.Session_ID, l.user_id, s.dyn_time_t ) }">
					<MvIF EXPR = "{ Users.d.c_fails GT 0 }">
						<MvASSIGN NAME = "l.c_fails" VALUE = 0>
						<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails }">
						<MvASSIGN NAME = "l.lo_date" VALUE = 0>
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					</MvIF>
				</MvELSE>
					<MvIF EXPR = "{ Users.d.c_fails GT Domain.d.li_trys }">
						<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
						<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
						<MvASSIGN NAME = "l.lo_date" VALUE = "{ s.dyn_time_t + ( Domain.d.lo_time * 60 ) }">
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					   <MvFUNCRETURN VALUE = 0>
					<MvELSE>
						<MvASSIGN NAME = "l.c_fails" VALUE = "{ Users.d.c_fails + 1 }">
						<MvASSIGN NAME = "l.t_fails" VALUE = "{ Users.d.t_fails + 1 }">
						<MvASSIGN NAME = "l.lo_date" VALUE = "{ Users.d.lo_date }">
						<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.null" VALUE = "{ User_Update( Users.d.id, Users.d.parent_id, Users.d.page_len, Users.d.name, '', Users.d.admin, Users.d.create, l.t_fails, l.c_fails, l.lo_date, Users.d.smod ) }">
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.user_id }">
</MvFUNCTION>

<MvFUNCTION NAME = "OpenBasket" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.basket_id" VALUE = 0>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ BasketList_FindSession( g.Session_ID ) }">
	
	<MvIF EXPR = "{ l.found }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ BasketLastUpdate_FindSession( g.Session_ID ) }">
		<MvIF EXPR = "{ ( s.time_t - BasketLastUpdate.d.lastupdate ) GT ( Stores.d.baskexp * 60 ) }">
			<MvIF EXPR = "{ BasketList.d.order_id AND ( NOT BasketList.d.order_proc ) }">
				<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ BasketList_Free_Order( g.Session_ID ) }">
			</MvIF>

			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ Basket_Delete_AllLines( BasketList.d.basket_id ) }">
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ BasketList_Update_Customer( g.Session_ID, 0 ) }">
		</MvIF>

		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ BasketLastUpdate_Update_LastUpdate( g.Session_ID, s.time_t ) }">
		<MvASSIGN NAME = "l.basket_id" VALUE = "{ BasketList.d.basket_id }">
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>

	<MvASSIGN NAME = "l.expired" VALUE = "{ ( s.time_t - BasketLastUpdate.d.lastupdate ) GT ( Stores.d.baskexp * 60 ) }">
	<MvIF EXPR = "{ l.expired }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ Store_ExpireBaskets() }">
	</MvIF>

	<MvIF EXPR = "{ ( l.found ) AND ( NOT l.expired ) }">
		<MvFUNCTIONRETURN VALUE = "{ l.basket_id }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 0>
</MvFUNCTION>

<MvFUNCTION NAME = "Module_Select" PARAMETERS = "type, name, default, tabindex" STANDARDOUTPUTLEVEL = "">
	<MvEVAL EXPR = "{ '<SELECT TABINDEX = ' $ l.tabindex $ ' NAME = \"' $ l.name $ '\">' }">
	<MvEVAL EXPR = "{ DrawOption_SelectOne() }">

	<MvIF EXPR = "{ l.type }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Module_FindFirst_Type( l.type ) }">
	<MvELSE>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Module_FindFirst() }">
	</MvIF>

	<MvWHILE EXPR = "{ l.found }">
		<MvIF EXPR = "{ Modules.d.id EQ l.default }">
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( Modules.d.id ) $ '\" SELECTED>' $ Modules.d.name $ '</OPTION>' }">
		<MvELSE>
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( Modules.d.id ) $ '\">' $ Modules.d.name $ '</OPTION>' }">
		</MvIF>

		<MvIF EXPR = "{ l.type }">
			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Module_FindNext_Type( l.type ) }">
		<MvELSE>
			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Module_FindNext() }">
		</MvIF>
	</MvWHILE>
	<MvEVAL EXPR = "</SELECT>">
</MvFUNCTION>

<MvFUNCTION NAME = "Country_Select" PARAMETERS = "name, default" STANDARDOUTPUTLEVEL = "">
	<MvEVAL EXPR = "{ '<SELECT NAME = \"' $ l.name $ '\">' }">
	<MvEVAL EXPR = "{ DrawOption_SelectOne() }">
	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Country_FindFirst() }">
	<MvWHILE EXPR = "{ l.found }">
		<MvIF EXPR = "{ Countries.d.alpha EQ l.default }">
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( Countries.d.alpha ) $ '\" SELECTED>' $ encodeentities( Countries.d.name ) $ '</OPTION>' }">
		<MvELSE>
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( Countries.d.alpha ) $ '\">' $ encodeentities( Countries.d.name ) $ '</OPTION>' }">
		</MvIF>

		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ Country_FindNext() }">
	</MvWHILE>
	<MvEVAL EXPR = "</SELECT>">

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "StoreCountry_Select" PARAMETERS = "name, default" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreCountry_FindFirst_Alpha() }">
	<MvASSIGN NAME = "l.first_country_name" VALUE = "{ StoreCountries.d.name }">
	<MvASSIGN NAME = "l.first_country_alpha" VALUE = "{ StoreCountries.d.alpha }">
	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreCountry_FindNext_Alpha() }">
	<MvIF EXPR = "{ NOT l.found }">
		<B><MvEVAL EXPR = "{ l.first_country_name }"></B>
		<INPUT TYPE = "hidden" NAME = "{ l.name }" VALUE = "{ encodeentities( l.first_country_alpha ) }">
	<MvELSE>
		<MvEVAL EXPR = "{ '<SELECT NAME = "' $ l.name $ '">' }">
		<MvEVAL EXPR = "{ DrawOption_SelectOne() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreCountry_FindFirst_Alpha() }">
		<MvWHILE EXPR = "{ l.found }">
			<MvIF EXPR = "{ StoreCountries.d.alpha EQ l.default }">
				<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( StoreCountries.d.alpha ) $ '\" SELECTED>' $ encodeentities( StoreCountries.d.name ) $ '</OPTION>' }">
			<MvELSE>
				<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( StoreCountries.d.alpha ) $ '\">' $ encodeentities( StoreCountries.d.name ) $ '</OPTION>' }">
			</MvIF>

			<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreCountry_FindNext_Alpha() }">
		</MvWHILE>
		<MvEVAL EXPR = "</SELECT>">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "State_Select" PARAMETERS = "name, default" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.selected" VALUE = 0>

	<MvEVAL EXPR = "{ '<SELECT NAME = \"' $ l.name $ '\">' }">
	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ State_FindFirst() }">
	<MvWHILE EXPR = "{ l.found }">
		<MvIF EXPR = "{ States.d.code EQ l.default }">
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( States.d.code ) $ '\" SELECTED>' $ encodeentities( States.d.name ) $ '</OPTION>' }">
			<MvASSIGN NAME = "l.selected" VALUE = 1>
		<MvELSE>
			<MvEVAL EXPR = "{ '<OPTION VALUE = \"' $ encodeentities( States.d.code ) $ '\">' $ encodeentities( States.d.name ) $ '</OPTION>' }">
		</MvIF>

		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ State_FindNext() }">
	</MvWHILE>
	<MvEVAL EXPR = "</SELECT>">

	<MvFUNCTIONRETURN VALUE = "{ l.selected }">
</MvFUNCTION>

<MvFUNCTION NAME = "Error" PARAMETERS = "code, message" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "g.Error_Code" VALUE = "{ l.code }">
	<MvASSIGN NAME = "g.Error_Message" VALUE = "{ l.message }">

	<MvFUNCTIONRETURN VALUE = 0>
</MvFUNCTION>

<MvFUNCTION NAME = "Screen_Error" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<HEAD>

	<TITLE>
	<MvLOCALIZED ID = "MER-UTL-00002">
		<MvLOCALIZED-TEXT LANGUAGE = "en-US">Miva Merchant: Fatal Error</MvLOCALIZED-TEXT>
	</MvLOCALIZED>					
	</TITLE>
	
	</HEAD>

	<!-- Title -->
	<TABLE BORDER = 0 CELLPADDING = 1 CELLSPACING = 0 WIDTH = "100%">
	<TR><TD BGCOLOR = "#000000">
		<TABLE BORDER = 0 CELLPADDING = 5 CELLSPACING = 0 WIDTH = "100%">
		<TR><TD BGCOLOR = "#f0f0f0" WIDTH = "100%">
			<FONT FACE = "Arial, Helvetica">
			<MvLOCALIZED ID = "MER-UTL-00003">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US"><B>Fatal Error</B></MvLOCALIZED-TEXT>
			</MvLOCALIZED>					
			</FONT>
		</TD></TR>
		</TABLE>
	</TD></TR>
	</TABLE>
	<BR>

	<TABLE BORDER = 0 CELLPADDING = 1 CELLSPACING = 0 WIDTH = "100%">
	<TR><TD BGCOLOR = "#000000">
		<TABLE BORDER = 0 CELLPADDING = 5 CELLSPACING = 0 WIDTH = "100%">
		<TR><TD BGCOLOR = "#f0f0f0">
			<FONT FACE = "Arial, Helvetica" SIZE = "-1">
			<MvLOCALIZED ID = "MER-UTL-00004">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">
					Miva Merchant has encountered a fatal error and is unable to continue.  The following information may assist you in determining the cause of the error:
				</MvLOCALIZED-TEXT>
			</MvLOCALIZED>					
			<BR>
			<BR>
			<TABLE BORDER = 0 CELLPADDING = 2 CELLSPACING = 0>
			<TR><TD>
				&nbsp;&nbsp;
			</TD><TD ALIGN = "left" VALIGN = "middle" NOWRAP>
				<FONT FACE = "Arial, Helvetica" SIZE = "-1">
				<MvLOCALIZED ID = "MER-UTL-00005">
					<MvLOCALIZED-TEXT LANGUAGE = "en-US"><B>Error Code:</B></MvLOCALIZED-TEXT>
				</MvLOCALIZED>					
				</FONT>
			</TD><TD ALIGN = "left" VALIGN = "middle">
				<FONT FACE = "Arial, Helvetica" SIZE = "-1">
				<MvEVAL EXPR = "{ g.Error_Code }">
				</FONT>
			</TD></TR>

			<TR><TD>
				&nbsp;&nbsp;
			</TD><TD ALIGN = "left" VALIGN = "top" NOWRAP>
				<FONT FACE = "Arial, Helvetica" SIZE = "-1">
				<MvLOCALIZED ID = "MER-UTL-00006">
					<MvLOCALIZED-TEXT LANGUAGE = "en-US"><B>Description:</B></MvLOCALIZED-TEXT>
				</MvLOCALIZED>					
				</FONT>
			</TD><TD ALIGN = "left" VALIGN = "middle">
				<FONT FACE = "Arial, Helvetica" SIZE = "-1">
				<MvEVAL EXPR = "{ g.Error_Message }">
				</FONT>
			</TD></TR>
			</TABLE>
			</FONT>
		</TD></TR>
		</TABLE>
	</TD></TR>
	</TABLE>
	</BODY>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "Screen_BasketChanged">
	<MvLOCALIZED NAME = "l.error_message" ID = "MER-MER-00009">
		<MvLOCALIZED-TEXT LANGUAGE = "en-US">Your basket's contents changed unexpectedly during the checkout process.  Please press your browser's back button and restart the checkout process.</MvLOCALIZED-TEXT>
	</MvLOCALIZED>
	
	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.ok" VALUE = "{ Module_Find_ID( Stores.d.ui_id ) }">
	<MvIF EXPR = "{ l.ok }">
		<MvIF EXPR = "{ Modules.d.version LT 3.00 }">
			<MvASSIGN NAME = "l.ok" VALUE = "{ Error( 'MER-UTL-00001', l.error_message ) }">
		<MvELSE>
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ UIModule_Order_BasketChanged() }">	
		</MvIF>
	<MvELSE>
		<MvASSIGN NAME = "l.ok" VALUE = "{ Error( 'MER-UTL-00002', l.error_message ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "l.ok">
</MvFUNCTION>

<MvFUNCTION NAME = "CanI" PARAMETERS = "admin, user_id, privilege, view, add, modify, delete" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.can" VALUE = 0>
	<MvIF EXPR = "{ l.admin OR ( Stores.d.manager_id EQ l.user_id ) }">
		<MvASSIGN NAME = "l.can" VALUE = 1>
	<MvELSE>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.can" VALUE = "{ User_Check_Privileges( l.user_id, l.privilege, l.view, l.add, l.modify, l.delete ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.can }">
</MvFUNCTION>

<MvFUNCTION NAME = "Email_Add_AngleBrackets" PARAMETERS = "address" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.pos" VALUE = 1>
	<MvASSIGN NAME = "l.current" VALUE = "{ gettoken( l.address, ',', l.pos ) }">
	<MvWHILE EXPR = "{ l.current }">
		<MvASSIGN NAME = "l.current" VALUE = "{ ltrim( rtrim( l.current ) ) }">
		<MvIF EXPR = "{ substring( l.current, 1, 1 ) NE '<' }">
			<MvASSIGN NAME = "l.current" VALUE = "{ '<' $ l.current }">
		</MvIF>

		<MvIF EXPR = "{ substring( l.current, len( l.current ), 1 ) NE '>' }">
			<MvASSIGN NAME = "l.current" VALUE = "{ l.current $ '>' }">
		</MvIF>

		<MvIF EXPR = "{ l.pos EQ 1 }">
			<MvASSIGN NAME = "l.rewritten" VALUE = "{ l.current }">
		<MvELSE>
			<MvASSIGN NAME = "l.rewritten" VALUE = "{ l.rewritten $ ', ' $ l.current }">
		</MvIF>

		<MvASSIGN NAME = "l.pos" VALUE = "{ l.pos + 1 }">
		<MvASSIGN NAME = "l.current" VALUE = "{ gettoken( l.address, ',', l.pos ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.rewritten }">
</MvFUNCTION>

<MvFUNCTION NAME = "Email_Validate" PARAMETERS = "address" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.valid" VALUE = 0>
	<MvASSIGN NAME = "l.atpos" VALUE = "{ '@' IN l.address }">

	<MvIF EXPR = "{ l.atpos GT 1 }">
		<MvASSIGN NAME = "l.before" VALUE = "{ substring( l.address, 1, l.atpos - 1 ) }">
		<MvASSIGN NAME = "l.after" VALUE = "{ substring( l.address, l.atpos + 1, len( l.address ) - l.atpos ) }">

		<MvIF EXPR = "{ ( '.' IN l.after ) AND ( len( l.after ) GE 3 ) AND isalpha( substring( l.after, len( l.after ) -1, 2 ) ) AND ( isalnum( substring( l.after, 1, 1 ) ) ) }">
			<MvASSIGN NAME = "l.valid" VALUE = 1>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.valid }">
</MvFUNCTION>

<MvFUNCTION NAME = "Phone_Validate" PARAMETERS = "phone, country" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.valid" VALUE = 1>
	
	<MvIF EXPR = "{ ( l.country EQ 'US' ) OR
					( l.country EQ 'DE' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '+', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '/', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '(', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, ')', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '-', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, 'x', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '.', '' ) }">
		<MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, ' ', '' ) }">

		<MvIF EXPR = "{ NOT isdigit( l.phone ) }">
			<MvASSIGN NAME = "l.valid" VALUE = 0>
		</MvIF>

		<MvIF EXPR = "{ len( l.phone ) EQ 0 }">
			<MvASSIGN NAME = "l.valid" VALUE = 0>
		</MvIF>
	<MvELSE>
		<MvASSIGN NAME = "l.valid" VALUE = "{ len( l.phone ) GT 0 }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.valid }">
</MvFUNCTION>

<MvFUNCTION NAME = "Zip_Validate" PARAMETERS = "zip, country" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.valid" VALUE = "{ len( l.zip ) GT 0 }">
	<MvIF EXPR = "{ l.valid }">
		<MvIF EXPR = "{ l.country EQ 'US' }">
			<MvASSIGN NAME = "l.dash_pos" VALUE = "{ '-' IN l.zip }">
			<MvIF EXPR = "{ l.dash_pos EQ 0 }">
				<MvIF EXPR = "{ ( NOT isdigit( l.zip ) ) OR ( len( l.zip ) NE 5 ) }">
					<MvASSIGN NAME = "l.valid" VALUE = 0>
				</MvIF>
			<MvELSE>
				<MvASSIGN NAME = "l.zip_noplus4" VALUE = "{ substring( l.zip, 1, l.dash_pos - 1 ) }">
				<MvASSIGN NAME = "l.plus4" VALUE = "{ substring( l.zip, l.dash_pos + 1, len( l.zip ) ) }">

				<MvIF EXPR = "{ ( NOT isdigit( l.zip_noplus4 ) ) OR ( len( l.zip_noplus4 ) NE 5 ) }">
					<MvASSIGN NAME = "l.valid" VALUE = 0>
				<MvELSE>
					<MvIF EXPR = "{ ( NOT isdigit( l.plus4 ) ) OR ( len( l.plus4 ) NE 4 ) }">
						<MvASSIGN NAME = "l.valid" VALUE = 0>
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>

		<MvIF EXPR = "{ l.country EQ 'DE' }">
			<MvIF EXPR = "{ ( NOT isdigit( l.zip ) ) OR
							( len( l.zip ) NE 5 ) }">
				<MvASSIGN NAME = "l.valid" VALUE = 0>
			</MvIF>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.valid }">
</MvFUNCTION>

<MvFUNCTION NAME = "Adjusted_Price" PARAMETERS = "product_id, pgrpcount, price, cost" STANDARDOUTPUTLEVEL = "compresswhitespace">
	<MvASSIGN NAME = "l.adjusted" VALUE = "{ l.price }">

	<MvIF EXPR = "{ ( l.pgrpcount GT 0 ) AND ( BasketList.d.cust_id NE 0 ) AND ( Customers.d.pgrpcount GT 0 ) }">
		<MvASSIGN NAME = "l.adjusted_found" VALUE = 0>
		<MvASSIGN NAME = "l.current_adjusted" VALUE = 0>

		<MvIF EXPR = "{ g.Features:Customers:Enabled AND g.Features:PriceGroups:Enabled }">
			<MvDO FILE = "{ g.Module_Feature_PGR_DB }" NAME = "l.found" VALUE = "{ PriceGroup_FindFirst_CustomerProduct( BasketList.d.cust_id, l.product_id ) }">
			<MvWHILE EXPR = "{ l.found }">
				<MvASSIGN NAME = "l.new_adjusted" VALUE = "{ l.price }">

				<MvIF EXPR = "{ PriceGroups.d.rate EQ 'C' }">
					<MvASSIGN NAME = "l.new_adjusted" VALUE = "{ l.cost }">
				</MvIF>

				<MvIF EXPR = "{ PriceGroups.d.rate EQ 'D' }">
					<MvASSIGN NAME = "l.new_adjusted" VALUE = "{ ( l.price - ( l.price * ( PriceGroups.d.discount / 100 ) ) ) ROUND 2 }">
				</MvIF>

				<MvIF EXPR = "{ PriceGroups.d.rate EQ 'M' }">
					<MvASSIGN NAME = "l.new_adjusted" VALUE = "{ ( l.cost + ( l.cost * ( PriceGroups.d.markup / 100 ) ) ) ROUND 2 }">
				</MvIF>

				<MvIF EXPR = "{ l.adjusted_found }">
					<MvIF EXPR = "{ ( ( Stores.d.pgrp_ovlp EQ 'HIGHEST' ) AND ( l.new_adjusted GT l.current_adjusted ) ) OR
									( ( Stores.d.pgrp_ovlp EQ 'LOWEST' ) AND ( l.new_adjusted LT l.current_adjusted ) ) }">
						<MvASSIGN NAME = "l.current_adjusted" VALUE = "{ l.new_adjusted }">
					</MvIF>
				<MvELSE>
					<MvASSIGN NAME = "l.adjusted_found" VALUE = 1>
					<MvASSIGN NAME = "l.current_adjusted" VALUE = "{ l.new_adjusted }">
				</MvIF>

				<MvDO FILE = "{ g.Module_Feature_PGR_DB }" NAME = "l.found" VALUE = "{ PriceGroup_FindNext_CustomerProduct( BasketList.d.cust_id, l.product_id ) }">
			</MvWHILE>
		</MvIF>

		<MvIF EXPR = "{ l.adjusted_found }">
			<MvASSIGN NAME = "l.adjusted" VALUE = "{ l.current_adjusted }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.adjusted }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Customer_Login" PARAMETERS = "ship_email" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Customer_Login( l.ship_email ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Customer_EmailPassword" PARAMETERS = "ship_email" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Customer_EmailPassword( l.ship_email ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Customer_Update" PARAMETERS = "ship_email" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Customer_Update( l.ship_email ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Customer_Insert" PARAMETERS = "ship_email" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Customer_Insert( l.ship_email ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_AddProductToBasket" PARAMETERS = "product_code, quantity" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_AddProductToBasket( l.product_code, l.quantity ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_AddUpsoldProductToBasket" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_AddUpsoldProductToBasket( l.product_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_UpdateQuantity" PARAMETERS = "product_code, quantity" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_UpdateQuantity( l.product_code, l.quantity ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_RemoveProductFromBasket" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_RemoveProductFromBasket( l.product_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Save_OrderInformation" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Save_OrderInformation() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_CalculateTax" PARAMETERS = "tax" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_CalculateTax( l.tax ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_CalculateShipping" PARAMETERS = "shipping" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_CalculateShipping( l.shipping ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_AuthorizePayment" PARAMETERS = "order_id, total" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_AuthorizePayment( l.order_id, l.total ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Affiliate_Login" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Affiliate_Login( l.login ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Affiliate_Update" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Affiliate_Update( l.login ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Affiliate_EmailPassword" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Affiliate_Update( l.login ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Affiliate_ManageEmail" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Affiliate_Update( l.login ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_Affiliate_Insert" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_Affiliate_Update( l.login ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_InventoryLevelChange" PARAMETERS = "old_level, new_level" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.version" VALUE = "{ Module_API_Version() }">
		<MvIF EXPR = "{ l.version GE 4.00 }">
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_InventoryLevelChange(old_level, new_level) }">
		</MvIF>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Action_InventoryAdjustment" PARAMETERS = "adjustment" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.version" VALUE = "{ Module_API_Version() }">
		<MvIF EXPR = "{ l.version GE 4.00 }">
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Action_InventoryAdjustment( l.adjustment) }">
		</MvIF>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>
	
<MvFUNCTION NAME = "Log_Screen_AffiliateLogin" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_AffiliateLogin() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_AffiliateCreate" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_AffiliateCreate() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_ProductAttributes" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_ProductAttributes( l.product_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_UpsoldProductAttributes" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_UpsoldProductAttributes( l.product_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Invoice" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Invoice() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_StoreFront" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_StoreFront() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Search" PARAMETERS = "search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Search( l.search ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_ProductList" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_ProductList() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Category" PARAMETERS = "category_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Category( l.category_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Product" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Product( l.product_code ) }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_BasketContents" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_BasketContents() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Order_CustomerInformation" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Order_CustomerInformation() }">	
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Order_UpsoldProduct" PARAMETERS = "product_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Order_UpsoldProduct( l.product_code ) }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Order_SelectShippingPayment" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Order_SelectShippingPayment() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_Order_Payment" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_Order_Payment() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_CustomerLogin" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_CustomerLogin() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>


<MvFUNCTION NAME = "Log_Screen_CustomerCreate" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_CustomerCreate() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_CustomerEdit" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_CustomerEdit() }">
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "Log_Screen_ProductLimited" PARAMETERS = "available" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.version" VALUE = "{ Module_API_Version() }">
		<MvIF EXPR = "{ l.version GE 4.00 }">
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_ProductLimited( l.available ) }">
		</MvIF>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>
	
<MvFUNCTION NAME = "Log_Screen_ProductOut" PARAMETERS = "" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>

	<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindFirst_Type( 'LOG' ) }">
	<MvWHILE EXPR = "{ l.ok AND l.found }">
		<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.version" VALUE = "{ Module_API_Version() }">
		<MvIF EXPR = "{ l.version GE 4.00 }">
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.ok" VALUE = "{ LogModule_Screen_ProductOut() }">
		</MvIF>
		<MvDO FILE = "{ g.Library_Filename_DB }" NAME = "l.found" VALUE = "{ StoreModule_FindNext_Type( 'LOG' ) }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "DrawOption" PARAMETERS = "value, default, text" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
<MvCOMMENT>
|
| l.default is NOT a boolean value, it is the value of the default option.  If this is the same
| as the current value, then this option will be marked selected
</MvCOMMENT>
	<MvASSIGN NAME = "l.option" VALUE = "{ '<OPTION VALUE = "' $ encodeentities( l.value ) $ '"'}">
	<MvIF EXPR = "{ l.value EQ l.default }">
		<MvASSIGN NAME = "l.option" VALUE = "{ l.option $ ' SELECTED' }">
	</MvIF>
	<MvASSIGN NAME = "l.option" VALUE = "{ l.option $ '>' $ l.text $ '</OPTION>' }">

	<MvEVAL EXPR = "{ l.option }">
	<MvFUNCTIONRETURN VALUE = "">
</MvFUNCTION>

<MvFUNCTION NAME = "DrawOption_SelectOne" PARAMETERS = "" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<MvLOCALIZED NAME = "l.option_text" ID = "MER-UTL-00001">
		<MvLOCALIZED-TEXT LANGUAGE = "en-US">Select One</MvLOCALIZED-TEXT>
	</MvLOCALIZED>
	
	<OPTION VALUE = "">&lt;<MvEVAL EXPR = "{ l.option_text }">&gt;</OPTION> 
	<MvFUNCTIONRETURN VALUE = "">
</MvFUNCTION>

<MvFUNCTION NAME = "DrawRadio" PARAMETERS = "name, value, default, text" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<MvIF EXPR = "{ l.value EQ l.default }">
		<INPUT TYPE = "radio" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }" CHECKED> <MvEVAL EXPR = "{ l.text }">
	<MvELSE>
		<INPUT TYPE = "radio" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }"> <MvEVAL EXPR = "{ l.text }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "DrawCheckbox" PARAMETERS = "checked, name, value, text" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<MvASSIGN NAME = "l.enabled" VALUE = 1>
	
	<MvIF EXPR = "{ l.name EQ 'Product_Attribute_Copy' }">
		<MvASSIGN NAME = "l.enabled" VALUE = "{ g.Features:AttributeTemplates:Enabled }">
	</MvIF>

	<MvIF EXPR = "{ l.enabled }">
		<MvIF EXPR = "{ l.checked }">
			<INPUT TYPE = "checkbox" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }" CHECKED> <MvEVAL EXPR = "{ l.text }">
		<MvELSE>
			<INPUT TYPE = "checkbox" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }"> <MvEVAL EXPR = "{ l.text }">
		</MvIF>
	<MvELSE>
		&nbsp;
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "DrawCheckboxModAlert" PARAMETERS = "checked, name, value, text" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
	<MvIF EXPR = "{ l.checked }">
		<INPUT TYPE = "checkbox" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }" CHECKED ONCLICK = "SetModified();"> <MvEVAL EXPR = "{ l.text }">
	<MvELSE>
		<INPUT TYPE = "checkbox" NAME = "{ encodeentities( l.name ) }" VALUE = "{ encodeentities( l.value ) }" ONCLICK = "SetModified();"> <MvEVAL EXPR = "{ l.text }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "Format_Address" PARAMETERS = "company, name, street, city, state, zip, cntry, seperater" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.address" VALUE = "">
	
	<MvIF EXPR = "{ len( l.company ) }">
		<MvIF EXPR = "{ len( l.address ) }">
			<MvASSIGN NAME = "l.address" VALUE = "{ l.address $ l.seperater $ l.company }">
		<MvELSE>
			<MvASSIGN NAME = "l.address" VALUE = "{ l.company }">
		</MvIF>
	</MvIF>
		
	<MvIF EXPR = "{ len( l.name ) }">
		<MvIF EXPR = "{ len( l.address ) }">
			<MvASSIGN NAME = "l.address" VALUE = "{ l.address $ l.seperater $ l.name }">
		<MvELSE>
			<MvASSIGN NAME = "l.address" VALUE = "{ l.name }">
		</MvIF>
	</MvIF>
	
	<MvIF EXPR = "{ len( l.street ) }">
		<MvIF EXPR = "{ len( l.address ) }">
			<MvASSIGN NAME = "l.address" VALUE = "{ l.address $ l.seperater $ l.street }">
		<MvELSE>
			<MvASSIGN NAME = "l.address" VALUE = "{ l.street }">
		</MvIF>
	</MvIF>

	<MvASSIGN NAME = "l.state_zip" VALUE = "{ ltrim( rtrim( l.state $ ' ' $ l.zip ) ) }">
		
	<MvIF EXPR = "{ len( l.city ) AND len( l.state_zip ) }">
		<MvASSIGN NAME = "l.address_line" VALUE = "{ l.city $ ', ' $ l.state_zip }">
	<MvELSE>
		<MvASSIGN NAME = "l.address_line" VALUE = "{ l.city $ l.state_zip }">
	</MvIF>
	
	<MvIF EXPR = "{ len( l.address_line ) }">
		<MvIF EXPR = "{ len( l.address ) }">
			<MvASSIGN NAME = "l.address" VALUE = "{ l.address $ l.seperater $ l.address_line }">
		<MvELSE>
			<MvASSIGN NAME = "l.address" VALUE = "{ l.address_line }">
		</MvIF>
	</MvIF>
	
	<MvFUNCTIONRETURN VALUE = "{ l.address }">
</MvFUNCTION>

<MvFUNCTION NAME = "Format_Date" PARAMETERS = "time_t, language" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.date" VALUE = "">
	
	<MvIF EXPR = "{ l.language EQ 'en-US' }">
		<MvASSIGN NAME = "l.date" VALUE = "{ padl( time_t_month( l.time_t, timezone() ), 2, '0' ) $ '/' $ padl( time_t_dayofmonth( l.time_t, timezone() ), 2, '0' ) $ '/' $ time_t_year( l.time_t, timezone() ) }">
	</MvIF>

	<MvIF EXPR = "{ l.language EQ 'de-DE' }">
		<MvASSIGN NAME = "l.date" VALUE = "{ padl( time_t_dayofmonth( l.time_t, timezone() ), 2, '0' ) $ '.' $ padl( time_t_month( l.time_t, timezone() ), 2, '0' ) $ '.' $ time_t_year( l.time_t, timezone() ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.date }">
</MvFUNCTION>

<MvFUNCTION NAME = "Format_Time" PARAMETERS = "time_t, language" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.time" VALUE = "">

	<MvIF EXPR = "{ l.language EQ 'en-US' }">
		<MvASSIGN NAME = "l.time" VALUE = "{ padl( time_t_hour( l.time_t, timezone() ), 2, '0' ) $ ':' $
											 padl( time_t_min( l.time_t, timezone() ), 2, '0' ) $ ':' $ 
											 padl( time_t_sec( l.time_t, timezone() ), 2, '0' ) $ ' ' $ s.stm_zone }">
	</MvIF>

	<MvIF EXPR = "{ l.language EQ 'de-DE' }">
		<MvASSIGN NAME = "l.time" VALUE = "{ padl( time_t_hour( l.time_t, timezone() ), 2, '0' ) $ ':' $
											 padl( time_t_min( l.time_t, timezone() ), 2, '0' ) $ ':' $ 
											 padl( time_t_sec( l.time_t, timezone() ), 2, '0' ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.time }">
</MvFUNCTION>

<MvFUNCTION NAME = "Format_Time_Short" PARAMETERS = "time_t, language" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.time" VALUE = "">

	<MvIF EXPR = "{ l.language EQ 'en-US' }">
		<MvASSIGN NAME = "l.time" VALUE = "{ padl( time_t_hour( l.time_t, timezone() ), 2, '0' ) $ ':' $
											 padl( time_t_min( l.time_t, timezone() ), 2, '0' ) $ ':' $ 
											 padl( time_t_sec( l.time_t, timezone() ), 2, '0' ) }">
	</MvIF>

	<MvIF EXPR = "{ l.language EQ 'de-DE' }">
		<MvASSIGN NAME = "l.time" VALUE = "{ padl( time_t_hour( l.time_t, timezone() ), 2, '0' ) $ ':' $
											 padl( time_t_min( l.time_t, timezone() ), 2, '0' ) $ ':' $ 
											 padl( time_t_sec( l.time_t, timezone() ), 2, '0' ) }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.time }">
</MvFUNCTION>

<MvFUNCTION NAME = "SetPaths" PARAMETERS = "" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "g.Module_Library_Utilities"	VALUE = "{ g.Module_Root $ g.Library_Utilities }">
	<MvASSIGN NAME = "g.Module_Library_DB"			VALUE = "{ g.Module_Root $ g.Library_DB }">
	<MvASSIGN NAME = "g.Module_Library_Help"		VALUE = "{ g.Module_Root $ g.Library_Help }">
	<MvASSIGN NAME = "g.Module_Admin"				VALUE = "{ g.Module_Root $ g.Filename_Admin }">
	<MvASSIGN NAME = "g.Module_Version"				VALUE = "{ g.Module_Root $ g.Filename_Version }">
	<MvASSIGN NAME = "g.Module_Upgrade"				VALUE = "{ g.Module_Root_Versionless $ g.Filename_Upgrade }">

	<MvDO FILE = "{ '../' $ g.Filename_Version }" NAME = "l.isEnabled" VALUE = "{ Features_Set_Enabled() }">

	<MvASSIGN NAME = "g.Module_Feature_AFF_DB"		VALUE = "{ g.Module_Root $ g.Feature_AFF_DB }">
	<MvASSIGN NAME = "g.Module_Feature_AFF"			VALUE = "{ g.Module_Root $ g.Feature_AFF }">

	<MvASSIGN NAME = "g.Module_Feature_AGR_DB"		VALUE = "{ g.Module_Root $ g.Feature_AGR_DB }">
	<MvASSIGN NAME = "g.Module_Feature_AGR_AD"		VALUE = "{ g.Module_Root $ g.Feature_AGR_AD }">

	<MvASSIGN NAME = "g.Module_Feature_CUS_DB"		VALUE = "{ g.Module_Root $ g.Feature_CUS_DB }">
	<MvASSIGN NAME = "g.Module_Feature_CUS_RT"		VALUE = "{ g.Module_Root $ g.Feature_CUS_RT }">
	<MvASSIGN NAME = "g.Module_Feature_CUS"			VALUE = "{ g.Module_Root $ g.Feature_CUS }">

	<MvASSIGN NAME = "g.Module_Feature_PGR_AD"		VALUE = "{ g.Module_Root $ g.Feature_PGR_AD }">
	<MvASSIGN NAME = "g.Module_Feature_PGR_DB"		VALUE = "{ g.Module_Root $ g.Feature_PGR_DB }">

	<MvASSIGN NAME = "g.Module_Feature_RPD_DB"		VALUE = "{ g.Module_Root $ g.Feature_RPD_DB }">
	<MvASSIGN NAME = "g.Module_Feature_RPD"			VALUE = "{ g.Module_Root $ g.Feature_RPD }">
	<MvASSIGN NAME = "g.Module_Feature_RPD_AD"		VALUE = "{ g.Module_Root $ g.Feature_RPD_AD }">

	<MvASSIGN NAME = "g.Module_Feature_INV_DB"		VALUE = "{ g.Module_Root $ g.Feature_INV_DB }">
	<MvASSIGN NAME = "g.Module_Feature_INV_RT"		VALUE = "{ g.Module_Root $ g.Feature_INV_RT }">
	<MvASSIGN NAME = "g.Module_Feature_INV"			VALUE = "{ g.Module_Root $ g.Feature_INV }">
	<MvASSIGN NAME = "g.Module_Feature_INV_AD"		VALUE = "{ g.Module_Root $ g.Feature_INV_AD }">

	<MvASSIGN NAME = "g.Module_Feature_NOT_DB"		VALUE = "{ g.Module_Root $ g.Feature_NOT_DB }">
	<MvASSIGN NAME = "g.Module_Feature_NOT"			VALUE = "{ g.Module_Root $ g.Feature_NOT_AD }">

	<MvASSIGN NAME = "g.Module_Feature_STA_DB"		VALUE = "{ g.Module_Root $ g.Feature_STA_DB }">
	<MvASSIGN NAME = "g.Module_Feature_STA"			VALUE = "{ g.Module_Root $ g.Feature_STA }">

	<MvASSIGN NAME = "g.Module_Feature_USL_AD"		VALUE = "{ g.Module_Root $ g.Feature_USL_AD }">
	<MvASSIGN NAME = "g.Module_Feature_USL_DB"		VALUE = "{ g.Module_Root $ g.Feature_USL_DB }">
	<MvASSIGN NAME = "g.Module_Feature_USL_RT"		VALUE = "{ g.Module_Root $ g.Feature_USL_RT }">

	<MvASSIGN NAME = "g.Module_Feature_PRV_AD"		VALUE = "{ g.Module_Root $ g.Feature_PRV_AD }">

	<MvCOMMENT> Begin Simple Administration Variables FEATURECODE=STP </MvCOMMENT>
		<MvASSIGN NAME = "g.Module_Feature_STP_DB" VALUE = "{ g.Module_Root $ g.Feature_STP_DB }">
		<MvASSIGN NAME = "g.Module_Feature_STP_AD" VALUE = "{ g.Module_Root $ g.Feature_STP_AD }">
	<MvCOMMENT> End Simple Administration Variables FEATURECODE=STP </MvCOMMENT>

	<MvCOMMENT> Begin Attribute Templates Variables CODE=ATT </MvCOMMENT>
		<MvASSIGN NAME = "g.Module_Feature_ATT_DB" VALUE = "{ g.Module_Root $ g.Feature_ATT_DB }">
		<MvASSIGN NAME = "g.Module_Feature_ATT" VALUE = "{ g.Module_Root $ g.Feature_ATT }">
	<MvCOMMENT> End Attribute Templates Variables CODE=ATT </MvCOMMENT>
	
	<MvFUNCTIONRETURN VALUE = "1">

</MvFUNCTION>

<MvFUNCTION NAME = "HTML_Format_Marks" PARAMETERS = "data" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, ' (R)', '<SUP>&reg;</SUP>' ) }">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, ' (sm)', '<SUP> SM</SUP>' ) }">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, ' (TM)', '<SUP> TM</SUP>' ) }">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, encodeentities( ' (R)' ), '<SUP>&reg;</SUP>' ) }">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, encodeentities( ' (sm)' ), '<SUP> SM</SUP>' ) }">
	<MvASSIGN NAME = "l.data" VALUE = "{ glosub( l.data, encodeentities( ' (TM)' ), '<SUP> TM</SUP>' ) }">
	
	<MvFUNCTIONRETURN VALUE = "{ l.data }">
</MvFUNCTION>

<MvFUNCTION NAME = "Data_Entry_Error" PARAMETERS = "message" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "g.Data_Entry_Error" VALUE = "1">
	<MvIF EXPR = "{ len( l.message ) }">
		<MvASSIGN NAME = "l.pos" VALUE = "{ miva_array_max( g.Data_Entry_Error_Message ) + 1 }">
		<MvASSIGN NAME = "g.Data_Entry_Error_Message" INDEX = "{ l.pos }" VALUE = "{ l.message }">
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "SendEmail" PARAMETERS = "to,from,cc,subject,headers,message" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "1">
	<MvIF EXPR = "{ Domain.d.mail_angl }">
		<MvASSIGN NAME = "l.from" VALUE = "{ Email_Add_AngleBrackets( l.from ) }">
		<MvASSIGN NAME = "l.to" VALUE = "{ Email_Add_AngleBrackets( l.to ) }">
		<MvASSIGN NAME = "l.cc" VALUE = "{ Email_Add_AngleBrackets( l.cc ) }">
	</MvIF>
	<MvASSIGN NAME = "l.mailhost" VALUE = "{ Domain.d.mailhost }">

	<MvIF EXPR = "{ len( Domain.d.mailmeth ) }">
		<MIVA MvCOMMERCE_ERROR = "nonfatal, nodisplay">
		<MvCOMMERCE METHOD = "{ Domain.d.mailmeth }" FIELDS = "to,from,cc,subject,headers,message,mailhost">
		</MvCOMMERCE>
		<MvIF EXPR = "{ MvCOMMERCE_ERROR }">
			<MvASSIGN NAME = "l.ok" VALUE = "{ Error( 'MER-UTL-00003', MvCOMMERCE_ERROR ) }">
		</MvIF>
	<MvELSE>
		<MIVA MvSMTP_ERROR = "nonfatal, nodisplay">
		<MvSMTP FROM = "{ l.from }" TO = "{ l.to }" CC = "{ l.cc }" SUBJECT = "{ l.subject }" MAILHOST = "{ l.mailhost }">
		<MvEVAL EXPR = "{ l.headers $ asciichar(10) $ asciichar(10) }">
		<MvEVAL EXPR = "{ l.message $ asciichar(10) $ asciichar(10) }">
		</MvSMTP>
		<MvIF EXPR = "{ MvSMTP_ERROR }">
			<MvASSIGN NAME = "l.ok" VALUE = "{ Error( 'MER-UTL-00003', MvSMTP_ERROR ) }">
		</MvIF>
	</MvIF>
	
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>
