﻿var xmlHttp;
window.onload = function(){OnGameChange();}
function createXMLHttpRequest()
{
 if(window.XMLHttpRequest)
   {
     xmlHttp=new XMLHttpRequest();
   }
 else  if(window.activeXObject)
   {
   xmlHttp=new ActiveXObject("Mircrosoft ActiveX");
   }
  
}

// function createXMLHttpRequest(){
//    if(window.XMLHttpRequest) return new XMLHttpRequest();
//    try{return new ActiveXObject('MSXML2.XMLHTTP.4.0');}
//    catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP.3.0');}
//    catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP.2.6');}
//    catch(e){try{return new ActiveXObject('MSXML2.XMLHTTP');}
//    catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP');}
//    catch(e){return null;}}}}}
//}

function OnGameChange()
{

 var gamecode=document.getElementById("QuickOrderControl1_ddlGame").value;
 var selectGameServer=document.getElementById("divGameServer");
 selectGameServer.innerHTML=" <select name=\"select4\" class=\"selecta\"  style=\"width: 150px\"><option>--Select--</option></select>";
 document.getElementById("divProduct").innerHTML="<select name=\"select8\" class=\"selecta\"  style=\"width: 150px\"><option>--Select--</option></select>";
 if(gamecode !=null && gamecode!="")
 {
  var url="GoldDataDispose.aspx?GameCode="+gamecode+"&Cmd=GetGameServer&"+new Date().toLocaleTimeString();
  $.ajax({
    url : 'GoldDataDispose.aspx?rd=' + Math.random(),
    type : 'get',
    data : 'GameCode='+gamecode+'&Cmd=GetGameServer',
    dataType : 'html',
    success : function(text){
          selectGameServer.innerHTML=text;
          OnGameServerChange();
    }
  });
 }
}
 function GetGameServer()
 {
  var selectGameServer=document.getElementById("divGameServer");
  if(xmlHttp.readyState!=4)
  {
    return;
  }
  var text=xmlHttp.responseText;
  selectGameServer.innerHTML=text;
  OnGameServerChange();
 }

function OnGameServerChange()
{
    
    var gameServerCode=document.getElementById("ddlGameServer").value;
 var selectGameServer=document.getElementById("divProduct");
 selectGameServer.innerHTML=" <select name='select4' class=\"selecta\" style='width: 150px'><option>Loading...</option></select>";
 if(gameServerCode !=null && gameServerCode!="")
 {
  var url="GoldDataDispose.aspx?gameServerCode="+gameServerCode+"&Cmd=GetProductPrice&"+new Date().toLocaleTimeString();
  $.ajax({
    url : 'GoldDataDispose.aspx?rd=' + Math.random(),
    type : 'get',
    data : 'gameServerCode='+gameServerCode+'&Cmd=GetProductPrice',
    dataType : 'html',
    success : function(text){
        selectGameServer.innerHTML=text;
    }
  });
  
  
  GetGameServerName();
  
    var now= new Date();
    var year=now.getYear();
    var month=now.getMonth()+1;
    var day=now.getDate();
    //document.getElementById("DivDate").innerHTML=year+"/"+month+"/"+day;
 }
}

function GetProduct()
{
   var selectGameServer=document.getElementById("divProduct");
  if(xmlHttp.readyState!=4)
  {
    return;
  }
  var text=xmlHttp.responseText;
  selectGameServer.innerHTML=text;
 }
 
  function GetGameServerName()
  {
       document.getElementById("QuickOrderControl1_hfiledGameServer").value=document.getElementById("ddlGameServer").options.item(document.getElementById("ddlGameServer").selectedIndex).text ;
  }