// Funktion Warenkorb

var ABO = 0;
var ABOPreis = 0;

var OSTEREI = 0;

function Warenkorb(param)
         {
         var d    = f_o.f_o_i.document;
         var text = "";
         var Preis, MwSt,Gesamt1=0 ,Gesamt2=0, GMwSt=0, zw, zw1, zw2, zw3, AID;

         for (var i=0 ; i < BestCount ; i++)
             {
             AID = Best[i][BArtNr];

             Preis = Math.round(Best[i][BPreis]*(1+Best[i][BMwSt]/10000))/100;
             MwSt  = Best[i][BPreis]*Best[i][BMwSt]/1000000;

             text += '<TR>';

             text += tdstart("c",0);
             text += '<A class="txt2br" href="javascript: aendern('+i+');">ändern</A>';
             text += '</TD>';

             text += tdstart("c",0);
             text += '<INPUT class="txt2" TYPE="Text" NAME="A'+i+'" VALUE="'+Best[i][BStk]+'" SIZE="3" MAXLENGTH="3">';
             text += '</TD>';

             text += tdstart("l",0);
             text += '<TABLE border="0" cellspacing="0" cellpadding="0" >';
             text += '<TR><TD align="left" class="txt2" >'+PRODUKT[AID][PName]+'</TD></TR>';
             if (Best[i][BArt] == 1) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BFarbe]+' )</TD></TR>';
             if (Best[i][BArt] == 2) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BGroesse]+' )</TD></TR>';
             if (Best[i][BArt] == 3) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BFarbe]+', '+Best[i][BGroesse]+' )</TD></TR>';
             text += '<TR><TD align="left" class="txt2" ><hr noshade size="1" class="txt2"></TD></TR>';
             text += '<TR><TD align="left" class="txt2" >';
             if (PRODUKT[AID][PBildK] != "0") text += '<IMG width="50" SRC="'+ PRODUKT[AID][PBildK] +'" BORDER="1" ALT="" align="left" vspace="5" hspace="5" >';
             text += PRODUKT[AID][PTextK];
             text += '</TD></TR>';
             text += '<TR><TD align="left" class="txt2" ><hr noshade size="1" class="txt2"></TD></TR>';
             text += '<TR><TD align="right" class="txt2" >Art.Nr : '+PRODUKT[AID][PArtNr]+'</TD></TR>';
             text += '</TABLE>';
             text += '</TD>';

             zw    = FormatZahl(String(Preis));
             zw1   = FormatZahl(String(MwSt));

             text += tdstart("r",0);
             text += '<B>'+zw+' '+Best[i][BWaehrung]+'</B>';
             text += '</TD>';

             zw1   = Preis*Best[i][BStk];
             zw    = FormatZahl(String(zw1));

             Gesamt1 += zw1;

             zw1   = (Best[i][BPreis]-Best[i][BRabatt]);
             zw2   = (Math.round(zw1*(1+Best[i][BMwSt]/10000))/100)*Best[i][BStk];
             zw3   = (zw1*Best[i][BMwSt]/1000000)*Best[i][BStk];
             zw2   = (Math.round(zw2*100))/100;
             zw    = FormatZahl(String(zw2));
             zw1   = FormatZahl(String(zw3));

             Gesamt2 += zw2;
             GMwSt   += zw3;

             text += tdstart("r",90);
             text += '<B class="txt10br">'+zw+' '+Best[i][BWaehrung]+'</B>';
             text += '</TD>';

             text += '<TD valign="top" class="txt2" align="center">';
             text += '<A class="txt2br" href="javascript: loeschen('+i+');">löschen</A>';
             text += '</TD>';

             text += '</TR>';

             text += '<TR><TD align="center" colspan="8"><hr width="90%" class="txt10b" noshade size="1"></TD></TR>';
             }


         if (Gesamt1 != 0 || GTSID > 0)
            {
            Gesamt1 = (Math.round(Gesamt1*100))/100;
            Gesamt2 = (Math.round(Gesamt2*100))/100;

            text += '<TR>';
            text += '<TD colspan="4" valign="top" class="txt2" align="right">';
            text += 'Gesamtpreis :&nbsp;';
            text += '</TD>';

            zw1   = Gesamt1;
            zw    = FormatZahl(String(zw1));

            zw2   = Gesamt2;
            zw3   = GMwSt;
            zw    = FormatZahl(String(zw2));
            zw1   = FormatZahl(String(zw3));

            text += tdstart("r",0);
            text += '<B class="txt1">'+zw+' '+Best[0][BWaehrung]+'</B>';
            text += '</TD>';


            text += '<TD valign="middle" class="txt10n" align="center">';
            text += '&nbsp;';
            text += '</TD>';

            text += '</TR>';

            if (GTSID > 0)
               {
               text += '<TR>';
               text += '<TD colspan="4" valign="top" class="txt2" align="right">';
               text += 'abzüglich Gutschein ( Nr. '+ GTSNR +' ) :&nbsp;-&nbsp;';
               text += '</TD>';

               zw1   = GTSWT/100;
               zw    = FormatZahl(String(zw1));

               text += tdstart("r",0);
               text += '<B class="txt1">'+zw+' '+Best[0][BWaehrung]+'</B>';
               text += '</TD>';


               text += '<TD valign="middle" class="txt10n" align="center">';
               text += '&nbsp;';
               text += '</TD>';

               text += '</TR>';
               text += '<TR>';
               text += '<TD colspan="4" valign="top" class="txt2" align="right">&nbsp;</TD>';
               text += tdstart("r",0);
               text += '<hr width="100%" class="txt10b" noshade size="1">';
               text += '</TD>';
               text += '<TD valign="middle" class="txt10n" align="center">';
               text += '&nbsp;';
               text += '</TD>';
               text += '</TR>';

               Gesamt3 = Gesamt1 - (GTSWT/100) ;
               if (Gesamt3 < 0) Gesamt3 = 0;

               text += '<TR>';
               text += '<TD colspan="4" valign="top" class="txt2" align="right">';
               text += 'Bestellwert :&nbsp;';
               text += '</TD>';

               zw1   = Gesamt3;
               zw    = FormatZahl(String(zw1));

               text += tdstart("r",0);
               text += '<B class="txt1">'+zw+' '+Best[0][BWaehrung]+'</B>';
               text += '</TD>';

               text += '<TD valign="middle" class="txt10n" align="center">';
               text += '&nbsp;';
               text += '</TD>';

               text += '</TR>';
               }

            }
         d.write(text);
         }

function Warenkorb1()
         {
         var d    = f_o.f_o_i.document;
         var text = "";
         var Preis, MwSt,Gesamt1=0 ,Gesamt2=0, GMwSt=0, zw, zw1, zw2, zw3;
         var GeSu = 0;

         for (var i=0 ; i < BestCount ; i++)
             {
             AID = Best[i][BArtNr];

             Preis = Math.round(Best[i][BPreis]*(1+Best[i][BMwSt]/10000))/100;
             MwSt  = Best[i][BPreis]*Best[i][BMwSt]/1000000;

             text += '<TR>';


             text += tdstart("c",0);
             text += Best[i][BStk];
             text += '</TD>';

             text += tdstart("l",0);

             text += '<TABLE border="0" cellspacing="0" cellpadding="0" >';
             text += '<TR><TD align="left" class="txt2" >'+PRODUKT[AID][PName]+'</TD></TR>';
             if (Best[i][BArt] == 1) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BFarbe]+' )</TD></TR>';
             if (Best[i][BArt] == 2) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BGroesse]+' )</TD></TR>';
             if (Best[i][BArt] == 3) text += '<TR><TD align="left" class="txt2" >( '+Best[i][BFarbe]+', '+Best[i][BGroesse]+' )</TD></TR>';
             text += '<TR><TD align="left" class="txt2" ><hr noshade size="1" class="txt2"></TD></TR>';
             text += '<TR><TD align="left" class="txt2" >';
             if (PRODUKT[AID][PBildK] != "0") text += '<IMG width="50" SRC="'+ PRODUKT[AID][PBildK] +'" BORDER="1" ALT="" align="left" vspace="5" hspace="5" >';
             text += PRODUKT[AID][PTextK];
             text += '</TD></TR>';
             text += '<TR><TD align="left" class="txt2" ><hr noshade size="1" class="txt2"></TD></TR>';
             text += '<TR><TD align="right" class="txt2" >Art.Nr : '+PRODUKT[AID][PArtNr]+'</TD></TR>';
             text += '</TABLE>';

             text += '</TD>';

             zw    = FormatZahl(String(Preis));
             zw1   = FormatZahl(String(MwSt));

             text += tdstart("r",0);
             text += '<B>'+zw+' '+Best[i][BWaehrung]+'</B><BR>';
             text += '('+zw1+' '+Best[i][BWaehrung]+')';
             text += '</TD>';

             zw1   = Preis*Best[i][BStk];
             zw    = FormatZahl(String(zw1));

             Gesamt1 += zw1;

             zw1   = (Best[i][BPreis]-Best[i][BRabatt]);
             zw2   = (Math.round(zw1*(1+Best[i][BMwSt]/10000))/100)*Best[i][BStk];
             zw2   = (Math.round(zw2*100))/100;
             zw3   = (zw1*Best[i][BMwSt]/1000000)*Best[i][BStk];
             zw    = FormatZahl(String(zw2));
             zw1   = FormatZahl(String(zw3));

             Gesamt2 += zw2;
             GMwSt   += zw3;

             text += tdstart("r",90);
             text += '<B class="txt2">'+zw+' '+Best[i][BWaehrung]+'</B><BR>';
             text += '('+zw1+' '+Best[i][BWaehrung]+')';
             text += '</TD>';

             text += '</TR>';

             text += '<INPUT value="'+Best[i][BArtNr]+'"   name="PIDS['+i+']" type="hidden">';
             text += '<INPUT value="'+Best[i][BStk]+'"     name="ANZS['+i+']" type="hidden">';
             text += '<INPUT value="'+Best[i][BRabatt]+'"  name="RABS['+i+']" type="hidden">';
             if (Best[i][BFarbe])   text += '<INPUT value="'+Best[i][BFarbe]+'"   name="FARS['+i+']" type="hidden">';
             if (Best[i][BGroesse]) text += '<INPUT value="'+Best[i][BGroesse]+'" name="GROS['+i+']" type="hidden">';


             if (OSTEREI == 1) text += '<INPUT value="1" name="OSTEREI" type="hidden">';

             text += '<TR><TD align="center" colspan="4"><hr width="100%" class="txt10b" noshade size="1"></TD></TR>';
             }



         if (Gesamt1 != 0 || GTSID > 0)
            {
            Gesamt1 = (Math.round(Gesamt1*100))/100;
            Gesamt2 = (Math.round(Gesamt2*100))/100;

            text += '<TR>';
            text += '<TD colspan="2" valign="middle" class="txt10n" align="center">';
            text += '&nbsp;';
            text += '</TD>';

            zw1   = Gesamt1;
            zw    = FormatZahl(String(zw1));

           GeSu = zw1*100;

            text += tdstart("r",0);
            text += zw+' '+Best[0][BWaehrung];
            text += '</TD>';

            zw2   = Gesamt2;
            zw3   = GMwSt;
            zw    = FormatZahl(String(zw2));
            zw1   = FormatZahl(String(zw3));

            text += tdstart("r",0);
            text += '<B class="txt2b">'+zw+' '+Best[0][BWaehrung]+'</B><BR>';
            text += '('+zw1+' '+Best[0][BWaehrung]+')';
            text += '</TD>';

            zw1   = (Gesamt1-Gesamt2)*100/Gesamt1;
            zw1   = Math.round(zw1*100)/100;
            zw    = FormatZahl(String(zw1));

            text += '</TR>';

            text += '<TR><TD colspan="2">&nbsp;</TD><TD colspan="2"><hr width="100%" noshade size="1"></TD></TR>';

            text += '<TR>';
            text += '<TD valign="middle" class="txt2" align="center">';
            text += '&nbsp;';
            text += '</TD>';

            if (VersandBis)
               {
               if (Gesamt2 >= VersandBis/100) Versand = 0;
               }
            zw = Versand;

            text += '<TD colspan="2" valign="middle" class="txt2" align="right">';
            text += VersandTxt+"&nbsp;+&nbsp;";
            text += '</TD>';

            zw2   = Versand/100;
            zw    = FormatZahl(String(zw2));

            text += tdstart("r",0);
            text += zw+' '+Best[0][BWaehrung];
            text += '</TD>';

            text += '</TR>';

            text += '<TR><TD colspan="2">&nbsp;</TD><TD colspan="2"><hr width="100%" noshade size="1"></TD></TR>';

            text += '<TR>';
            text += '<TD valign="middle" class="txt10n" align="center">';
            text += '&nbsp;';
            text += '</TD>';

            text += '<TD colspan="2" valign="middle" class="txt2" align="right">';
            text += GesamtTxt+"&nbsp;&nbsp;&nbsp;&nbsp;";
            text += '</TD>';

            zw2   = Gesamt2 + Versand/100;
            zw    = FormatZahl(String(zw2));

            text += tdstart("r",0);
            text += '<B class="txt1b">'+zw+' '+Best[0][BWaehrung]+'</B>';
            text += '</TD>';


            text += '</TR>';

            if (GTSID > 0)
               {
               text += '<INPUT value="'+GTSID+'"   name="GTSID" type="hidden">';
               text += '<TR>';
               text += '<TD colspan="3" valign="top" class="txt2" align="right">';
               text += 'abzüglich Gutschein ( Nr. '+ GTSNR +' )&nbsp;-&nbsp;';
               text += '</TD>';

               zw1   = GTSWT/100;
               zw    = FormatZahl(String(zw1));

               text += tdstart("r",0);
               text += '<B class="txt1">'+zw+' '+Best[0][BWaehrung]+'</B>';
               text += '</TD>';

               text += '</TR>';
               text += '<TR><TD colspan="2">&nbsp;</TD><TD colspan="2"><hr width="100%" noshade size="1"></TD></TR>';
               Gesamt9 = zw2 - (GTSWT/100) ;
               if (Gesamt9 < 0) Gesamt9 = 0;

               GeSu = Gesamt9*100

               text += '<TR>';
               text += '<TD colspan="3" valign="top" class="txt2" align="right">';
               text += 'Bestellwert&nbsp;&nbsp;&nbsp;&nbsp;';
               text += '</TD>';

               zw1   = Gesamt9;
               zw    = FormatZahl(String(zw1));

               text += tdstart("r",0);
               text += '<B class="txt1">'+zw+' '+Best[0][BWaehrung]+'</B>';
               text += '</TD>';

               text += '</TR>';
               }
            }

//         alert (GeSu+" - "+ABOPreis);
         if (ABO == 1 && GeSu >= ABOPreis)
            {
            spid=holeShop();
            if (spid == 6)
               {
               text += '<TR><TD colspan="4">';
               text += '<TABLE width="100%" cellspacing="0" cellpadding="0" border="0">';
               text += '<TR><TD align="center"><hr width="90%" noshade size="1"></TD></TR>';
               text += '<TR><TD align="center"><TABLE width="90%" cellspacing="0" cellpadding="0" border="0">';
               text += '<TR><TD width="115" align="left" valign="middle"><IMG bordercolor="#000000" SRC="images/emgp.jpg" WIDTH="100" BORDER="1" ALT="Test-ABO der Zeitung -- EUROSPORT MOTOMAGAZIN"></TD>';
               text += '<TD valign="top" align="left" class="txt2"><B>Testabonnement der Zeitschrift "EUROSPORT MOTOMAGAZIN"</B><BR><BR>Als Dankeschön an unsere treuen Kunden haben Sie hier die Möglichkeit von uns ein kostenfreies Test-Abonement der neuen Zeitschrift <B>"EUROSPORT MOTOMAGAZIN"</B> ( 3 Ausgaben ) zu erhalten.<BR><BR>Möchten Sie dieses Angebot nutzen, dann vergessen Sie bitte nicht das Häkchen zu setzen.<P align="right">Ich möchte dieses kostenfreie Test-Abonnement bekommen <INPUT TYPE="Checkbox" NAME="TESTABO" VALUE="5"> !</P></TD></TR><TR><TD align="left" colspan="2" class="txt3"><BR><B>Vertrauensgarantie:</B> Mir ist bekannt, dass ich diese Bestellung innerhalb von 14 Tagen schriftlich beim Motiv Medien Abo Service · Postfach 13 31 · 53335 Meckenheim widerrufen kann. Zur Wahrung der Frist genügt das rechtzeitige Absenden des Widerrufs (Datum des Poststempels). Bitte beachten! Das Abonnement verlängert sich automatisch um den Bezug von 12 Ausgaben EUROSPORT MOTOMAGAZIN, wenn es nicht spätestens eine Woche nach Erhalt der Folgerechnung schriftlich gekündigt wird.<BR><BR>Dieses kostenfreie Angebot gilt nur für Kunden aus Deutschland. Waren oder sind Sie schon Abonnent dieser Zeitschrift, können wir Ihnen dieses GRATIS Test-Abo nicht ermöglichen.</TD></TR>';
               text += '</TABLE></TD></TR>';
               text += '</TABLE>';
               text += '</TD></TR>';
               }
            else
               {
               text += '<TR><TD colspan="4">';
               text += '<TABLE width="100%" cellspacing="0" cellpadding="0" border="0">';
               text += '<TR><TD align="center"><hr width="90%" noshade size="1"></TD></TR>';
               text += '<TR><TD align="center"><TABLE width="90%" cellspacing="0" cellpadding="0" border="0">';
               text += '<TR><TD width="115" align="left" valign="middle"><IMG bordercolor="#000000" SRC="images/h0502-k.jpg" WIDTH="100" BORDER="1" ALT="Test-ABO der Zeitung -- FORMEL aktuell"></TD>';
               text += '<TD valign="top" align="left" class="txt2"><B>Testabonnement der Zeitschrift "FORMEL aktuell"</B><BR><BR>Als Dankeschön an unsere treuen Kunden haben Sie hier die Möglichkeit von uns ein kostenfreies Test-Abonement der neuen Zeitschrift <B>"FORMEL aktuell"</B> ( 3 Ausgaben ) zu erhalten.<BR><BR>Möchten Sie dieses Angebot nutzen, dann vergessen Sie bitte nicht das Häkchen zu setzen.<P align="right">Ich möchte dieses kostenfreie Test-Abonnement bekommen <INPUT TYPE="Checkbox" NAME="TESTABO" VALUE="1"> !</P></TD></TR><TR><TD align="left" colspan="2" class="txt3"><BR><B>Vertrauensgarantie:</B> Mir ist bekannt, dass ich diese Bestellung innerhalb von 14 Tagen schriftlich beim Motiv Medien Abo Service · Postfach 13 31 · 53335 Meckenheim widerrufen kann. Zur Wahrung der Frist genügt das rechtzeitige Absenden des Widerrufs (Datum des Poststempels). Bitte beachten! Das Abonnement verlängert sich automatisch um den Bezug von 12 Ausgaben FORMEL aktuell, wenn es nicht spätestens eine Woche nach Erhalt der Folgerechnung schriftlich gekündigt wird.<BR><BR>Dieses kostenfreie Angebot gilt nur für Kunden aus Deutschland. Waren oder sind Sie schon Abonnent dieser Zeitschrift, können wir Ihnen dieses GRATIS Test-Abo nicht ermöglichen.</TD></TR>';
               text += '</TABLE></TD></TR>';
               text += '</TABLE>';
               text += '</TD></TR>';
               }
            }
         d.write(text);
         }

function tdstart(t,w)
         {
         var txt = '<TD valign="top" class="txt2"'
         if (w != 0)  txt += ' width="'+w+'"';
         if (t== "l") txt += ' align="left">';
         if (t== "r") txt += ' align="right">';
         if (t== "c") txt += ' align="center">';
         return txt;
         }

function setzeVersand(t,a,txt,Gtxt) { Versand = t; if (OSTEREI == 0) VersandBis = a; VersandTxt = txt; GesamtTxt = Gtxt; }

function setzeAbo(a) { if (OSTEREI == 0) { ABO = 1; ABOPreis = a; } }
function deleteAbo() { ABO = 0; }

function setzeOsterei()
         {
         OSTEREI = 1;
         VersandBis = 100;
         ABO = 1;
         ABOPreis = 1;
         }
