﻿var thispath="../";
function setthispath(Mthispath)
	{
		thispath=Mthispath;
	}
function showdiv(obj)
	{
		
		if(obj.value==1)
		{
			document.getElementById("divtrack").style.display="";
			document.getElementById("divpowl").style.display="none";
		}
		else
		{
			document.getElementById("divtrack").style.display="none";
			document.getElementById("divpowl").style.display="";
		}
	}
	function rs_Email(emailStr)
	{ 
		var re=/^[\w-]+(\.*[\w-]+)*@([0-9a-z]+(([0-9a-z]*)|([0-9a-z-]*[0-9a-z]))+\.)+[a-z]{2,3}$/i;
		if(re.test(emailStr))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	function Tcheck()
	{
		if(document.getElementById("OrderIDT").value.search(/[^0-9]/)!=-1)
		{
			alert('Please enter your valid Order ID');
			return false;
		}
		else if(!rs_Email(document.getElementById("EmailT").value))
		{
			alert('Please enter your valid email address!');
			return false;
		}
		else
		{
			return true;
		}
			
	}
	function Pcheck()
	{
		if(document.getElementById("OrderIDP").value.search(/[^0-9]/)!=-1)
		{
			alert('Please enter your valid Order ID');
			return false;
		}
		else if(!rs_Email(document.getElementById("EmailP").value))
		{
			alert('Please enter your valid email address!');
			return false;
		}
		else
		{
			return true;
		}
	}
	function Mcheck()
	{
		if (!rs_Email(document.getElementById("LetterEmail").value))
		{
			alert('Please enter your valid Email address');
			return false;
		}
		else
		{
			return true;
		}
	}
	function Scheck()
	{
		if (document.getElementById("txtkeyword").value=="keyword"||document.getElementById("txtkeyword").value=="")
		{
			alert("Please enter a search query");
			return false;		
		}
		else
		{
			return true;
		}
	}


function Check()
{
	var patrn=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 

	if(document.theform.GameNameListID.options[document.theform.GameNameListID.selectedIndex].value==0)
	{
		alert("Please select a game!");
		return false;
	}
	else if(document.theform.ServerNameListID.options[document.theform.ServerNameListID.selectedIndex].value==0)
	{
		alert("Please select a server!");
		return false;
	}
	else if(document.theform.ProductNameListID.options[document.theform.ProductNameListID.selectedIndex].value==0)
	{
		alert("Please select a product");
		return false;
	}
	else if((document.theform.Username.value.Trim()=="")||CheckString(document.theform.Username.value.Trim(),"The First UserName")==false)
	{
		alert("Please enter your First Name.");
		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()=="")||CheckString(document.theform.Telephone.value.Trim(),"Your Telephone")==false)
	{
		alert("Please enter your Telephone.");
		return false;
	}
	else if((document.theform.Email.value.Trim()=="")||CheckString(document.theform.Email.value.Trim(),"Email Information")==false)
	{
		alert("Please enter your Email.");
		return false;
	}
	else if(!patrn.exec(document.theform.Email.value.Trim()))
	{
		alert("Please enter a validate Email.");
		return false;
	}
	else
	{
		document.getElementById('theform').submit();
	}
}

function Check1()
{
	if(document.theform.GameNameListID.value==0)
	{
		alert("Please select a game!");
		return false;
	}
	else if(document.theform.ServerNameListID.options[document.theform.ServerNameListID.selectedIndex].value==0)
	{
		alert("Please select a server!");
		return false;
	}
	else if(document.theform.ProductNameListID.options[document.theform.ProductNameListID.selectedIndex].value==0)
	{
		alert("Please select a product");
		return false;
	}
	else
	{
		return true;
	}
}

function send_request(url,obj) 
{
	http_request = false;
	
	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(thispath+"ajax/getGameList.cfm",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 A 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 getServerList(gameid)
{
	send_request(thispath+"ajax/getServerList.cfm?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 A 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 getProductList(gameid,serverid)
{
	send_request(thispath+"ajax/getProductList.cfm?gameid="+gameid+"&serverid="+serverid,BoandProductList);
}
function BoandProductList()
{
	while(document.theform.ProductNameListID.options.length>0)
	{
		document.theform.ProductNameListID.remove(0)
	}
	document.theform.ProductNameListID.selectedIndex=-1;
	var opt=document.createElement("OPTION");
	opt.text="---Loading...---";
	opt.value="0";
	document.theform.ProductNameListID.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 A Qty--";
			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 getTestTime(TestTime)
{
	var str=ReAjax.prototype.LoadUrl2(thispath+"ajax/getTestTime.cfm?Time="+TestTime);
}

function cleartext(obj,mmark)
{
	if(obj.value==mmark)
	{
		obj.value='';
	}
}