<%@ Page language="c#" Codebehind="ShoppingCart.aspx.cs" AutoEventWireup="false" Inherits="wqeshop.ShoppingCart" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD><!--#include file="inc/head.inc"-->
<title><%=GetResourceString("ShoppingCart")%></title>
<script language="javascript" src="inc/overlib.js"></script>
<script language="javascript">
	function jb() 
	{ 
		var A=null; 
		try 
		{ 
			A=new ActiveXObject("Msxml2.XMLHTTP"); 
		} 
		catch(e) 
		{ 
			try 
			{ 
				A=new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			catch(oc) 
			{ 
				A=null 
			} 
		} 
		if ( !A && typeof XMLHttpRequest != "undefined" ) 
		{ 
			A=new XMLHttpRequest() 
		} 
		return A 
	}
	function getTotal(qID,mPrice,iPrice,recordID)
	{
		document.getElementById("quantity"+qID).value = document.getElementById("quantity"+qID).value.replace(/\D/g,"");
		if(Number(document.getElementById("quantity"+qID).value)<1 || document.getElementById("quantity"+qID).value=="")
		{
			
			document.getElementById("quantity"+qID).value = "";
			document.getElementById("total"+qID).innerHTML = "0";
		}
		else
		{
			var itotal = Number(mPrice)*Number(document.getElementById("quantity"+qID).value)+Number(iPrice)*Number(document.getElementById("quantity"+qID).value);
			document.getElementById("total"+qID).innerHTML = itotal.toFixed(2) ;
		}
		var total = 0;
		var total_quantity = 0;
		var count = document.getElementsByTagName("span").length-3;
		for(var i=1;i<=count;i++)
		{
			total = Number(total) + Number(document.getElementById("total"+i).innerHTML);
			total_quantity = Number(total_quantity) + Number(document.getElementById("quantity"+i).value);
		}
		document.getElementById("total").innerHTML = total.toFixed(2);
		document.getElementById("total_quantity").innerHTML = total_quantity;
		
            //定义要处理数据的页面 
            var weburl = "ajax.aspx?recordID="+recordID+"&q=" + document.getElementById("quantity"+qID).value; 
            //初始化个xmlhttp对象 
            var xmlhttp = jb(); 
            //提交数据，第一个参数最好为get，第三个参数最好为true 
            xmlhttp.open("get",weburl,true); 
        
            //发送数据，请注意顺序和参数，参数一定为null或者"" 
            xmlhttp.send(null);	
	}
</script>
</HEAD>
<body style="background:#FFFFFF">
<form id="Form1" method="post" runat="server">
  <div class="mframe" style="width:650px;">
    <div class="tl"></div>
    <div class="tr"></div>
    <div class="tm"><span class="tt"><%=GetResourceString("ShoppingCart")%></span></div>
    <div class="ml"></div>
    <div class="mr"></div>
    <div class="mm">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td valign="top"><TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
              <TR align="center">
                <TD height="38" width="5%">&nbsp;</TD>
                <TD height="38" width="25%" align="left"><b><%=GetResourceString("ProductName")%></b></TD>
                <TD height="38" width="15%"><b><%=GetResourceString("MarketPrice")%></b></TD>
                <TD height="38" width="15%"><b><%=GetResourceString("MemberPrice")%></b></TD>
                <TD height="38" width="15%"><b><%=GetResourceString("Fittings")%></b></TD>
                <TD width="10%" ><b><%=GetResourceString("Quantity")%></b></TD>
                <TD height="38" width="15%"><b><%=GetResourceString("SumPrice")%></b></TD>
                <TD height="38" width="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
              </TR>
            </TABLE>
            <asp:datalist id="dlShoppingCart" Width="100%" RepeatColumns="1" Runat="server" DataKeyField="RecordID">
              <ItemTemplate>
                <TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
                  <TR align="center">
                    <TD height="38" width="5%"><a href="#" onMouseOver="return overlib('<IMG SRC=<%=config.Path%>Upload/<%# DataBinder.Eval(Container.DataItem, "ThumbnailImg") %> width=200>', CAPTION, '<%# DataBinder.Eval(Container.DataItem, "Name") %>',FGCOLOR, '#fcfcfc', BGCOLOR, '#0080C0', CAPCOLOR, '#ffffff', BORDER, 2, CLOSETEXT, 'Close');" onMouseOut="nd();"><IMG SRC="images/icon-viewpic.gif" border="0"></a> </TD>
                    <TD height="38" width="25%" align="left"><a href='Show.aspx?PID=<%# DataBinder.Eval(Container.DataItem, "ProductID") %>' target=_blank><%# DataBinder.Eval(Container.DataItem, "Name") %></a><br>
                      <%# GetItemNames(DataBinder.Eval(Container.DataItem, "Items").ToString()) %></TD>
                    <TD height="38" width="15%"><%# DataBinder.Eval(Container.DataItem, "MarketPrice","{0:c2}") %></TD>
                    <TD height="38" width="15%"><%# DataBinder.Eval(Container.DataItem, "MemberPrice","{0:c2}") %></TD>
                    <TD height="38" width="15%"><%# GetFieldItemPrice(DataBinder.Eval(Container.DataItem, "Items").ToString()) %></TD>
                    <TD width="10%" align=center><input name="quantity<%# Container.ItemIndex+1%>" type="text" class="inputstyle" id="quantity<%# Container.ItemIndex+1%>" value='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' size="9" maxlength="10" onKeyUp="getTotal(<%# Container.ItemIndex+1%>,<%#DataBinder.Eval(Container.DataItem, "MemberPrice")%>,<%#GetFieldItemPrice(DataBinder.Eval(Container.DataItem, "Items").ToString())%>,<%#DataBinder.Eval(Container.DataItem, "RecordID")%>)"/>
                    <TD height="38" width="15%"><span id="total<%# Container.ItemIndex+1%>"><%# (decimal)DataBinder.Eval(Container.DataItem, "MemberPrice") * (int)DataBinder.Eval(Container.DataItem, "Quantity") + GetFieldItemPrice(DataBinder.Eval(Container.DataItem, "Items").ToString()) * (int)DataBinder.Eval(Container.DataItem, "Quantity") %></span></TD>
                    <TD height="38" width="10%"><A href='Actions.aspx?Action=DeleteCartItem&pid=<%# DataBinder.Eval(Container.DataItem, "ProductID") %>&items=<%# DataBinder.Eval(Container.DataItem, "Items") %>'><IMG height="16" src="images/delete.gif" width="16" border="0"></A></TD>
                  </TR>
                </TABLE>
              </ItemTemplate>
            </asp:datalist>
          </td>
        </tr>
        <tr>
          <td class="hr"></td>
        </tr>
        <tr>
          <td align="right"><b><%=GetResourceString("Total")%>: </b><span id="total"><%=GetTotal()%></span><br>
            <b><%=GetResourceString("Weight")%>: </b><%=GetTotalWeight()%>Kg<br>
            <b><%=GetResourceString("Quantity")%>: </b><span id="total_quantity"><%=GetTotalQuantity()%></span>
            <% if(config.MarkUnit == 1) {%>
            <br>
            <b><%=GetResourceString("Credit")%>: </b><%=GetScore()%>
            <% }%>
          </td>
        </tr>
        <tr>
          <td class="hr"></td>
        </tr>
        <tr>
          <td align="right"><a href="Actions.aspx?Action=EmptyCart"> <img src='Images/<%=GetResourceString("ButtonCartClear")%>' border="0"></a>&nbsp;
            <asp:ImageButton id="ibtUpdate" runat="server" ImageUrl="Images/cart_change.gif" BorderWidth="0" Visible="False"></asp:ImageButton>
            <a href="javascript:window.close();opener.focus();"> <img src='Images/<%=GetResourceString("ButtonCartContinue")%>' border="0"></a>&nbsp;
            <asp:ImageButton id="ibtNextStep" runat="server" ImageUrl="Images/cart_next.gif" BorderWidth="0"></asp:ImageButton></td>
        </tr>
      </table>
    </div>
    <div class="bl"></div>
    <div class="br"></div>
    <div class="bm"></div>
  </div>
  <div id="overDiv" style="Z-INDEX: 1000; VISIBILITY: hidden; POSITION: absolute"></div>
</form>
</body>
</HTML>
