﻿// 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(),
                   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(),
                   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(),
                   success: function(data, textStatus){ 
                   $("#prices").html(data);                    
                   }
               });                    
                   }
               });   

}

function gamountchange(){
$.ajax({
                   type: "GET",
                   url: ws+"price&id="+$("#numb").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)){
	  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
}



