	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) {
		if (newQuantity <= 0) {
			rc = alert('Entrez un quantité correcte !');
		} else {
			if (confirm('Voulez-vous ajouter : '+newQuantity+' x '+newItem+' au chariot ?')) {
				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+"|"+newQuantity+"]";
						//--- Pour recharger la page -
						
						
						location.reload() ;
			}
		}
	}


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

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

		if (document.cookie) {
                } else {
                  alert('You have disabled using cookies.\nThis shop needs cookies to store your orders.\nPlease activate cookies in your browser settings and reload the shop pages.');
                }

	}



//-----------------------------------------------------------------------------------------------------------
	function showItems() {
                var tablerowcolor = '#FFFFFF';
                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=700 px BORDER=0 CELLPADDING="2" ALIGN="center">');
document.writeln(' <TR><TD><b>Votre chariot</b><p></TD></TR>');
document.writeln('<TR BGCOLOR="#EDFECA"><TD><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Articles</FONT></b></TD><TD width="50px" align="right"><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Quantité</FONT></b></TD><TD align="right" width="80px" ><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Prix pièce</FONT></b></TD><td align="right" width="80px"><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Total</FONT></b></TD><TD width="80px">&nbsp;</TD></TR>');
// Nun die horizontale Linie:
document.writeln('<TR BGCOLOR="EDFECA"><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;
				document.write('<tr valign="center" BGCOLOR="'+tablerowcolor+'"><td><FONT FACE="Arial,Verdana,Helvetica" SIZE=-2>'+theitem+'</FONT></td>');

				document.write('<td valign="center" align="right"><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=2></td><td valign="center" align="right"><FONT FACE="Arial,Verdana,Helvetica" SIZE=-2>'+theprice+'</FONT></td><td valign="center" align="right"><FONT FACE="Arial,Verdana,Helvetica" SIZE=-2>'+alterError(itemtotal)+'</FONT></td><td  align="center" valign="center"><a href="javascript:removeItem('+itemlist+')"><FONT FACE="Arial,Verdana,Helvetica" SIZE=-2>Effacer</FONT></a>&nbsp;<a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)"><FONT FACE="Arial,Verdana,Helvetica" SIZE=-2>Calculer</FONT></a></td></tr>');

                                if (tablerowcolor == '#FFFFFF') {
                                  tablerowcolor = "#FFFFFF";
                                } else {
                                  tablerowcolor = "#FFFFFF";
                                }



			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theitem = fulllist.substring(itemstart, i);
				if (thisitem==2) theprice = fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}



		}

                document.writeln('<tr><TD colspan="5"><HR></TD></TR>');
		document.writeln('<tr><td colspan=3><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Total de la commande</FONT></b></td><td align=right><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1>Euros '+alterError(totprice)+'</FONT></b></td><td>&nbsp;</td></tr>');
				document.writeln('<tr><td colspan=3><b><FONT FACE="Arial,Verdana,Helvetica" SIZE=-1><a href="index.php">Continuez vos achats </FONT></b></a></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);
				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("GSBasket");
		document.cookie="GSBasket="+newItemList;
		self.location = "chariot.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 = "chariot.html";
	}


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

	// clearBasket() - removes all items from the basket
	function clearBasket() {
		if (confirm('Voulez vous vider votre chariot ?')) {
			index = document.cookie.indexOf("GSBasket");
			document.cookie="GSBasket=.";
			self.location = "chariot.html";
		}
	}




