﻿var $j=jQuery.noConflict();$j(document).ready(function(){
    loadCheckJs();
    $j('#div_centerNews > ul > li > font').each(function(){$j(this).show()});
    document.getElementById('ddlGame').value="013";
    document.getElementById('txtPrice').value='';
    //document.getElementById('txtGoldPrice').value='';
    getServer('013');
    //getServerName('083');
    //getPowerLeveling();
});
function changeTab(tabId){$j('div[class=team] > ul > li > a').each(function(i){$j(this).attr('class','tab'+(i+1))});$j('#'+tabId).attr('class','tabactive');$j('div[class=team_content]').each(function(){$j(this).hide()});$j('#div_'+tabId).fadeIn(800)}var lastAmount=0;
function GetCustomerGoldPrice(amount)
{
    if(document.getElementById('zxCheckBox').checked)
    {
        var gameCode=document.getElementById('ddlGame').value;
    }
    else if(document.getElementById('chCheckBox').checked)
    {
       var gameCode=document.getElementById('ddlGameName').value;
    }
    if(!document.getElementById('zxCheckBox').checked&&!document.getElementById('chCheckBox').checked)
    {return}
    try
    {
        if(gameCode=="013"||gameCode=="019")
         {
            if(parseFloat(amount)<500&&document.getElementById('ddlServer').value!='-1')
               {
                 document.getElementById('txtAmount').value='500';amount=500
               }
        }
       if(gameCode=="083"||gameCode=="087"&&document.getElementById('ddlServerName').value!='-1')
       {
            if(parseFloat(amount)<0.1)
                {document.getElementById('txtTotal').value='0.1';amount=0.1}
       }
    }
    catch(e)
    {return}
    if(document.getElementById('zxCheckBox').checked&&document.getElementById('txtAmount').value!="")
    {
    var gameServerCode=document.getElementById('ddlServer').value;
    if(gameServerCode=='-1')
        {
            alert('Please choose your server');return
        }
    if(amount==lastAmount)
    {return}
    lastAmount=amount;$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,dataType:'html',
        success:function(data){
                $j('#div_wait_gold2').hide();
                document.getElementById('txtPrice2').value=data
                }
           })
    }
    else if(document.getElementById('chCheckBox').checked&&document.getElementById('txtTotal').value!="")
    {
    var gameServerCode=document.getElementById('ddlServerName').value;
    
    if(gameServerCode=='-1')
        {
            alert('Please choose your server');return
        }
    if(amount==lastAmount)
    {return}
    lastAmount=amount;$j('#div_wait2').show();document.getElementById('txtGoldPrice2').value='0';
    $j.ajax({
        url:'/Ajax.aspx?rd='+Math.random(),
        type:'get',
        data:'operate=GetCustomerGoldPrice&amount='+amount+'&gameServerCode='+gameServerCode,dataType:'html',
        success:function(data){
                $j('#div_wait2').hide();
                document.getElementById('txtGoldPrice2').value=data
                }
           })
    }
}
var isIE=navigator.userAgent.indexOf("MSIE")>0;
function checkCustomerEnter(e)
{
     var keyNum=0;
     if(isIE)
        {keyNum=e.keyCode}
     else
        {keyNum=e.which}
     if(document.getElementById('txtAmount').value!="")
     {
       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('ddlGame').value;
           if(gameCode!='013'||gameCode!='019')
           {
             if(amount.charAt(i)!='.')
               {amount=amount.replace(amount.charAt(i),'')}
               
            }
//           else
//           {amount=amount.replace(amount.charAt(i),'')}
         }
        }
//         alert(amount);
        document.getElementById('txtAmount').value=amount
     }
     else
     { 
        amount=document.getElementById('txtTotal').value;
        for(var i=0;i<amount.length;i++)
         {
             var keyCode=amount.charCodeAt(i);
       
        if(keyCode<48||keyCode>57)
        {
           var gameCode=document.getElementById('ddlGameName').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('txtTotal').value=amount
     }
     
}
 function canSubmit()
 {
   if(document.getElementById('ddlGame').value=='-1')
   {
     alert('Please choose your game'); return false;
   }
   if(document.getElementById('ddlServer').value=='-1')
   {
    alert('Please choose your server');return false
   }
//   if(!checkForm())
//   {return false}
//   debugger
   var price2=document.getElementById('txtPrice2').value;
  
   if((price2==''||price2=='0')&&document.getElementById('zxCheckBox').checked)
   {return false}
   if(!document.getElementById('zxCheckBox').checked)
    {document.getElementById('txtAmount').value='';document.getElementById('txtPrice2').value='';return true}
   else
    {GetCustomerGoldPrice(document.getElementById('txtAmount').value)}
}
 function canButton()
 {
   if(document.getElementById('ddlServerName').value=='-1')
   {
    alert('Please choose your server');return false
   }
//   if(!checkForm())
//   {return false}
 var price3=document.getElementById('txtGoldPrice2').value;
   if((price3==''||price3=='0')&&document.getElementById('chCheckBox').checked)
   {return false}
   if(!document.getElementById('chCheckBox').checked)
    {document.getElementById('txtTotal').value='';document.getElementById('txtGoldPrice2').value='';return true}
   else
    {GetCustomerGoldPrice(document.getElementById('txtTotal').value)}
}
function getPowerLeveling()
{
    $j.ajax({
        url:'/default.aspx?rd='+Math.random(),
        type:'get',
        data:'operate=BindHotPackage',
        dataType:'html',
        success:function(data){
            $j('#img_pl_load').hide();
            $j('.pl_index > ul').hide();
            $j('.pl_index > ul').html(data);
            $j('.pl_index > ul').slideDown()}})}
