
var products ='';
var iclearstr ='';

function alterError(value) {
		if (value<=0.99) {
			newPounds = '0';
		} else {
			newPounds = parseInt(value);
		}
		newPence = parseInt((value+.0008 - newPounds)* 100);
		if (eval(newPence) <= 9) newPence='0'+newPence;
		newString = newPounds + '.' + newPence;
		return (newString);
	}


	function buyItem(newItem, newPrice, newQuantity,ref) {

		
		if (newQuantity <= 0) {
			rc = alert('Bitte gebe eine Menge ein!');
		} else {
			if (confirm(+newQuantity+' x '+newItem+' in den Warenkorb legen?')) {
				index = document.cookie.indexOf("GSBasket");
				countbegin = (document.cookie.indexOf("=", index) + 1);
        			countend = document.cookie.indexOf(";", index);
	        		if (countend == -1) {
        	    			countend = document.cookie.length;
	        		}
		                document.cookie="GSBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newPrice+"|"+ref+"|"+newQuantity+"]";
			// window.location = 'bestellen.html';
			}
		}
	}


	function resetShoppingBasket() {
		index = document.cookie.indexOf("GSBasket");
		document.cookie="GSBasket=.";

		if (document.cookie) {
                } else {
                  alert('Dein Browser akzeptierst keine Cookies.\nDieser E-Shop benoetigt leider noch Cookies.\nBitte aktieviere Cookies in deiner Browsereinstelling und lade die Seite nochmal. Vielen Dank fuer den Umstand.Manuel :-)');
                }

	}
	function showItems() {
                var tablerowcolor = '#F0F0F0';
                index = document.cookie.indexOf("GSBasket");
		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;
		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;
				var color= fulllist.substring(itemstart, itemend);
				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>löschen</FONT></a>&nbsp;<a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>update</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) ref = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}



		}

                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>Total</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+alterError(totprice)+'</FONT></b></td><td>&nbsp;</td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Versandkosten</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+'15.00'+'</FONT></b></td><td>&nbsp;</td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Endpreis</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+alterError(totprice+15)+'</FONT></b></td><td>&nbsp;</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;
				if (itemlist != itemno) {
					newItemList = newItemList+'['+fulllist.substring(fullstart, itemend)+']';
				} else {
					newItemList = newItemList + '['+theitem+'|'+theprice+'|'+newquant+']';
				}
			} 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) ref = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("GSBasket");
		document.cookie="GSBasket="+newItemList;
		self.location = "warenkorb.html";

	}

	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("GSBasket");
		document.cookie="GSBasket="+newItemList;
		self.location = "warenkorb.html";
	}

	// clearBasket() - removes all items from the basket
	function clearBasket() {
		if (confirm('Willst Du wirklich alle Produke loeschen?')) {
			index = document.cookie.indexOf("GSBasket");
			document.cookie="GSBasket=.";
			self.location = "warenkorb.html";
		}
	}



	function changeimage(towhat,url){

        if (document.images){

            document.images.targetimage.src=towhat.src

        gotolink=url

        }

}

    function warp(){

        window.location=gotolink

}

    var myimages=new Array()

    var gotolink="#"

    function preloadimages(){

        for (i=0;i<preloadimages.arguments.length;i++){

            myimages[i]=new Image()

            myimages[i].src=preloadimages.arguments[i]

        }

}

    preloadimages("./sandalen/sandale02.jpg","./sandalen/schuhe.jpg","./sandalen/stiefel.jpg","./sandalen/moccasin.jpg","./sandalen/kinder.jpg")



	function showItems2() {
		var allcart="";
                var tablerowcolor = '#F0F0F0';
		index = document.cookie.indexOf("GSBasket");
		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;
		document.writeln('<TABLE BORDER=0 CELLPADDING="2" WIDTH="100%">');
		document.writeln('<TR BGCOLOR="#C0C0C0"><TD><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Item</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Quantity</FONT></b></TD><TD align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Price</FONT></b></TD><td align="right"><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Price Total</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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				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="Articulo'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="Cantidad'+itemlist+'" VALUE="'+thequantity+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="Precio'+itemlist+'" VALUE="'+theprice+'" SIZE="40">');
 				document.writeln('<INPUT TYPE="hidden" NAME="Total '+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
allcart = allcart+ "Articulo"+itemlist+": "+theitem+"<br>Cantidad"+itemlist+": "+thequantity+"<br>Precio"+itemlist+": "+theprice+"<br>Total"+itemlist+": "+alterError(itemtotal)+"<br>";
                                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) ref = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		        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>Total</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+alterError(totprice)+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Versandkosten</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+'15.00'+'</FONT></b></td></tr>');
		document.writeln('<tr BGCOLOR="#C0C0C0"><td colspan=3><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Endpreis</FONT></b></td><td align=right><b><FONT FACE="Verdana,Arial,Helvetica" SIZE=-1>Euro '+alterError(totprice+15)+'</FONT></b></td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="Total con Transporte" VALUE="'+alterError(totprice+15.00)+'" SIZE="40">');
		document.writeln('</TABLE>');
		document.writeln('<INPUT TYPE="hidden" NAME="cart" VALUE="'+allcart+'" SIZE="40">');
		
	}

	
	
	
	function iclear(){

		var tablerowcolor = '#F0F0F0';
		index = document.cookie.indexOf("GSBasket");
		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;
		

		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;
				thequantity = fulllist.substring(itemstart, itemend);
				itemtotal = 0;
				itemtotal = (eval(theprice*thequantity));
				temptotal = itemtotal * 100;
				totprice = totprice + itemtotal;
				itemlist=itemlist+1;

				
				products += (theitem+'::'+ref+'::'+ thequantity+'::'+theprice+'::'+ theprice+'::0:::');


			


                                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) ref = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}
		
	 iclearstr = 'https://www.iclear.de/servlets/BuyToolUniversal3e?ShopID=1000000979&BasketID='+(Math.floor (1+Math.random()*9999))+'&Currency=EUR&ProductIndex='+(itemlist+1)+'&Products='+products+'Versandkosten::Versand::1::15.00::15.00::0:::&User-Def=iclearTeststring';	        

	document.writeln('<iframe src="'+iclearstr+'" width=700 height=700 align=center hspace=0 vspace=0 scrolling=yes>Dieser Test wird angezeigt, wenn der Browser den Befehl nicht kennt</iframe>');
	//document.writeln(iclearstr);
	}
