﻿var thispath="../";



function Check()
{
	if(document.theform.GameNameListID.options[document.theform.GameNameListID.selectedIndex].value==0)
	{
		alert("Please select the game!");
		return false;
	}
	else if(document.theform.ServerNameListID.options[document.theform.ServerNameListID.selectedIndex].value==0)
	{
		alert("Please select the server!");
		return false;
	}
	else if(document.theform.ProductNameListID.options[document.theform.ProductNameListID.selectedIndex].value==0)
	{
		alert("Please select the product");
		return false;
	}
	/*else if((document.theform.Email.value.Trim()!="")&&CheckString(document.theform.Email.value.Trim(),"Email Information")==false)
	{
		return false;
	}
	else if((document.theform.Username.value.Trim()!="")&&CheckString(document.theform.Username.value.Trim(),"The First UserName")==false)
	{
		return false;
	}
	else if((document.theform.LUsername.value.Trim()!="")&&CheckString(document.theform.LUsername.value.Trim(),"The Last UserName")==false)
	{
		return false;
	}
	else if((document.theform.Telephone.value.Trim()!=null)&&CheckString(document.theform.Telephone.value.Trim(),"Your Telephone")==false)
	{
		return false;
	}*/
	else
	{
		send_LinkCount(4); //这个函数在js/linkcount.js里面 作用是调用Ajax作点击统?
		return true;
	}
}

function Check1()
{
	if(document.theform.GameNameListID.value==0)
	{
		alert("Please select the game!");
		return false;
	}
	else if(document.theform.ServerNameListID.options[document.theform.ServerNameListID.selectedIndex].value==0)
	{
		alert("Please select the server!");
		return false;
	}
	else if(document.theform.ProductNameListID.options[document.theform.ProductNameListID.selectedIndex].value==0)
	{
		alert("Please select the product");
		return false;
	}
	else
	{
		return true;
	}
}

function send_request(url,obj) 
{
	http_request = false;
	http_request.async=false
	//http_request.validateOnParse ?true;
	if(window.XMLHttpRequest) 
	{ 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) 
	{ 
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) 
			{}
		}
	}
	if (!http_request) 
	{ 
		return false;
	}
		http_request.onreadystatechange = obj;
				
		http_request.open("GET", url, true);
		http_request.send(null);
}

function getGamelist()  //获得游戏列表
{
	send_request("game.asp",BoandGamelist);
}

function BoandGamelist()
{
	/*var str=ReAjax.prototype.LoadUrl2(thispath+"ajax/getGameList.cfm");*/
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{ 
			var str=http_request.responseText;
			while(document.theform.GameNameListID.options.length>0)
			{
				document.theform.GameNameListID.remove(0)
			}
			document.theform.GameNameListID.selectedIndex=-1;
			var rightstr=str.split("$$$");
			var arrayStr=rightstr[0].split("|");
			var i;
			var opt=document.createElement("OPTION");
			opt.text="---Please select the game---";
			opt.value="0";
			document.theform.GameNameListID.options.add(opt);
			opt.selected=true;
			if(arrayStr.length-1>0)
			{
				for(i=0;i<arrayStr.length-1;i++)
				{
					var arrayName=new Array(1);
					arrayName=arrayStr[i].split("@");
					var opt=document.createElement("OPTION");
					opt.text=arrayName[1];
					opt.value=arrayName[0];
					document.theform.GameNameListID.options.add(opt);
				}
			}
		}
	}
		
}
function change(obj){
	//var obj=document.getElementById("GameNameListID");
   //var strsel = obj.options[obj.selectedIndex].text;
  // gameid=document.getElementById("GameNameListID").value=strsel;
 
   var obj=document.getElementById("GameNameListID");
     for(i=0;i<obj.length;i++){
     if(obj[i].selected==true){
		 
      var gameid=obj[i].innerText;
	  var gameid=obj[i].value;
   }
   }
	 
	
  //alert(gameid);
   send_request("server.asp?gameid="+gameid,BoandServerList);
  }



function BoandServerList()
{
	//while(document.theform.ServerNameListID.options.length>0)
	//{
	//	document.theform.ServerNameListID.remove(0)
	//}
	////document.theform.ServerNameListID.selectedIndex=-1;
	var opt=document.createElement("OPTION");
	//opt.text="---Loading...---";
	//opt.value="0";
	//document.theform.ServerNameListID.options.add(opt);
	//opt.selected=true;
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{ 
			var str=http_request.responseText;
			while(document.theform.ServerNameListID.options.length>0)
			{
				document.theform.ServerNameListID.remove(0)
			}
			document.theform.ServerNameListID.selectedIndex=-1;
			var rightstr=str.split("$$$");
			var arrayStr=rightstr[0].split("|");
			var i;
			var opt=document.createElement("OPTION");
			opt.text="---Please select the server---";
			opt.value="0";
			document.theform.ServerNameListID.options.add(opt);
			opt.selected=true;
			if(arrayStr.length-1>0)
			{
				for(i=0;i<arrayStr.length-1;i++)
				{
					var arrayName=new Array(1);
					arrayName=arrayStr[i].split("@");
					var opt=document.createElement("OPTION");
					opt.text=arrayName[1];
					opt.value=arrayName[0];
					document.theform.ServerNameListID.options.add(opt);
				}
			}
		}
	}
}

function change1(obj){
	//var obj=document.getElementById("GameNameListID");
   //var strsel = obj.options[obj.selectedIndex].text;
  // gameid=document.getElementById("GameNameListID").value=strsel;
 
   var obj=document.getElementById("ServerNameListID");
     for(i=0;i<obj.length;i++){
     if(obj[i].selected==true){
	
	
      var gameid=obj[i].innerText;
	
	 var uid=obj[i].value;

		 var str= new Array();  

	 var str=uid.split('-'); 
	 // session("gameid")=gameid
	  //session("game")=uid
	//alert(gameid);
	//alert(str[0]);
	var seruid=str[0];
	var serid=str[1];

   }
   }
	 
	
  //alert(gameid);
//alert(uid);
   send_request("product.asp?server="+gameid+"&uid="+seruid+"&serid="+serid,BoandProductList);
   
  }

  
  
function BoandProductList()
{
	//while(document.theform.ServerNameListID.options.length>0)
	//{
	//	document.theform.ServerNameListID.remove(0)
	//}
	////document.theform.ServerNameListID.selectedIndex=-1;
	var opt=document.createElement("OPTION");
	//opt.text="---Loading...---";
	//opt.value="0";
	//document.theform.ServerNameListID.options.add(opt);
	//opt.selected=true;
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{ 
			var str=http_request.responseText;
			while(document.theform.ProductNameListID.options.length>0)
			{
				document.theform.ProductNameListID.remove(0)
			}
			document.theform.ProductNameListID.selectedIndex=-1;
			var rightstr=str.split("$$$");
			var arrayStr=rightstr[0].split("|");
			var i;
			var opt=document.createElement("OPTION");
			opt.text="---Please select the product---";
			opt.value="0";
			document.theform.ProductNameListID.options.add(opt);
			opt.selected=true;
			if(arrayStr.length-1>0)
			{
				for(i=0;i<arrayStr.length-1;i++)
				{
					var arrayName=new Array(1);
					arrayName=arrayStr[i].split("@");
					var opt=document.createElement("OPTION");
					opt.text=arrayName[1];
					opt.value=arrayName[0];
					document.theform.ProductNameListID.options.add(opt);
				}
			}
		}
	}
}

function change2(obj){  //select area
	//var obj=document.getElementById("GameNameListID");
   //var strsel = obj.options[obj.selectedIndex].text;
  // gameid=document.getElementById("GameNameListID").value=strsel;
 
   var obj=document.getElementById("ServerNameListID");
     for(i=0;i<obj.length;i++){
     if(obj[i].selected==true){
		 
      //var gameid=obj[i].innerText;
	  var uid=obj[i].value;
   }
   }
	 
	
     alert(uid);
   send_request("area.asp?uid="+uid,BoandAreaList);
}

function BoandAreaList()
{
	//while(document.theform.ServerNameListID.options.length>0)
	//{
	//	document.theform.ServerNameListID.remove(0)
	//}
	////document.theform.ServerNameListID.selectedIndex=-1;
	var opt=document.createElement("OPTION");
	//opt.text="---Loading...---";
	//opt.value="0";
	//document.theform.ServerNameListID.options.add(opt);
	//opt.selected=true;
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{ 
			var str=http_request.responseText;
			while(document.theform.arealistid.options.length>0)
			{
				document.theform.arealistid.remove(0)
			}
			document.theform.arealistid.selectedIndex=-1;
			var rightstr=str.split("$$$");
			var arrayStr=rightstr[0].split("|");
			var i;
			var opt=document.createElement("OPTION");
			opt.text="---Please select the product---";
			opt.value="0";
			document.theform.arealistid.options.add(opt);
			opt.selected=true;
			if(arrayStr.length-1>0)
			{
				for(i=0;i<arrayStr.length-1;i++)
				{
					var arrayName=new Array(1);
					arrayName=arrayStr[i].split("@");
					var opt=document.createElement("OPTION");
					opt.text=arrayName[1];
					opt.value=arrayName[0];
					document.theform.arealistid.options.add(opt);
				}
			}
		}
	}
}


 