
<!--meta http-equiv="Content-Type" content="text/html; charset=windows-1250"-->

<!-- JShop v2.2 (22nd October 1997)                         -->
<!-- by Gareth Lancaster @ Whorl (www.whorl.co.uk)         -->
<!-- SHOPPING BASKET                                       -->

	// showItems() - displays shopping basket in a table
	function showItems() {
		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;
		itemlist = 0;
		//document.all.cashvalue.innerHTML="<font class='Stdtxt'>Din kundvagn är tom</font>&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>"
		//var cashvalue="";
		//
		parent.bottomFrame.document.getElementById("cashvalue").innerHTML="<font class='Stdtxt'>Din kundvagn är tom</font>&nbsp;<span class='StdTxt'><font size='1'>(alla priser exkl moms och frakt)</font></span>"

		var divTop;
		//divTop+='<FORM NAME="updateform">';
		//divTop+='<TABLE BORDER>'
		//////<tr><td colspan=3><a href=\"#\" onMouseDown=\"MM_dragLayer(\"editbasket\",\"\",0,0,0,0,true,false,-1,-1,-1,-1,false,false,0,\"\",false,\"\")\" >Flytta</a></td></tr>';
		//divTop+='<TR><TD><b><font size=-1>Vara</font></b></TD><TD><b><font size=-1>Antal</font></b></TD><TD><b><font size=-1>Pris/st.</font></b></TD><td><b><font size=-1>Summa Totalt</font></b><TD><b><font size=-1> </font></b></TD></TR>';


		
		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 topCashOption
				
				
				topCashOption+="<option>"+itemName+" "+itemParam1+" "+itemParam2+"  antal: "+thequantity+" st ā "+theprice+" kr </option>";
				
				//parent.bottomFrame.document.all.cashvalue.innerHTML="<select>"+ topCashOption+"</select>&nbsp;<input type='button' name='clear' class='mainButton2' value='Töm' onclick='clearBasket()'>&nbsp;<input type='button' name='clear' value='Redigera' onclick='javascript:parent.mainFrame.location = \"bbasket.asp\";'>&nbsp;<input type='button' name='clear' value='Kassan' onclick='javascript:parent.mainFrame.location = \"bbuy.asp\";'><br><font color='#000000' size='2' face='Verdana'><b>Summa Totalt: "+alterError(totprice)+"</b></font>&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>";
				
				parent.bottomFrame.document.getElementById("cashvalue").innerHTML="<select>"+ topCashOption+"</select>&nbsp;&nbsp;<input type='button' class='mainButton2' name='clear' value='Ändra' onclick='javascript:parent.mainFrame.location = \"bbasket.asp\";'>&nbsp;<input type='button' class='mainButton2' name='clear' value='Kassan' onclick='javascript:parent.mainFrame.location = \"bbuy.asp\";'><br><font color='#663300' size='2' face='Verdana'><b>Summa totalt: "+alterError(totprice)+"</b></font>&nbsp;<span class='StdTxt'><font size='1'>(alla priser exkl moms och frakt)</font></span>";
																													//<input type='button' class='mainButton2' name='clear' value='Töm' onclick='clearBasket()'>&nbsp;
				var divContent
				//divContent+='<tr><td>'+theitem+'</td>';
				var divEnd
				//divEnd+='<td align=right><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td><a href="javascript:removeItem('+itemlist+')">Tabort</a>&nbsp;<a href="javascript:amendItem('+itemlist+',document.updateform.quant'+itemlist+'.value)">Redigera</a></td></tr>';
				//document.all.editbasket.innerHTML=divTop+divContent+divEnd;


			} 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) itemName= fulllist.substring(itemstart, i);
				if (thisitem==4) itemParam1= fulllist.substring(itemstart, i);
				if (thisitem==5) itemParam2= fulllist.substring(itemstart, i);
				thisitem++;
				itemstart=i+1;
			}
		}

		//document.writeln('<tr><td colspan=3><b>Total</b></td><td align=right>'+alterError(totprice)+'</td><td></td></tr>');
		//document.writeln('</TABLE>');
		//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+'|'+itemName+'|'+itemParam1+'|'+itemParam2+'|'+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) itemName = fulllist.substring(itemstart, i);
				if (thisitem==4) itemParam1= fulllist.substring(itemstart, i);
				if (thisitem==5) itemParam2= fulllist.substring(itemstart, i);

				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("TheBasket");
		
		document.cookie="TheBasket="+newItemList;
		self.location = "bbasket.asp";

	}

	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;
		self.location = "bbasket.asp";
		
	}

	// clearBasket() - removes all items from the basket
	function clearBasket() {
		if (confirm('Är du säker på att du vill tömma korgen?')) {
			index = document.cookie.indexOf("TheBasket");
			document.cookie="TheBasket=.";
			//self.location = "bbasket.htm";
			document.all.cashvalue.innerHTML="<font class='Stdtxt'>Din kundvagn är tom</font>&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>"
			parent.bottomFrame.cashvalue.innerHTML="<font class='Stdtxt'>Din kundvagn är tom</font>&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>"

			//showItems();
		}
	}





	showItems();


<!--form><input type="button" name="clear" value="Töm Korgen" onclick="clearBasket()"></form-->


