	function warenkorb(){
		this.First= null;
		this.Last= this.First;
		this.N="e";
		this.G=null;
		this.Vers=0;
	   	this.Vorname="";
		this.Nachname="";
		this.Strasse="";
		this.Hausnummer="";
		this.Ort="";
		this.Plz="";
		this.Land=0;
		this.Land2="";
		this.Mail="";
		this.Tel="";
		this.GesamtPreis=0;
		this.GesamtNixBuchPreis=0;
		this.GesamtBuchPreis=0;
		this.Anzahl=0;		
		this.getPreis=function getPreis(){
			return Math.round(100* this.GesamtPreis)/100;
		};

		this.getNixBuchPreis=function getBuchPreis(){
			return Math.round(100* this.GesamtNixBuchPreis)/100;
		};	

		this.getBuchPreis=function getBuchPreis(){
			return Math.round(100* this.GesamtBuchPreis)/100;
		};	


		this.insert= function insert (A,B,C,D){
			if(C!=0){
				if (this.First==null){
					this.First=new article (A,B,C,D,0);
					this.Anzahl=1;
					this.GesamtPreis=Math.round((this.GesamtPreis + C*D)*100)/100;
					this.GesamtNixBuchPreis=Math.round((this.GesamtNixBuchPreis + C*D)*100)/100;
					this.Last=this.First;}
				else{
					this.G=new article (A,B,C,D,0);
					this.GesamtPreis=Math.round((this.GesamtPreis + C*D)*100)/100;
					this.GesamtNixBuchPreis=Math.round((this.GesamtNixBuchPreis + C*D)*100)/100;
					this.Anzahl+= 1;
					this.Last.Next=this.G;
					this.Last=this.G;};
			};
		};

		this.insert2= function insert2 (A,B,C,D,E){
			if(C!=0){
				if (this.First==null){
					this.First=new article (A,B,C,D,E);
					this.Anzahl=1;
					this.GesamtPreis=Math.round((this.GesamtPreis + C*D)*100)/100;
					this.GesamtBuchPreis=Math.round((this.GesamtBuchPreis + C*D)*100)/100;
					this.Last=this.First;}
				else{
					this.G=new article (A,B,C,D,E);
					this.GesamtPreis=Math.round((this.GesamtPreis + C*D)*100)/100;
					this.GesamtBuchPreis=Math.round((this.GesamtBuchPreis + C*D)*100)/100;
					this.Anzahl+= 1;
					this.Last.Next=this.G;
					this.Last=this.G;};
			};
		};


		this.loesche= function loesche (Nr){			
			
			if(1==Nr){
				if(this.Anzahl!=1){
					this.GesamtPreis = Math.round(100*(this.GesamtPreis - this.First.Bestellmenge * this.First.Preis))/100;
					if(this.First.Index==0){	
						this.GesamtNixBuchPreis = Math.round(100*(this.GesamtNixBuchPreis - this.First.Bestellmenge * this.First.Preis))/100;}
					else{						
						this.GesamtBuchPreis = Math.round(100*(this.GesamtBuchPreis - this.First.Bestellmenge * this.First.Preis))/100;};
					this.Anzahl=this.Anzahl-1;
					this.First=this.First.Next;}
				else{
					this.GesamtPreis=0;
					this.Anzahl=this.Anzahl-1;
					this.First=null;
					this.Last=null;};
			}
			else{
				N=2;
				BArticle=this.First;
				Article=this.First.Next;
				while (Nr!=N){
					BArticle=Article;
					Article=Article.Next;
					N++;
				};
				if(Nr==this.Anzahl){
					this.GesamtPreis= Math.round(100*(this.GesamtPreis - Article.Bestellmenge * Article.Preis))/100;
					if(Article.Index==0){
						this.GesamtNixBuchPreis = Math.round(100*(this.GesamtNixBuchPreis - Article.Bestellmenge * Article.Preis))/100;}
					else{
						this.GesamtBuchPreis= Math.round(100*(this.GesamtBuchPreis - Article.Bestellmenge * Article.Preis))/100;};

					BArticle.Next=null;
					this.Last=BArticle;
				}
				else{
					this.GesamtPreis= Math.round(100*(this.GesamtPreis - Article.Bestellmenge * Article.Preis))/100;
					if(Article.Index==0){
						this.GesamtNixBuchPreis = Math.round(100*(this.GesamtNixBuchPreis - Article.Bestellmenge * Article.Preis))/100;}
					else{
						this.GesamtBuchPreis= Math.round(100*(this.GesamtBuchPreis - Article.Bestellmenge * Article.Preis))/100;};
					this.Anzahl=this.Anzahl-1;
					BArticle.Next=Article.Next;
				};
				
			};
		};
	};

	Ware=new this.warenkorb();
	
		

	function mwst(){
		return Math.round(100*(nbpreis()- nbpreis()*100/119))/100;};
		
	function mwst2(){
		return Math.round(100*(bpreis()- bpreis()*100/107))/100;};


	function versand(){
		return Ware.betragVersand;};
	
	function mwstversand(){
		return Math.round(100*(versand()- versand()*100/119))/100;};
	

	
	function preis(){return Ware.getPreis()};
	function nbpreis(){return Ware.getNixBuchPreis()};
	function bpreis(){return Ware.getBuchPreis()};


		
	function versand(){
		if (Ware.Vers==0 && Ware.Land==0){
			if(preis()>=100){
				return 0.0;
			}
			return 4.90;
		}
		else if (Ware.Vers==1 && Ware.Land!=0){
			return 0.0;}
		;
	};
	
	function preis(){return Ware.getPreis()};
	
	function epreis(){
		return Math.round((preis() + versand())*100)/100};
	
	function article (AName,AMenge,ABMenge,APreis,AIndex){
		this.Name=AName;
		this.Menge=AMenge;
		this.Bestellmenge=ABMenge;
		this.Preis=APreis;
		this.Index=AIndex;
		this.Next=null};
		
	function einfuegen (A,B,C,D){
		Ware.insert(A,B,C,D);
		alert("Das Produkt wurde in den Warenkorb eingefügt!");};

	function einfuegen2 (A,B,C,D,E){
		Ware.insert2(A,B,C,D,E);
		alert("Das Produkt wurde in den Warenkorb eingefügt!");};
		

	function loeschen (A){
		Ware.loesche (A)};
	function versart(){return Ware.Vers};
		
	function ausgabe (){
  		var N=1;
		var W=" ";
		function builtw(Art,N){
		var Preis= 0;
			while (Art!=null){
				Preis= Math.round(Art.Bestellmenge * Art.Preis*100)/100;				
				W=W+ "<tr><th>";
				W=W + Art.Name;
				W=W+"</th><th>"+Art.Menge+"</th><th>";
				W=W+Art.Bestellmenge+"</th><th>"+dm(Art.Preis);
				W=W+"</th><th>"+dm(Preis)+"</th><th>";
				W=W+"<input type=button value=\"L&ouml;schen\" onClick=\"loesch(";
				W=W+N+")\">";
				W=W + "</th></tr>";			
				Art=Art.Next;
				N++;
			}
		};
		builtw(Ware.First,N);
		return W
	};
	function dm(a){
		var b=Math.round(a - 0.5);
		var c=Math.round(100*(a-b));
		if (c==0){
			return b + "," + "00";
		}
		else{	
			if (c<10){
				return b + "," +"0" +c;
			}
			else{
				return b + "," + c;
			};
		};
	};
	function ausgabe2 (){
  		var N=1;
		var W="";
		W=W + "Artikelname\tFüllmenge / Grösse / Details\tAnzahl\tEinzelpreis\tPreis in DM\n";
		function builtw(Art,N){
		var Preis= 0;
			while (Art!=null){
				Preis= Math.round(Art.Bestellmenge * Art.Preis*100)/100;				
				W=W + Art.Name +"\t";
				W=W+Art.Menge+"\t";
				W=W+Art.Bestellmenge+"\t"+dm(Art.Preis);
				W=W+"\t"+dm(Preis)+"\n";		
				Art=Art.Next;
				N++;
			};
		W=W+"Preis: "+dm(preis())+"\nMWST 19%: " + dm(mwst()+ parent.versand()-(parent.versand()/1.19))+"\nMWST 19: " + dm(mwst2())+"\nVersand: "+ dm(versand());
		W=W+"\nEndpreis: "+dm(epreis())+"\n";	
		};
		builtw(Ware.First,N);
		return W
	};
	
	function changeVers(A){
		Ware.Vers=A;
	};
	
	function update(){
		Ware.Vorname=hauptframe.document.ab.vorname.value;
		Ware.Nachname=hauptframe.document.ab.nachname.value;
		Ware.Strasse=hauptframe.document.ab.strasse.value;
		Ware.Ort=hauptframe.document.ab.ort.value;
		Ware.Hausnummer=hauptframe.document.ab.hausnummer.value;
		Ware.Plz=hauptframe.document.ab.plz.value;
		for (i=0;i<1;i++){
			if(hauptframe.document.ab.land.options[i].selected==true){
				Ware.Land=i;
			};
		};
		Ware.Land2=hauptframe.document.ab.land2.value;
		Ware.Tel=hauptframe.document.ab.tel.value;
		Ware.Mail=hauptframe.document.ab.Mail.value;
	};

	function makeupdate(){
		hauptframe.document.ab.vorname.value=Ware.Vorname;
		hauptframe.document.ab.nachname.value=Ware.Nachname;
		hauptframe.document.ab.strasse.value=Ware.Strasse;
		hauptframe.document.ab.ort.value=Ware.Ort;
		hauptframe.document.ab.hausnummer.value=Ware.Hausnummer;
		hauptframe.document.ab.plz.value=Ware.Plz;
		hauptframe.document.ab.land.options[Ware.Land].selected=true;
		hauptframe.document.ab.land2.value=Ware.Land2;
		hauptframe.document.ab.tel.value=Ware.Tel;
		hauptframe.document.ab.Mail.value=Ware.Mail;
		hauptframe.document.ab.Bestellung.value=parent.ausgabe2();
	};

	function chkFormular(){
		if(Ware.getPreis()<20)    {
			alert("Ihre Bestellung liegt unterhalb des Mindestbestellwertes von 20,00 €!");
			hauptframe.document.ab.vorname.focus();
			return false;    };

		if(hauptframe.document.ab.vorname.value == "")    {
			alert("Bitte Ihren Vornamen eingeben!");
			hauptframe.document.ab.vorname.focus();
			return false;    };
		if(hauptframe.document.ab.nachname.value == "")    {
			alert("Bitte Ihren Nachnamen eingeben!");
			hauptframe.document.ab.nachname.focus();
			return false;    };
		if(hauptframe.document.ab.strasse.value == "")    {
			alert("Bitte Ihrer Strasse eingeben!");
			hauptframe.document.ab.strasse.focus();
			return false;    };
		if(hauptframe.document.ab.hausnummer.value == "")    {
			alert("Bitte Ihre Hausnummer eingeben!");
			hauptframe.document.ab.hausnummer.focus();
			return false;    };
		if(hauptframe.document.ab.ort.value == "")    {
			alert("Bitte Ihren Wohnort eingeben!");
			hauptframe.document.ab.ort.focus();
			return false;    };
		if(hauptframe.document.ab.plz.value == "")    {
			alert("Bitte Ihre Postleitzahl eingeben!");
			hauptframe.document.ab.plz.focus();
			return false;    };
				
		if(hauptframe.document.ab.vers.options[0].selected == true && hauptframe.document.ab.land.options[0].selected==false)    {
				alert("Fehler beim Ausfüllen! Sie haben oben Versand nach Deutschland mit Bezahlung per Überweisung ausgewählt, was nur bei Versand nach Deutschland möglich ist. Bei Ihrer Adresse haben Sie aber ein Land im Ausland angegeben.");
				hauptframe.document.ab.land.focus();
				return false;};		
		if(hauptframe.document.ab.tel.value == "")    {
			alert("Bitte Ihre Telefonnummer eingeben!");
			hauptframe.document.ab.tel.focus();
			return false;    };
		if(hauptframe.document.ab.Mail.value == ""){
		       alert("Bitte Ihre E-Mail-Adresse eingeben!");
		       hauptframe.document.ab.Mail.focus();
		       return false;};
		if(hauptframe.document.ab.Mail.value.indexOf('@') == -1){
       			alert("Sie haben keine korrekte E-Mail-Adresse eingegeben!");
		       	hauptframe.document.ab.Mail.focus();
       			return false;};
		if(hauptframe.document.ab.Mail.value.indexOf('.') == -1){
       			alert("Sie haben keine korrekte E-Mail-Adresse eingegeben!");
		       	hauptframe.document.ab.Mail.focus();
       			return false;};    
      
	};

