﻿// JScript 文件
var ws  = "http://"+document.location.host+"/get.aspx?class=";



$(document).ready(function(){
                $.ajax({
                   type: "GET",
                   url: ws+"game",
                   success: function(data, textStatus){ 
                   $("#games").html(data); 
                        //load servers ,numbers and price  
      $.ajax({
         type: "GET",
         url: ws+"server&id="+$("#game").val(),
         success: function(data, textStatus){ 
         $("#servers").html(data);
         //show number
           $.ajax({
              type: "GET",
              url: ws+"numb&id="+$("#server").val(),
              success: function(data, textStatus){ 
              $("#numbs").html(data);
              
                $.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").val()+"&gtcurr="+$("#gtcurr").val(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);                    
                   }
               });                    
              }
           });
         }
     });                   
                   }
               });});

function gamechange(){ 
         $.ajax({
         type: "GET",
         url: ws+"server&id="+$("#game").val(),
         success: function(data, textStatus){ 
         $("#servers").html(data);
         //show number
           $.ajax({
              type: "GET",
              url: ws+"numb&id="+$("#server").val(),
              success: function(data, textStatus){ 
              $("#numbs").html(data);
                $.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").val()+"&gtcurr="+$("#gtcurr").val(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);                    
                   }
               });                    
              }
           });
         }
     });
}

function serverchange(){
 $.ajax({
                   type: "GET",
                   url: ws+"numb&id="+$("#server").val(),
                   success: function(data, textStatus){ 
                   $("#numbs").html(data);
                   $.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").val()+"&gtcurr="+$("#gtcurr").val(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);
                   }
               });
                   }
               });
}

function gamountchange(){
$.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").val()+"&gtcurr="+$("#gtcurr").val(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);
                   }
               });
}

function currchange(){
$.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").val()+"&gtcurr="+$("#gtcurr").val(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);
                   }
               });
}

function checkform(f) {
   if(f.numb.value==""||f.numb.value==0){
	  alert('Please select Quantity');
	  return false;
    }
    //if(/\W|^$/g.test(f.TextBox1.value)){
    if(f.TextBox1.value==""){
	  alert('Please input correct character name!');
          f.TextBox1.focus();
	  return false;
    }
    if(f.fname.value==""){
	  alert('Please input correct full name!');
          f.fname.focus();
	  return false;
    }
   var emailv=f.email.value;
   if(!/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(emailv)){
    alert("Please Type correct email");
    f.email.focus();
    return false;
    }

   if(f.phone.value==""){
	  alert('Please Type correct US e.g xxx-xxx-xxxx/Non-US phone number: xxx-xxxxx. ');
      f.phone.focus();
	  return false;
    }
    return true
}
function checkform1(f) {
    //if(/\W|^$/g.test(f.textfield3.value)){
    if(f.textfield3.value==""){
	  alert('Please input correct Full name!');
          f.textfield3.focus();
	  return false;
    }
   var emailv=f.textfield5.value;
   if(!/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(emailv)){
    alert("Please Type correct email");
    f.textfield5.focus();
    return false;
    }
   //if(/\W|^$/g.test(f.gpcharactername.value)){
   if(f.gpcharactername.value==""){
	  alert('Please input correct character name!');
          f.gpcharactername.focus();
	  return false;
    }

   if(f.gpphone.value==""){
	  alert('Please Type correct US e.g xxx-xxx-xxxx/Non-US phone number: xxx-xxxxx. ');
      f.gpphone.focus();
	  return false;
    }
    return true
}
function checkform2(f) {
    //if(/\W|^$/g.test(f.textfield3.value)){
    if(f.gpfullname.value==""){
	  alert('Please input correct Full name!');
          f.gpfullname.focus();
	  return false;
    }
   var emailv=f.gpemail.value;
   if(!/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(emailv)){
    alert("Please Type correct email");
    f.gpemail.focus();
    return false;
    }   
    if(f.gpphone.value==""){
	  alert('Please Type correct US e.g xxx-xxx-xxxx/Non-US phone number: xxx-xxxxx. ');
      f.gpphone.focus();
	  return false;
    }
   //if(/\W|^$/g.test(f.Character.value)){
   if(f.Account.value==""){
	  alert('Please input correct Account name!');
          f.Account.focus();
	  return false;
    }
       if(f.password.value==""){
	  alert('Please input correct Account password!');
          f.password.focus();
	  return false;
    }
 if(f.gpcharactername.value==""){
	  alert('Please input correct character name!');
          f.gpcharactername.focus();
	  return false;
    }
        if(f.Level.value==""){
	  alert('Please input correct server name!');
          f.Level.focus();
	  return false;
    }

    return true
}