
<!--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 varukorg är tom</font>&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>"
		//var cashvalue="";
		//
		if (parent.document.getElementById("cashvalue")){
		parent.document.getElementById("cashvalue").innerHTML="<div id='bredtext'> Din varukorg är tom</div>&nbsp;" //<span class='StdTxt'><font size='1'>(Alla Priser exkl.moms och frakt)</font></span>
		}
		var divTop;
		
		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+="<div id=bredtext>"+itemName.substring(0, 17)+"<Br>"+thequantity+" á "+(theprice*1)+" Kr st</div><Br>";
				

				//************************************************
				var hostpath=location.host;
				var subbtn
				subbtn="<a href=\"#\" class=button id=buttonOK  onclick='javascript:parent.location = \"?subpage=http://"+hostpath+shopKassaSrc+"\";'><span id=bredtext>Kassan</span></a>"
//				subbtn="<a href=\"#\" class=button id=buttonOK  onclick='showItemsShopSubmit();'><span id=bredtext>Kassan</span></a>"
				var chgbtn
				chgbtn="<a href=\"#\" class=button id=buttonOK  onclick='javascript:parent.location = \"?subpage=http://"+hostpath+editBasketSrc+"\";'><span id=bredtext>Ändra</span></a>"
				//subbtn="<p style=display:none;><input alt=Kassan name=Send class=send-btn type=buttom onclick='javascript:parent.minIframe.location = \"webmotor/bildgallerier/bbuy.asp\";' value=Kassan id=Send src=\"/img/btn.gif\" /></p><p><input alt=Kassan name=Send class=send-btn type=image id=Send src=\"/img/btn.gif\" onclick='javascript:parent.minIframe.location = \"webmotor/bildgallerier/bbuy.asp\";'  tabindex=5/></p>"
				//************************************************
				if (parent.document.getElementById("cashvalue")){
				parent.document.getElementById("cashvalue").innerHTML=topCashOption.replace("undefined","")+"<table width=100%><tr><td>"+chgbtn+"</td><td>"+subbtn+"</td></tr><tr><td colspan=2><font id='bredtext'><B>Summa: "+ alterError(totprice*1) +" Kr</b></font></td></tr></table>"; //&nbsp;<span class='StdTxt'><font size='1'>(Alla Priser inkl.moms men exkl.frakt)</font></span>
				}

				var divContent
				var 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);
				
				if (thisitem==6) ArtNum= fulllist.substring(itemstart, i);
				if (thisitem==7) CatNum= fulllist.substring(itemstart, i);

				thisitem++;
				itemstart=i+1;
			}
		}

	}

	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 {
				//itemVikt=(itemVikt*newquant)
					newItemList = newItemList + '['+theitem+'|'+theprice+'|'+itemName+'|'+itemParam1+'|'+itemParam2+'|'+ArtNum+'|'+CatNum+'|'+itemVikt+'|'+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);

				if (thisitem==6) ArtNum= fulllist.substring(itemstart, i);
				if (thisitem==7) CatNum= fulllist.substring(itemstart, i);
				if (thisitem==8) itemVikt= fulllist.substring(itemstart, i);

				thisitem++;
				itemstart=i+1;
			}
		}
		index = document.cookie.indexOf("TheBasket");
		
		document.cookie="TheBasket="+newItemList;
		document.getElementById("varukorg").innerHTML=showItems_return();

		//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;
		document.getElementById("varukorg").innerHTML=showItems_return();

//		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="<div id='bredtext'> Din varukorg är tom</div>"
			parent.cashvalue.innerHTML="<div id='bredtext'>Din varukorg är tom</div>"

			//showItems();
		}
	}





	showItems();




