	<!-- JavaCartv1.0     株式会社　モールサービス     1998/3/17   -->
<!-- 梅本泰弘　(http://infomix.com Email:umemoto@infomix.com)  -->
<!-- 　　　 shopping_cart.js (外部呼出用スクリプト)　　 　　　 -->

<!-- 　　　 数字部分の整形　　 　　　 -->

	function alterError(value) {
		newPounds = parseInt(value);
		newString = newPounds;
		return (newString);
	}

<!-- 　　　 買物カゴに加える　　 　　 -->

	function ItemsToBuy(newItem, newPrice, newQuantity) {
		if (newQuantity <= 0) {
			rc = alert('入力された数字は無効です。');
		} 
		
		else {
			if (confirm('商品名　「'+newItem+'」　を　「'+newQuantity+'」　個バスケットに入れました。')) {
				index = document.cookie.indexOf("買物カゴ");
				countbegin = (document.cookie.indexOf("=", index) + 1);
        			countend = document.cookie.indexOf(";", index);
	        		if (countend == -1) {
        	    			countend = document.cookie.length;
	        		}
		                document.cookie="買物カゴ="+document.cookie.substring(countbegin, countend)+"["+newItem+"|"+newPrice+"|"+newQuantity+"]";
			}
		}
	}

	function resetShoppingBasket() {
		index = document.cookie.indexOf("買物カゴ");
		document.cookie="買物カゴ=.";
	}

<!-- 　　　 買物カゴの内容を表示　　 　　 -->

	function showItems() {
		index = document.cookie.indexOf("買物カゴ");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totalPrice = 0;
		document.writeln('<FORM NAME="cartform">');
		document.writeln('<SCRIPT SRC="shopping_cart.js"></SCRIPT>');
		document.writeln('<TABLE BORDER="0">');

document.writeln('<TR><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　商　品　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　数　量　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　単　価　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　小　計　</FONT></B><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　　処　理　　</FONT></B></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;
				totalPrice = totalPrice + itemtotal;
				itemlist=itemlist+1;
				document.write('<TR><TD BGCOLOR="#FFF0F5">'+theitem+'</TD>');

				document.write('<TD BGCOLOR="#FFF0F5" ALIGN=RIGHT><INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></TD><TD ALIGN=RIGHT BGCOLOR="#FFF0F5" >'+theprice+'</TD><TD ALIGN=RIGHT BGCOLOR="#FFF0F5" >'+alterError(itemtotal)+'</TD><TD ALIGN=CENTER BGCOLOR="#FFF0F5" ><A HREF="javascript:removeItem('+itemlist+')">削除</A>&nbsp;　　<A HREF="javascript:changeItem('+itemlist+',document.cartform.quant'+itemlist+'.value)">変更</A></TD></TR>');

			} 
			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="5"></TD></TR><TR><TD COLSPAN=3>合　計</TD><TD ALIGN=RIGHT>'+alterError(totalPrice)+'</TD><TD></TD></TR>');
	document.writeln('</TABLE>');
	document.writeln('</FORM>');
	}

<!-- 　　　 買物カゴの内容を表示 オーダー用　　 　　 -->

	function showItemsOrder() {
		index = document.cookie.indexOf("買物カゴ");
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
        	}
		fulllist = document.cookie.substring(countbegin, countend);
		totalPrice = 0;
		document.writeln('<SCRIPT SRC="shopping_cart.js"></SCRIPT>');
		document.writeln('<TABLE BORDER="0">');

document.writeln('<TR><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　商　品　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　数　量　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　単　価　</FONT></B></TD><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　小　計　</FONT></B><TD BGCOLOR="#0000FF" NOWARP><B><FONT COLOR="#FFFFFF">　　処　理　　</FONT></B></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;
				totalPrice = totalPrice + itemtotal;
				itemlist=itemlist+1;
				document.write('<TR><TD BGCOLOR="#FFF0F5">'+theitem+'</TD>');

				document.write('<TD BGCOLOR="#FFF0F5" ALIGN=RIGHT><INPUT TYPE=TEXT  NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></TD><TD ALIGN=RIGHT BGCOLOR="#FFF0F5" >'+theprice+'</TD><TD ALIGN=RIGHT BGCOLOR="#FFF0F5" >'+alterError(itemtotal)+'</TD><TD ALIGN=CENTER BGCOLOR="#FFF0F5" ><A HREF="javascript:removeItem('+itemlist+')">削除</A>&nbsp;　　<A HREF="javascript:changeItem('+itemlist+',document.cartform.quant'+itemlist+'.value)">変更</A></TD></TR>');

			SolditemList = '';
			SolditemList = theitem+'　単価（￥'+theprice+'）　個数（'+thequantity+'）　小計（￥'+alterError(itemtotal)+'）　';
			document.write('<INPUT TYPE="HIDDEN" NAME="商品（'+itemlist+'）" VALUE="'+SolditemList+'">');

			} 
			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"></TD></TR><TR><TD COLSPAN=3>小　計</TD><TD ALIGN=RIGHT>'+alterError(totalPrice)+'</TD><TD></TD></TR>');

<!--　＊＊送料の設定　ここから-->
		
		if (totalPrice < 10000 && totalPrice != 0) {
			freight = 0;
			document.writeln('<TR><TD COLSPAN="5"></TD></TR><TR><TD COLSPAN=3>送　料</TD><TD ALIGN=RIGHT>'+alterError(freight)+'</TD><TD></TD></TR>');			
		}

		else if (totalPrice >= 10000 && totalPrice < 20000) {
			freight = 0;
			document.writeln('<TR><TD COLSPAN="5"></TD></TR><TR><TD COLSPAN=3>送　料</TD><TD ALIGN=RIGHT>'+alterError(freight)+'</TD><TD></TD></TR>');			
		}

		else if (totalPrice > 20000) {
			freight = 0;
			document.writeln('<TR><TD COLSPAN="5"></TD></TR><TR><TD COLSPAN=3>送　料</TD><TD ALIGN=RIGHT>'+alterError(freight)+'</TD><TD></TD></TR>');			
		}

<!--　＊＊送料の設定　ここまで-->

		else {
	 		freight = 0;
		}

		preTax = totalPrice + freight ;
		tax = preTax * 0.05;
		inClude = preTax + tax;
		document.writeln('<TR><TD COLSPAN="5"></TD></TR><TR><TD COLSPAN=3>消費税</TD><TD ALIGN=RIGHT>'+alterError(tax)+'</TD><TD></TD></TR>');	
		document.writeln('<TR><TD COLSPAN="5"><HR></TD></TR><TR><TD COLSPAN=3><B>合　計</B></TD><TD ALIGN=RIGHT>'+alterError(inClude)+'</TD><TD></TD></TR>');

		if (freight > 0) {
			document.write('<INPUT TYPE="HIDDEN" NAME="　　送　料" VALUE="'+alterError(freight)+'">');
		}
		document.write('<INPUT TYPE="HIDDEN" NAME="　　消費税" VALUE="'+alterError(tax)+'">');
		document.write('<INPUT TYPE="HIDDEN" NAME="請求計" VALUE="'+alterError(inClude)+'">');
		document.writeln('</TABLE>');

	}

<!-- 　　　 買物カゴに変更を加える　　 　　 -->

	function changeItem(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("買物カゴ");
		document.cookie="買物カゴ="+newItemList;
		self.location = "cart.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("買物カゴ");
		document.cookie="買物カゴ="+newItemList;
		self.location = "cart.html";
	}

	function clearBasket() {
		if (confirm('買物カゴの中身を消去します。よろしいですか？')) {
			index = document.cookie.indexOf("買物カゴ");
			document.cookie="買物カゴ=.";
			self.location = "cart.html";
		}
	}

<!-- 　　　 買物カゴをクリア　　 　　 -->

	function clearBasket() {
		if (confirm('買物カゴの中身を消去します。よろしいですか？')) {
			index = document.cookie.indexOf("買物カゴ");
			document.cookie="買物カゴ=.";
			self.location = "cart.html";
		}
	}
