
// Drachenland
//
// Javascript-Shop Version 1.5 ohne Cookies! (c) Georg Conrad Januar 2002
// DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
//-----------------------------------------------------------------------



function show( Name, Datei ) { document[Name].src=Datei; }



function BuildButtonRoot( ButtonName )
{
  if( wievielArtikel( ButtonName ) == 0 )
  {
    document.write( 
      " <a href=\"javascript:merken(\'"+ButtonName+"\')\" " +
      " title=\"diesen Artikel in den Warenkorb legen...\" " +
      " onmouseout=\'show(\""+ButtonName+"\",\"-/Shop/plusPunkt.gif\")\' " +
      " onmouseover=\'show(\""+ButtonName+"\",\"-/Shop/plusPunkt-.gif\")\'> " +
      " <img src=\"-/Shop/plusPunkt.gif\" " +
      " name=\""+ButtonName+"\" " +
      " width=\"20\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
  else
  {
    document.write(
      " <a href=\"Shop/Warenkorb.shtml\" " +
      " title=\"... liegt bereits im Warenkorb\"> " +
      " <img src=\"-/Shop/plusPunkt-.gif\" " +
      " width=\"20\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
}



function BuildTextButton( ButtonName )
{
  if( wievielArtikel( ButtonName ) == 0 )
  {
    document.write( 
      " <a href=\"javascript:merken(\'"+ButtonName+"\')\" " +
      " title=\"diesen Artikel in den Warenkorb legen...\" " +
      " onmouseout=\'show(\""+ButtonName+"\",\"../-/Shop/Text-plusPunkt.gif\")\' " +
      " onmouseover=\'show(\""+ButtonName+"\",\"../-/Shop/Text-plusPunkt-.gif\")\'> " +
      " <img src=\"../-/Shop/Text-plusPunkt.gif\" " +
      " name=\""+ButtonName+"\" " +
      " width=\"114\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
  else
  {
    document.write(
      " <a href=\"../Shop/Warenkorb.shtml\" " +
      " title=\"... liegt bereits im Warenkorb\"> " +
      " <img src=\"../-/Shop/Text-plusPunkt-.gif\" " +
      " width=\"114\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
}




function BuildTextButtonRoot( ButtonName )
{
  if( wievielArtikel( ButtonName ) == 0 )
  {
    document.write( 
      " <a href=\"javascript:merken(\'"+ButtonName+"\')\" " +
      " title=\"diesen Artikel in den Warenkorb legen...\" " +
      " onmouseout=\'show(\""+ButtonName+"\",\"-/Shop/Text-plusPunkt.gif\")\' " +
      " onmouseover=\'show(\""+ButtonName+"\",\"-/Shop/Text-plusPunkt-.gif\")\'> " +
      " <img src=\"-/Shop/Text-plusPunkt.gif\" " +
      " name=\""+ButtonName+"\" " +
      " width=\"114\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
  else
  {
    document.write(
      " <a href=\"Shop/Warenkorb.shtml\" " +
      " title=\"... liegt bereits im Warenkorb\"> " +
      " <img src=\"-/Shop/Text-plusPunkt-.gif\" " +
      " width=\"114\" " +
      " height=\"20\" " +
      " border=\"0\" /> " +
      " </a> "
    );
  }
}




function initFormButton()
{
  for( i = 0; i < document.frm.elements.length; i++ )
    document.frm.elements[i].value = wievielArtikel( document.frm.elements[i].name );
}



function vergessen( was )
{
  if( was == "*" )
  {
    if( confirm( "Warenkorb entleeren?" ) ) 
    {
      self.name = "";
      window.location.reload();
    }
  }
  else
  if( was == "**" )
  {
      self.name = "";
  }
    self.name = self.name.replace( was + "::", "" );
}



function merken( neu )
{
  self.name +=  neu + "::";
  //  bleibt auf der jeweiligen Seite
  window.location.reload();
  // spring auf jeden Fall zum Warenkorb 
  // klappt jedoch nur aus dem Root 
  // window.location.href = "Shop/Warenkorb.shtml";
}



function merkeNeu( was, n )
{
  chck = true;

  for( i = 0; i < n.length; ++i )
    if( n.charAt(i) < "0" || n.charAt(i) > "9" )
      chck = false;

  if( chck )
  {
    while( self.name.search( was + "::" ) != -1 )
      vergessen( was );

    while( n-- > 0 )
      self.name +=  was + "::";

    window.location.reload();
  }
  else
  {
    alert( "Bitte nur Zahlen eingeben!" );
    initFormButton();
  }
}


function wievielArtikel( was )
{
  was += "::";
  counter = 0;
  Bestellung = self.name;

  while( Bestellung.search( was ) != -1 )
  {
    Bestellung = Bestellung.replace( was, "" );
    counter++;
  }

  return counter;
}



function Punkt00( dm )
{
  dm = dm + 0.001;
  dm = dm.toString();
  dm = dm.substr( 0, dm.indexOf(".") + 3);

  return dm;
}



function Warenkorb( change )
{
  pvp  = 0.50;
  sum  = 0;
  flip = false;
  tr1  = "<tr bgcolor=\"#ffeecc\">";
  tr2  = "<tr>";
  tr3  = "<tr bgcolor=\"#ff9900\">";

     s = "<table>" + tr1 +
         "<td><img height=\"30\" width=\"6\" src=\"../-/nix.gif\" /></td>" +
         "<td width=\"90%\"><b>Artikel Ihrer Bestellung</b></td>" +
         "<td align=\"right\"><b>&nbsp;Euro&nbsp;</b></td>" +
         "<td align=\"right\"><b>&nbsp;St.</b></td>" +
         "<td align=\"right\"><b>&nbsp;Sum&nbsp;</b></td>" +
         "</tr>";

  for( anp = 0; anp < Artikel.length - 1 ; anp += 3 )
  {
    ANr   = Artikel[ anp     ];
    Name  = Artikel[ anp + 1 ];
    Preis = Artikel[ anp + 2 ];

    St = wievielArtikel( ANr );
    if( St )
    {
      if( flip ) { s += tr1; flip = false; }
      else       { s += tr2; flip = true;  }
      s += "<td><img height=\"20\" width=\"6\" src=\"../-/nix.gif\" /></td>" +
           "<td>" + Name + "</td>" +
           "<td align=\"right\">&nbsp;" + Punkt00( Preis ) + "&nbsp;</td>";
      if( change )
        s += "<td align=\"right\"><input type=\"TEXT\" name=\"" + ANr + "\" value=\"" + St + "\" size=\"3\" maxlength=\"2\" onchange=\"merkeNeu(this.name,this.value)\"></td>";
      else 
        s += "<td align=\"right\">&nbsp;" + St + "</td>";
      s += "<td align=\"right\">&nbsp;" + Punkt00( Preis * St ) + "&nbsp;</td>" +
           "</tr>";

      s += "<input type=hidden name=\"" + ANr + "\" value=\"" + Name + "   --> " + St + " * " + Punkt00( Preis ) + " = " + Punkt00( St * Preis ) + "\">";
      sum += Preis * St;
    }
  }

  s += tr3 + "<td colspan=\"6\"><img height=\"1\" width=\"1\" src=\"../-/nix.gif\" /></td></tr>" +
       tr2 + "<td><img height=\"20\" width=\"6\" src=\"../-/nix.gif\" /></td><td colspan=\"2\"align=\"right\"><i>Zwischensumme</i></td><td></td><td align=\"right\"><b>" + Punkt00( sum ) + "&nbsp;</b></td></tr>" +
       tr2 + "<td><img height=\"20\" width=\"6\" src=\"../-/nix.gif\" /></td><td colspan=\"2\"align=\"right\"><i>Porto &amp; Verpackung</i></td><td></td><td align=\"right\"><b>" + Punkt00( pvp ) + "&nbsp;</b></td></tr>" +
       tr1 + "<td><img height=\"20\" width=\"6\" src=\"../-/nix.gif\" /></td><td colspan=\"2\"align=\"right\"><i>Gesamtsumme in Euro inkl. " + Punkt00( sum * 0.07) + " MWSt</i></td><td>&nbsp;</td><td align=\"right\"><b>" + Punkt00( sum + pvp ) + "&nbsp;</b></td></tr>" +
       "</table>";

  s += "<input type=hidden name=\"SUMME\" value=\"" + Punkt00( sum ) + "\">" +
       "<input type=hidden name=\"MWSt\"  value=\"" + Punkt00( sum * 0.07 ) + "\">" +
       "<input type=hidden name=\"PVP\"   value=\"" + Punkt00( pvp ) + "\">" +
       "<input type=hidden name=\"TOTAL\" value=\"" + Punkt00( sum + pvp ) + "\">";

  if( change )
  {
    s += "<div align=\"center\">";
    s += "<br /><a href=\"javascript:history.back()\">&nbsp;zur&uuml;ck zum Einkauf...&nbsp;</a> &#149; ";
    s += "<a href=\"javascript:bestellen()\">&nbsp;Einkauf abschlie&szlig;en&nbsp;</a> &#149; ";
    s += "<a href=\"javascript:vergessen(\'*\')\">&nbsp;Warenkorb l&ouml;schen&nbsp;</a>";
    s += "</div>";
  }
  else
  {
    s += "<div align=\"center\">";
    s += "<br /><a href=\"Warenkorb.shtml\">&nbsp;zur&uuml;ck zum Warenkorb...&nbsp;</a>";
    s += "</div>";
  }
  
  document.write(s);
  document.close();
}



function bestellen()
{
  if( self.name == "" )
    alert("Ihr Warenkorb ist leer!");
  else window.location.href = "Bestellung.shtml"
}


//-----------------------------------------------------------------------
