//=====================================================================||
//               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                                     ||
//=====================================================================||


//Options for Everyone:
MonetarySymbol        = 'EUR';
DisplayNotice         = false;
DisplayShippingColumn = false;
DisplayShippingRow    = true;
DisplayTaxRow         = true;
TaxRate               = 0.19;
TaxByRegion           = false;
TaxPrompt             = 'For tax purposes, please select if you are a Washington resident before continuing';
TaxablePrompt         = 'WA Residents    ';
NonTaxablePrompt      = 'Other States      ';
MinimumOrder          = 0.01;
MinimumOrderPrompt    = 'Dein Warenkorb ist leer';
ShippingRegionPrompt  = 'Du hast mußt Deine Versandregion auswählen';

//Payment Processor Options:
PaymentProcessor      = '';

//Options for Programmers:
OutputItemTh          = 'TH_';
OutputItemId          = 'ID_';
OutputItemQuantity    = 'QUANTITY_';
OutputItemPrice       = 'PRICE_';
OutputItemName        = 'NAME_';
OutputItemShipping    = 'SHIPPING_';
OutputItemAddtlInfo   = 'ADDTLINFO_';
OutputOrderSubtotal   = 'SUBTOTAL';
OutputOrderShipping   = 'SHIPPING';
OutputOrderMethod     = 'METHOD';
OutputOrderTax        = 'TAX';
OutputOrderTotal      = 'TOTAL';
OutputOrderAmount     = 'AMOUNT';
OutputOrderRabatt     = 'RABATT';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = true;


//---------------------------------------------------------------------||
//                      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  = "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 = "Preis";
   strTLabel = "Total";
   strSLabel = "Versand";
   strRLabel = "Remove from Cart";
   strWLabel = "test";
   strRButton = "Remove";
   strThLabel = "Image"; 
   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 ( strQUANTITY <0 ) strQUANTITY = 1; 

      
      if ( thisForm.Thumb == null ) 
		strThumb = ""; 
	else 
		strThumb = thisForm.Thumb.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;
   }

   //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);
      Token5 = database.indexOf("|", Token4+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, Token5 );
      fields[6] = database.substring( Token5+1, database.length ); 


      if ( fields[0] == strThumb && 
      	 fields[1] == strID_NUM &&
           fields[3] == strPRICE  &&
           fields[4] == strNAME   &&
           fields[6] == strADDTLINFO
         ) {
         bAlreadyInCart = true;
         dbUpdatedOrder = strThumb + "|" +
         				 strID_NUM    + "|" +
                          (parseInt(strQUANTITY)+parseInt(fields[2]))  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;
         strNewOrder = "Order." + i;
         DeleteCookie(strNewOrder, "/");
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
//         notice = strQUANTITY + " " + strID_NUM + strAdded;
notice = strAdded + "\n-------------------------------------------------------------------\n" + "Anzahl : " + strQUANTITY + "\nBild  : " + strNAME;
         break;
      }
   }


   if ( !bAlreadyInCart ) {
      iNumberOrdered++;

      if ( iNumberOrdered > 12 )
         alert( strSorry );
      else {
         dbUpdatedOrder = strThumb + "|" + 
         				  strID_NUM    + "|" + 
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strADDTLINFO;

         strNewOrder = "Order." + iNumberOrdered;
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
         SetCookie("NumberOrdered", iNumberOrdered, null, "/");
//         notice = strQUANTITY +" "+ strID_NUM + strAdded;
notice = strAdded + "\n-------------------------------------------------------------------\n" + "Anzahl : " + strQUANTITY + "\nBild  : " + strNAME;
      }
   }

   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) {


   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                                           ||
// 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 {
   	 if (NewQuantity < 1 ) NewQuantity = 1;
      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);
      Token5 = database.indexOf("|", Token4+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, Token5 );
      fields[6] = database.substring( Token5+1, database.length );

      dbUpdatedOrder = fields[0] + "|" +
      			   fields[1] + "|" + 
                       NewQuantity + "|" +
                       fields[3] + "|" +
                       fields[4] + "|" +
                       fields[5] + "|" +
                       fields[6];
      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                                            ||
// 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 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 fTotal          = 0;        //Total cost of order
   var fTax            = 0;        //Tax amount
   var fShipping       = 0;        //Shipping amount
   var strMethod       = "";       //Shipping Method
   var strTotal        = "";       //Total cost formatted as money
   var strTLabel       = "Total";  //Total cost per line
   var strThLabel      = "Image";  //Image label
   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 fprodttl        = 0;        //Total product cost = QTY * PRICE 
   var weight          = 0; 
   var fcoupon         = 0;
   var coupon          = ""; //code entered for the coupon
  
   iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;
      
    shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'ground';
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );
   }

   if ( bDisplay )
      strOutput = "<TABLE id=\"myTable\" cellpadding=0 cellspacing=0 border=0><TR>" +
      		  "<TD>Artikel</TD>" + //Beschreibung
                  "<TD align=\"center\">Menge</TD>" + //Anzahl
                  "<TD align=\"right\">St&uuml;ckpreis</TD>" +  //Preis
                  "<TD>&nbsp;</TD>" + //Total
                  "</TR>"; 

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=4 bgcolor=\"#CCCCCC\"><CENTER><BR><B>Dein Warenkorb ist leer</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);
      Token5 = database.indexOf("|", Token4+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );                 // Product Image
      fields[1] = database.substring( Token0+1, Token1 );          // Product ID
      fields[2] = database.substring( Token1+1, Token2 );          // Quantity
      fields[3] = database.substring( Token2+1, Token3 );          // Price
      fields[4] = database.substring( Token3+1, Token4 );          // Product Name/Description
      fields[5] = database.substring( Token4+1, Token5 );          // Shipping Cost
      fields[6] = database.substring( Token5+1, database.length ); //Additional Information

      Qty	 += parseInt( fields[2] );
      fprodttl    = (parseInt(fields[2]) * parseFloat(fields[3]) ); 
      fTotal     += (parseInt(fields[2]) * parseFloat(fields[3]) );
      weight     += (parseInt(fields[2]) * parseFloat(fields[5]) );
      fItems 	 += parseInt( fields[2] ); //Added to allow shipping increases based on qty
      fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      strTax      = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);



      if ( bDisplay ) {
         strOutput += "<TR>";

         if ( fields[6] == "" )
            strOutput += "<TD bgcolor=\"#CCCCCC\">" + fields[4] + "</TD>";
         else
            strOutput += "<TD  bgcolor=\"#CCCCCC\">"  + fields[4] + " - "+ fields[6] + "</TD>";

         strOutput += "<TD bgcolor=\"#CCCCCC\" align=\"center\"><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[2] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
         strOutput += "<TD bgcolor=\"#CCCCCC\" align=\"right\">" + moneyFormat(fields[3]) + "&nbsp;" + MonetarySymbol + "</TD>";



         strOutput += "<TD bgcolor=\"#CCCCCC\" ALIGN=\"center\"><input type=\"button\" value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\"></TD></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[1] + ", " + fields[4];
         if ( fields[6] != "" )
            strPP += " - " + fields[6];
         strPP += ", Qty. " + fields[2] + "\n";
      } else {
         strOutput += "<input type=hidden name=\"" + OutputItemTh        + strFooter + "\" value=\"" + fields[0] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[1] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[2] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + fields[3] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[4] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[5] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[6] + "\">";
        
      } 
      }
   
   
   
    //=========================================SHIPPING=========================||
    shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'ground';
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );

       if ( shipMethod == "ground" )
	   shipMethod = "ground";
	      SetCookie( "ShippingMeth", 'ground', "persistent", "/" );
       if ( shipMethod == "priority" )
	   shipMethod = "priority";
	      SetCookie( "ShippingMeth", 'priority', "persistent", "/" );
       if ( shipMethod == "overnight" )
	   shipMethod = "overnight";
	   SetCookie( "ShippingMeth", 'overnight', "persistent", "/" );
	   
	   
      
  }


//=========================================SHIPPING==========\\		  
// Versandkosten für Deutschland		  
    if ( shipMethod == "ground") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 0.65};
        if (weight <= 50 && weight > 20){fShipping += 0.95};
        if (weight <= 200 && weight > 50){fShipping += 1.55};
        if (weight <= 1000 && weight > 200){fShipping += 2.35};
        if (weight <= 2000 && weight > 1000){fShipping += 4.20};
        if (weight <= 10000 && weight > 2000){fShipping += 7.50};
        if (weight  > 10000){fShipping += 11.20};
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );        
    }


// Versandkosten für EU
    if ( shipMethod == "priority") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 0.90};
        if (weight <= 50 && weight > 20){fShipping += 1.40};
        if (weight <= 100 && weight > 50){fShipping += 2.60};
        if (weight <= 500 && weight > 100){fShipping += 4.80};
        if (weight <= 2000 && weight > 500){fShipping += 9.80};
        if (weight <= 5000 && weight > 2000){fShipping += 20.00};
        if (weight <= 10000 && weight > 5000){fShipping += 24.00};
        if (weight  > 10000){fShipping += 34.00};
        SetCookie( "ShippingMeth", 'priority', "persistent", "/" );
    }

// Versandkosten weltweit

    if ( shipMethod == "overnight") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 2.40};
        if (weight <= 50 && weight > 20){fShipping += 2.80};
        if (weight <= 100 && weight > 50){fShipping += 5.00};
        if (weight <= 500 && weight > 100){fShipping += 8.70};
        if (weight <= 2000 && weight > 500){fShipping += 13.50};
        if (weight <= 5000 && weight > 2000){fShipping += 39.00};
        if (weight <= 10000 && weight > 5000){fShipping += 55.00};
        if (weight  > 10000){fShipping += 85.00};
        SetCookie( "ShippingMeth", 'overnight', "persistent", "/" );


    }
    
     if ( shipMethod == "pickup") {
	fShipping = 0;
        SetCookie( "ShippingMeth", 'pickup', "persistent", "/" );
        
    }
   
   strShipping = moneyFormat( fShipping ); 
   strMethod   = shipMethod;
   
//===============================END SHIPPING================||



  //===============================START ADVANCED DROPDOWN MOD================||   
  
  groundTEXT = ((fShipping));
  strgroundTEXT = moneyFormat(groundTEXT);
  priorityTEXT = ((fShipping));
  strpriorityTEXT = moneyFormat(priorityTEXT);
  overnightTEXT = ((fShipping));
  strovernightTEXT = moneyFormat(overnightTEXT);
 
  
  
  //===============================END ADVANCED DROPDOWN MOD================||  

   if ( bDisplay ) {
      strOutput += "<TR><td colspan=2 align=\"right\">Zwischensumme:</td><td align=\"right\">" + strTotal + "&nbsp;" + MonetarySymbol + "</td><td></td></tr>";
            strOutput += "<tr>";
            strOutput += "<td colspan=2 align=\"right\">darin 19% MwSt. enthalten:</td><td align=\"right\">" + strTax + "&nbsp;" + MonetarySymbol + "</td><td></td>";
            strOutput += "</tr>";
            
 if ( DisplayShippingRow ) {
	     strOutput += "<TR>";
	     strOutput += "<TD bgcolor=\"#CCCCCC\" align=\"right\">Versandkosten:</td><td colspan=3 bgcolor=\"#CCCCCC\">" +  
		  "<SELECT name=shipMethod class=checkoutinput onChange=\"ChangeShipping(this.options[this.selectedIndex].value)\">" + 
                  "<OPTION SELECTED VALUE=0>Region wählen</OPTION>" +
		  "<OPTION VALUE=ground " + (shipMethod == "ground" ? ' SELECTED' : '') + ">Deutschland:  "+ strgroundTEXT + "&nbsp;EUR</OPTION>" +
		  "<OPTION VALUE=priority" + (shipMethod == "priority" ? ' SELECTED' : '') + ">Restliche EU:  "+ strpriorityTEXT +"&nbsp;EUR</OPTION>" +
		  "<OPTION VALUE=overnight" + (shipMethod == "overnight" ? ' SELECTED' : '') + ">Weltweit:  "+ strovernightTEXT +"&nbsp;EUR</OPTION>" +
		  "</SELECT></TD>";
   

//============Definition OUTPUT im Managecart================||   
    
	     strOutput += "</TR>";
	  }
	  
      if ( !TaxByRegion ) {
         strOutput += "<TR><TD COLSPAN=2 align=right><b>Gesamt:</b></TD>";
		 strOutput += "<TD align=\"right\"><B>" + moneyFormat((fTotal + fShipping)) + "&nbsp;" + MonetarySymbol + "</B></TD><td></td>";
         strOutput += "</TR>";
      }
 
     
fTax        = (fTotal * TaxRate);
strTotal = moneyFormat(fTotal); 
strTax = moneyFormat(fTax); 
strShipping = moneyFormat(fShipping); 
TaxSelected = 0;


      if ( DisplayTaxRow || TaxByRegion ) {
         if ( TaxByRegion ) {
            strOutput += "<TR><TD CLASS=\"noptotal\" colspan=3></td><TD CLASS=\"noptotal\" align=right><B>"+strTAX+"</B></TD>";
            strOutput += "<TD CLASS=\"noptotal\" COLSPAN=3><B>";
            strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + moneyFormat((fTotal + fShipping) - ((fTotal + fShipping) / TaxRate)) + "\" onClick = \"TaxSelected = 1 \">";
            strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax;
            strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\"  onClick = \"TaxSelected = 1 \">";
            strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00";
            strOutput += "</B></TD>";
            strOutput += "</TR>";
         } else {
		    strOutput += "<TR><TD bgcolor=\"#CCCCCC\" colspan=4 align=\"center\"><a href=\"../index.html\"><img src=\"../img/continue_shopping.gif\" width=\"120\" height=\"18\" border=\"0\"></a> &nbsp; <input type\=\"image\" src\=\"..\/img\/checkout.gif\" border=\"0\"></td>";
         }
      }
	  
       strOutput += "</tr></TABLE>";
       


      if ( HiddenFieldsToCheckout ) {
       
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + "&nbsp;" + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + "&nbsp;" + strShipping + "\">";
          strOutput += "<input type=hidden name=\""+OutputOrderMethod+"\" value=\""+ strMethod + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\"" + MonetarySymbol + "&nbsp;" + moneyFormat((fTotal * TaxRate)) + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + "&nbsp;" + moneyFormat((fTotal + fShipping)) + "\">";
	  }
   }
   
   g_TotalCost = (fTotal + fShipping);

   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;
      }
   }

   if (theForm.shipMethod.selectedIndex == 0) {
	     alert( ShippingRegionPrompt );
         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 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 fShipping      = 0;    //Shipping amount
   var strMethod      = "";    //Shipping Method
   var strTotal       = "";   //Total cost formatted as money
   var strTLabel      = "Total";   //Total cost per line
   var strThLabel     = "";  //Image label
   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
   var fprodttl       = 0; //Total product cost = QTY * PRICE
   var weight         = 0; 
   var fcoupon        = 0;
   var coupon         = ""; //code entered for the coupon

	

   iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;
      
    couponcode = GetCookie( 'coupon' );
    
   
      
    shipMethod = GetCookie( 'ShippingMeth' );
    
 
    
    if ( shipMethod == null) {
        shipMethod = 'ground';
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );
   }
   

   if ( TaxByRegion ) {
      QueryString_Parse();
      fTax = parseFloat( QueryString( OutputOrderTax ) );
      strTax = moneyFormat(fTax);
     
   }

   if ( bDisplay )
      strOutput = "<TABLE id=\"myTable\" cellpadding=0 cellspacing=0 border=0><TR>" +
       		  "<TD>Artikel</TD>" +
                  "<TD align=\"center\">Menge</TD>" +
                  "<TD align=\"right\">St&uuml;ckpreis</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);
      Token5 = database.indexOf("|", Token4+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );                 // Product Image
      fields[1] = database.substring( Token0+1, Token1 );          // Product ID
      fields[2] = database.substring( Token1+1, Token2 );          // Quantity
      fields[3] = database.substring( Token2+1, Token3 );          // Price
      fields[4] = database.substring( Token3+1, Token4 );          // Product Name/Description
      fields[5] = database.substring( Token4+1, Token5 ); 		  //Shipping Cost
      fields[6] = database.substring( Token5+1, database.length ); //Additional Information

      fprodttl = (parseInt(fields[2]) * parseFloat(fields[3]) );
      fTotal     += (parseInt(fields[2]) * parseFloat(fields[3]) );
      weight     += (parseInt(fields[2]) * parseFloat(fields[5]) );
      fItems += parseInt( fields[2] ); //Added to allow shipping increases based on qty
       
      if ( !TaxByRegion ) fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      if ( !TaxByRegion ) strTax = moneyFormat(fTax);
      strShipping = moneyFormat(fShipping);

      if ( bDisplay ) {
       	    
         if ( fields[6] == "" )
            strOutput += "<TD bgcolor=\"#CCCCCC\">" + fields[4] + "</TD>";
         else
            strOutput += "<TD bgcolor=\"#CCCCCC\">"  + fields[4] + " - " + fields[6] + "</TD>";

         strOutput += "<TD bgcolor=\"#CCCCCC\" align=\"center\">" + fields[2] + "</TD>";
         strOutput += "<TD bgcolor=\"#CCCCCC\" align=\"right\">" + moneyFormat(fields[3]) + "&nbsp;" + MonetarySymbol + "</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[1] + ", " + fields[4];
         if ( fields[6] != "" )
            strPP += " - " + fields[6];
         strPP += ", Qty. " + fields[2] + "\n";
      } else {
     
         strOutput += "<input type=hidden name=\"" + OutputItemTh        + strFooter + "\" value=\"" + fields[0] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[1] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[2] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + fields[3] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[4] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[5] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[6] + "\">";
        
      } 

   }
   
       var gShipping = 0;


//=========================================SHIPPING==========\\		  
// Versandkosten für Deutschland		  
    if ( shipMethod == "ground") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 0.65};
        if (weight <= 50 && weight > 20){fShipping += 0.95};
        if (weight <= 200 && weight > 50){fShipping += 1.55};
        if (weight <= 1000 && weight > 200){fShipping += 2.35};
        if (weight <= 2000 && weight > 1000){fShipping += 4.20};
        if (weight <= 10000 && weight > 2000){fShipping += 7.50};
        if (weight  > 10000){fShipping += 11.20};
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );        
    }


// Versandkosten für EU
    if ( shipMethod == "priority") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 0.90};
        if (weight <= 50 && weight > 20){fShipping += 1.40};
        if (weight <= 100 && weight > 50){fShipping += 2.60};
        if (weight <= 500 && weight > 100){fShipping += 4.80};
        if (weight <= 2000 && weight > 500){fShipping += 9.80};
        if (weight <= 5000 && weight > 2000){fShipping += 20.00};
        if (weight <= 10000 && weight > 5000){fShipping += 24.00};
        if (weight  > 10000){fShipping += 34.00};
        SetCookie( "ShippingMeth", 'priority', "persistent", "/" );
    }

// Versandkosten weltweit

    if ( shipMethod == "overnight") {
        if (weight <= 0){fShipping += 0.00}
        if (weight <= 20 && weight > 0){fShipping += 2.40};
        if (weight <= 50 && weight > 20){fShipping += 2.80};
        if (weight <= 100 && weight > 50){fShipping += 5.00};
        if (weight <= 500 && weight > 100){fShipping += 8.70};
        if (weight <= 2000 && weight > 500){fShipping += 13.50};
        if (weight <= 5000 && weight > 2000){fShipping += 39.00};
        if (weight <= 10000 && weight > 5000){fShipping += 55.00};
        if (weight  > 10000){fShipping += 85.00};
        SetCookie( "ShippingMeth", 'overnight', "persistent", "/" );


    }
    
     if ( shipMethod == "pickup") {
	fShipping = 0;
        SetCookie( "ShippingMeth", 'pickup', "persistent", "/" );
        
    }



 //===============================START ADVANCED DROPDOWN MOD================||   
  
  groundTEXT = ((fShipping));
  strgroundTEXT = moneyFormat(groundTEXT);
  priorityTEXT = ((fShipping));
  strpriorityTEXT = moneyFormat(priorityTEXT);
  overnightTEXT = ((fShipping));
  strovernightTEXT = moneyFormat(overnightTEXT);
 
  
  
  //===============================END ADVANCED DROPDOWN MOD================||  
   


strTotal = moneyFormat(fTotal); 
strTax = moneyFormat(fTax); 
strShipping = moneyFormat(fShipping); 
   //gShipping?
  

   if ( bDisplay ) {
      strOutput += "<TR><TD align=right colspan=2>Zwischensumme:</TD>";
      strOutput += "<TD ALIGN=RIGHT>" + strTotal + "&nbsp;" + MonetarySymbol + "</TD>";
      strOutput += "</TR>";
                


//=========================================SHIPPING==========\\		  
	 shipMethod = GetCookie( 'ShippingMeth' );
    if ( shipMethod == null) {
        shipMethod = 'ground';
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );
    }

	if ( shipMethod == "ground") {
	strMethod = "Deutschland";
        SetCookie( "ShippingMeth", 'ground', "persistent", "/" );
    }
    if ( shipMethod == "priority") {
	strMethod = "innerhalb der EU";
        SetCookie( "ShippingMeth", 'priority', "persistent", "/" );
    }
    if ( shipMethod == "overnight") {
	strMethod = "Weltweit";
        SetCookie( "ShippingMeth", 'overnight', "persistent", "/" );
    }

   
   strShipping = moneyFormat( fShipping ); 
   
//===============================END SHIPPING================||  


     if ( DisplayTaxRow || TaxByRegion ) {
         strOutput += "<TR><TD COLSPAN=2 align=right>darin 19% MwSt. enthalten:</TD>";
         strOutput += "<TD ALIGN=RIGHT>" + strTax + "&nbsp;" + MonetarySymbol + "</TD>";
	 strOutput += "</TR>";
      }


      if ( DisplayShippingRow ) {
         strOutput += "<TR><TD COLSPAN=2 align=\"right\" bgcolor=\"#CCCCCC\">Versandkosten&nbsp;" +strMethod+ ":</TD>";
         strOutput += "<TD ALIGN=\"RIGHT\" bgcolor=\"#CCCCCC\">" + strShipping + "&nbsp;" + MonetarySymbol + "</TD>";
         strOutput += "</TR>";
      }


      strOutput += "<TR><TD colspan=2 align=right><B>Gesamt:</B></TD>";
      strOutput += "<TD ALIGN=RIGHT><b>" + moneyFormat((fTotal + fShipping)) + "&nbsp;" + MonetarySymbol + "</b></TD>";      
      
      strOutput += "</TR>";
      strOutput += "<tr><td colspan=3 bgcolor=\"#CCCCCC\"><table><tr><td><a href=\"managecart.html\"><img src=\"../img/back_to_cart.gif\" width=\"150\" height=\"18\" border=\"0\" vspace=\"2\" hspace=\"5\">";
      strOutput += "</a></td><td><span class=\"smallText\">Um Bestellungen zu &auml;ndern zur&uuml;ck zum Warenkorb.</span></td></tr></table></td></tr>";

      strOutput += "</TABLE>";
     

      
      if ( PaymentProcessor == 'an') {
         //Process this for Authorize.net WebConnect
         strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
         strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
         strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
         //strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
		 strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping)) + "\">";
      }  
         else {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + "&nbsp;" + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + "&nbsp;" + strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderMethod+"\"   value=\""+ strMethod + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + "&nbsp;" + moneyFormat((fTotal * TaxRate)) + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + "&nbsp;" + moneyFormat((fTotal + fShipping)) + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderAmount+"\"    value=\""+ moneyFormat((fTotal + fShipping)) + "\">";      
	  }
   }

   document.write(strOutput);
   document.close();
}








//=====================================================================||
//               END NOP Design SmartPost Shopping Cart                ||
//=====================================================================||




//==================================================================================||
//             BEGIN SmartPost Shopping Cart Items in Cart   modification           ||
//==================================================================================||
//

//---------------------------------------------------------------------|| 
// 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 


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); 
Token5 = database.indexOf("|", Token4+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product Thumbnail
fields[1] = database.substring( Token0+1, Token1 );// Product ID 
fields[2] = database.substring( Token1+1, Token2 ); // Quantity 
fields[3] = database.substring( Token2+1, Token3 ); // Price 
fields[4] = database.substring( Token3+1, Token4 ); // Product Name/Description 
fields[5] = database.substring( Token4+1, Token5 ); // Weight 
fields[6] = database.substring( Token5+1, database.length ); //Additional Information 

fTotal += (parseInt(fields[2]) * parseFloat(fields[3]) ); 

} 

strTotal = moneyFormat(fTotal); 
strOutput+=strTotal; 
if ( bSymbol ) 
strOutput =  strOutput + "&nbsp;" + MonetarySymbol  
document.write(strOutput); 

} 

//---------------------------------------------------------------------|| 
// FUNCTION: Print_total_products || 
// PARAMETERS: true/false if you want "item(s)" added to string || 
// RETURNS: Total cost currently racked up by shopper || 
// PURPOSE: Aesthetics || 
//---------------------------------------------------------------------|| 
function Print_total_products(bVerbose) { 
var strOutput = ""; //String to be written to page 
var fTotal = 0; 
var 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); 
Token5 = database.indexOf("|", Token4+1); 

fields = new Array; 
fields[0] = database.substring( 0, Token0 ); // Product Thumbnail 
fields[1] = database.substring( Token0+1, Token1 );// Product ID 
fields[2] = database.substring( Token1+1, Token2 ); // Quantity 
fields[3] = database.substring( Token2+1, Token3 ); // Price 
fields[4] = database.substring( Token3+1, Token4 ); // Product Name/Description 
fields[5] = database.substring( Token4+1, Token5 ); // Weight 
fields[6] = database.substring( Token5+1, database.length ); //Additional Information 

fTotal += (parseInt(fields[2])); 

} 

strOutput+=fTotal; 
if ( bVerbose ) { 
if (fTotal == 1) { 
strOutput+=" Artikel" 
} 
else { 
strOutput+=" Artikel" 
} 
} 
document.write(strOutput); 

} 

//---------------------------------------------------------------------|| 
// FUNCTION: Cart_is_empty                                             || 
// PARAMETERS: none                                                    || 
// RETURNS: Total true if cart is empty, false otherwise               || 
// PURPOSE: Aesthetics                                                 || 
//---------------------------------------------------------------------|| 
function Cart_is_empty( ) { 
iNumInCart = GetCookie("NumberOrdered"); 

if ( iNumInCart == null ) iNumInCart = 0; 

if ( iNumInCart == 0 ) return true; 

return false; 

} 



//==================================================================================||
//             END SmartPost Shopping Cart Items in Cart   modification             ||
//==================================================================================||
//


//---------------------------------------------------------------------|| 
// FUNCTION: cleanCart                                                 || 
// PARAMETERS: none                                                    || 
// RETURNS: none                                                       || 
// PURPOSE: Clears the cookies after checkout                          || 
//---------------------------------------------------------------------|| 

function cleanCart(){ 
   var iNumberOrdered = GetCookie("NumberOrdered"); 
   if ( iNumberOrdered == null ){ 
         iNumberOrdered = 0; 
   } 
   for ( i = 1; i <= iNumberOrdered; i++ ) { 
         NewOrder = "Order." + i; 
         DeleteCookie(NewOrder, "/"); 
   } 
   DeleteCookie("NumberOrdered", "/"); 
}

 


