<%@ Page Language="C#"  AutoEventWireup="true"  Codebehind="OrderPay.aspx.cs" Inherits="PPFOR.CustomAction.OrderPay" Title="订单信息" %>
<%@ Register Src="~/User/UserCenter/PopupMessage.ascx" TagName="popupMessage" TagPrefix="popup" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<link type="text/css" href="/CustomAction/goods/Css/cart.css" rel="stylesheet" />
<script type="text/javascript" src="JS/doAjax.js"></script>
<title>订单信息</title>
<style type="text/css">
    .payment img{width:142px;height:42px; margin-bottom:10px;vertical-align:middle}
</style>
<script type="text/javascript">
var paymentSelectedId=-1;
var totalMoney="<%=PPFOR_totalMoney %>";
var moneySign="<%=PPFOR_moneySign %>"; 
var moneyRate="<%=PPFOR_moneyRate %>"; 
var online="<%=PPFOR_online %>"; 
function showPaymentList()
{      
    var code="<%=PPFOR_moneyCode %>";   
    var cashType="<%=PPFOR_cashType %>"; 
    DoAjax('JScript.aspx?action=getpayment&money='+totalMoney+'&cashtype='+cashType+'&code='+code,'GET',null,appendPaymentList);       
}
function setPayAction()
{
    var obj=document.getElementById('paymentButton');
    if(obj!=null){
        obj.style.display='';
    }
}
function checkRadioIsChecked(name){
    var objs=document.getElementsByName(name);
    var retValue=false;
    if(objs!=null && objs.length>0){
        for(var i=0; i<objs.length; i++){
            if(objs[i].checked==true){
                retValue=true;
                break;
            }
        }
    }else{
        retValue=true;
    }
    return retValue;
}
function checkInput(){  
    if(checkRadioIsChecked('paymentIdList')){
        return true;
    }else{
        confirm('<%=languageMessage.GetMessage("orderPaymentNone", "请选择支付方式")%>');
        return false;
    }
}
function appendPaymentList(xmlHttp){
    if(xmlHttp.responseText!=null){  
        var objPayment=document.getElementById('paymentList');
        if(objPayment!=null){
            objPayment.innerHTML=xmlHttp.responseText;
            setPayAction();
        }
    }
}
function changePayment(obj)
{
    if(obj.type=='radio'){        
        if(obj.checked){
            if(paymentSelectedId!=obj.value){
                var objInner=document.getElementById('payment_inner'+paymentSelectedId);
                if(objInner!=null){
                    objInner.style.display='none';
                } 
                var price=parseFloat(obj.getAttribute('price')||'0'); 
                var rate=parseFloat(obj.getAttribute('rate')||'0');                                   
                paymentSelectedId=obj.value; 
                
                online=obj.getAttribute('online')||'0';
                setPayAction();
                
                var objOrderMoney=document.getElementById("<%=PPFOR_orderMoney.ClientID %>");
                if(objOrderMoney!=null){                    
                    objOrderMoney.innerHTML=formatMoney((parseFloat(totalMoney)*(1+rate)+price)*moneyRate,moneySign,0.01);
                }
                objInner=document.getElementById('payment_inner'+paymentSelectedId);
                if(objInner!=null){
                    objInner.style.display='';
                }                                         
            }
        }
    }
}
function formatMoney(money,sign,minValue){
    if(minValue!=null){
        if(minValue>money){
            money=minValue;
        }
    }
    var moneyStr=''+money; 
    if(moneyStr.indexOf('.')<0){    
        moneyStr=moneyStr+'.00'; 
    }else if(moneyStr.indexOf('.')==moneyStr.length-1){
        moneyStr=moneyStr+'00';    
    }else if(moneyStr.indexOf('.')==moneyStr.length-2){
        moneyStr=moneyStr+'0';    
    }else if(moneyStr.indexOf('.')<moneyStr.length-3){ 
        moneyStr=''+(money+0.005);
        moneyStr=moneyStr.substr(0,moneyStr.indexOf('.')+3);  
    }
    return sign+moneyStr;
}
function submitPayForm()
{
    var obj=document.getElementById("<%=PPFOR_payForm.ClientID %>");
    if(obj!=null){
        var forms=obj.getElementsByTagName('form');
        if(forms!=null && forms.length>0){
            forms[0].submit();
        }
    }
}
</script>
</head>
<body>
<form runat="server" id="form1" action="OrderPay.aspx" onsubmit="return checkInput();">
<asp:Label ID="PPFOR_orderId" runat="server" Enabled="false" Visible="false"></asp:Label>
<div class="tableco"> 
    <span class="chkouttitle"><%= languageMessage.GetMessage("userOrderSubmitSuccess", "恭喜！您的订单已经提交！")%></span>
</div>
<br />
<div class="tableco">    
    <table class="tableco">
        <tr>
            <td><%=languageMessage.GetMessage("userOrderNo", "订单编号：")%><asp:Label ID="PPFOR_orderNo" runat="server"></asp:Label></td>
            <td><%= languageMessage.GetMessage("userOrderNeedPay", "共需支付：")%><asp:Label ID="PPFOR_orderMoney" CssClass="cart_yellow" runat="server"></asp:Label></td>
            <td><%= languageMessage.GetMessage("userOrderHadPaid", "已支付：")%><asp:Label ID="PPFOR_paidMoney" CssClass="cart_yellow" runat="server"></asp:Label></td>
        </tr>
        <tr>
            <td colspan="3"><asp:HyperLink ID="PPFOR_goDetail" runat="server" ></asp:HyperLink></td>
        </tr>
    </table>   
</div>
<div id="PPFOR_showPaymentList" runat="server">
<br />
<div class="tableco">    
    <table class="tableco">
        <tr>
            <td><%= languageMessage.GetMessage("userPaymentSelStart", "您选择了")%><asp:Label CssClass="cart_yellow" ID="PPFOR_payment" runat="server"></asp:Label><%= languageMessage.GetMessage("userPaymentSelEnd", "支付方式")%> &nbsp;             
            <a onclick="showPaymentList();" href="javascript:void(0);" style="cursor:pointer;"><%= languageMessage.GetMessage("userPaymentSelOther", "选择其他支付方式")%></a>
            <div id="paymentList" style="margin-top:10px; margin-bottom:10px;">  
                <asp:HyperLink CssClass="payment" ImageUrl="~/CustomAction/Images/banks/bank_abc.gif" ID="PPFOR_payUrl" runat="server" Target="_blank"></asp:HyperLink>
                <span style="vertical-align:middle; color:Gray;"><%= languageMessage.GetMessage("userPayLeft", "点击左边的按钮付款")%></span>
                <br />
                <asp:Label ID="PPFOR_paymentDescription" runat="server"></asp:Label>                
                <input style="display:none;" name="paymentIdList" type="radio" value="<%=PPFOR_currentPayment %>" checked="checked" />                
             </div>
             <div id="paymentButton" style="text-align:left; display:none;"><asp:Button ID="PPFOR_payOrder" CssClass="blueinput" runat="server" OnClick="PPFOR_payOrderClick" /></div> 
            </td>           
        </tr>
    </table>   
</div>
<br />                         
</div>
</form>
<asp:Label runat="server" ID="PPFOR_payForm"></asp:Label>
</body>
</html>
