var xmlhttp;
var gameid;
gameid=document.fastorder.s_gl.value;


function gl_chg(){
	var url;
	document.fastorder.s_pl.options.length=0;
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Select Product',0);
	document.fastorder.s_pl.disabled=true;
	document.fastorder.s_price.value='';
	document.fastorder.s_sl.options.length=0;
	document.fastorder.s_sl.options[document.fastorder.s_sl.options.length]=new Option("...Loading...",0);
	url='/fast-order/read-data.asp?action=serverlist\&game_id='+gameid;
	xmlhttp=getXMLRequester();
    xmlhttp.onreadystatechange = do_gl_chg;
	xmlhttp.open('GET', url, true); 
	xmlhttp.send(null);
 }
gl_chg();


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;
        oldlen=str.length;
		for(var i=0;i < str.length-1;i++)
		{
		sstr=str[i];
		sid=sstr.split('|');
		document.fastorder.s_sl.options[document.fastorder.s_sl.options.length]=new Option(sid[0],sid[1]);
		}
		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 sa = new Array();
var sb = new Array();
var dw;
var price;
var goldstr;
goldstr='';
	if(document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].value==0){
	document.fastorder.s_pl.options.length=0;
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Select Product',0);
	document.fastorder.s_pl.disabled=true;
	document.fastorder.s_price.value='';
	}
	else{
    document.fastorder.s_pl.options.length=0;
	document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option('Select Product',0);
	document.fastorder.s_pl.disabled=true;
	document.fastorder.s_price.value='';
	ssa=document.fastorder.count_str.value;
	sa=ssa.split('|');
	dw=sa[sa.length-1];
	goldstr='<div class="gold_list_title">VOLUME DISCOUNT</div><table class="table_gold_list" border="0" cellpadding="0" cellspacing="0"><tbody><tr><th>NAME</th><th>TOTAL</th></tr>';
		for(var i=0;i < sa.length-1;i++)
		{
		ssb=sa[i];
		sb=ssb.split(':');
		price=sb[0]*sb[1]*document.fastorder.s_sl.options[document.fastorder.s_sl.selectedIndex].value;
		price=price.toFixed(2);
		goldstr=goldstr+'<tr><td>'+ sb[0] + '' + dw +'</td><td>' + money_n + ' ' + price + '</td></tr>';
		document.fastorder.s_pl.options[document.fastorder.s_pl.options.length]=new Option(sb[0] + ' ' + dw,sb[0] + ':' + price);
		}
	document.fastorder.s_pl.disabled=false;
 	 goldstr=goldstr+'</tbody></table>';
	 document.getElementById('GoldList').innerHTML='<img src="/images/process.gif"/>';
	 setTimeout(function(){document.getElementById('GoldList').innerHTML=goldstr;},1000);
	}
}

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.s_price.value='';
	
	}
	else{
    
	document.fastorder.s_price.value='';
	
      ssa=document.fastorder.s_pl.options[document.fastorder.s_pl.selectedIndex].value;
	  sa=ssa.split(":");
	  document.fastorder.price.value=sa[1];
	  document.fastorder.count.value=sa[0];
      x1=money_p;
      x2=sa[1];
      x2=x2*x1;
      x2=x2.toFixed(2);
      document.fastorder.s_price.value=x2;
	  
    }

}

