//=====================================================================||
//               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                                     ||
//=====================================================================||

//---------------------------------------------------------------------||
//                       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="nopcart.js">... line.          ||
//  For example: <SCRIPT SRC="language-en.js">                         ||
//                                                                     ||
// 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        = 'RM';
DisplayNotice         = true;
DisplayShippingColumn = false;
DisplayShippingRow    = false;
DisplayTaxRow         = false;
TaxRate               = 0.07;
TaxByRegion           = false;
TaxPrompt             = 'For tax purposes, please select if you are an Arizona resident before continuing';
TaxablePrompt         = 'Arizona Residents';
NonTaxablePrompt      = 'Other States';
MinimumOrder          = 0.00;
MinimumOrderPrompt    = 'Your order is below our minimum order, please order more before checking out.';

//Payment Processor Options:
PaymentProcessor      = '';

//Options for Programmers:
OutputItemId          = 'ID_';
OutputItemQuantity    = 'QUANTITY_';
OutputItemPrice       = 'PRICE_';
OutputItemName        = 'NAME_';
OutputItemShipping    = 'SHIPPING_';
OutputItemAddtlInfo   = 'ADDTLINFO_';
OutputOrderSubtotal   = 'SUBTOTAL';
OutputOrderShipping   = 'SHIPPING';
OutputOrderTax        = 'TAX';
OutputOrderTotal      = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = false;


//=====================================================================||
//---------------------------------------------------------------------||
//    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 = "Quantity";
   strPLabel = "Price";
   strP2Label = "Subtotal";
   strSLabel = "Shipping";
   strRLabel = "Remove From Cart";
   strRButton= "Remove";
   strSUB    = "SUBTOTAL";
   strSHIP   = "SHIPPING";
   strTAX    = "TAX";
   strTOT    = "TOTAL";
   strErrQty = "Invalid Quantity.";
   strNewQty = 'Please enter new quantity:';
   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             ||
//---------------------------------------------------------------------||
function AddToCart(thisForm) {
   var iNumberOrdered = 0;
   var bAlreadyInCart = false;
   var notice = "";
   iNumberOrdered = GetCookie("NumberOrdered");

   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( thisForm.ID_NUM == null )
      strID_NUM    = "";
   else
      strID_NUM    = thisForm.ID_NUM.value;

   if ( thisForm.QUANTITY == null )
      strQUANTITY  = "1";
   else
      strQUANTITY  = thisForm.QUANTITY.value;

   if ( thisForm.PRICE == null )
      strPRICE     = "0.00";
   else
      strPRICE     = thisForm.PRICE.value;
	  
   if ( thisForm.NAME == null )
      strNAME      = "";
   else
      strNAME      = thisForm.NAME.value;

   if ( thisForm.SHIPPING == null )
      strSHIPPING  = "0.00";
   else
      strSHIPPING  = thisForm.SHIPPING.value;
	  
   if ( thisForm.ADDITIONALINFO == null ) {
      strADDTLINFO = "";
   } else {
      strADDTLINFO = thisForm.ADDITIONALINFO.value;
   }
   if ( thisForm.ADDITIONALINFO2 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO2.value;
   }
   if ( thisForm.ADDITIONALINFO3 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO3.value;
   }
   if ( thisForm.ADDITIONALINFO4 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO4.value;
   }
      if ( thisForm.DISCOUNT == null )
      strDISCOUNT  = "0.00";
   else
      strDISCOUNT  = thisForm.SHIPPING.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] == strID_NUM &&
           fields[2] == strPRICE  &&
           fields[3] == strNAME   &&
           fields[5] == strADDTLINFO
         ) {
         bAlreadyInCart = true;
         dbUpdatedOrder = strID_NUM    + "|" +
                          (parseInt(strQUANTITY)+parseInt(fields[1]))  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;
         strNewOrder = "Order." + i;
         DeleteCookie(strNewOrder, "/");
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
         notice = strQUANTITY + " " + strNAME + strAdded;
         break;
      }
   }


   if ( !bAlreadyInCart ) {
      iNumberOrdered++;

      if ( iNumberOrdered > 12 )
         alert( strSorry );
      else {
         dbUpdatedOrder = strID_NUM    + "|" + 
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;

         strNewOrder = "Order." + iNumberOrdered;
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
         SetCookie("NumberOrdered", iNumberOrdered, null, "/");
         notice = strQUANTITY + " " + strNAME + strAdded;
      }
   }

   if ( DisplayNotice )
      alert(notice);
}


//---------------------------------------------------------------------||
// 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          ||
//---------------------------------------------------------------------||
function ManageCart( ) {
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var minimum        = 0;    //Total cost of order
   var discount       = "";    //Total cost of order
   var afterless      = "";    //Total cost of order
   var fTax           = 0;    //Tax amount
   var fShipping      = 0;    //Shipping amount
   var strTotal       = "";   //Total cost formatted as money
   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;

   if ( bDisplay )
      strOutput = "<TABLE id=\"myTable\" CLASS=\"nopcart\" align=\"center\" border=\"1\" bordercolor=\"#471F1F\"><TR>" +
  //                "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
				  "<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strPRLabel+"</B></TD>" +
                  (DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
                  "<TD CLASS=\"nopheader\"><B>"+strRLabel+"</B></TD></TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your cart is empty</B><BR><BR></CENTER></TD></TR>";
   }

   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 );          // Shipping Cost
      fields[5] = database.substring( Token4+1, database.length ); //Additional Information
	
	  minimum    = (fields[1]) * (fields[4]) ;        // qty * packaging = total qty
	  
	  if (fields[2] == 0.20)
      	afterless   = 0.17;                // rm 0.10 * packaging
	  else if (fields[2] == 0.16)
	  	afterless   = 0.13;                // rm 0.10 * packaging
	  else if (fields[2] == 0.23)
      	afterless   = 0.20;                // rm 0.10 * packaging
	  else if (fields[2] == 0.28)
	  	afterless   = 0.25;                // rm 0.10 * packaging		
	  else{
		discount   = 0.1 * (fields[4]) ;           
		afterless  = fields[2]-moneyFormat(discount);   // price per packaging for more than 500 pcs
	  }


      if ( bDisplay ) {
      //   strOutput += "<TR><TD CLASS=\"nopentry\">"  + fields[0] + "</TD>";

         if ( fields[5] == "" )
            strOutput += "<TD CLASS=\"nopentry2\">"  + "&nbsp;" + fields[0] +  " "  +  fields[3] + "&nbsp;" + "</TD>";
         else
            strOutput += "<TD CLASS=\"nopentry2\">"  + "&nbsp;" + fields[0] +  " "  + fields[3] + "&nbsp;" + "<br><I>&nbsp;"+ fields[5] +  "</I></TD>";

if ( minimum >= 500 )
      {
	  fields[2] = afterless;
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + " " + moneyFormat(fields[2]) + "&nbsp;" + "</TD>";
	  strOutput += "<TD CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=1 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + " " + moneyFormat(fields[2]*fields[1]) + "&nbsp;" + "</TD>";
				}
      else {		
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + " " +  moneyFormat(fields[2]) + "&nbsp;" + "</TD>";
  	  strOutput += "<TD CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=1 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + " " + moneyFormat(fields[2]*fields[1]) + "&nbsp;" + "</TD>";
      }
	  
      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
      fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
      fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      strTax      = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);	  
	  
         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
         }

         strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></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=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
      }

   }



  if ( bDisplay ) {
  //    strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
  //    strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTotal + "</B></TD>";
  //    strOutput += "</TR>";

      if ( DisplayShippingRow ) {
	  strOutput += "<tr><th>"+strTOT+"</th>";
      strOutput += "<td></td><td></td><td align=\"center\"><b>" + MonetarySymbol + moneyFormat(strTotal) + "</b></td>";
      strOutput += "</tr>";		 
      }

      if ( DisplayTaxRow || TaxByRegion ) {
         if ( TaxByRegion ) {
            strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
            strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><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=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
            strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTax + "</B></TD>";
            strOutput += "</TR>";
         }
      }

      if ( !TaxByRegion ) {
         strOutput += "<TR><TD align=\"center\"><B>"+strTOT+"</B></TD><td></td><td></td><td></td>";
         strOutput += "<TD><B>" + MonetarySymbol + "&nbsp;" + moneyFormat(fTotal) + "</B></TD>";
         strOutput += "</TR>";
      }


      strOutput += "</TABLE>";
	  strOutput += "<center><strong><br>** Shipping charges will be added to your invoice after you have submitted this order form.<br>** Please click the 'Checkout' button when you have placed all items that you want to order in the Shopping Cart.</strong></center>";
	  
	  if ( iNumberOrdered == 0 ) 
      		strOutput += "<CENTER><BR></CENTER>";
	  else
			strOutput += "<CENTER><BR><INPUT TYPE=IMAGE SRC=\"images/btn-checkout.png\" align=\"middle\" BORDER=0></CENTER>";
			
      if ( HiddenFieldsToCheckout ) {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
      }
   }
   g_TotalCost = (fTotal + fTax);

   document.write(strOutput);
   document.close();
}

//---------------------------------------------------------------------||
// 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 ( MinimumOrder >= 0.01 ) {
      if ( g_TotalCost < MinimumOrder ) {
         alert( MinimumOrderPrompt );
         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 fTax           = 0;    //Tax amount
   var minimum         = 0;    //Total cost of order
   var discount         = "";    //Total cost of order
   var afterless         = "";    //Total cost of order
   var fShipping      = 0;    //Shipping amount
   var strTotal       = "";   //Total cost formatted as money
   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 id=\"myTable\" CLASS=\"nopcart\" align=\"center\" border=\"1\" bordercolor=\"#471F1F\"><TR>" +
  //                "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
				  "<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strPRLabel+"</B></TD>" +
                  (DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
                  "</TR>";

   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 );          // Shipping Cost
      fields[5] = database.substring( Token4+1, database.length ); //Additional Information


	  minimum    = (fields[1]) * (fields[4]) ;

	  if (fields[2] == 0.20)
      	afterless   = 0.17;                // rm 0.10 * packaging
	  else if (fields[2] == 0.16)
	  	afterless   = 0.13;                // rm 0.10 * packaging
	  else if (fields[2] == 0.23)
      	afterless   = 0.20;                // rm 0.10 * packaging
	  else if (fields[2] == 0.28)
	  	afterless   = 0.25;                // rm 0.10 * packaging				
	  else{
		discount   = 0.1 * (fields[4]) ;           
		afterless  = fields[2]-moneyFormat(discount);   // price per packaging for more than 500 pcs
	  }


       if ( bDisplay ) {
       //  strOutput += "<tr><th></th><td>"  + fields[0] + "</td>";

         if ( fields[5] == "" )
            strOutput += "<TD CLASS=\"nopentry2\">"  + "&nbsp;" + fields[0] +  " "  +  fields[3] + "&nbsp;" + "</TD>";
         else
            strOutput += "<TD CLASS=\"nopentry2\">"  + "&nbsp;" + fields[0] +  " "  + fields[3] + "&nbsp;" + "<br><I>&nbsp;"+ fields[5] +  "</I></TD>";

 if ( minimum >= 500 )
      {
	  fields[2] = afterless;
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" +  moneyFormat(fields[2]) + "&nbsp;" + "</TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + fields[1] + "&nbsp;" + "</TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + moneyFormat(fields[2]*fields[1]) + "&nbsp;" + "</TD>";
				}
      else {		
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + moneyFormat(fields[2]) + "&nbsp;" + "</TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + fields[1] + "&nbsp;" + "</TD>";
	  strOutput += "<TD CLASS=\"nopentry\">" + "&nbsp;" + moneyFormat(fields[2]*fields[1]) + "&nbsp;" + "</TD>";
      }

      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
      fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
      fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      strTax      = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
         }

         strOutput += "</TR>";
      }

      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 {
         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=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
      } 
   }


   if ( bDisplay ) {
   //   strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSUB+"</B></TD>";
   //   strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
   //   strOutput += "</TR>";

      if ( DisplayShippingRow ) {
         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+"</B></TD>";
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
         strOutput += "</TR>";
      }

      if ( DisplayTaxRow || TaxByRegion ) {
         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTAX+"</B></TD>";
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
         strOutput += "</TR>";
      }

	  strOutput += "<tr><td align=\"center\"><B>"+strTOT+"</B></td>";
      strOutput += "<td></td><td></td><td align=\"center\"><b>" + MonetarySymbol + moneyFormat(strTotal) + "</b></td>";
      strOutput += "</tr>";

      strOutput += "</tbody></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)) + "\">";
      } 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=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
      } else {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
      }
   }
g_TotalCost = (fTotal + fShipping + fTax);
   document.write(strOutput);
   document.close();
}

//=====================================================================||
//               END NOP Design SmartPost Shopping Cart                ||
//=====================================================================||

//---------------------------------------------------------------------||
// 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: Print_total                                               ||
// PARAMETERS: true/false if you want MonetarySymbol added to string   ||
// RETURNS: Total cost currently racked up by shopper                  ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Print_total(bSymbol) {
var strOutput = ""; //String to be written to page
var strTotal = ""; //Total cost formatted as money
var fTotal = 0;
var iNumberOrdered = 0; //Number of products ordered
var minimum         = 0;    //Total cost of order
var discount         = "";    //Total cost of order
var afterless         = "";    //Total cost of order

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

	   minimum    = (fields[1]) * (fields[4]) ;
	   
	  if (fields[2] == 0.20)
      	afterless   = 0.17;                // rm 0.10 * packaging
	  else if (fields[2] == 0.16)
	  	afterless   = 0.13;                // rm 0.10 * packaging
	  else if (fields[2] == 0.23)
      	afterless   = 0.20;                // rm 0.10 * packaging
	  else if (fields[2] == 0.28)
	  	afterless   = 0.25;                // rm 0.10 * packaging		
	  else{
		discount   = 0.1 * (fields[4]) ;           
		afterless  = fields[2]-moneyFormat(discount);   // price per packaging for more than 500 pcs
	  }

   
		 if ( minimum >= 500 )
			    fields[2] = afterless;

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
}
  
strTotal = moneyFormat(fTotal);
strOutput+=strTotal;

if ( bSymbol )
   strOutput = MonetarySymbol + "&nbsp;" + strOutput
document.write(strOutput);
}



// CHECK ORDERING FORM
function CheckForm( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: First Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: City\n";
	}
	if( theform.b_state.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: State\n";
	}
	if( theform.b_zip.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Zipcode\n";
	}
	if( theform.b_phone.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Phone\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Email\n";
	}
		if( theform.weddingdate.value == '' ){
		bMissingFields = true;
		strFields += "     Engagement/Wedding Date\n";
	}
		
	if( bMissingFields ) {
		alert( "I'm sorry, but you must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}


	
	return true;
}

   function computetyr() // for tq tag rectangle
   {
  var num1 = parseFloat(document.order.PRICE.value);

	if (document.order.QUANTITY.value < 500 && document.order.material.options[document.order.material.selectedIndex].value == 'Thank you tag')
	   document.order.PRICE.value = 0.18;
	   
	if (document.order.QUANTITY.value < 500 && document.order.material.options[document.order.material.selectedIndex].value == 'Sticker')
	   document.order.PRICE.value = 0.35;	   
	   
	if (document.order.QUANTITY.value > 499 && document.order.material.options[document.order.material.selectedIndex].value == 'Thank you tag')
	   document.order.PRICE.value = 0.23;
	   
	if (document.order.QUANTITY.value >499 && document.order.material.options[document.order.material.selectedIndex].value == 'Sticker')
	   document.order.PRICE.value = 0.35;	  

document.order.ADDITIONALINFO.value='<br>Material : ' + document.order.material.value + '<br>Text : ' + document.order.bride.value +'<br> Tag color/Font Color  : ' +document.order.color.value+ '/' +document.order.color2.value+'<br>Font type : '+document.order.font.value+'<br>With picture : '+document.order.picture.value+'<br>Hole Punch : '+document.order.punch.value;
}

   function computetyd()  // for tq tag diamond and square
   {
   var num1 = parseFloat(document.order.PRICE.value);

	if (document.order.QUANTITY.value < 500 && document.order.material.options[document.order.material.selectedIndex].value == 'Thank you tag')
	   document.order.PRICE.value = 0.25;
	   
	if (document.order.QUANTITY.value < 500 && document.order.material.options[document.order.material.selectedIndex].value == 'Sticker')
	   document.order.PRICE.value = 0.50;	   
	   
	if (document.order.QUANTITY.value > 499 && document.order.material.options[document.order.material.selectedIndex].value == 'Thank you tag')
	   document.order.PRICE.value = 0.30;
	   
	if (document.order.QUANTITY.value >499 && document.order.material.options[document.order.material.selectedIndex].value == 'Sticker')
	   document.order.PRICE.value = 0.50;	  

document.order.ADDITIONALINFO.value='<br>Material : ' + document.order.material.value + '<br>Text : ' + document.order.bride.value +'<br> Tag color/Font Color  : ' +document.order.color.value+ '/' +document.order.color2.value+'<br>Font type : '+document.order.font.value+'<br>With picture : '+document.order.picture.value+'<br>Hole Punch : '+document.order.punch.value;
}


   function compute3()  // for glue stick
   {
   var num1 = parseFloat(document.order.PRICE.value);
   var num2 = 15.00;

   if (document.order.Color.options[document.order.Color.selectedIndex].value == '1 kg')
		document.order.PRICE.value = num1 + num2;
}


   function compute4()  // for personalized paperbag
   {
   if (document.order.picture.options[document.order.picture.selectedIndex].value == '250')
		document.order.PRICE.value = '2.50';
   if (document.order.picture.options[document.order.picture.selectedIndex].value == '500')
		document.order.PRICE.value = '1.80';		
   if (document.order.picture.options[document.order.picture.selectedIndex].value == '1000')
		document.order.PRICE.value = '1.50';
		
	document.order.QUANTITY.value = document.order.picture.options[document.order.picture.selectedIndex].value;
}

   function compute5() // for paperbag fbx27
   {
   if (document.order.size.options[document.order.size.selectedIndex].value == 'Small'){
		document.order.PRICE.value = '11.20';
		document.order.NAME.value = 'Small paperbag (20 pcs/packet)'}
   if (document.order.size.options[document.order.size.selectedIndex].value == 'Medium'){
		document.order.PRICE.value = '9.20';
		document.order.NAME.value = 'Medium paperbag (10 pcs/packet)'}
   if (document.order.size.options[document.order.size.selectedIndex].value == 'Large'){
		document.order.PRICE.value = '19.00';
		document.order.NAME.value = 'Large paperbag (10 pcs/packet)'}
}

   function compute6() // for wedding card biii501-biii508
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes'){
		document.order.PRICE.value = '148.00';
		document.order.ADDITIONALINFO.value = 'With printing)'}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No'){
		document.order.PRICE.value = '48.00';
		document.order.ADDITIONALINFO.value = 'Without printing'}
}


   function compute7() // for wedding card biii601-biii604
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '148.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '48.00';
}


   function compute8() // for wedding card fancy envelope
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '200.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '140.00';
}

   function compute9() // for love tag
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Gold'){
		document.order.PRICE.value = '30.00';
		document.order.ADDITIONALINFO.value = 'Color : Gold';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Ivory Gold'){
		document.order.PRICE.value = '30.00';
		document.order.ADDITIONALINFO.value = 'Color : Ivory Gold';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Diamond White'){
		document.order.PRICE.value = '30.00';
		document.order.ADDITIONALINFO.value = 'Color : Diamond White';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yellow'){
		document.order.PRICE.value = '30.00';		
		document.order.ADDITIONALINFO.value = 'Color : Yellow';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Blue'){
		document.order.PRICE.value = '40.00';			
		document.order.ADDITIONALINFO.value = 'Color : Blue';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Lilac'){
		document.order.PRICE.value = '40.00';		
		document.order.ADDITIONALINFO.value = 'Color : Lilac';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Olive Green'){
		document.order.PRICE.value = '40.00';		
		document.order.ADDITIONALINFO.value = 'Color : Olive Green';}
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Pink'){
		document.order.PRICE.value = '40.00';				
		document.order.ADDITIONALINFO.value = 'Color : Pink';}
}


   function compute10() // for wedding card hard cover
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '260.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '210.00';
}


   function compute11() // for wedding card perfume envelope 46
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '135.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '60.00';
}

   function compute12() // for wedding card perfume envelope 48
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '145.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '80.00';
}

   function compute13() // for wedding card royal classic 46
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '160.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '100.00';
}


   function compute13() // for wedding card royal classic 48
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '175.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '120.00';
}


   function compute14() // for wedding card royal classic 69
   {
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Yes')
		document.order.PRICE.value = '215.00';
   if (document.order.Color.options[document.order.Color.selectedIndex].value == 'No')
		document.order.PRICE.value = '160.00';
}

   function computehbd() // bungadulang
   {

	document.order.ADDITIONALINFO.value='Color : ' + document.order.color.value;
		}

   function compute15() // FCF01  and  FCF02
   {
   var num1 = 75.00;
   var num2 = 0.00;
   var num3 = 0.00;


   if (document.order.sticker.value == 'No' ){
	   document.order.ADDITIONALINFO.value='Sticker\'s text : -<br>Organza cover color : '+document.order.picture.value;
		num3 = 0.00;}
	if (document.order.sticker.value == 'Yes' ){
		document.order.ADDITIONALINFO.value='Sticker\'s text : ' + document.order.bride.value + '<br>Font type : '+document.order.font.value+'<br>Organza cover color : '+document.order.picture.value;
		num3 = 10.00;}

   if (document.order.picture.options[document.order.picture.selectedIndex].value == 'None')
		num2 = 0.00;
	else
		num2 = 25.00;

		document.order.PRICE.value = num1 + num2 + num3;
		}
		
   function compute16() // enable/disable sticker's text
   {
   if (document.order.sticker.options[document.order.sticker.selectedIndex].value == 'Yes')
		document.order.bride.disabled = false;
   if (document.order.sticker.options[document.order.sticker.selectedIndex].value == 'No')
		document.order.bride.disabled = true;
}		


   function compute17() // FCF03
   {
   var num1 = 200.00;
   var num2 = 0.00;
   var num3 = 0.00;


   if (document.order.sticker.value == 'No' ){
	   document.order.ADDITIONALINFO.value='Organza fan color : '+ document.order.fan.value+'<br>Sticker\'s text : -<br>Organza cover color : '+document.order.picture.value;
		num3 = 0.00;}
	if (document.order.sticker.value == 'Yes' ){
		document.order.ADDITIONALINFO.value='Organza fan color : '+ document.order.fan.value+'<br>Sticker\'s text : ' + document.order.bride.value + '<br>Font type : '+document.order.font.value+'<br>Organza cover color : '+document.order.picture.value;
		num3 = 20.00;}

   if (document.order.picture.options[document.order.picture.selectedIndex].value == 'None')
		num2 = 0.00;
	else
		num2 = 40.00;

		document.order.PRICE.value = num1 + num2 + num3;
		}

     function computehr12()  // HR12
   {
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Dates' ){
	   document.order.PRICE.value = 9.00;}
	   
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Kiwi' ){
		document.order.PRICE.value = 8.50;}
		
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Apricot' ){
		document.order.PRICE.value = 11.00;	}	
		
}


     function computeadh()  // ADH01
   {
	if (document.order.Color.options[document.order.Color.selectedIndex].value == '0.5 kg' )
	   document.order.PRICE.value = 20.00;
	   
	if (document.order.Color.options[document.order.Color.selectedIndex].value == '1 kg' )
		document.order.PRICE.value = 35.00;
		
	  	document.order.ADDITIONALINFO.value='Decoration : '+document.order.Color.options[document.order.Color.selectedIndex].value;
}

     function computefsb19()  // FSB19
   {
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Small' )
	   document.order.PRICE.value = 100.00;
	   
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Medium' )
		document.order.PRICE.value = 175.00;
		
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Large' )
		document.order.PRICE.value = 225.00;		
		
	  	document.order.ADDITIONALINFO.value='Size : '+document.order.Color.options[document.order.Color.selectedIndex].value;
}

     function computefbx56()  // FBX56
   {
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Small' )
	   document.order.PRICE.value = 24.00;
	   
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Medium' )
		document.order.PRICE.value = 30.00;
		
	if (document.order.Color.options[document.order.Color.selectedIndex].value == 'Large' )
		document.order.PRICE.value = 36.00;		
		
	  	document.order.ADDITIONALINFO.value='Size : '+document.order.Color.options[document.order.Color.selectedIndex].value;
}

     function compute22()  // FBX23-EX
   {
	  	document.order.ADDITIONALINFO.value='Paperbox\'s Color  : ' + document.order.Color.options[document.order.Color.selectedIndex].value + '<br>Ribbon\'s Color : '+ document.order.ribbon1.value+'<br>Ribbon\'s Text : '+document.order.ribbon2.value;
}


     function compute23()  // FBX01-EX
   {
	  	document.order.ADDITIONALINFO.value='Ribbon\'s Color : '+ document.order.ribbon1.value+'<br>Ribbon\'s Text : '+document.order.ribbon2.value;
}

     function computetinbox()  // FTB 1-4
   {
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 3.50;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 3.20;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 2.95;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 2.80;   
}


     function computefca24()  // FCA24/25
   {
	if (document.order.QUANTITY.value < 50)
	   document.order.PRICE.value = 7.90;
	   
	if (document.order.QUANTITY.value > 49 && document.order.QUANTITY.value < 100) 
	   document.order.PRICE.value = 5.80;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 5.20;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 5.10;	   

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 4.95;   
}

     function computefsa01()  // FSA01
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 4.00;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 3.90;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 3.80;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 3.70;   
}

     function computefsa02()  // FSA02
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 5.90;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 5.50;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 5.30;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 5.00;   
}

     function computefsa03()  // FSA03
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 6.90;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 6.50;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 6.30;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 6.00;    
}

     function computefsa04()  // FSA04
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 7.90;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 7.50;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 7.30;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 7.00;    
}

     function computefsa05()  // FSA05
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 3.00;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 2.90;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 2.90;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 2.80;    
}

     function computefot27()  // FOT27
{
	if (document.order.QUANTITY.value < 100)
	   document.order.PRICE.value = 3.50;
	   
	if (document.order.QUANTITY.value > 99 && document.order.QUANTITY.value < 500) 
	   document.order.PRICE.value = 3.40;
	   
	if (document.order.QUANTITY.value > 499 && document.order.QUANTITY.value < 1000) 
	   document.order.PRICE.value = 3.40;

	if (document.order.QUANTITY.value > 999)
	   document.order.PRICE.value = 3.30;    
}

     function computepvcbs()  // PVC Bag small
{
	if (document.order.QUANTITY.value < 9)
	   document.order.PRICE.value = 18.00;
	   
	if (document.order.QUANTITY.value > 8 && document.order.QUANTITY.value < 42) 
	   document.order.PRICE.value = 16.80;
	   
	if (document.order.QUANTITY.value > 41 && document.order.QUANTITY.value < 84) 
	   document.order.PRICE.value = 15.60;

	if (document.order.QUANTITY.value > 83)
	   document.order.PRICE.value = 14.40;    
}

     function computepvcbl()  // PVC Bag large
{
	if (document.order.QUANTITY.value < 9)
	   document.order.PRICE.value = 30.00;
	   
	if (document.order.QUANTITY.value > 8 && document.order.QUANTITY.value < 42) 
	   document.order.PRICE.value = 28.80;
	   
	if (document.order.QUANTITY.value > 41 && document.order.QUANTITY.value < 84) 
	   document.order.PRICE.value = 27.60;

	if (document.order.QUANTITY.value > 83)
	   document.order.PRICE.value = 26.40;    
}

     function computeptyb()  // party bag
{
	if (document.order.QUANTITY.value < 10)
	   document.order.PRICE.value = 33.00;
	   
	if (document.order.QUANTITY.value > 9 && document.order.QUANTITY.value < 50) 
	   document.order.PRICE.value = 30.00;
	   
	if (document.order.QUANTITY.value > 49 && document.order.QUANTITY.value < 100) 
	   document.order.PRICE.value = 30.00;

	if (document.order.QUANTITY.value > 99)
	   document.order.PRICE.value = 28.00;    
}


     function computepbh()  // PBH bag
{
	if (document.order.QUANTITY.value < 10)
	   document.order.PRICE.value = 20.00;
	   
	if (document.order.QUANTITY.value > 9 && document.order.QUANTITY.value < 50) 
	   document.order.PRICE.value = 19.00;
	   
	if (document.order.QUANTITY.value > 49 && document.order.QUANTITY.value < 100) 
	   document.order.PRICE.value = 18.00;

	if (document.order.QUANTITY.value > 99)
	   document.order.PRICE.value = 16.00;    
}


     function computehb28()  // HB28
   {
	if (document.order.size.options[document.order.size.selectedIndex].value == 'Small' )
	   document.order.PRICE.value = 38.00;
	   
	if (document.order.size.options[document.order.size.selectedIndex].value == 'Medium' )
	   document.order.PRICE.value = 44.00;
	   
	if (document.order.size.options[document.order.size.selectedIndex].value == 'Large' )
		document.order.PRICE.value = 49.00;
		
	  	document.order.ADDITIONALINFO.value='Size : '+document.order.size.options[document.order.size.selectedIndex].value;
}

     function computeribbon()  // ribbon
   {
	if (document.order.QUANTITY.value < 10 )
	   document.order.QUANTITY.value = 10;	
		
	 document.order.ADDITIONALINFO.value='<br>Imprint : ' + document.order.imprint.value + '<br> Ribbon color : ' +document.order.color.value+ '<br> Hotstamping Color  :' +document.order.color2.value+'<br>Font type : '+document.order.font.options[document.order.font.selectedIndex].value
}

     function computeribbonoffer()  // ribbon
   {
	   document.order.QUANTITY.value = 5;		
	 document.order.ADDITIONALINFO.value='<br>Imprint : ' + document.order.imprint.value + '<br> Ribbon color : ' +document.order.color.value+ '<br> Hotstamping Color  :' +document.order.color2.value+'<br>Font type : '+document.order.font.options[document.order.font.selectedIndex].value
}

     function computeribbon2()  // ribbon 2
   {
	if (document.order.QUANTITY.value < 10 )
	   document.order.QUANTITY.value = 10;	
		
	 document.order.ADDITIONALINFO.value='<br>Imprint : ' + document.order.imprint.value + '<br> Ribbon color : ' +document.order.color.value+ '<br> Ribbon edge : ' +document.order.edge.value+ '<br> Hotstamping Color  :' +document.order.color2.value+'<br>Font type : '+document.order.font.options[document.order.font.selectedIndex].value
}

     function computeribbon2offer()  // ribbon 2
   {
	   document.order.QUANTITY.value = 5;
	 document.order.ADDITIONALINFO.value='<br>Imprint : ' + document.order.imprint.value + '<br> Ribbon color : ' +document.order.color.value+ '<br> Ribbon edge : ' +document.order.edge.value+ '<br> Hotstamping Color  :' +document.order.color2.value+'<br>Font type : '+document.order.font.options[document.order.font.selectedIndex].value
}


function cleanCart(){
   var iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null ){
         iNumberOrdered = 0;
   }
   for ( i = 1; i <= iNumberOrdered; i++ ) {
         NewOrder = "Order." + i;
         DeleteCookie(NewOrder, "/");
   }
   DeleteCookie("NumberOrdered", "/");
}