﻿var xmlHttp;
window.onload = function(){OnGameChange();}
function createXMLHttpRequest()
{
 if(window.XMLHttpRequest)
   {
     xmlHttp=new XMLHttpRequest();
   }
 else  if(window.activeXObject)
   {
   xmlHttp=new ActiveXObject("Mircrosoft ActiveX");
   }
  
}

function OnGameChange()
{
 createXMLHttpRequest();
 var gamecode=document.getElementById("Right1_ddlGame").value;
 var selectGameServer=document.getElementById("divGameServer");
 selectGameServer.innerHTML=" <select name=\"select4\" class=\"selecta\" style=\"width: 170px\"><option>Loading...</option></select>";

 if(gamecode !=null && gamecode!="")
 {
  var url="GoldDataDispose.aspx?GameCode="+gamecode+"&Cmd=GetGameServer&"+new Date().toLocaleTimeString();
  xmlHttp.onreadystatechange=GetGameServer;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
 }
}
 function GetGameServer()
 {
  var selectGameServer=document.getElementById("divGameServer");
  if(xmlHttp.readyState!=4)
  {
    return;
  }
  var text=xmlHttp.responseText;
  selectGameServer.innerHTML=text;
  OnGameServerChange();
 }

function OnGameServerChange()
{
  createXMLHttpRequest();
 var gameServerCode=document.getElementById("ddlGameServer").value;
 var selectGameServer=document.getElementById("divProduct");
 selectGameServer.innerHTML=" <select name='select4' class='selecta' style='width: 170px'><option>Loading...</option></select>";
 if(gameServerCode !=null && gameServerCode!="")
 {
  var url="GoldDataDispose.aspx?gameServerCode="+gameServerCode+"&Cmd=GetProductPrice&"+new Date().toLocaleTimeString();
  xmlHttp.onreadystatechange=GetProduct;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  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("Right1_hfiledGameServer").value=document.getElementById("ddlGameServer").options.item(document.getElementById("ddlGameServer").selectedIndex).text ;
  }
 
//function Logout()
//{
//  createXMLHttpRequest();
// var url="Quit.aspx?"+new Date().toLocaleTimeString();
// xmlHttp.onreadystatechange=Out;
// xmlHttp.open("GET",url,true);
//  xmlHttp.send(null);
//}
//function Out
//{
// if(xmlHttp.readyState!=4)
// {
//    return;
// }
//  window.location.href="Default.aspx";
//}