var enviomoto = 22;
var regional = new Array(5);
var nacional = new Array(5);

regional[0] = 29;
regional[1] = 35;
regional[2] = 45;
regional[3] = 54;
regional[4] = 63;

nacional[0] = 41;
nacional[1] = 53;
nacional[2] = 69;
nacional[3] = 85;
nacional[4] = 99;
//=====================================================================|| 
// NOP Design JavaScript Shopping Cart || 
// || 
// For more information on SmartSystems, or how NOPDesign can help you || 
// Please visit us on the WWW at http://www.nopdesign.com || 
// || 
// Javascript portions of this shopping cart software are available as || 
// freeware from NOP Design. You must keep this comment unchanged in || 
// your code. For more information contact FreeCart@NopDesign.com. || 
// || 
// JavaScript Shop Module, V.4.4.0 || 
//=====================================================================|| 

//=====================================================================||
// UPS Shiping Mod by Stefko V.1.0.0 ||
// ||
// Version History: 02/23/03  V.1.0.0 Released ||
//                            includes USERENTRY ||                            
//                  03/02/03  V.1.1.0 Now works with Netscape & Opera ||
//                            added Taxable and Non-taxable product code||
//                            added MathRound to Weight ||
//=====================================================================|| 

//---------------------------------------------------------------------|| 
// Global Options || 
// ---------------- || 
// Shopping Cart Options, you can modify these options to change the || 
// the way the cart functions. || 
// || 
// Language Packs || 
// ============== || 
// You may include any language pack before nopcart.js in your HTML || 
// pages to change the language. Simply include a language pack with || 
// a script src BEFORE the <SCRIPT SRC="../os1/nopcart.js">... line. || 
// For example: <SCRIPT SRC="language-en.js"></SCRIPT> || 
// || 
// Options For Everyone: || 
// ===================== || 
// * MonetarySymbol: string, the symbol which represents dollars/euro, || 
// in your locale. || 
// * DisplayNotice: true/false, controls whether the user is provided || 
// with a popup letting them know their product is added to the cart || 
// * DisplayShippingColumn: true/false, controls whether the managecart|| 
// and checkout pages display shipping cost column. || 
// * DisplayShippingRow: true/false, controls whether the managecart || 
// and checkout pages display shipping cost total row. || 
// * DisplayTaxRow: true/false, controls whether the managecart || 
// and checkout pages display tax cost total row. || 
// * TaxRate: number, your area's current tax rate, ie: if your tax || 
// rate was 7.5%, you would set TaxRate = 0.075 || 
// * TaxByRegion: true/false, when set to true, the user is prompted || 
// with TaxablePrompt to determine if they should be charged tax. || 
// In the USA, this is useful to charge tax to those people who live || 
// in a particular state, but no one else. || 
// * TaxPrompt: string, popup message if user has not selected either || 
// taxable or nontaxable when TaxByRegion is set to true. || 
// * TaxablePrompt: string, the message the user is prompted with to || 
// select if they are taxable. If TaxByRegion is set to false, this || 
// has no effect. Example: 'Arizona Residents' || 
// * NonTaxablePrompt: string, same as above, but the choice for non- || 
// taxable people. Example: 'Other States' || 
// * MinimumOrder: number, the minium dollar amount that must be || 
// purchased before a user is allowed to checkout. Set to 0.00 || 
// to disable. || 
// * MinimumOrderPrompt: string, Message to prompt users with when || 
// they have not met the minimum order amount. || 
// || 
// Payment Processor Options: || 
// ========================== || 
// * PaymentProcessor: string, the two digit payment processor code || 
// for support payment processor gateways. Setting this field to || 
// anything other than an empty string will override your OutputItem || 
// settings -- so please be careful when receiving any form data. || 
// Support payment processor gateways are: || 
// * Authorize.net (an) || 
// * Worldpay (wp) || 
// * LinkPoint (lp) || 
// || 
// Options For Programmers: || 
// ======================== || 
// * OutputItem<..>: string, the name of the pair value passed at || 
// checkouttime. Change these only if you are connecting to a CGI || 
// script and need other field names, or are using a secure service || 
// that requires specific field names. || 
// * AppendItemNumToOutput: true/false, if set to true, the number of || 
// each ordered item will be appended to the output string. For || 
// example if OutputItemId is 'ID_' and this is set to true, the || 
// output field name will be 'ID_1', 'ID_2' ... for each item. || 
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields || 
// for the cart items will be passed TO the checkout page, from the || 
// ManageCart page. This is set to true for CGI/PHP/Script based || 
// checkout pages, but should be left false if you are using an || 
// HTML/Javascript Checkout Page. Hidden fields will ALWAYS be || 
// passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script || 
//---------------------------------------------------------------------|| 

//Options for Everyone: 
MonetarySymbol = 'U$D '; 
Pesos = '$ '
DisplayNotice = true; 
DisplayChangeQty = false; 
DisplayShippingColumn = true; 
DisplayShippingRow = true; 
TaxRate = 0.00; //set taxable region rate ||
DisplayTaxRow = false; 
TaxByRegion = false; //leave this at false, UPS Shipping Mod will activate taxable Zone ||
TaxPrompt = 'For tax purposes, please select if you are an Kansas branch of Oasis before continuing'; //Deactivated ||
TaxablePrompt = 'Kansas Branch'; //Deactivated ||
NonTaxablePrompt = 'Other Branches'; //Deactivated ||
MinimumOrder = 0.01; 
MinimumOrderPrompt = 'No puede efectuarse la compra dado que\nsu carrito está vacio.'; 
//original syntax - MinimumOrderPrompt = 'Your order is below our minimum order, please order more before checking out.'; 

var SHIPPINGLabel = "";

NoQtyPrompt = 'You cannot proceed until a Shipping Zone has been selected'; //If attempted to go to checkout before selecting shipping zone ||

//Payment Processor Options: 
PaymentProcessor = ''; 

//Options for Programmers: 
OutputItemId = 'ID_'; 
OutputItemQuantity = 'QUANTITY_'; 
OutputItemPrice = 'PRICE_'; 
OutputItemName = 'NAME_'; 
OutputItemWeight = 'WEIGHT_'; //Added for UPS mod ||
OutputItemAddtlInfo = 'ADDTLINFO_'; 
OutputItemXtend = 'XTEND_'; 
OutputOrderZone = 'SHIPZONE'; 
OutputOrderSubtotal = 'SUBTOTAL'; 
OutputOrderSubtotalAr = 'SUBTOTALAR'; 
OutputOrderShipping = 'SHIPPING'; 
OutputOrderShippingAr = 'SHIPPINGARG'; 
OutputOrderTax = 'TAX'; 
OutputOrderTotal = 'TOTAL'; 
OutputOrderTotalAr = 'TOTALAR'; 
Outputb_payment = 'METODOENVIO'; 
AppendItemNumToOutput = true; 
HiddenFieldsToCheckout = true; 

//Options for Shipping by Weight: 
LocationLabel = 'ZONA'; 
LocationPrompt = 'Por favor elija una zona de envio, de lo contrario no podra efectuarse la compra.'; 
MaxWeightPrompt = 'Sorry, maximum weight allowable is 500lbs.'; 



//=====================================================================|| 
//---------------------------------------------------------------------|| 
// YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE || 
//---------------------------------------------------------------------|| 
//=====================================================================|| 


//---------------------------------------------------------------------|| 
// Language Strings || 
// ------------------ || 
// These strings will not be used unless you have not included a || 
// language pack already. You should NOT modify these, but instead || 
// modify the strings in language-**.js where ** is the language pack || 
// you are using. || 
//---------------------------------------------------------------------|| 
if ( !bLanguageDefined ) { 
strSorry = "I'm Sorry, your cart is full, please proceed to checkout."; 
strAdded = " Added to your shopping cart."; 
strRemove = "Click 'Ok' to remove this product from your shopping cart."; 
strILabel = "Product Id"; 
strDLabel = "Product Name/Description"; 
strQLabel = "Qty"; 
strPLabel = "Price"; 
strSLabel = "Weight"; //Added for UPS mod ||
strRLabel = "Remove From Cart"; 
strRButton= "Remove"; 
strSUB = "SUBTOTAL"; 
strWTOT = "TOTAL WEIGHT"; //Added for UPS mod ||
strSHIP = "SHIPPING"; 
strTAX = "TAX"; 
strTOT = "TOTAL"; 
strErrQty = "Invalid Quantity."; 
strNewQty = 'Please enter new quantity:'; 
var METODOENVIO = 0;
bLanguageDefined = true; 
} 

//---------------------------------------------------------------------|| 
// FUNCTION: CKquantity || 
// PARAMETERS: Quantity to || 
// RETURNS: Quantity as a number, and possible alert || 
// PURPOSE: Make sure quantity is represented as a number || 
//---------------------------------------------------------------------|| 
function CKquantity(checkString) { 
var strNewQuantity = ""; 

for ( i = 0; i < checkString.length; i++ ) { 
ch = checkString.substring(i, i+1); 
if ( (ch >= "0" && ch <= "9") || (ch == '.') ) 
strNewQuantity += ch; 
} 

if ( strNewQuantity.length < 1 ) 
strNewQuantity = "1"; 

return(strNewQuantity); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: AddToCart || 
// PARAMETERS: Form Object || 
// RETURNS: Cookie to user's browser, with prompt || 
// PURPOSE: Adds a product to the user's shopping cart || 
// EXTRAS ADDED IN: USERENTRY for customer text input ||
//---------------------------------------------------------------------|| 
function AddToCart(thisForm) { 
var iNumberOrdered = 0; 
var bAlreadyInCart = false; 
var notice = ""; 
iNumberOrdered = GetCookie("NumberOrdered"); 

if ( iNumberOrdered == null ) 
iNumberOrdered = 0; 

if ( thisForm.PRECIO == null ) 
strPRECIO = ""; 
else 
strPRECIO = thisForm.PRECIO.value; 

if ( thisForm.QUANTITY == null ) 
strQUANTITY = "1"; 
else 
strQUANTITY = thisForm.QUANTITY.value; 

if ( thisForm.PRICE == null ) 
strPRICE = "0.00"; 
else 
strPRICE = thisForm.PRECIO.value; 

if ( thisForm.NAME == null ) 
strNAME = ""; 
else 
strNAME = thisForm.NAME.value; 

if ( thisForm.WEIGHT == null ) //Added for UPS mod ||
strSHIPPING = "0"; 
else 
strSHIPPING = thisForm.WEIGHT.value; 

if ( thisForm.ADDITIONALINFO == null ) { strADDTLINFO = ""; } else { strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value; } if ( thisForm.ADDITIONALINFO2 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO2[thisForm.ADDITIONALINFO2.selectedIndex].value; } if ( thisForm.ADDITIONALINFO3 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO3[thisForm.ADDITIONALINFO3.selectedIndex].value; } if ( thisForm.ADDITIONALINFO4 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO4[thisForm.ADDITIONALINFO4.selectedIndex].value; } 
if ( thisForm.USERENTRY != null ) { 
strADDTLINFO += "; " + thisForm.USERENTRY.value; 
} 
if ( thisForm.USERENTRY2 != null ) { 
strADDTLINFO += "; " + thisForm.USERENTRY2.value; 
} 
if ( thisForm.USERENTRY3 != null ) { 
strADDTLINFO += "; " + thisForm.USERENTRY3.value; 
} 
//Is this product already in the cart? If so, increment quantity instead of adding another. 
for ( i = 1; i <= iNumberOrdered; i++ ) { 
NewOrder = "Order." + i; 
database = ""; 
database = GetCookie(NewOrder); 

Token0 = database.indexOf("|", 0); 
Token1 = database.indexOf("|", Token0+1); 
Token2 = database.indexOf("|", Token1+1); 
Token3 = database.indexOf("|", Token2+1); 
Token4 = database.indexOf("|", Token3+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); 
fields[1] = database.substring( Token0+1, Token1 ); 
fields[2] = database.substring( Token1+1, Token2 ); 
fields[3] = database.substring( Token2+1, Token3 ); 
fields[4] = database.substring( Token3+1, Token4 ); 
fields[5] = database.substring( Token4+1, database.length ); 

if ( fields[0] == strPRECIO && 
fields[2] == strPRICE && 
fields[3] == strNAME && 
fields[5] == strADDTLINFO 
) { 
bAlreadyInCart = true; 
dbUpdatedOrder = strPRECIO + "|" + 
(parseInt(strQUANTITY)+parseInt(fields[1])) + "|" + 
strPRICE + "|" + 
strNAME + "|" + 
strSHIPPING + "|" + 
strADDTLINFO; 
strNewOrder = "Order." + i; 
DeleteCookie(strNewOrder, "/"); 
SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); 
break; 
} 
} 


if ( !bAlreadyInCart ) { 
iNumberOrdered++; 

if ( iNumberOrdered > 12 ) 
alert( strSorry ); 
else { 
dbUpdatedOrder = strPRECIO + "|" + 
strQUANTITY + "|" + 
strPRICE + "|" + 
strNAME + "|" + 
strSHIPPING + "|" + 
strADDTLINFO; 

strNewOrder = "Order." + iNumberOrdered; 
SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); 
SetCookie("NumberOrdered", iNumberOrdered, null, "/"); 
} 
} 

if ( DisplayNotice && notice!=''){ 
alert(notice); 
}else{ 
} 

} 


//---------------------------------------------------------------------|| 
// FUNCTION: getCookieVal || 
// PARAMETERS: offset || 
// RETURNS: URL unescaped Cookie Value || 
// PURPOSE: Get a specific value from a cookie || 
//---------------------------------------------------------------------|| 
function getCookieVal (offset) { 
var endstr = document.cookie.indexOf (";", offset); 

if ( endstr == -1 ) 
endstr = document.cookie.length; 
return(unescape(document.cookie.substring(offset, endstr))); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: FixCookieDate || 
// PARAMETERS: date || 
// RETURNS: date || 
// PURPOSE: Fixes cookie date, stores back in date || 
//---------------------------------------------------------------------|| 
function FixCookieDate (date) { 
var base = new Date(0); 
var skew = base.getTime(); 

date.setTime (date.getTime() - skew); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: GetCookie || 
// PARAMETERS: Name || 
// RETURNS: Value in Cookie || 
// PURPOSE: Retrieves cookie from users browser || 
//---------------------------------------------------------------------|| 
function GetCookie (name) { 
var arg = name + "="; 
var alen = arg.length; 
var clen = document.cookie.length; 
var i = 0; 

while ( i < clen ) { 
var j = i + alen; 
if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j)); 
i = document.cookie.indexOf(" ", i) + 1; 
if ( i == 0 ) break; 
} 

return(null); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: SetCookie || 
// PARAMETERS: name, value, expiration date, path, domain, security || 
// RETURNS: Null || 
// PURPOSE: Stores a cookie in the users browser || 
//---------------------------------------------------------------------|| 
function SetCookie (name,value,expires,path,domain,secure) { 
document.cookie = name + "=" + escape (value) + 
((expires) ? "; expires=" + expires.toGMTString() : "") + 
((path) ? "; path=" + path : "") + 
((domain) ? "; domain=" + domain : "") + 
((secure) ? "; secure" : ""); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: DeleteCookie || 
// PARAMETERS: Cookie name, path, domain || 
// RETURNS: null || 
// PURPOSE: Removes a cookie from users browser. || 
//---------------------------------------------------------------------|| 
function DeleteCookie (name,path,domain) { 
if ( GetCookie(name) ) { 
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") + 
((domain) ? "; domain=" + domain : "") + 
"; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
} 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: MoneyFormat || 
// PARAMETERS: Number to be formatted || 
// RETURNS: Formatted Number || 
// PURPOSE: Reformats Dollar Amount to #.## format || 
//---------------------------------------------------------------------|| 
function moneyFormat(input) { 
var dollars = Math.floor(input); 
var tmp = new String(input); 

for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) { 
if ( tmp.charAt(decimalAt)=="." ) 
break; 
} 

var cents = "" + Math.round(input * 100); 
cents = cents.substring(cents.length-2, cents.length) 
dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0; 

if ( cents == "0" ) 
cents = "00"; 


return(dollars + "." + cents); 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: RemoveFromCart || 
// PARAMETERS: Order Number to Remove || 
// RETURNS: Null || 
// PURPOSE: Removes an item from a users shopping cart || 
//---------------------------------------------------------------------|| 
function RemoveFromCart(RemOrder) { 
if ( confirm( strRemove ) ) { 
NumberOrdered = GetCookie("NumberOrdered"); 
for ( i=RemOrder; i < NumberOrdered; i++ ) { 
NewOrder1 = "Order." + (i+1); 
NewOrder2 = "Order." + (i); 
database = GetCookie(NewOrder1); 
SetCookie (NewOrder2, database, null, "/"); 
} 
NewOrder = "Order." + NumberOrdered; 
SetCookie ("NumberOrdered", NumberOrdered-1, null, "/"); 
DeleteCookie(NewOrder, "/"); 
location.href=location.href; 
} 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: ChangeQuantity || 
// PARAMETERS: Order Number to Change Quantity || 
// RETURNS: Null || 
// PURPOSE: Changes quantity of an item in the shopping cart || 
//---------------------------------------------------------------------|| 
function ChangeQuantity(OrderItem,NewQuantity) { 
if ( isNaN(NewQuantity) ) { 
alert( strErrQty ); 
} else { 
NewOrder = "Order." + OrderItem; 
database = ""; 
database = GetCookie(NewOrder); 

Token0 = database.indexOf("|", 0); 
Token1 = database.indexOf("|", Token0+1); 
Token2 = database.indexOf("|", Token1+1); 
Token3 = database.indexOf("|", Token2+1); 
Token4 = database.indexOf("|", Token3+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); 
fields[1] = database.substring( Token0+1, Token1 ); 
fields[2] = database.substring( Token1+1, Token2 ); 
fields[3] = database.substring( Token2+1, Token3 ); 
fields[4] = database.substring( Token3+1, Token4 ); 
fields[5] = database.substring( Token4+1, database.length ); 

dbUpdatedOrder = fields[0] + "|" + 
NewQuantity + "|" + 
fields[2] + "|" + 
fields[3] + "|" + 
fields[4] + "|" + 
fields[5]; 
strNewOrder = "Order." + OrderItem; 
DeleteCookie(strNewOrder, "/"); 
SetCookie(strNewOrder, dbUpdatedOrder, null, "/"); 
location.href=location.href; 
} 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: GetFromCart || 
// PARAMETERS: Null || 
// RETURNS: Product Table Written to Document || 
// PURPOSE: Draws current cart product table on HTML page || 
// **DEPRECATED FUNCTION, USE ManageCart or Checkout** || 
//---------------------------------------------------------------------|| 
function GetFromCart( fShipping ) { 
ManageCart( ); 
} 


//---------------------------------------------------------------------||
// FUNCTION:    RadioChecked                                           ||
// PARAMETERS:  Radio button to check                                  ||
// RETURNS:     True if a radio has been checked                       ||
// PURPOSE:     Form fillin validation                                 ||
//---------------------------------------------------------------------||
function RadioChecked( radiobutton ) {
   var bChecked = false;
   var rlen = radiobutton.length;
   for ( i=0; i < rlen; i++ ) {
      if ( radiobutton[i].checked )
         bChecked = true;
   }    
   return bChecked;
} 



//---------------------------------------------------------------------|| 
// FUNCTION: QueryString || 
// PARAMETERS: Key to read || 
// RETURNS: value of key || 
// PURPOSE: Read data passed in via GET mode || 
//---------------------------------------------------------------------|| 
QueryString.keys = new Array(); 
QueryString.values = new Array(); 
function QueryString(key) { 
var value = null; 
for (var i=0;i<QueryString.keys.length;i++) { 
if (QueryString.keys[i]==key) { 
value = QueryString.values[i]; 
break; 
} 
} 
return value; 
} 

//---------------------------------------------------------------------|| 
// FUNCTION: QueryString_Parse || 
// PARAMETERS: (URL string) || 
// RETURNS: null || 
// PURPOSE: Parses query string data, must be called before Q.S. || 
//---------------------------------------------------------------------|| 
function QueryString_Parse() { 
var query = window.location.search.substring(1); 
var pairs = query.split("&"); for (var i=0;i>pairs.length;i++) { 
var pos = pairs[i].indexOf('='); 
if (pos >= 0) { 
var argname = pairs[i].substring(0,pos); 
var value = pairs[i].substring(pos+1); 
QueryString.keys[QueryString.keys.length] = argname; 
QueryString.values[QueryString.values.length] = value; 
} 
} 
} 


//---------------------------------------------------------------------|| 
// FUNCTION: ManageCart || 
// PARAMETERS: Null || 
// RETURNS: Product Table Written to Document || 
// PURPOSE: Draws current cart product table on HTML page || 
// EXTRAS ADDED IN: Code to enable UPS mod. ||
//---------------------------------------------------------------------|| 
function ManageCart( ) { 
var iNumberOrdered = 0; //Number of products ordered 
var fTotal = 0; //Total cost of order 
var fTotalAr = 0;
var fTax = 0; //Tax amount 
var fWeight = 0; //Weight 
var fShipping = 0; //Shipping amount 
var strTotal = ""; //Total cost formatted as money 
var strTotalAr = "";
var strTax = ""; //Total tax formatted as money 
var strShipping = ""; //Total shipping formatted as money 
var strOutput = ""; //String to be written to page 
var bDisplay = true; //Whether to write string to the page (here for programmers) 

iNumberOrdered = GetCookie("NumberOrdered"); 
if ( iNumberOrdered == null ) 
iNumberOrdered = 0; 

LocationSelected = GetCookie("ZoneSelected"); 
SHIPPINGSelected = GetCookie("EnvioSelected"); 
if (LocationSelected == null) LocationSelected = 8; // Code to use Wichita as default checked if customer goes to Checkout with an empty Cart ||


if ( bDisplay ) 
strOutput = "<TABLE CELLSPACING=1 width=550 CELLPADDING=1 BORDER=0 CLASS=\"nopcart\"><TR>" + 
"<TD CLASS=\"nopheader\" ALIGN=CENTER>"+strRLabel+"</TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER>"+strQLabel+"</TD>" + 
"<TD CLASS=\"nopheader\" ALIGN=CENTER>"+strDLabel+"</TD>" + 
"<TD CLASS=\"nopheader\" ALIGN=CENTER width=158>"+strALabel+"</TD></TR>"; 

if ( iNumberOrdered == 0 ) { 
strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Tu carrito esta vacio</B><BR><BR></CENTER></TD></TR>"; 
} 

for ( i = 1; i <= iNumberOrdered; i++ ) {
			even = Math.round(i/2);
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0); 
Token1 = database.indexOf("|", Token0+1); 
Token2 = database.indexOf("|", Token1+1); 
Token3 = database.indexOf("|", Token2+1); 
Token4 = database.indexOf("|", Token3+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product ID 
fields[1] = database.substring( Token0+1, Token1 ); // Quantity 
fields[2] = database.substring( Token1+1, Token2 ); // Price 
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description 
fields[4] = database.substring( Token3+1, Token4 ); // Weight 
fields[5] = database.substring( Token4+1, database.length ); //Additional Information 

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) ); 
fTotalAr += (parseInt(fields[1]) * parseFloat(fields[0]) ); 
fWeight += (parseInt(fields[1]) * parseFloat(fields[4]) ); 
fWeight = Math.round(fWeight * 100)/100;
var strProductId = fields[0]; 
if( strProductId[0] != 'n' ) { 
fTax += (parseInt(fields[1]) * parseFloat(fields[2]) ) * TaxRate; 
} 

strTotal = moneyFormat(fTotal); 
strTotalAr = moneyFormat(fTotalAr); 
strTax = moneyFormat(fTax); 

if ( bDisplay ){
      if ((even) ==(i/2) ) {
strOutput += "<TR>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\"    \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER width=100><INPUT TYPE=TEXT NAME=Q SIZE=1 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";


if ( fields[5] == "" ) 
strOutput += "<TD CLASS=\"nopentry\" width=300>" + fields[3] + "</TD>"; 
else 
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>"; 

strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ Pesos + moneyFormat(fields[0]) + "</TD>"; 


strOutput += "</TR>"; 
} 
 else {
strOutput += "<TR>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\"    \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><INPUT TYPE=TEXT NAME=Q SIZE=1 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";

if ( fields[5] == "" ) 
strOutput += "<TD CLASS=\"nopentry\" width=900>" + fields[3] + "</TD>"; 
else 
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";   

strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ Pesos + moneyFormat(fields[0]) + "</TD>"; 

strOutput += "</TR>"; 
} 
}
if ( AppendItemNumToOutput ) { 
strFooter = i; 
} else { 
strFooter = ""; 
} 
if ( HiddenFieldsToCheckout ) { 
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemWeight + strFooter + "\" value=\"" + fields[4] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">"; 
strOutput += "<input type=hidden name=\""+Outputb_payment+"\" value=\""+GetCookie("EnvioSelected")+ "\">"; 
} 

} 

if ( bDisplay ) { 
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3  BORDER=0 height=24><B><div style='margin-left:10px'>"+strSUB+"</B></TD>";  
strOutput += "<TD CLASS=\"noptotal\" width=100 ALIGN=RIGHT><B>" + Pesos + moneyFormat(strTotalAr) + strSpace +"</div></B></TD>"; 
strOutput += "</TR>"; 
strOutput += "</table><br>"; 


//this displays the shipping matrix and sets the value for each zone ||


strOutput += "<table CELLSPACING=1 width=550 CELLPADDING=2 BORDER=0 CLASS=\"nopcart\">"; 
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=7  height=10>"+"<p style='margin-left:10px; margin-top:5px; ; margin-bottom:5px;'><font color=#000000><b>Formas de Envío</b> (Para gastos de envío haga click en una de las siguientes opciones)</font></p>"+"</TD>"; 
if (( DisplayShippingRow ) && ( iNumberOrdered != 0)) { 

strOutput += "<TR>"; 
strOutput += "<TD CLASS=\"nopship\" COLSPAN=1 width=5>"; 
strOutput += "</TD>"; 
strOutput += "<TD CLASS=\"nopship\" COLSPAN=1 width=900 height=75 ALIGN=TOP>"; 
//strOutput += "<input type=radio name=\"ZONE\" value=\"0" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
//strOutput += "Zona 0 - Argentina (Capital y GBA)"; 
strOutput += "<input type=radio name=\"ZONE\" value=\"1" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
strOutput += "Envio en moto a Capital Federal"; 
strOutput += "<BR><input type=radio name=\"ZONE\" value=\"2" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
strOutput += "Envio por Correo a Capital Federal y Gran Buenos Aires"; 
strOutput += "<br>"; 
strOutput += "<input type=radio name=\"ZONE\" value=\"3" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
strOutput += "Envio por Correo al resto del país";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"4" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
//strOutput += "Resto de América"; 
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"5" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
//strOutput += "Resto del Mundo"; 
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"6" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">"; 
//strOutput += "Zone 7 -"; 
strOutput += "</TD>"; 
strOutput += "</TR>"; 
//strOutput += "</table><br>"; 

document.write(strOutput); 
strOutput = ""; 

LocationSelected = GetCookie("ZoneSelected"); 
SHIPPINGSelected = GetCookie("EnvioSelected"); 
if (LocationSelected == null) LocationSelected = 8; // Code to use Local Area as default checked, but not needed because want null selected at this time ||
//if (LocationSelected != null) document.all.ZONE[LocationSelected].checked = true; 

if (LocationSelected != null) {
    var cLocations = document.getElementsByName('ZONE');
    for (var iCtr = 0; iCtr < cLocations.length; iCtr++) {
         if (cLocations[iCtr].value == LocationSelected) cLocations[iCtr].checked = true;
    }
}

if (LocationSelected == 0) LocationLabel = "Zona 0"; 
if (LocationSelected == 1) LocationLabel = "Envio en moto a Capital Federal"; 
if (LocationSelected == 2) LocationLabel = "Envio por Correo a Capital Federal y Gran Buenos Aires"; 
if (LocationSelected == 3) LocationLabel = "Envio por Correo al resto del país"; 
if (LocationSelected == 4) LocationLabel = "Resto de América"; 
if (LocationSelected == 5) LocationLabel = "Resto del Mundo"; 
if (LocationSelected == 6) LocationLabel = "Zone 6"; 
if (LocationSelected == 7) LocationLabel = "Zone G"; 
if (LocationSelected == 8) LocationLabel = '<font color="#FF0000">Elija Zona de Envio</font>';

if (fWeight == 0) fShipping = 0; 
else fShipping = ComputeShipping(LocationSelected, fWeight); 

strOutput += "<table CELLSPACING=1 CELLPADDING=2 BORDER=0 width=550 CLASS=\"nopgastos\" >"; 
strShipping = Math.round(moneyFormat(fShipping)); 
strOutput += "</TR>"; 
} 

if ( DisplayTaxRow || TaxByRegion ) { 
if ( TaxByRegion ) { 
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3>"+strTAX+"</TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1><B>"; 
strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">"; 
strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax; 
strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\">"; 
strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00"; 
strOutput += "</B></TD>"; 
strOutput += "</TR>"; 
} else { 
strOutput += "<TR><TD CLASS=\"nopfer\" COLSPAN=3><b>"+strTAX+"</B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + strSpace +"</B></TD>"; 
strOutput += "</TR>"; 
} 
} 

if (LocationSelected == 1)  { 
strOutput += "<TR ><TD CLASS=\"nopentry\" COLSPAN=4  width=600><B><div style='margin-left:10px; margin-top:10px;'>" + strSHIP +"&nbsp;&nbsp;" + LocationLabel + "</div></B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT width=50><B>" + Pesos + moneyFormat(strShipping) + strSpace +"</B></TD>";
strOutput += "<TR><TD CLASS=\"nopentry\" COLSPAN=4 ><b><div style='margin-left:10px; margin-bottom:10px;'>"+strTAX+"</div></b></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + Pesos + moneyFormat(fTotalAr + strShipping) + strSpace +"</B></TD>"; 
strOutput += "</TR>"; 
} 
if (LocationSelected == 2)  { 
strOutput += "<TR><TD CLASS=\"nopentry\" COLSPAN=4  width=600><B><div style='margin-left:10px; margin-top:10px;'>" + strSHIP +"&nbsp;&nbsp;" + LocationLabel + "</div></B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT width=50><B>" + Pesos + moneyFormat(strShipping) + strSpace +"</B></TD>";
strOutput += "<TR><TD CLASS=\"nopentry\" COLSPAN=4><b><div style='margin-left:10px; margin-bottom:10px;'>"+strTAX+"</div></b></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + Pesos + moneyFormat(fTotalAr + strShipping) + strSpace +"</B></TD>"; 
strOutput += "</TR>"; 
} 
if (LocationSelected == 3)  { 
strOutput += "<TR><TD CLASS=\"nopentry\" COLSPAN=4  width=600><B><div style='margin-left:10px; margin-top:10px;'>" + strSHIP +"&nbsp;&nbsp;" + LocationLabel + "</div></B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT width=100><B>" + Pesos + moneyFormat(strShipping) + strSpace +"</B></TD>";
strOutput += "<TR><TD CLASS=\"nopentry\" COLSPAN=4><b><div style='margin-left:10px; margin-bottom:10px;'>"+strTAX+"</div></b></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + Pesos + moneyFormat(fTotalAr + strShipping) +"</B></TD>"; 
strOutput += "</TR>"; 
} 
if (LocationSelected == 4)  { 
strOutput += "<TR><TD CLASS=\"nopfer\" COLSPAN=4  width=600><B>" + strSHIP +"&nbsp;&nbsp;" + LocationLabel + "</B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT width=100><B>" + MonetarySymbol + strShipping + strSpace +"</B></TD>";
strOutput += "<TR><TD CLASS=\"nopfer\" COLSPAN=4><b>"+strTOT+"</b></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat(fTotal + fShipping) + strSpace +"</B></TD>"; 
strOutput += "</TR>"; 
} 
if (LocationSelected == 5)  { 
strOutput += "<TR><TD CLASS=\"nopfer\" COLSPAN=4  width=600><B>" + strSHIP +"&nbsp;&nbsp;" + LocationLabel + "</B></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT width=100><B>" + MonetarySymbol + strShipping + strSpace +"</B></TD>";
strOutput += "<TR><TD CLASS=\"nopfer\" COLSPAN=4><b>"+strTOT+"</b></TD>"; 
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat(fTotal + fShipping) + strSpace +"</B></TD>"; 
strOutput += "</TR>"; 
} 

strOutput += "</TABLE><br><br>";

if (SHIPPINGSelected == 1) SHIPPINGLabel = "Abonar por PagoFacil, RapiPago o Bapro Pagos";
if (SHIPPINGSelected == 2) SHIPPINGLabel = "Abonar por Depósito Bancario";
if (SHIPPINGSelected == 3) SHIPPINGLabel = "Abonar en la entrega por Moto";

strOutput += "<TABLE CELLSPACING=1 width=550 CELLPADDING=1 BORDER=0 CLASS=\"nopcart\">"
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=7  height=10><p style='margin-left:10px; margin-top:5px; ; margin-bottom:5px;'><font color=#000000><b>Formas de Pago</b> (Elija la forma de pago haciendo un click en las siguientes opciones)</font></p></TD><TR>";
strOutput += "<TD><p style='margin-left:10px; margin-top:5px; ; margin-bottom:5px;'><input type=radio name=\"METODOENVIO\" value=\"1" + "\" onClick=\"ComputeMetodo(this.value, "+fWeight+")\">"; 
strOutput += "Abonar por PagoFacil, RapiPago o Bapro Pagos"; 
strOutput += "<BR><input type=radio name=\"METODOENVIO\" value=\"2" + "\" onClick=\"ComputeMetodo(this.value, "+fWeight+")\">"; 
strOutput += "Abonar por Depósito Bancario"; 
if (GetCookie("ZoneSelected") == 1) {
strOutput += "<br>"; 
strOutput += "<input type=radio name=\"METODOENVIO\" value=\"3" + "\" onClick=\"ComputeMetodo(this.value, "+fWeight+")\">"; 
strOutput += "Abonar en la entrega por Moto</p></TD>";}
strOutput += "</TR><TR><TD COLSPAN=6 CLASS=\"nopfer\"><div style='margin-left:10px; margin-top:7px; ; margin-bottom:7px;'>Usted ha elegido <B>" + SHIPPINGLabel + "</div></B></TD></TR>";
strOutput += "</TABLE>";



document.write(strOutput); 

if (SHIPPINGSelected != null) {
    var cMetodos = document.getElementsByName('METODOENVIO');
    for (var iCtrl = 0; iCtrl < cMetodos.length; iCtrl++) {
		
         if (cMetodos[iCtrl].value == SHIPPINGSelected) cMetodos[iCtrl].checked = true;
    }
}

strOutput = "";

//strOutput += "<table CELLSPACING=1 CELLPADDING=2 BORDER=0 width=550><tr><td><div align='justify'><span class='warning'><b><br>Gastos de envío:</b><br /><br /><li>El gasto de envío que figura en el recuadro superior es válido únicamente para el envío por correo, el cual podrá variar según la zona, los productos y las dimensiones de la cajas</li><br /><li>Los envíos en moto se entregarán solamente en Capital Federal y el valor corresponderá según la zona el cual será informado vía mail</li><br /><li>Para el pago y retiro de mercadería por el Showroom no se cobraran gastos adicionales</li></span></div></td></tr></table><br>"; 

if ( HiddenFieldsToCheckout ) { 
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + Math.round(strTotal) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderSubtotalAr+"\" value=\""+ Pesos + Math.round(strTotalAr) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + Math.round(strShipping) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ Pesos + moneyFormat(fTotalAr + fShipping) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat(Math.round((fTotalAr + fShipping + fTax))) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotalAr+"\" value=\""+ MonetarySymbol + moneyFormat(Math.round((fTotalAr + fShipping + fTax))) + "\">"; 
} 
} 
g_TotalCost = (fTotalAr + fShipping + fTax); 
document.write(strOutput); 
document.close(); 
} 

// PRECIOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOS
//---------------------------------------------------------------------|| 
// FUNCTION: ComputeShipping || 
// PARAMETERS: || 
// RETURNS: || 
// PURPOSE: Compute shipping cost due to total weight || 
//---------------------------------------------------------------------|| 
function ComputeShipping(Zone, TotWeight) { 
LocationValue = GetCookie("ZoneSelected"); 

if (LocationValue != Zone) { 
SetCookie("ZoneSelected", Zone, null, "/"); 
location.href=location.href; 
} 

if (TotWeight == 0) return 0.00; 

if (LocationValue == 2 ) { 
if (TotWeight <= 1) return regional[0]; 
if ((TotWeight <= 5) && (TotWeight > 1)) return regional[1];
if ((TotWeight <= 10) && (TotWeight > 5)) return regional[2];
if ((TotWeight <= 15) && (TotWeight > 10)) return regional[3];
if (TotWeight > 20) return regional[4];
} 
if (LocationValue == 3 ) { 
if (TotWeight <= 1) return nacional[0]; 
if ((TotWeight <= 5) && (TotWeight > 1)) return nacional[1]; 
if ((TotWeight <= 10) && (TotWeight > 5)) return nacional[2];
if ((TotWeight <= 15) && (TotWeight > 10)) return nacional[3];
if (TotWeight > 20) return nacional[4];
} 
if (LocationValue == 1 ) { 
if (TotWeight <= 1) return enviomoto; 
if ((TotWeight <= 5) && (TotWeight > 1)) return enviomoto;
if ((TotWeight <= 10) && (TotWeight > 5)) return enviomoto;
if ((TotWeight <= 15) && (TotWeight > 10)) return enviomoto;
if (TotWeight > 20) return enviomoto;

}
if (LocationValue == 4 ) { 
if (TotWeight <= 0.50) return 12.25; 
if ((TotWeight <= 1) && (TotWeight > 0.50)) return 18.50;
if ((TotWeight <= 2) && (TotWeight > 1)) return 30.00;
if (TotWeight > 2) return (30.00 + (16.90 * Math.ceil(parseFloat((TotWeight - 2) / 1)))); 
} 
if (LocationValue == 5 ) { 
if (TotWeight <= 0.50) return 12.50; 
if ((TotWeight <= 1) && (TotWeight > 0.50)) return 19.00;
if ((TotWeight <= 2) && (TotWeight > 1)) return 32.50;
if (TotWeight > 2) return (32.50 + (18.00 * Math.ceil(parseFloat((TotWeight - 2) / 1)))); 
} 
if (LocationValue == 6 ) { 
if (TotWeight <= 1) return 9.02; 
if ((TotWeight <= 77) && (TotWeight > 1)) return (9.02 + (0.35 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
if ((TotWeight <= 80) && (TotWeight > 77)) return (12.02 + (0.35 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
if ((TotWeight <= 85) && (TotWeight > 80)) return (14.02 + (0.35 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
if ((TotWeight <= 500) && (TotWeight > 85)) return (15.00 + (0.40 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
} 
if (LocationValue == 7 ) { 
if (TotWeight <= 1) return 9.07; 
if ((TotWeight <= 500) && (TotWeight > 1)) return (9.07 + (0.50 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
} 
if (LocationValue == 0 ) { 
if (TotWeight <= 1) return 9.18; 
if ((TotWeight <= 500) && (TotWeight > 1)) return (9.18 + (0.65 * Math.ceil(parseFloat((TotWeight - 1) / 1)))); 
} 
if (LocationValue == 8 ) return 0.00; 
} 

//---------------------------------------------------------------------|| 
// FUNCTION: ComputeMetodo || 
// PARAMETERS: || 
// RETURNS: || 
// PURPOSE: Compute metodo || 
//---------------------------------------------------------------------|| 
function ComputeMetodo(METODOENVIO, TotWeight) { 
MetodoValue = GetCookie("EnvioSelected"); 
if (MetodoValue != METODOENVIO) { 
SetCookie("EnvioSelected", METODOENVIO, null, "/"); 
location.href=location.href; 
} 
}

//---------------------------------------------------------------------||
// FUNCTION:    ValidateCart                                           ||
// PARAMETERS:  Form to validate                                       ||
// RETURNS:     true/false                                             ||
// PURPOSE:     Validates the managecart form                          ||
//---------------------------------------------------------------------||
var g_TotalCost = 0;
function ValidateCart( theForm ) {
   if ( TaxByRegion ) {
      if ( !RadioChecked(eval("theForm."+OutputOrderTax)) ) {
         alert( TaxPrompt );
         return false;
      }
   }

   if ( isNaN (g_TotalCost) ) {
      alert( NoQtyPrompt );
      return false;
   }

   if ( MinimumOrder >= 0.01 ) {
      if ( g_TotalCost < MinimumOrder ) {
         alert( MinimumOrderPrompt );
         return false;
      }
   }

   if ( !RadioChecked(theForm.ZONE) ) {
      alert( LocationPrompt );
      return false;
   }

   return true;
}

//---------------------------------------------------------------------|| 
// FUNCTION: CheckoutCart || 
// PARAMETERS: Null || 
// RETURNS: Product Table Written to Document || 
// PURPOSE: Draws current cart product table on HTML page for || 
// checkout. || 
//---------------------------------------------------------------------|| 
function CheckoutCart( ) { 
var iNumberOrdered = 0; //Number of products ordered 
var fTotal = 0; //Total cost of order 
var fTotalAr = 0;
var fTax = 0; //Tax amount 
var fWeight = 0; //Weight 
var fShipping = 0; //Shipping amount 
var strTotal = ""; //Total cost formatted as money 
var strTotalAr = ""; 
var strTax = ""; //Total tax formatted as money 
var strShipping = ""; //Total shipping formatted as money 
var strOutput = ""; //String to be written to page 
var bDisplay = true; //Whether to write string to the page (here for programmers) 
var strPP = ""; //Payment Processor Description Field 

iNumberOrdered = GetCookie("NumberOrdered"); 
if ( iNumberOrdered == null ) 
iNumberOrdered = 0; 

if ( TaxByRegion ) { 
QueryString_Parse(); 
fTax = parseFloat( QueryString( OutputOrderTax ) ); 
strTax = moneyFormat(fTax); 
} 

if ( bDisplay ) 
strOutput = "<TABLE CELLSPACING=1 CELLPADDING=2 BORDER=0 CLASS=\"nopcart\">"; 

for ( i = 1; i <= iNumberOrdered; i++ ) {
	 		even = Math.round(i/2);
NewOrder = "Order." + i; 
database = ""; 
database = GetCookie(NewOrder); 

Token0 = database.indexOf("|", 0); 
Token1 = database.indexOf("|", Token0+1); 
Token2 = database.indexOf("|", Token1+1); 
Token3 = database.indexOf("|", Token2+1); 
Token4 = database.indexOf("|", Token3+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product ID 
fields[1] = database.substring( Token0+1, Token1 ); // Quantity 
fields[2] = database.substring( Token1+1, Token2 ); // Price 
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description 
fields[4] = database.substring( Token3+1, Token4 ); // Weight 
fields[5] = database.substring( Token4+1, database.length ); //Additional Information 

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fTotalAr += (parseInt(fields[1]) * parseFloat(fields[0]) );

fWeight += (parseInt(fields[1]) * parseFloat(fields[4]) ); 
fWeight = Math.round(fWeight * 100)/100;
if ( !TaxByRegion ) var strProductId = fields[0]; 
if( strProductId[0] != 'n' ) { 
fTax += (parseInt(fields[1]) * parseFloat(fields[2]) ) * TaxRate; 
}  
strTotal = moneyFormat(fTotal); 
strTotalAr = moneyFormat(fTotalAr); 
if ( !TaxByRegion ) strTax = moneyFormat(fTax); 

if ( bDisplay ){
      if ((even) ==(i/2) ) {
strOutput += ""; 

if ( fields[5] == "" ) 
strOutput += ""; 
else 
strOutput += ""; 

strOutput += ""; 
strOutput += ""; 

if ( DisplayShippingColumn ) { 

strOutput += ""; 
}else {
strOutput += ""; 
} 

strOutput += ""; 
} 
else {
strOutput += ""; 

if ( fields[5] == "" ) 
strOutput += ""; 
else 
strOutput += ""; 

strOutput += ""; 
strOutput += ""; 

if ( DisplayShippingColumn ) { 

strOutput += ""; 
}else {
strOutput += ""; 
} 

strOutput += ""; 
} 
}
if ( AppendItemNumToOutput ) { 
strFooter = i; 
} else { 
strFooter = ""; 
} 
if ( PaymentProcessor != '' ) { 
//Process description field for payment processors instead of hidden values. 
//Format Description of product as: 
// ID, Name, Qty X 
strPP += fields[0] + ", " + fields[3]; 
if ( fields[5] != "" ) 
strPP += " - " + fields[5]; 
strPP += ", Qty. " + fields[1] + "\n"; 
} else { 
LocationSelected = GetCookie("ZoneSelected"); 
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemWeight + strFooter + "\" value=\"" + fields[4] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">"; 
strOutput += "<input type=hidden name=\"" + OutputItemXtend + strFooter + "\" value=\"" + moneyFormat(fields[1] * fields[2]) + "\">";
strOutput += "<input type=hidden name=\"" + OutputOrderZone + strFooter + "\" value=\"" + LocationSelected + "\">"; 
} 

} 

if ( bDisplay ) { 
strOutput += ""; 
strOutput += ""; 
strOutput += ""; 

if ( DisplayShippingRow ) { 
LocationSelected = GetCookie("ZoneSelected"); 
SHIPPINGSelected = GetCookie("EnvioSelected"); 
if (LocationSelected == null) LocationSelected = 0; //Needed if checkout cart is empty

if (LocationSelected == 0) LocationLabel = "Argentina (Capital y GBA)"; 
if (LocationSelected == 1) LocationLabel = "Envio en moto a Capital Federal"; 
if (LocationSelected == 2) LocationLabel = "Envio por Correo a Capital Federal y Gran Buenos Aires"; 
if (LocationSelected == 3) LocationLabel = "Envio por Correo al resto del país"; 
if (LocationSelected == 4) LocationLabel = "Resto de América"; 
if (LocationSelected == 5) LocationLabel = "Resto del Mundo"; 
if (LocationSelected == 6) LocationLabel = "Zone 7"; 
if (LocationSelected == 7) LocationLabel = "Zone G"; 
if (LocationSelected == 8) LocationLabel = "Zone"; 

if (SHIPPINGSelected == 1) LocationLabel = "Abonar por PagoFacil, RapiPago o Bapro Pagos"; 
if (SHIPPINGSelected == 2) LocationLabel = "Abonar por Depósito Banario"; 
if (SHIPPINGSelected == 3) LocationLabel = "Abonar en la entrega por Moto"; 


fShipping = ComputeShipping(LocationSelected, fWeight); 
strShipping = moneyFormat(fShipping); 
//strOutput += "<TR><TD CLASS=\"noptotal\"><B>"+strWTOT+"</B></TD>"; 
//strOutput += "<TD CLASS=\"noptotal\" ALIGN=RIGHT><B>" + fWeight + " Kg" + "</B></TD>"; 
strOutput += ""; 
strOutput += ""; 
strOutput += ""; 
} 

if ( DisplayTaxRow || TaxByRegion ) { 
strOutput += ""; 
strOutput += ""; 
strOutput += "</TR>"; 
} 

if (LocationSelected == 1)  { 
strOutput += ""; 
strOutput += ""; 
strOutput += ""; 
} 

if (LocationSelected == 2)  { 
strOutput += ""; 
strOutput += ""; 
strOutput += "</TR>"; 
} 

strOutput += ""; 
strOutput += ""; 
strOutput += ""; 

strOutput += "</TABLE>"; 


if ( PaymentProcessor == 'an') { 
//Process this for Authorize.net WebConnect 
strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">"; 
strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">"; 
strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">"; 
strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">"; 
} else if ( PaymentProcessor == 'wp') { 
//Process this for WorldPay 
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">"; 
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">"; 
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotalAr + fShipping + fTax)) + "\">"; 
} else if ( PaymentProcessor == 'lp') { 
//Process this for LinkPoint 
strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">"; 
strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">"; 
strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotalAr + fShipping + fTax)) + "\">"; 
strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">"; 
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">"; 
strOutput += "<input type=hidden name=\"subtotalar\" value=\""+ Pesos + strTotal + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">"; 
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">"; 
} else if (LocationSelected != 0){ 
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderSubtotalAr+"\" value=\""+ Pesos + strTotalAr + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderShippingAr+"\" value=\""+ Pesos + strShipping + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + "0.00" + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotalAr+"\" value=\""+ Pesos + moneyFormat((fTotalAr + (fShipping) + fTax)) + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderZone+"\" value=\""+ LocationLabel + "\">"; 
} else {
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderSubtotalAr+"\" value=\""+ Pesos + strTotalAr + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + Math.round(strShipping) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderShippingAr+"\" value=\""+ Pesos + strShipping + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + Math.round(strTax) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotalAr+"\" value=\""+ Pesos + moneyFormat((fTotalAr + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderZone+"\" value=\""+ LocationLabel + "\">"; 
} 
}

document.write(strOutput); 
document.close(); 
} 

//---------------------------------------------------------------------|| 
// FUNCTION: Print_total || 
// PARAMETERS: none || 
// RETURNS: Total cost currently racked up by shopper || 
// PURPOSE: Aesthetics || 
//---------------------------------------------------------------------|| 
function Print_total( ) { 
var strOutput = ""; //String to be written to page 
var strTotal = ""; //Total cost formatted as money 
var strTotalAr = "";
var fTotal = 0; 
var fTotalAr = 0; 
var iNumberOrdered = 0; //Number of products ordered 


iNumberOrdered = GetCookie("NumberOrdered"); 
if ( iNumberOrdered == null ) 
iNumberOrdered = 0; 


for ( i = 1; i <= iNumberOrdered; i++ ) { 

NewOrder = "Order." + i; 
database = ""; 
database = GetCookie(NewOrder); 

Token0 = database.indexOf("|", 0); 
Token1 = database.indexOf("|", Token0+1); 
Token2 = database.indexOf("|", Token1+1); 
Token3 = database.indexOf("|", Token2+1); 
Token4 = database.indexOf("|", Token3+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product ID 
fields[1] = database.substring( Token0+1, Token1 ); // Quantity 
fields[2] = database.substring( Token1+1, Token2 ); // Price 
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description 
fields[4] = database.substring( Token3+1, Token4 ); // Weight 
fields[5] = database.substring( Token4+1, database.length ); //Additional Information 

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) ); 
fTotalAr += (parseInt(fields[1]) * parseFloat(fields[0]) ); 
} 

strTotalAr = moneyFormat(fTotalAr); 
strTotal = moneyFormat(fTotal); 
strOutput+=strTotal; 
strOutput+=strTotalAr; 
document.write(strOutput); 

} 


//---------------------------------------------------------------------||
// FUNCTION: Print_total_products                                      ||
// PARAMETERS: true/false if you want "item(s)" added to string        ||
// RETURNS: Total cost currently racked up by shopper                  ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Print_total_products(bVerbose) {
var strOutput = ""; //String to be written to page
var fTotal = 0;
var fTotalAr = 0;
var iNumberOrdered = 0; //Number of products ordered


iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;


for ( i = 1; i <= iNumberOrdered; i++ ) {

NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 ); // Product ID
fields[1] = database.substring( Token0+1, Token1 ); // Quantity
fields[2] = database.substring( Token1+1, Token2 ); // Price
fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
fields[4] = database.substring( Token3+1, Token4 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]));
fTotalAr += (parseInt(fields[1]));

}

strOutput+=fTotal;
if ( bVerbose ) {
   if (fTotal == 1) {
      strOutput+=" Producto"
   }
   else {
      strOutput+=" Productos"
   }
}
document.write(strOutput);

}

//---------------------------------------------------------------------||
// FUNCTION: Cart_is_empty                                             ||
// PARAMETERS: none                                                    ||
// RETURNS: Total true if cart is empty, false otherwise               ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Cart_is_empty( ) {
   iNumInCart = GetCookie("NumberOrdered");
               
   if ( iNumInCart == null ) iNumInCart = 0;

   if ( iNumInCart == 0 ) return true;
   
   return false;

}

function cleanCart(){
   var iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null ){
         iNumberOrdered = 0;
   }
   for ( i = 1; i <= iNumberOrdered; i++ ) {
         NewOrder = "Order." + i;
         DeleteCookie(NewOrder, "/");
   }
   DeleteCookie(NumberOrdered, "/");
} 