// JavaScript Document

function GetXmlHttpObject(){

	 var xmlHttp=null;

	 

	 try

		{

	   // Firefox, Opera 8.0+, Safari

		xmlHttp=new XMLHttpRequest();

		}

	 catch (e)

		{

	

	  // Internet Explorer

	   try

		  {

		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

		  }

	   catch (e)

		  {

		  

			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

		  

		  }

		}

		return xmlHttp;



 }
 ////////////////////////////////////////////////////////////////////////
function Showserver(){

	var sid=document.getElementById("game").value;

		if (sid.length==0)

		{ 

		alert("Please select your server!");

		return;

		}

	

	  xmlHttp=GetXmlHttpObject();

	  

	  if (xmlHttp==null)

		{

		alert ("Your browser does't support AJAX£¡");

		return;

		}

	

	var url="xmlHttp_ser_ser.php";

	url=url+"?sid="+sid;

	url=url+"&random="+Math.random();

	xmlHttp.onreadystatechange=wnserverStateChanged;

	xmlHttp.open("GET",url,true);

	xmlHttp.send(null);

		

}

	

function wnserverStateChanged(){ 

	  if (xmlHttp.readyState==4)

	  { 

	  document.getElementById("server_list").innerHTML=xmlHttp.responseText;

	  }

}	

///////////////////// JavaScript Document
 
////////////////////////////////////////////////////////////////////////
function showProducts(){

	var sid=document.getElementById("server").value;

		if (sid.length==0)

		{ 

		alert("Please select your server!");

		return;

		}

	

	  xmlHttp=GetXmlHttpObject();

	  

	  if (xmlHttp==null)

		{

		alert ("Your browser does't support AJAX£¡");

		return;

		}

	

	var url="xmlHttp_ser.php";

	url=url+"?sid="+sid;

	url=url+"&random="+Math.random();

	xmlHttp.onreadystatechange=serverStateChanged;

	xmlHttp.open("GET",url,true);

	xmlHttp.send(null);

		

}

	

function serverStateChanged(){ 

	  if (xmlHttp.readyState==4)

	  { 

	  document.getElementById("products_list").innerHTML=xmlHttp.responseText;

	  }

}	

///////////////////

function showPrice(){

	var pid=document.getElementById("products").value;

		if (pid.length==0)

		{ 

		alert("Please select your products!");

		return;

		}

	

	  xmlHttp=GetXmlHttpObject()

	  

	  if (xmlHttp==null)

		{

		alert ("Your browser does't support AJAX£¡");

		return;

		}

	

	var url="xmlHttp_ser.php";

	url=url+"?pid="+pid;

	url=url+"&random="+Math.random();

	xmlHttp.onreadystatechange=productsStateChanged;

	xmlHttp.open("GET",url,true);

	xmlHttp.send(null);

		

}

	

function productsStateChanged(){ 

	  if (xmlHttp.readyState==4)

	  { 

	  document.getElementById("products_info").innerHTML=xmlHttp.responseText;

	  }

}	



/////////////////////////////////////////////////////

function showDiscount(cid){

	var sid=document.getElementById("server").value;

	document.getElementById("discount").innerHTML = "<br><img src='../images/loading.gif' />&nbsp;&nbsp; Loading...";


	  xmlHttp2=GetXmlHttpObject();

	  

	  if (xmlHttp2==null)

		{

		alert ("Your browser does't support AJAX£¡");

		return;

		}

	

	var url="xmlHttp2.php";

	url=url+"?sid="+sid+"&cid="+cid;

	url=url+"&random="+Math.random();

	xmlHttp2.onreadystatechange=serverChanged;

	xmlHttp2.open("GET",url,true);

	xmlHttp2.send(null);

		

}



function serverChanged(){ 

	  if (xmlHttp2.readyState==4)

	  { 

	  document.getElementById("discount").innerHTML=xmlHttp2.responseText;

	  }

}	



///////////////////////////

function checkout(){

   var server=document.getElementById("server");

   var products=document.getElementById("products");

   var firstname=document.getElementById("first_name");

   var lastname=document.getElementById("last_name");

   var charactername=document.getElementById("character_name");

   var email=document.getElementById("email");

   var phone=document.getElementById("phone");

   var country=document.getElementById("country");

   

    if(server.value==""){

     alert("Please select your server!");

	 server.focus();

	 return false;

   }

   

    if(products.value==""){

     alert("Please select your products!");

	 products.focus();

	 return false;

   }

	

   if(firstname.value==""){

     alert("Your firstname must contain a minimun of 2 characters!");

	 firstname.value="";

	 firstname.focus();

	 return false;

   }

   

   if(lastname.value==""){

     alert("Your lastname must contain a minimun of 2 characters!");

	 lastname.value="";

	 lastname.focus();

	 return false;

   }

   

    if(charactername.value==""){

     alert("Your charactername must contain a minimun of 2 characters!");

	 charactername.value="";

	 charactername.focus();

	 return false;

   }

   

     if(!email.value.match(/^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/)){

     alert("Your Email contain Error!");

	 //email.value="";

	 email.focus();

	 return false;

   }

   

     if(phone.value.length<7 || phone.value.match(/\D/)){

     alert("Your Telephone Number must contain a minimun of 7 characters!!");

	// phone.value="";

	 phone.focus();

	 return false;

   }

   

    if(country.value==""){

     alert("Please Enter Your Country!");

	 //country.value="";

	 country.focus();

	 return false;

   }

   

   return true;

 }
 ////////////////////////////////////
 
 function showrd(){
	 
	 
	//document.getElementById("dit").style.height ="100" ;
//	document.getElementById("dit").style.width ="500" ;
//document.getElementById("dit").style.margin-left ="20" ;

	  xp2=GetXmlHttpObject();

	  if (xp2==null)

		{

		alert ("Your browser does't support AJAX£¡");

		return;

		}

	

	var url = "gold_top.php"+'?'+Math.random();;

	xp2.onreadystatechange=sed;

	xp2.open("GET",url,true);

	xp2.send(null);

		

}



function sed(){ 

	  if (xp2.readyState==4)

	  { 

	  document.getElementById("dit").innerHTML=xp2.responseText;

	  }

}	