function checkemail(){
		var testresults;			
		var str=document.seminar_form.email.value;
		var filter=/^(['_a-z0-9-+]+)(\.['_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/i
		if (filter.test(str))
		testresults=true
		else				
		testresults=false				
		return (testresults)			
}

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}

function displayItem(key){
if(queryString(key)=='false') 
{
document.write("you didn't enter a ?name=value querystring item.");
}else{
document.write(queryString(key));
}
}

function ValidateForm(){	
	
	      var ischecked
	      
        for (var i=0; i<document.seminar_form.seminar.length; i++)  { 
        if (document.seminar_form.seminar[i].checked)  {

        ischecked = 1;
        } 
        }  	      
		    
		    if (ischecked != 1)
		    {
		    	alert("请选择您要参加的讲座");
		    	document.seminar_form.seminar[0].focus();
          //and return false so the form doesn't get submitted                                
          return false;
        }  
        
        //make sure that the first name is not blank.
        if (document.seminar_form.first_name.value.length < 2)  {
                //it isn't so show the user an alert and go to that field
                alert("请输入您的名字");
                document.seminar_form.first_name.focus();
                //and return false so the form doesn't get submitted
                return false;
        }
        
        //make sure that the firstname field is in English characters
			  if (document.seminar_form.first_name.value.length >= 1)  {
				//it's a valid length, so let's validate it
				// define valid characters
				var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
				var string=document.seminar_form.first_name.value;									
				for (var i=0; i< string.length; i++) {
       				if (valid.indexOf(string.charAt(i)) == -1)
       				{
       					alert ("姓名请用英文字母或拼音填写！");
       					document.seminar_form.first_name.focus();       																		
          			return false;
          			}
          	}
    		}
        
        //make sure that the last name is not blank.
        if (document.seminar_form.last_name.value.length < 2)  {
                //it isn't so show the user an alert and go to that field
                alert("请输入您的姓氏");
                document.seminar_form.last_name.focus();
                //and return false so the form doesn't get submitted
                return false;
        }
        
        //make sure that the lastname field is in English characters
			  if (document.seminar_form.last_name.value.length >= 1)  {
				//it's a valid length, so let's validate it
				// define valid characters
				var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
				var string=document.seminar_form.last_name.value;									
				for (var i=0; i< string.length; i++) {
       				if (valid.indexOf(string.charAt(i)) == -1)
       				{
       					alert ("姓名请用英文字母或拼音填写！");
       					document.seminar_form.last_name.focus();       																
          			return false;
    				}    				
    			}
    		}              
        
        //make sure that the email is not blank.
        if (checkemail()==false)  {
                //it isn't so show the user an alert and go to that field
         				alert("您的电子邮件地址不正确，请重新输入");
                document.seminar_form.email.focus();
                //and return false so the form doesn't get submitted
                return false;
        }
        
        //make sure that the last phone field is not blank.
        if (document.seminar_form.phoneprefix.value.length < 2)  {        	
                 //it isn't so show the user an alert and go to that field
                 alert ("请输入正确的区号");
                 document.seminar_form.phoneprefix.focus();                 
                 //and return false so the form doesn't get submitted                 
                 return false;
         }
        
        //make sure that the last phone field is not blank.
        if (document.seminar_form.phonesuffix.value.length < 2)  {        	
                 //it isn't so show the user an alert and go to that field
                 alert ("请输入正确的电话号码");
                 document.seminar_form.phonesuffix.focus();                 
                 //and return false so the form doesn't get submitted                 
                 return false;
         }     
        
        
        //everything checks out, submit the form
        return true;
}

function writeSeminar() 
{               
  if (queryString('source') != 'false')
    {              
     	switch (queryString('source'))
  			  	{				                 			  		                 			  		
  			  		case '20071027-CN-SH-01' : document.write(''); break;
  			  		case '20071027-CN-SH-02' : document.write(''); break;
  			  		case '20071028-CN-BJ-01' : document.write(''); break;
  			  		case '20071028-CN-BJ-02' : document.write(''); break;
  			  	} 		
    }
}