/*------------------------------------------------------------------------------------------
site.page.init.first.dir.js
da peng
dp165137419@163.com
------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------
site.page.init.first.dir.js
田鸿端
117119949@163.com

增加功能：	初始化游戏金币快速购买部分的游戏列表
			构建游戏服务器
			改变form中action的值，使页面顺利跳转到对应的checkout.html
			当字母被选中，构建以该字母开头的游戏服务器列表
			改变form中action的值，使页面顺利跳转到对应的checkout.html
			当服务器被选中时，构建 product 列表
------------------------------------------------------------------------------------------*/

(function ($) {
    $(document).ready(function () {
	//      $('#gamePage').html(GetGamePageList());
		  
		  /* 初始化游戏金币快速购买部分的游戏列表 */
		  $('#gameTypeIdGold').html(GetGameList());
		  
		  
		/*  
				$('#gamePage').change(function () {
						$('#productPage').html(GetProductPageList($(this).val()));
				});
				
				$('#goto').click(function () {
				    var pagePath = GetPagePath(3, $('#gamePage').val(), $('#productPage').val());
						window.location.href = pagePath;
				});
	
		*/				
			/* 初始化游戏金币快速购买部分的游戏列表 */	
			/*
			$.post('configs/ajax/fit.gold.server.ajax.php',function(data){
							$('#gameTypeIdGold').html(data);
			});
						
			*/
			
			/* 构建游戏服务器 */
			$('#gameTypeIdGold').change(function(){
				var gameTypeIdGold = $(this).val();
				var action;
				
				switch (gameTypeIdGold){
					case '1':
					case '2':
					
						$('.select_v').show();
						$('#serverIdGold').width(200);
						$.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(200);
							$('#serverIdGold').html('<option>---Please select the server--- </option>');
						break;
					default:
						$('.select_v').hide();
						$('#serverIdGold').width(200);
						$.post('configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#serverIdGold').html(data);
						});
						break;						
				}
				
				
					/*
					if(gameTypeIdGold == 1 || gameTypeIdGold ==2){
						$('.select_v').show();
						$('#serverIdGold').width(230);
						
						$.post('configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#serverIdGold').html(data);
						});
					}else if(gameTypeIdGold=='0' || gameTypeIdGold==0 || gameTypeIdGold==''){
							$('.select_v').hide();
							$('#serverIdGold').width(275);
							$('#serverIdGold').html('<option>---Please select the server--- </option>');
					}else{
						$('.select_v').hide();
						$('#serverIdGold').width(275);						
						$.post('configs/ajax/fit.gold.server.ajax.php',{'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#serverIdGold').html(data);
						});						
					}
					
					*/
					
					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;
					var gameTypeIdGold = $('#gameTypeIdGold').val();
					$.post('configs/ajax/fit.gold.bag.ajax.php',{'serverIdGold':serverIdGold,'type':type,'gameTypeIdGold':gameTypeIdGold},function(data){
							$('#ProductNameListID').html(data);
					});
			});
			
			
		});
})(jQuery);


