

(function ($) {
    $(document).ready(function () {
								

		  
		  /* 初始化游戏金币快速购买部分的游戏列表 */
		  $('#gameTypeIdGold').html(GetGameList());


			/* 构建游戏服务器 */
			$('#gameTypeIdGold').change(function(){
				var gameTypeIdGold = $(this).val();
				var action;
				$('#serverIdGold').attr("disabled",false);
				switch (gameTypeIdGold){
					case '1':
					case '2':
					
						$('.select_v').show();
						$('#serverIdGold').width(280);
						$.post('/configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#serverIdGold').html(data);
						});
						break;
					case '0':
					case  0 :
					case  '':
							$('.select_v').hide();
							$('#serverIdGold').width(280);
							$('#serverIdGold').html('<option>---Please select the server--- </option>');
						break;
					default:
						$('.select_v').hide();
						$('#serverIdGold').width(280);
						$.post('/configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#serverIdGold').html(data);
						});
						break;						
				}
				
				
			
					
					var productHtml = '<option>---Please select the product--- </option>';
					
					$('#ProductNameListID').html(productHtml);
					
							
			/* 改变form中action的值，使页面顺利跳转到对应的checkout.html */
			/* GoldAction为site.page.name.js 中方法 */
				action = GoldAction(gameTypeIdGold);
				$("#actionform").attr("action",action);
							
			});
			
			/* 当字母被选中，构建以该字母开头的游戏服务器列表，此功能暂时针对魔兽世界 */
			$('#AZs').change(function(){
					var azs = $(this).val();
					var gameTypeIdGold = $('#gameTypeIdGold').val();
					$.post('/configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold,'azs':azs},function(data){
						$('#serverIdGold').html(data);
				});
			});
			
			/* 当服务器被选中时，构建 product 列表 */
			$('#serverIdGold').change(function(){
					var serverIdGold = $(this).val();
					var type = true;
					$('#ProductNameListID').attr("disabled",false);
					var gameTypeIdGold = $('#gameTypeIdGold').val();
					$.post('/configs/ajax/fit.gold.bag.ajax.php',{'serverIdGold':serverIdGold,'type':type,'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#ProductNameListID').html(data);
					});
			});
			
			
		});
})(jQuery);


