 function anzeigen(das){
	 if(document.getElementById(das).style.display=='none')
	         document.getElementById(das).style.display='block';
	 else
	         document.getElementById(das).style.display='none';
 }

 function anzeigenm(das,stil){
 	alert(das);
	alert(stil);
	document.getElementById(das).style.display=stil;
 }

 var sichtbar=false;

 function strpos(str, ch) {
   chl=ch.length
   for (var i = 0; i < str.length; i++)
   if (str.substring(i, i+chl) == ch) return i;
   return -1;
 }

 function toggleLieferfelder()
 {
  sichtbar=!sichtbar;
   if (sichtbar==true)
   {
    wert="visible";
   } else {
    wert="hidden";
   }
   document.bf.lAnrede.style.visibility=wert;
   document.bf.lTitel.style.visibility=wert;
   document.bf.lVorname.style.visibility=wert;
   document.bf.lName.style.visibility=wert;
   document.bf.lAdrzeile2.style.visibility=wert;
   document.bf.lAdrzeile3.style.visibility=wert;
   document.bf.lStrasse.style.visibility=wert;
   document.bf.lPLZ.style.visibility=wert;
   document.bf.lOrt.style.visibility=wert;
   document.bf.lLand.style.visibility=wert;
   //document.bf.lEmail.style.visibility=wert;
   document.bf.lTelefon.style.visibility=wert;
   document.getElementById('applyFelder').style.visibility=wert;
 }

 function applyRechAdr()
 {

   document.bf.lAnrede.selectedIndex=document.bf.Anrede.selectedIndex;
   document.bf.lTitel.selectedIndex=document.bf.Titel.selectedIndex;
   document.bf.lVorname.value=document.bf.Vorname.value;
   document.bf.lName.value=document.bf.Name.value;
   document.bf.lAdrzeile2.value=document.bf.Adrzeile2.value;
   document.bf.lAdrzeile3.value=document.bf.Adrzeile3.value;
   document.bf.lStrasse.value=document.bf.Strasse.value;
   document.bf.lPLZ.value=document.bf.PLZ.value;
   document.bf.lOrt.value=document.bf.Ort.value;
   document.bf.lLand.selectedIndex=document.bf.Land.selectedIndex;
   document.bf.lTelefon.value=document.bf.Telefon.value;
 }

function SwapImgRestore() { //v2.0
  if (document.SwapImgData != null)
    for (var i=0; i<(document.SwapImgData.length-1); i+=2)
      document.SwapImgData[i].src = document.SwapImgData[i+1];
}

function SwapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.SwapImgData;
  for (i=0; i < (SwapImage.arguments.length-2); i+=3) {
    objStr = SwapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = SwapImage.arguments[i+2];
  } }
  document.SwapImgData = swapArray; //used for restore
}

function alterError(value)
{

	value=parseInt(value*100+0.5);
	if (isNaN(value) == true)
        value = eval('0');
	newPounds = String(value).substr(0,String(value).length-2);
       if (newPounds == '')
        {newPounds = '0';
	};
        if (isNaN(newPounds) == true)
        newPounds = eval('0');
	newPence = String(value).substr(String(value).length-2,2);
        if (isNaN(newPence) == true)
        newPence = eval('0');
	if (eval(newPence) <= 9) newPence='0'+newPence;
	if (eval(newPence) == 0) newPence='00';
	return(newPounds+'.'+newPence);

}



	function showItems() {
                var tablerowcolor = '#F0F0F0';
		index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		totsum = 0;
		tottrans = 0;
		totweight = 0;
		totkat = 0;
		document.writeln('<FORM action="bfinish.htm" target="_top">');
		document.writeln('<TABLE BORDER=0 CELLPADDING="2">');
		document.writeln('<TR BGCOLOR="#C0C0C0"><TD><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Artikel</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Menge</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Einzelpreis</FONT></b></TD><td align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Gesamtpreis</FONT></b></td></TR>');
                document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="4"><HR></TD></TR>');

		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {

			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theweight = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				itemweight = (eval(theweight*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				totweight = totweight + itemweight;
				itemlist=itemlist+1;

				document.write('<tr BGCOLOR="'+tablerowcolor+'"> <td><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+theitem+'</FONT></td>');
				document.writeln('<td align=right><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+thequantity+'</FONT></td><td align=right><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+theprice+'</FONT></td><td align=right><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+alterError(itemtotal)+'</FONT></td></tr>');
				document.writeln('<INPUT TYPE="hidden" NAME="Produkt'+itemlist+'" VALUE="'+theitem+'">');
				document.writeln('<INPUT TYPE="hidden" NAME="Gewicht'+itemlist+'" VALUE="'+theweight+'">');
				document.writeln('<INPUT TYPE="hidden" NAME="Menge'+itemlist+'" VALUE="'+thequantity+'">');
				document.writeln('<INPUT TYPE="hidden" NAME="Stückpreis'+itemlist+'" VALUE="'+theprice+'">');
 				document.writeln('<INPUT TYPE="hidden" NAME="Summe'+itemlist+'" VALUE="'+alterError(itemtotal)+'">');

                                if (tablerowcolor == '#F0F0F0') {
                                  tablerowcolor = "#F8F8F8";
                                } else {
                                  tablerowcolor = "#F0F0F0";
                                }

			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) thequantity = fulllist.substring(itemstart, i);
				if (thisitem==4) thekat = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}

		totsum = totprice;
		tottrans = 0;
   		if (totweight<360) { tottrans = 1.45; }
		else if (totweight<860) { tottrans = 2.00; }
		else if (totweight<30000) { tottrans = 5.49; }
		else {
		 tottrans = eval(totweight / 30000 * 5.49);
		}
		if (totsum>300.00 && thekat==0) { tottrans = 0; }

		totprice = totsum + tottrans;

        document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="4"><HR></TD></TR>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Summe</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(totsum)+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Versand ('+alterError(totweight)+' g)</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(tottrans)+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Total</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(totprice)+'</FONT></b></td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="Warenkosten" VALUE="'+alterError(totsum)+'">');
		document.writeln('<INPUT TYPE="hidden" NAME="Gesamtgewicht" VALUE="'+alterError(totweight)+'">');
		document.writeln('<INPUT TYPE="hidden" NAME="Versandkosten" VALUE="'+alterError(tottrans)+'">');
		document.writeln('<INPUT TYPE="hidden" NAME="Gesamtkosten" VALUE="'+alterError(totprice)+'">');
		document.writeln('</TABLE>');

	}


	function showItemsext() {
                var tablerowcolor = '#F0F0F0';
                index = document.cookie.indexOf("TheBasket");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		totsum = 0;
		tottrans = 0;
		totweight = 0;
		document.writeln('<FORM NAME="updateform">');
		document.writeln('<div align="left">');
		document.writeln('<TABLE WIDTH=100% BORDER=0 CELLPADDING="2">');
document.writeln('<TR BGCOLOR="#C0C0C0"><TD><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Artikel</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Menge</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Einzelpreis</FONT></b></TD><td align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Gesamtpreis</FONT></b></TD><TD>&nbsp;</TD></TR>');
// Nun die horizontale Linie:
document.writeln('<TR BGCOLOR="F8F8F8"><TD colspan="5"><HR></TD></TR>');

		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theweight = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				itemweight = (eval(theweight*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				totweight = totweight + itemweight;
				itemlist=itemlist+1;
				document.write('<tr valign="top"BGCOLOR="'+tablerowcolor+'"><td><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+theitem+'</FONT></td>');

				document.write('<td valign="top" align="right"><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td><td valign="top" align="right"><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+theprice+'</FONT></td><td valign="top" align="right"><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>'+alterError(itemtotal)+'</FONT></td><td  align="center" valign="top"><a href="javascript:removeItem('+itemlist+')"><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Entfernen</FONT></a>&nbsp;<a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Aktualisieren</FONT></a></td></tr>');

                                if (tablerowcolor == '#F0F0F0') {
                                  tablerowcolor = "#F8F8F8";
                                } else {
                                  tablerowcolor = "#F0F0F0";
                                }



			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) thequantity = fulllist.substring(itemstart, i);
				if (thisitem==4) thekat = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}



		}

		totsum = totprice;
		tottrans = 0;
   		if (totweight<360) { tottrans = 1.45; }
		else if (totweight<860) { tottrans = 2.00; }
		else if (totweight<30000) { tottrans = 5.49; }
		else {
		 tottrans = eval(totweight / 30000 * 5.49);
		}
		if (totsum>300.00 && thekat==0) { tottrans = 0; }

		totprice = totsum + tottrans;

        document.writeln('<TR BGCOLOR="FCFCFC"><TD colspan="5"><HR></TD></TR>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Summe</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(totsum)+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Versand ('+alterError(totweight)+' g)</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(tottrans)+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Total</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>€ '+alterError(totprice)+'</FONT></b></td></tr>');
		document.writeln('</TABLE><cr>');
		document.writeln('</div>');
		document.writeln('</FORM>');
	}

	function amendItem(itemno, newquant) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				thisitem = 1;
				itemstart = i+1;
				fullstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				itemlist=itemlist+1;
				theweight = fulllist.substring(itemstart, itemend);
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
				} else {
					newItemList = newItemList + '['+theitem+'|'+theprice+'|'+newquant+'|'+thekat+'|'+theweight+']';
				}
			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				if (thisitem==3) thequantity = fulllist.substring(itemstart, i);
				if (thisitem==4) thekat = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket="+newItemList;
		location.reload();

	}

	function removeItem(itemno) {
		newItemList = null;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theitem = fulllist.substring(itemstart, itemend);
				itemlist=itemlist+1;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
				}
			}
		}
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket="+newItemList;
		location.reload();
	}

	// clearBasket() - removes all items from the basket
	function clearBasket() {
		if (confirm('Möchten Sie wirklich alle Artikel aus dem Einkaufswagen entfernen?')) {
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
			location.reload();
		}
	}

	function clearBasket2() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}

        function buyItem(newItem, newPrice, newQuantity, newKat, newWeight) {
                if (newQuantity <= 0) {
                        rc = alert('Die eingegebene Menge ist inkorrekt');
                } else {
                        if (confirm(newQuantity+' x '+newItem+' in den Einkaufskorb legen?')) {
                                index = document.cookie.indexOf("TheBasket");
                                countbegin = (document.cookie.indexOf("=", index) + 1);
                                countend = document.cookie.indexOf(";", index);
                                if (countend == -1) {
                                            countend = document.cookie.length;
                                }
                                document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newPrice+"|"+newQuantity+"|"+newKat+"|"+newWeight+"]";
                        }
                }
        }


        function resetShoppingBasket() {
                index = document.cookie.indexOf("TheBasket");
                document.cookie="TheBasket=.";

                if (document.cookie) {
                } else {
                  alert('Sie haben die Verwendung von Cookies deaktiviert.\nDer Onlineshop benötigt aber unbedingt Cookies, um Ihre Bestellung zu speichern.\nBitte aktivieren Sie in Ihrem Browser die Verwendung von Cookies und laden Sie die Shopseiten neu!');
                }

        }


   function checkall(checkboxen, wert)
   {
      for (i=0; i<checkboxen.length; i++)
        {
             if (checkboxen[i].name.substr(0,4)=="list")
			 {
 			 	checkboxen[i].checked = wert.checked;
			 }
		}
   }

   function checksach(checkboxen, sgnr)
   {
      for (i=0; i<checkboxen.length; i++)
        {
             if (checkboxen[i].id==sgnr)
			 {
				 checkboxen[i].checked = !checkboxen[i].checked;
			 }
		}
   }

 function emailCheck (emailPatternString) {
  var emailPattern=/^(.+)@(.+)$/
  var allowedChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
  var allowed2Chars="\[^\\s" + allowedChars + "\]"
  var UserChars="(\"[^\"]*\")"
  var IpdomainPatternStringtern=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
  var atomString=allowed2Chars + '+'
  var StringWord="(" + atomString + "|" + UserChars + ")"
  var UserPatternString=new RegExp("^" + StringWord + "(\\." + StringWord + ")*$")
  var domainPatternString=new RegExp("^" + atomString + "(\\." + atomString +")*$")
  var matchArray=emailPatternString.match(emailPattern)

if (matchArray==null) {
  alert("Die EMail Adresse ist nicht Korrekt (@ und Punkte gesetzt?)")
  return false
}

  var user=matchArray[1]
  var domain=matchArray[2]
if (user.match(UserPatternString)==null) {
  alert("Der Username icht ungültig.")
  return false
}

  var IPArray=domain.match(IpdomainPatternStringtern)
if (IPArray!=null) {
  for (var i=1;i<=4;i++) {
    if (IPArray[i]>255) {
      alert("Die IP Adresse ist ungültig!")
      return false
     }
   } return true
}

var domainArrayString=domain.match(domainPatternString)
if (domainArrayString==null) {
   alert("Der Domain Name ist ungültig.")
   return false
}

var atomStringPat=new RegExp(atomString,"g")
var DomainArray=domain.match(atomStringPat)
var len=DomainArray.length
if (DomainArray[DomainArray.length-1].length<2 || DomainArray[DomainArray.length-1].length>3) {
   alert("Der Domain Name muß mit 2 oder 3 Buchstaben enden")
   return false
}
if (len<2) {
  var errString="Bitte auch den Hostnamen angeben!"
  alert(errString)
  return false
  }
}

function ChangeTicker()
{
  //var aktTicker=(document.getElementById('BuchTickerNr').value);
  //alert (strpos(document.cookie,"BuchTickerNr"));
  if (strpos(document.cookie,"BuchTickerNr")>-1)
  {
                index = document.cookie.indexOf("BuchTickerNr");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
	//alert (document.cookie.substring(countbegin, countend));
    var aktTicker=Number(document.cookie.substring(countbegin, countend));
  }
  else
  {
    var aktTicker=0;
  }
  //alert(document.cookie);
  //alert(aktTicker);
  var TickerCount=(document.getElementById('BuchTickerCount').value);
  if (Number(aktTicker)>Number(TickerCount)) aktTicker=0;

  LoadImage(aktTicker,0);

  var longstring=document.getElementById('BuchTickerLoad#'+aktTicker).value;
  var broken=longstring.split("|");
  setContent("id", "BuchTickerAntiquariat", null, broken[0]);
  setContent("id", "BuchTickerAutor", null, broken[1]);
  setContent("id", "BuchTickerTitel", null, broken[2]);
  setContent("id", "BuchTickerPreis", null, broken[3]+" €");
  setContent("id", "BuchTickerBNr", null, broken[4]);
  document.forms['TickerBestellung'].elements['PNr'].value=broken[5];
  document.forms['TickerBestellung'].elements['BNr'].value=broken[4];
  aktTicker=(Number(aktTicker)+1);

  //document['buchbild'].src = eval("buchbild_h.src");

  //alert("BuchTickerNr="+aktTicker)
  if (Number(aktTicker)>Number(TickerCount)) aktTicker=0;
  document.cookie="BuchTickerNr="+aktTicker;
  //document.getElementById('BuchTickerNr').value=aktTicker;
  setTimeout("ChangeTicker()", 10000);
}

 function LoadImage(aktTicker, piccount)
 {
   var longstring=document.getElementById('BuchTickerLoad#'+aktTicker).value;
   var broken=longstring.split("|");
   var buch;
   bnr=broken[4];
   pfad=broken[6];
   //document.forms['TickerBestellung'].elements['PicPath'].value;
   //alert (pfad);
   //setContent("id", "BuchTickerAntiquariat", null, pfad);
   if (document.forms['TickerBestellung'])
   {
    //if (pfad!=document.forms['TickerBestellung'].elements['PicPath'].value)
    if (piccount<10)
    {
     buchbild=new Image();
     buchbild.src = pfad;
     if (buchbild.complete == false && pfad!='')
     {
         //var loadp="'LoadImage("+aktTicker+")'";
	//alert(loadp);
	setTimeout("LoadImage("+aktTicker+","+(piccount+1)+")",1000);
     }
     //alert (buchbild.fileSize);
     if (buchbild.fileSize<0) {
       buchbild.src = "bilder/empty.gif";
       document.images['buchbild'].width=0;
       document.images['buchbild'].height=0;
     } else {
       document.images['buchbild'].width=(180/buchbild.width)*buchbild.width;
       document.images['buchbild'].height=(180/buchbild.width)*buchbild.height;
	   if (buchbild.width<document.images['buchbild'].width) document.images['buchbild'].width=buchbild.width;
	   if (buchbild.height<document.images['buchbild'].height) document.images['buchbild'].height=buchbild.height;
     }
     document.forms['TickerBestellung'].elements['PicPath'].value=pfad;
     if (document.buchbild) document.images['buchbild'].src=buchbild.src;
     delete buchbild;
    }
   }
 }