function fonster(link) {
  open(link,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=480,height=320");
}


function foo() {
  open("avtal.html","new","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=480,height=240");
}


// showItemstot() - displays shopping basket in a table with shipping
	function showItemstot() {
		index = document.cookie.indexOf("Korgen");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
		document.writeln('<TABLE BORDER=0>');
		document.writeln('<TR><td rowspan=100 width=20></td><TD width="200"><b><p>Vara</b></TD><TD width="60"><p><b>Antal</b></TD><TD width="60"><p><b>Pris/st</b></TD><td width="70"><p><b>Totalt</b></td></TR>');
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totprice = 0;
		weighttot = 0;
		itemlist = 0;
		porto = 0;
		postforskott = 0;
		if (fulllist.length <= 4) {
            		document.writeln('<tr><td BGCOLOR=#E5ECF3><p>Frakt</td><td align=right BGCOLOR=#E5ECF3><p>1</td><td align=right BGCOLOR=#E5ECF3><p>0</td><td align=right BGCOLOR=#E5ECF3><p>0</td></tr>');
		}
		else {

		
		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;
				commands = fulllist.substring(itemstart, itemend);
				fields = commands.split("#");
				itemlist = itemlist +1;
				theitem = fields[0];
				theprice = fields[1];
				thequantity = fields[2];
				theweight = fields[3];
				weighttot = weighttot + (parseInt(theweight)*thequantity);
				itemtotal = (eval(theprice*thequantity));
				totprice = totprice + itemtotal;
				document.writeln('<tr><td BGCOLOR=#E5ECF3><p>'+theitem+'</td><td align=right BGCOLOR=#E5ECF3><p>'+thequantity+'</td><td align=right BGCOLOR=#E5ECF3><p>'+theprice+'</td><td align=right BGCOLOR=#E5ECF3><p>'+alterError(itemtotal)+'</td></tr>');
				document.writeln('<INPUT TYPE="hidden" NAME="vara'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="antal'+itemlist+'" VALUE="'+thequantity+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="pris'+itemlist+'" VALUE="'+theprice+'" SIZE="40">');
				document.writeln('<INPUT TYPE="hidden" NAME="varatot'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
			}
		}


		if (weighttot < 11){
			weighttot = weighttot + 9;
		}
		else {
			weighttot = weighttot + 80;
		}

		if (weighttot < 20){
			porto = 20;
		}
		else if (weighttot < 250){
			porto = 30;
		}
		else if (weighttot < 500){
			porto = 40;
		}
		else if (weighttot < 1000){
			porto = 60;
		}
		else {
			porto = 135;
		}
		
		document.writeln('<tr><td BGCOLOR=#E5ECF3><p>Frakt</td><td align=right BGCOLOR=#E5ECF3><p>1</td><td align=right BGCOLOR=#E5ECF3><p>'+porto+'</td><td align=right BGCOLOR=#E5ECF3><p>'+porto+'.00</td></tr>');
		document.writeln('<INPUT TYPE="hidden" NAME="porto" VALUE="'+porto+'" SIZE="40">');


		}
		if (document.order.betalning[1].checked){
			postforskott = 50;
			document.writeln('<tr><td BGCOLOR=#E5ECF3><p>Postförskott</td><td align=right BGCOLOR=#E5ECF3><p>1</td><td align=right BGCOLOR=#E5ECF3><p>'+postforskott+'</td><td align=right BGCOLOR=#E5ECF3><p>'+postforskott+'.00</td></tr>');
			document.writeln('<INPUT TYPE="hidden" NAME="postforskott" VALUE="'+postforskott+'" SIZE="40">');
		}
		document.writeln('<tr><td colspan=3><p><b>Total summa (ink moms)</b></td><td align=right><p><b>'+alterError(totprice+porto+postforskott)+'</td><td></td></tr></p>');
		document.writeln('<INPUT TYPE="hidden" NAME="goodstotal" VALUE="'+alterError(totprice+porto+postforskott)+'" SIZE="40">');
		document.writeln('</TABLE>');
	}



// Betalsätt skriv
        function payway_write(way) {
       
                
                        
                document.cookie="TheWay="+way;
		location = "kassa.shtml"; 	
		 
        }

// Betalsätt läs
	function payway_read() {
		if(document.cookie)
		{
			index = document.cookie.indexOf("TheWay");
			if (index != -1)
			{
				namestart = (document.cookie.indexOf("=", index) + 1);
				nameend = document.cookie.indexOf(";", index);
				if (nameend == -1) {nameend = document.cookie.length;}
				PayWay = document.cookie.substring(namestart, nameend);
				if (PayWay == 'forskott') {
					document.order.betalning[0].checked = true;
				} 
				else if (PayWay == 'postforskott') {
					document.order.betalning[1].checked = true;
				}
				else {
					document.order.betalning[0].checked = true;
					document.order.betalning[1].checked = false;
				}
			}
			else {
			document.order.betalning[0].checked = true;
			document.order.betalning[1].checked = false;
			}
		}
		else {
		document.order.betalning[0].checked = true;
		document.order.betalning[1].checked = false;
		}
	}


// alterError - fixes a rounding bug in Netscape 2
        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);
        }