﻿        var $j = jQuery.noConflict();
        $j(document).ready(function(){
            loadCheckJs();
            couponhide();
        });
        
        function couponhide(){
            if($j('#googleConfig').val()!="0")
            {
                $j('#coupontr').hide();
            }
        }
        
        function DIVShow(i){
            if(document.getElementById('zxCheckBox').checked){
               document.getElementById(i).style.display = 'block';
           }else{
               document.getElementById(i).style.display = 'none';
           }
        }
        
        var lastAmount = 0;
        var lastMoneyType = 'USD';
        function GetCustomerGoldPrice(amount){
            var gameCode = document.getElementById('sltGame').value;
            if(!document.getElementById('zxCheckBox').checked){
                return;
            }
            try{
                if(amount == ''){
                    return;
                }
                if(gameCode=="013"||gameCode=="019"){
                  if(parseFloat(amount) < 500){
                    document.getElementById('txtAmount').value = '500';
                    amount = 500;
                   }
                }
                if(gameCode=="083"||gameCode=="087"){
                  if(parseFloat(amount) < 0.1){
                   document.getElementById('txtAmount').value = '0.1';
                    amount = 0.1;
                    }
                }
            }catch(e){return;}
            var gameServerCode = document.getElementById('sltServers').value;
            var moneyType = document.getElementById('sp_moneyType2').innerHTML;
            if(gameServerCode == '-1'){
                alert('Please choose your server');
                return;
            }
            if(amount == lastAmount && moneyType == lastMoneyType){
                return;
            }
            lastAmount = amount;
            lastMoneyType = moneyType;
            $j('#div_wait_gold2').show();
            document.getElementById('txtPrice2').value = '0';
            $j.ajax({
                url : '/Ajax.aspx?rd=' + Math.random(),
                type : 'get',
                data : 'operate=GetCustomerGoldPrice&amount=' + amount + '&gameServerCode=' + gameServerCode + '&moneyType=' + moneyType,
                dataType : 'html',
                success : function(data){
                    $j('#div_wait_gold2').hide();
                     document.getElementById('txtPrice2').value = data;
                }
            });
        }
    
        var isIE = navigator.userAgent.indexOf("MSIE") > 0;
        function checkCustomerEnter(e){
            var keyNum = 0;
            if(isIE){
                keyNum = e.keyCode;
            }else{
                keyNum = e.which;
            }
            var amount = document.getElementById('txtAmount').value;
            for(var i = 0; i < amount.length; i++){
                var keyCode = amount.charCodeAt(i);
                if(keyCode < 48 || keyCode > 57){
                    var gameCode = document.getElementById('sltGame').value;
                    if(gameCode != '013' || gameCode != '019'){
                        if(amount.charAt(i) != '.'){
                            amount = amount.replace(amount.charAt(i), '');               
                        }
                    }else{
                        amount = amount.replace(amount.charAt(i), '');
                    }
                }
            }
            document.getElementById('txtAmount').value = amount;
        }
        
        function canSubmitForm(){
            if(document.getElementById('sltServers').value == '-1'){alert('Please choose your server'); return false;}
            if(!checkForm()){return false;}
            var price2 = document.getElementById('txtPrice2').value;
            if((price2 == '' || price2 == '0' || price2 == '0.00') && document.getElementById('zxCheckBox').checked){
                return false;
            }
            if(!document.getElementById('zxCheckBox').checked){
                document.getElementById('txtAmount').value = '';
                document.getElementById('txtPrice2').value = '';
                $j('#form1').submit();
                return true;
            }else{
                GetCustomerGoldPrice(document.getElementById('txtAmount').value);
                $j('#form1').submit();
                return true;
            }
        }
        