//=====================================================================||
//               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                                     ||
//=====================================================================||

MonetarySymbol        = '$';
DisplayNotice         = true;
DisplayShippingColumn = false;
DisplayShippingRow    = true;
DisplayTaxRow         = false;
TaxRate               = 0.00;
TaxByRegion           = false;
MinimumOrder          = 0.01;
MinimumOrderPrompt    = 'Your order is below our minimum order, please order at least 12 bottles before checking out.';

PaymentProcessor      = '';

OutputItemId          = 'ID_';
OutputItemQuantity    = 'QUANTITY_';
OutputItemPrice       = 'PRICE_';
OutputItemName        = 'NAME_';
OutputItemShipping    = 'SHIPPING_';
OutputItemAddtlInfo   = 'ADDTLINFO_';
OutputOrderSubtotal   = 'SUBTOTAL';
OutputOrderGST        = 'GST';
OutputOrderShipping   = 'SHIPPING';
OutputOrderMethod     = 'METHOD';
OutputOrderTax        = 'TAX';
OutputOrderTotal      = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = false;


//                      Language Strings                               ||

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";
   strSLabel = "Shipping";
   strRLabel = "Remove From Cart";
   strWLabel = "test";
   strRButton= "Remove";
   strSUB    = "SUBTOTAL";
   strSHIP   = "SHIPPING";
   strTAX    = "TAX";
   strTOT    = "TOTAL";
   strErrQty = "Invalid Quantity.";
   strNewQty = 'Please enter new quantity:';
   bLanguageDefined = true;
}


// FUNCTION:    CKquantity                                             ||

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                                              ||

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[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;
   }

   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 > 15 )
         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                                           ||

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                                          ||

function FixCookieDate (date) {
   var base = new Date(0);
   var skew = base.getTime();

   date.setTime (date.getTime() - skew);
}



// FUNCTION:    GetCookie                                              ||

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                                              ||

function SetCookie( name, value, expires, path, domain, secure) {
   if ( expires == "persistent" ) {	// expire in 5 years
       var cookieDate = new Date();
       cookieDate.setTime( cookieDate.getTime() + 30*24*60*60*1000);
       expires = cookieDate;
   }

   document.cookie = name + "=" + escape (value) +
	     ((expires) ? "; expires=" + expires.toGMTString() : "") +
	     ((path) ? "; path=" + path : "") +
	     ((domain) ? "; domain=" + domain : "") +
	     ((secure) ? "; secure" : "");
}


// FUNCTION:    DeleteCookie                                           ||

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                                            ||

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                                         ||

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                                         ||

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 ChangeShipping( NewShipping ) {
   DeleteCookie( "ShippingMeth" );
   SetCookie( "ShippingMeth", NewShipping, "persistent", "/" );
   location.href = location.href; 
}


// FUNCTION:    GetFromCart                                            ||

function GetFromCart( fShipping ) {
   ManageCart( );
}



// FUNCTION:    RadioChecked                                           ||

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                                            ||

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                                      ||

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                                             ||

function ManageCart( ) {
   var fItems = 0; //Added to allow shipping increases based on qty
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var fTax           = 0;    //Tax amount
   var Qty	          = 0;	  // Total # of items ordered
   var fShipping      = 0;    //Shipping amount
   var strMethod      = "";    //Shipping Method
   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;
	  
	  shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'Perth';
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );
   }

   if ( bDisplay )
      strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
                  "<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strILabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strDLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=center><B>"+strPLabel+"</B></TD>" +
                  (DisplayShippingColumn?"<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strSLabel+"</B></TD>":"") +
                  "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>Update Cart</B></TD>" +
				  "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strRLabel+"</B></TD></TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your cart is currently 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

      Qty	 += parseInt( fields[1] );
      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
      fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
	  fItems += fields[1]; 
      fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      strTax      = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);

      if ( bDisplay ) {
         strOutput += "<TR><TD CLASS=\"nopentry\" >"  + fields[0] + "</TD>";

         if ( fields[5] == "" )
            strOutput += "<TD CLASS=\"nopentry\" >"  + fields[3] + "</TD>";
         else
            strOutput += "<TD CLASS=\"nopentry\" >"  + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

         strOutput += "<TD CLASS=\"nopentry\" ALIGN=center><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
         strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

         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>";
         }
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\ Update \" onClick=\"UpdateCart("+i+")\" class=\"nopbutton\"></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] + "\">";
      }

   }
  //=========================================SHIPPING==========\\
    shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'Perth';
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );

       if ( shipMethod == "Perth" )
	   shipMethod = "Perth";
	      SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );

       if ( shipMethod == "SouthMidwest" )
	   shipMethod = "SouthMidwest";
	      SetCookie( "ShippingMeth", 'SouthMidwest', "persistent", "/" );

       if ( shipMethod == "Northwest" )
	   shipMethod = "Northwest";
	      SetCookie( "ShippingMeth", 'Northwest', "persistent", "/" );         
		  
       if ( shipMethod == "Sydney" )
	   shipMethod = "Sydney";
	      SetCookie( "ShippingMeth", 'Sydney', "persistent", "/" );  		  
		  
       if ( shipMethod == "NSWCountry" )
	   shipMethod = "NSWCountry";
	      SetCookie( "ShippingMeth", 'NSWCountry', "persistent", "/" ); 

       if ( shipMethod == "Melbourne" )
	   shipMethod = "Melbourne";
	      SetCookie( "ShippingMeth", 'Melbourne', "persistent", "/" );

       if ( shipMethod == "VICCountry" )
	   shipMethod = "VICCountry";
	      SetCookie( "ShippingMeth", 'VICCountry', "persistent", "/" );

       if ( shipMethod == "Adelaide" )
	   shipMethod = "Adelaide";
	      SetCookie( "ShippingMeth", 'Adelaide', "persistent", "/" );         
		  
       if ( shipMethod == "SACountry" )
	   shipMethod = "SACountry";
	      SetCookie( "ShippingMeth", 'SACountry', "persistent", "/" );  		  
		  
       if ( shipMethod == "Brisbane" )
	   shipMethod = "Brisbane";
	      SetCookie( "ShippingMeth", 'Brisbane', "persistent", "/" );   
	
       if ( shipMethod == "QLDCountry" )
	   shipMethod = "QLDCountry";
	      SetCookie( "ShippingMeth", 'QLDCountry', "persistent", "/" );

       if ( shipMethod == "Canberra" )
	   shipMethod = "Canberra";
	      SetCookie( "ShippingMeth", 'Canberra', "persistent", "/" );         
		  
       if ( shipMethod == "NT" )
	   shipMethod = "NT";
	      SetCookie( "ShippingMeth", 'NT', "persistent", "/" );  		  
		  
       if ( shipMethod == "Tasmania" )
	   shipMethod = "Tasmania";
	   SetCookie( "ShippingMeth", 'Tasmania', "persistent", "/" );   
  }
  //===============================END SHIPPING================||   

   if ( bDisplay ) {
      if ( iNumberOrdered > 0 ) {
	  strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
	  strOutput += "<TD CLASS=\"noptotal\" align=center COLSPAN=2><B>" + 
	      MonetarySymbol + strTotal + "</B></TD>";
	  strOutput += "</TR>";

if ( DisplayShippingRow ) {
	     strOutput += "<TR valign=top><TD CLASS=\"noptotal\"><B>"+strSHIP+"</B><br><br></TD>";
	     strOutput += "<TD CLASS=\"noptotal\" COLSPAN=3>" +
		  "&nbsp;&nbsp;&nbsp;&nbsp; <SELECT name=shipMethod class=checkoutinput onChange=\"ChangeShipping(this.options[this.selectedIndex].value)\">" + 
		  "<OPTION VALUE=Perth " + (shipMethod == "Perth" ? ' SELECTED' : '') + "selected>Perth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</OPTION>" +
		  "<OPTION VALUE=SouthMidwest" + (shipMethod == "SouthMidwest" ? ' SELECTED' : '') + ">South Midwest </OPTION>" +
		  "<OPTION VALUE=Northwest" + (shipMethod == "Northwest" ? ' SELECTED' : '') + ">North West </OPTION>" +
		  "<OPTION VALUE=Sydney " + (shipMethod == "Sydney" ? ' SELECTED' : '') + ">Sydney </OPTION>" +
		  "<OPTION VALUE=NSWCountry" + (shipMethod == "NSWCountry" ? ' SELECTED' : '') + ">NSW Country </OPTION>" +
		  "<OPTION VALUE=Melbourne" + (shipMethod == "Melbourne" ? ' SELECTED' : '') + ">Melbourne </OPTION>" +
		  "<OPTION VALUE=VICCountry " + (shipMethod == "VICCountry" ? ' SELECTED' : '') + ">VIC Country </OPTION>" +
		  "<OPTION VALUE=Adelaide" + (shipMethod == "Adelaide" ? ' SELECTED' : '') + ">Adelaide </OPTION>" +
		  "<OPTION VALUE=SACountry" + (shipMethod == "SACountry" ? ' SELECTED' : '') + ">SA Country </OPTION>" +
		  "<OPTION VALUE=Brisbane " + (shipMethod == "Brisbane" ? ' SELECTED' : '') + ">Brisbane </OPTION>" +
		  "<OPTION VALUE=QLDCountry" + (shipMethod == "QLDCountry" ? ' SELECTED' : '') + ">QLD Country </OPTION>" +
		  "<OPTION VALUE=Canberra" + (shipMethod == "Canberra" ? ' SELECTED' : '') + ">Canberra </OPTION>" +
		  "<OPTION VALUE=NT" + (shipMethod == "NT" ? ' SELECTED' : '') + ">NT </OPTION>" +
		  "<OPTION VALUE=Tasmania" + (shipMethod == "Tasmania" ? ' SELECTED' : '') + ">Tasmania </OPTION>" +
		  "</SELECT>"+ " &nbsp; &nbsp; &nbsp;(Location To Be Delivered)"
		  "</TD>";

//=========================================SHIPPING==========\\		  
		  
    if ( shipMethod == "Perth") {
	fShipping = ((fShipping) + 6.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );
    }
    if ( shipMethod == "SouthMidwest") {
	fShipping = ((fShipping) + 10.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'SouthMidwest', "persistent", "/" );
    }
    if ( shipMethod == "Northwest") {
	fShipping = ((fShipping) + 13.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Northwest', "persistent", "/" );
    }
	    if ( shipMethod == "Sydney") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Sydney', "persistent", "/" );
    }
    if ( shipMethod == "NSWCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'NSWCountry', "persistent", "/" );
    }
    if ( shipMethod == "Melbourne") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Melbourne', "persistent", "/" );
    }
	    if ( shipMethod == "VICCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'VICCountry', "persistent", "/" );
    }
    if ( shipMethod == "Adelaide") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Adelaide', "persistent", "/" );
    }
    if ( shipMethod == "SACountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'SACountry', "persistent", "/" );
    }
	    if ( shipMethod == "Brisbane") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Brisbane', "persistent", "/" );
    }
    if ( shipMethod == "QLDCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'QLDCountry', "persistent", "/" );
    }
    if ( shipMethod == "Canberra") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Canberra', "persistent", "/" );
	}
	    if ( shipMethod == "NT") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'NT', "persistent", "/" );
    }
    if ( shipMethod == "Tasmania") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Tasmania', "persistent", "/" );
	}
   strShipping = moneyFormat( fShipping ); 
   strMethod   = shipMethod;

   
//===============================END SHIPPING================||
   
	     strOutput += "<TD CLASS=\"noptotal\" ALIGN=center COLSPAN=2><B>" + MonetarySymbol + strShipping + "<br><br></B></TD>";
	     strOutput += "</TR>";
	  }
var GST = ( fTotal + fShipping ) /11; 

         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strGST+"</B></TD>"; 
         strOutput += "<TD CLASS=\"noptotal\" align=center COLSPAN=2><B>" + MonetarySymbol + moneyFormat(GST) + " </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 CLASS=\"noptotal\" COLSPAN=4><B>"+strTOT+"</B></TD>";
	     strOutput += "<TD CLASS=\"noptotal\" ALIGN=center COLSPAN=2><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
	     strOutput += "</TR>";
	  }
      }
	  
      strOutput += "</TABLE>";

      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)) + "\">";
		 strOutput += "<input type=hidden name=\""+OutputOrderGST+"\" value=\""+ MonetarySymbol + moneyFormat(GST) + "\">";
	  }
   }
   g_TotalCost = (fTotal + fShipping + fTax);

   document.write(strOutput);
   document.close();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// short basket code

function SmallCart( ) {
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //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 width=140 cellspacing=0 cellpadding=5 CLASS=\"nopcart\"><TR>" +
                  "<TD bgcolor=#FFFFFF CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
                  "<TD bgcolor=#FFFFFF CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
				  "<TD bgcolor=#FFFFFF CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +

              
                  (DisplayShippingColumn?"<TD bgcolor=#FFFFFF CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +  "</TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD bgcolor=#FFFFFF COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your Basket 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

      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 ( bDisplay ) {

         if ( fields[5] == "" )
            strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\">"  + fields[3] + "</TD>";
         else
            strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\">"  + fields[3];
		 
		 
		 strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "</TD>"; 
         strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=1 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
         

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD bgcolor=#FFFFFF CLASS=\"nopentry\">N/A</TD>";
         }

         strOutput += "</TR>";
		 
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
   

   }

   if ( bDisplay ) {
       strOutput += "<table width=200 bgcolor=#FFFFFF>";
	   strOutput += "<TD bgcolor=#CCCCCC CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\ Update \" onClick=\"UpdateCart("+i+")\" class=\"nopbutton\"></TD>";
	   strOutput += "<TD bgcolor=#CCCCCC CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\ "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD>";
	  }
   g_TotalCost = (fTotal + fShipping + fTax);

   document.write(strOutput);
   document.close();
}


// FUNCTION:    ValidateCart                                           ||

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;
      }
   }

var fItems = 0; 
var looseitems = 0; 
   iNumberOrdered = GetCookie("NumberOrdered"); 
   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 

      fItems += (parseInt(fields[1])); 
      fItems = fItems 

      looseitems+=(parseInt(fields[1])%12); 
    } 
      looseitems = ((looseitems)%12) 
      if (looseitems != 0){ 
     alert( 'In order for you to continue to the checkout, please order in multiples of 12. (Straight or Mixed Cases)' ); 
        return false; 
   } 
   return true; 
} 


// FUNCTION:    CheckoutCart                                           ||

function CheckoutCart( ) {
   var fItems = 0; //Added to allow shipping increases based on qty
   var iNumberOrdered = 0;    //Number of products ordered
   var Qty	          = 0;	  // Total # of items ordered
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var fTax           = 0;    //Tax amount
   var fShipping      = 0;    //Shipping amount
   var strGST         = "GST";   //GST amount
   var strMethod      = "Perth";    //Shipping Method
   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;
      
    shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'Perth';
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );
   }

   if ( TaxByRegion ) {
      QueryString_Parse();
      fTax = parseFloat( QueryString( OutputOrderTax ) );
      strTax = moneyFormat(fTax);
   }

        if ( bDisplay ) 
         strOutput = "<TABLE CELLSPACING=0 CELLPADDING=2 BORDER=0 CLASS=\"nopcart\"><TR>" + 
        "<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strILabel+"</B></TD>" +
        "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strDLabel+"</B></TD>" +
        "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
        "<TD CLASS=\"nopheader\"ALIGN=CENTER><B>"+strPLabel+"</B></TD>" +
        (DisplayShippingColumn?"<TD CLASS=\"nopheader\"ALIGN=CENTER><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

      Qty	 += parseInt( fields[1] );
      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
      fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
      fItems += fields[1]; 

      if ( !TaxByRegion ) fTax = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      if ( !TaxByRegion ) strTax = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);
      

      if ( bDisplay ) {
         strOutput += "<TR><TD CLASS=\"nopentry\"ALIGN=CENTER>"  + fields[0] + "</TD>";

         if ( fields[5] == "" )
            strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>"  + fields[3] + "</TD>";
         else
            strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>"  + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

         strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>" + fields[1] + "</TD>";
         strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD CLASS=\"nopentry\"ALIGN=CENTER>N/A</TD>";
         }

         strOutput += "</TR>";
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
      if ( PaymentProcessor == 'it' ) { 

strOutput += "<input type=hidden name=\"item_number_"+ strFooter + "\" value=\"" + fields[0] + "\">"; 
strOutput += "<input type=hidden name=\"quantity_" + strFooter + "\" value=\"" + fields[1] + "\">"; 
strOutput += "<input type=hidden name=\"amount_" + strFooter + "\" value=\"" + fields[2] + "\">"; 
strOutput += "<input type=hidden name=\"item_name_" + strFooter + "\" value=\"" + fields[3] + "\">"; 
if (i == iNumberOrdered) { 
strOutput += "<input type=hidden name=\"shipping_" + strFooter + "\" value=\"" + strShipping + "\">"; 
} else { 
strOutput += "<input type=hidden name=\"shipping_" + strFooter + "\" value=\"0.00\">"; 
} 
strOutput += "<input type=hidden name=\"on0_" + strFooter + "\" value=\"" + fields[5] + "\">"; 
} 
      if ( PaymentProcessor != '' ) {

         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] + "\">";
      } 

   }

var GST = ( fTotal + fShipping ) /11; 

         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strGST+"</B></TD>"; 
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat(GST) + " </B></TD>"; 
         strOutput += "</TR>";

   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>";

//=========================================SHIPPING==========\\		  
	 shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'Perth';
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );
    }

    if ( shipMethod == "Perth") {
	fShipping = ((fShipping) + 6.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Perth', "persistent", "/" );
    }
    if ( shipMethod == "SouthMidwest") {
	fShipping = ((fShipping) + 10.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'SouthMidwest', "persistent", "/" );
    }
    if ( shipMethod == "Northwest") {
	fShipping = ((fShipping) + 13.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Northwest', "persistent", "/" );
    }
	    if ( shipMethod == "Sydney") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Sydney', "persistent", "/" );
    }
    if ( shipMethod == "NSWCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'NSWCountry', "persistent", "/" );
    }
    if ( shipMethod == "Melbourne") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Melbourne', "persistent", "/" );
    }
	    if ( shipMethod == "VICCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'VICCountry', "persistent", "/" );
    }
    if ( shipMethod == "Adelaide") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Adelaide', "persistent", "/" );
    }
    if ( shipMethod == "SACountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'SACountry', "persistent", "/" );
    }
	    if ( shipMethod == "Brisbane") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Brisbane', "persistent", "/" );
    }
    if ( shipMethod == "QLDCountry") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'QLDCountry', "persistent", "/" );
    }
    if ( shipMethod == "Canberra") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Canberra', "persistent", "/" );
	}
	    if ( shipMethod == "NT") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'NT', "persistent", "/" );
    }
    if ( shipMethod == "Tasmania") {
	fShipping = ((fShipping) + 22.00 * (Qty/12));
        SetCookie( "ShippingMeth", 'Tasmania', "persistent", "/" );
	}
   strShipping = moneyFormat( fShipping ); 
   
//===============================END SHIPPING================||   

      if ( DisplayShippingRow ) {
         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+shipMethod+ "</B></TD>";
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
         strOutput += "</TR>";
      }



      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTOT+"</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
      strOutput += "</TR>";

      strOutput += "</TABLE>";

      
      if ( PaymentProcessor == 'an') {

         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') {

         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
         strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
      } else if ( PaymentProcessor == 'lp') {
       
         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=\""+OutputOrderMethod+"\" value=\""+ shipMethod + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
		 strOutput += "<input type=hidden name=\""+OutputOrderGST+"\" value=\""+ MonetarySymbol + moneyFormat(GST) + "\">";
      }
   }

   document.write(strOutput);
   document.close();
}


//               END NOP Design SmartPost Shopping Cart                ||



// FUNCTION: Print_total                                               || 

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 


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]) ); 

} 

strTotal = moneyFormat(fTotal); 
strOutput+=strTotal; 
if ( bSymbol ) 
   strOutput = MonetarySymbol + strOutput 
document.write(strOutput); 

} 



// FUNCTION: Print_QTY                                                 || 

function Print_qty(pSymbol) { 
var strOutput = ""; //String to be written to page 
var strQTY = ""; //Total cost formatted as money 
var fTotal = 0; 
var iNumberOrdered = 0; //Number of products ordered 
var fQTY           = 0;    //Total wines 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); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product ID 
fields[1] = database.substring( Token0+1, Token1 ); // Quantity 

fQTY	 += parseInt( fields[1] );

} 

strQTY = fQTY; 
strOutput+=strQTY; 
if ( pSymbol ) 
   strOutput = strOutput 
document.write(strOutput); 

} 


//               END NOP Design SmartPost Shopping Cart                ||


