// JavaScript Document
function build_gl()
{
document.fastorder.s_gl.options.length=0;
for(var i=0;i < gamestr.length;i++)
{
document.fastorder.s_gl.options[document.fastorder.s_gl.options.length]=new Option(gamestr[i],gameid[i]);
}
document.fastorder.s_gl.disabled=false;
}
build_gl();
function gl_chg(){
	var url;
	document.fastorder.s_sl.options.length=0;
	document.fastorder.s_pl.options.length=0;
	document.fastorder.s_sl.options[document.fastorder.s_sl.options.length]=new Option('Please Select The Server',0);
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Please Select The Quantity',0);
	document.fastorder.s_sl.disabled=true;
	document.fastorder.s_pl.disabled=true;
	document.fastorder.gold_amount.value='';
	if(document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value!=0){
	document.fastorder.s_sl.options.length=0;
	document.fastorder.s_sl.options[document.fastorder.s_sl.options.length]=new Option("...Loading...",0);
	document.fastorder.gameid.value=document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value;
	document.fastorder.gamename.value=document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].text;
    try{
	xmlhttp=new XMLHttpRequest();
	}
	catch(e)
	{
	xmlhttp=new ActiveXObject("MIcrosoft.XMLHttp");
	}
	xmlhttp.onreadystatechange = do_gl_chg;
	url='/GetGameServerData.asp?game_id='+document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value;
	xmlhttp.open('GET',url, true); 
	xmlhttp.send(null);
	}
	else
	{
	document.fastorder.gameid.value='';
	document.fastorder.gamename.value='';	
	}
}
function do_gl_chg(){
var sstr;
var sid = new Array();
var str = new Array();
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200){
		str=xmlhttp.responseText.split('||');		
		document.fastorder.s_sl.options.length=0;
		for(var i=0;i < str.length-1;i++)
		{
		sstr=str[i];
		sid=sstr.split('|');                                                                    //服务器名称  单价  ID
		document.fastorder.s_sl.options[document.fastorder.s_sl.options.length]=new Option(sid[0],sid[0]+'#'+sid[1]+'#'+sid[2]);
		}
		document.fastorder.count_str.value=str[str.length-1];
		document.fastorder.s_sl.disabled=false;
		}
		else alert('read data error:'+xmlhttp.status);
	}
}
function sl_chg(){
var ssa;
var ssb;
var ssc;
var goldprice;
var sa = new Array();
var sb = new Array();
var sc = new Array();
var slis = new Array();
var dw;
var price;
	if(document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].value=='Please Select The Server#0#'+document.fastorder.s_gl.options[document.fastorder.s_gl.selectedIndex].value){
	document.fastorder.s_pl.options.length=0;
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Please Select The Quantity',0);
	document.fastorder.s_pl.disabled=true;
	document.fastorder.gold_amount.value='';
	document.fastorder.servername.value='';
	document.fastorder.serverprice.value='';
	document.fastorder.serverid.value='';
	document.fastorder.goldname.value='';
	}
	else{
    document.fastorder.s_pl.options.length=0;
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Please Select The Quantity',0);
	document.fastorder.s_pl.disabled=true;
	document.fastorder.gold_amount.value='';
	ssa=document.fastorder.count_str.value;	
	sa=ssa.split('|');//WOW US:20000:75:0.99:1
	ssc=document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].value;	   //Ambossar DE - Horde#0.01043#791
	sc=ssc.split("#");
	document.fastorder.servername.value=sc[0];
	document.fastorder.serverprice.value=sc[1];
	goldprice=sc[1];  //服务器金币单价
	document.fastorder.serverid.value=sc[2];   //服务器ID
	dw=sa[sa.length-1];    //Gold  游戏币单位
	document.fastorder.goldname.value=dw;
		for(var i=0;i < sa.length-1;i++)
		{
		ssb=sa[i];
		sb=ssb.split(':');   //WOW EU:2000:97.5:0.99:20
		price=sb[1]*sb[2]/100*goldprice;
		//price=Math.round(price,2);
		//price=price+1+parseFloat(sb[3]);
		price=price.toFixed(2);
		document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option(sb[0] + ' '+sb[1]+' ' + dw,sb[0] + ':' + sb[1] + ':'+sb[2]+':'+sb[3]+':'+sb[4]+':' + price);
		}
	document.fastorder.s_pl.disabled=false;
	}
}
function pl_chg(){
var ssa;
var ssb;
var sa = new Array();
var sb = new Array();
var dw;
var x1;
var x2;
var price;
	if(document.fastorder.s_pl.options[document.fastorder.s_pl.selectedIndex].value==0){
	document.fastorder.realmoney.value='';
	document.fastorder.gold_amount.value='';
	document.fastorder.goldnum.value='';
	document.fastorder.buyitem.value='';
	document.fastorder.ChargePercent.value='';
	document.fastorder.MoneyDecimal.value='';
	document.fastorder.saleblockid.value='';
	}
	else{
	  document.fastorder.gold_amount.value='';
	  ssa=document.fastorder.s_pl.options[document.fastorder.s_pl.selectedIndex].value;
	  sa=ssa.split(":");   //WOW US:800:81.5:0.99:14:11.99
	  document.fastorder.ChargePercent.value=sa[2];
	  document.fastorder.MoneyDecimal.value=sa[3];
	  document.fastorder.saleblockid.value=sa[4];	  
	  document.fastorder.buyitem.value=document.fastorder.s_pl.options[document.fastorder.s_pl.selectedIndex].text;
      x1=document.fastorder.Currency_Price.value;    //汇率
	  document.fastorder.goldnum.value=sa[1];   //金币数量	  
      price=document.fastorder.serverprice.value*sa[1]*sa[2]/100*document.fastorder.Currency_Price.value;
	  //price=Math.round(price,2);
	  //price=price+1+parseFloat(sa[3]);
	  price=price.toFixed(2);
	  document.getElementById("fastorder").realmoney.value=price;
	  document.fastorder.gold_amount.value=document.fastorder.Currency_Logo.value+' '+price;
    }
}
