var domList = new Array(".com",".org",".gov",".net",".mil",".edu",".cc",".biz",".sh",".zj",".js",".sd",".gd",".fj",".it",".gs",".yzjs",".hn",".co",".ln",".xj",".ne",".sn",".xa",".sx",".or",".he",".be",".cn",".ha",".de",".ah",".icn",".jx");

function doSubmit()
{
	var bTF = validate_pubreg(document.enqform1,5);

	if (bTF)
	{
		document.enqform1.submit();
	}
}

function submit_form(theForm)
{
	theForm.action = theForm.action + "?username=" + theForm.uName.value;	
	theForm.submit();
}

function reset_form(theForm)
{
	theForm.reset();
}

function afterlogin(theForm)
{
	theForm.action = theForm.action + "?username=" + theForm.uName.value;
	return true;
}

function check_pwd(theForm)
{
	if (theForm.OlduPwd.value == "")
  	{
    		alert("Please enter \"Old password\".");
    		theForm.OlduPwd.focus();
    		return (false);
  	}
  		
	if (theForm.uPwd.value == "")
  	{
    		alert("Please enter \"New password\".");
    		theForm.uPwd.focus();
    		return (false);
  	}
	else
	{
		if (checkMinLen(theForm.uPwd, 'New password', 6) == false)
	    		return (false);
	}

	if (theForm.uConfirm.value == "")
  	{
    		alert("Please enter \"Confirm password\".");
    		theForm.uConfirm.focus();
    		return (false);
  	}
	else
	{
		if (checkPwd(theForm.uConfirm,theForm.uPwd, 'Confirm password', 'New password') == false)
	    		return (false);
	}
}

function validate_userinfo(theForm,atWhere)
{
	if (theForm.mFName.value == "")
  	{
    		alert("Please enter \"First name\".");
    		theForm.mFName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mFName, 'First name', 1) == false)
	    		return (false);
	} 

	if (atWhere == 4)
	{
		if (theForm.Gender_id.options[theForm.Gender_id.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Salutation\".");
	    		theForm.Gender_id.focus();
	    		return (false);
	  	}
	}
	
	if (theForm.mEmail.value == "")
  	{
    		alert("Please enter \"Email address\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
		else
		{
			ChkEmail1 = 0;
			ChkEmail2 = 0;
			for (j=0; j < theForm.mEmail.value.length; j++)
			{
				if (theForm.mEmail.value.charAt(j) == "@")
					ChkEmail1 = 1;
				if (theForm.mEmail.value.charAt(j) == ".")
					ChkEmail2 = 1;				
			}
			
		  	if (ChkEmail1 == 0 || ChkEmail2 == 0)
		  	{
			    	alert("Not a valid email address.");
			    	theForm.mEmail.focus();
			    	return (false);  		
			}  			
		}  

	if (theForm.mCname.value == "")
  	{
    		alert("Please enter \"Company name\".");
    		theForm.mCname.focus();
    		return (false);
  	}

	if (theForm.mCadd1.value == "")
  	{
    		alert("Please enter \"Company address\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	if (theForm.Country_id.options[theForm.Country_id.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Country\".");
    		theForm.Country_id.focus();
    		return (false);
  	}
  	else if (theForm.Country_id.selectedIndex == 44)	
  	{
  		if (theForm.Province_id.options[theForm.Province_id.selectedIndex].value == 0)
  		{
	    		alert("Please enter \"Province\".");
	    		theForm.Province_id.focus();
	    		return (false);
  		} 
  		
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("Please enter \"Postal Code\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}
  	else if (theForm.Country_id.selectedIndex == 223)	
  	{
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("Please enter \"Postal Code\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}	

	// telephone number
	if (theForm.mTelAC.value == "")
  	{
    		alert("Please enter \"area code\".");
    		theForm.mTelAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mTelAC)) {
          		alertBox("Please use digits (0-9)", theForm.mTelAC)
          		return false;
    		}  		
  	}

	if (theForm.mTel.value == "")
  	{
    		alert("Please enter \"number\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	}  	  	

	if (theForm.Title_id.options[theForm.Title_id.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Title/Position\".");
    		theForm.Title_id.focus();
    		return (false);
  	}
  	else if (theForm.Title_id.selectedIndex == (theForm.Title_id.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Title_other.value == "")
  		{
	    		alert("Please specify your \"Title/Position\".");
	    		theForm.Title_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.department.options[theForm.department.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Department\".");
    		theForm.department.focus();
    		return (false);
  	}
  	else if (theForm.department.selectedIndex == (theForm.department.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Dept_other.value == "")
  		{
	    		alert("Please specify your \"Department\".");
	    		theForm.Dept_other.focus();
	    		return (false);
  		}
  	}
  	  	  	
	if (theForm.ProductAdv.value == "")
  	{
    		alert("Please enter \"Major Product / Service\".");
    		theForm.ProductAdv.focus();
    		return (false);
  	}
		
	if (theForm.bizNature.options[theForm.bizNature.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Business nature\".");
    		theForm.bizNature.focus();
    		return (false);
  	}
  	else if (theForm.bizNature.selectedIndex == (theForm.bizNature.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.bizNature_other.value == "")
  		{
	    		alert("Please specify \"Business nature\".");
	    		theForm.bizNature_other.focus();
	    		return (false);
  		}
  	}

	if (atWhere != 2 && atWhere != 3)
	{
		if (theForm.Ownership.options[theForm.Ownership.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Ownership\".");
	    		theForm.Ownership.focus();
	    		return (false);
	  	}
	  	else if (theForm.Ownership.selectedIndex == (theForm.Ownership.length-1))
	  	{
	  		// select others, but didn't fill in the text box
	  		if (theForm.Owner_other.value == "")
	  		{
		    		alert("Please specify \"Ownership\".");
		    		theForm.Owner_other.focus();
		    		return (false);
	  		}
	  	}
	
		if (theForm.noemp.options[theForm.noemp.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Total No. of Employee\".");
	    		theForm.noemp.focus();
	    		return (false);
	  	}
	}

	// check choices
	if (atWhere == 0)
	{
		theForm.prod_list.value = "";
			
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
	
		ChkChoice = 0;
	  	for (i=1; i <= 3; i++)
	  	{
	  		tmpV = "theForm.ch"+i+".checked";
	  		if (eval(tmpV))
				ChkChoice = 1;
		}
	  	
	  	if (ChkChoice == 0)
	  	{
		    	alert("Please specify \"what do you want to know more\".");
		    	theForm.ch1.focus();
		    	return (false);  		
		}
	}
		
	// check aes enquiry
	if (atWhere == 1)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
				
		theForm.show_list.value = "";
	
		ChkExh1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.exhc"+i+".checked";
	  		if (eval(tmpV))
				ChkExh1 = 1;
		}
	  	
	  	if (ChkExh1 == 0)
	  	{
		    	alert("Please specify \"your wish of Exhibitions\".");
		    	theForm.exhc1.focus();
		    	return (false);  		
		}
	
		ChkExh2 = 0;
		for (i=0; i < theForm.myshow.length; i++)
		{
			if (theForm.myshow.options[i].selected)
			{
				ChkExh2 = 1;					
			}
		}
	  	
	  	if (ChkExh2 == 0)
	  	{
		    	alert("Please specify \"your interest of Exhibitions\".");
		    	theForm.myshow.focus();
		    	return (false);  		
		}
	  	else
	  	{
			for (j=0; j < theForm.myshow.length; j++)
			{
				if (theForm.myshow.options[j].selected)
				{
		  			if (theForm.show_list.value != "")
		  				theForm.show_list.value += ",";
		
					theForm.show_list.value += theForm.myshow.options[j].value;  						
				}
			}  	
	  	}		
	}

	// check pub enquiry
	if (atWhere == 2)
	{
		ChkPub1 = 0;
	  	for (i=1; i <= 5; i++)
	  	{
	  		tmpV = "theForm.pubi"+i+".checked";
	  		if (eval(tmpV))
				ChkPub1 = 1;
		}
	  	
	  	if (ChkPub1 == 0)
	  	{
		    	alert("Please specify \"your interest of Industry\".");
		    	theForm.pubi1.focus();
		    	return (false);  		
		}
	
		ChkPub2 = 0;
	  	for (i=1; i <= 4; i++)
	  	{
	  		tmpV = "theForm.pubc"+i+".checked";
	  		if (eval(tmpV))
				ChkPub2 = 1;
		}
	  	
	  	if (ChkPub2 == 0)
	  	{
		    	alert("Please specify \"your interest of Publication\".");
		    	theForm.pubc1.focus();
		    	return (false);  		
		}	
	}

	// check pub magazine enquiry
	if (atWhere == 3)
	{
		ChkCh1 = 0;
		for (i=0; i < theForm.mylnofbiz.length; i++)
		{
			if (theForm.mylnofbiz.options[i].selected)
			{
				ChkCh1 = 1;					
			}
		}
	  	
	  	if (ChkCh1 == 0)
	  	{
		    	alert("Please specify \"Product Categories\".");
		    	theForm.mylnofbiz.focus();
		    	return (false);  		
		}
	  	else
	  	{
	  		theForm.lnofbiz_list.value = "";
	  		
			for (j=0; j < theForm.mylnofbiz.length; j++)
			{
				if (theForm.mylnofbiz.options[j].selected)
				{
		  			if (theForm.lnofbiz_list.value != "")
		  				theForm.lnofbiz_list.value += ",";
		
					theForm.lnofbiz_list.value += theForm.mylnofbiz.options[j].value;  						
				}
			}  	
	  	}
/*
	  	theForm.purchase_list.value = "";
	  		
		for (j=0; j < theForm.mypurchase.length; j++)
		{
			if (theForm.mypurchase.options[j].selected)
			{
				if (theForm.purchase_list.value != "")
					theForm.purchase_list.value += ",";
		
				theForm.purchase_list.value += theForm.mypurchase.options[j].value;  						
			}
		}  	*/
	  	/*	  				
		ChkPub2 = 0;
	  	for (i=1; i <= 4; i++)
	  	{
	  		tmpV = "theForm.pubc"+i+".checked";
	  		if (eval(tmpV))
				ChkPub2 = 1;
		}
	  	
	  	if (ChkPub2 == 0)
	  	{
		    	alert("Please specify \"your interest of Publication\".");
		    	theForm.pubc1.focus();
		    	return (false);  		
		}	
		*/
	}

	if (atWhere == 4)
	{
		theForm.prod_list.value = "";
				
	  	// compose the product list for saving
		for (j=0; j < theForm.myptype.length; j++)
		{
			if (theForm.myptype.options[j].selected)
			{
	  			if (theForm.prod_list.value != "")
	  				theForm.prod_list.value += ",";
	
				theForm.prod_list.value += theForm.myptype.options[j].value;  						
			}
		}
				
		ChkWeb1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.webc"+i+".checked";
	  		if (eval(tmpV))
				ChkWeb1 = 1;
		}
	  	
	  	if (ChkWeb1 == 0)
	  	{
		    	alert("Please specify \"your interest of Online Services\".");
		    	theForm.webc1.focus();
		    	return (false);  		
		}		
	}
			
	return (true);
}

function validate_form2info(theForm)
{
	if (theForm.ch1.value == "1")
	{
		theForm.show_list.value = "";
	
		ChkExh1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.exhc"+i+".checked";
	  		if (eval(tmpV))
				ChkExh1 = 1;
		}
	  	
	  	if (ChkExh1 == 0)
	  	{
		    	alert("Please specify \"your wish of Exhibitions\".");
		    	theForm.exhc1.focus();
		    	return (false);  		
		}
	
		ChkExh2 = 0;
		for (i=0; i < theForm.myshow.length; i++)
		{
			if (theForm.myshow.options[i].selected)
			{
				ChkExh2 = 1;					
			}
		}
	  	
	  	if (ChkExh2 == 0)
	  	{
		    	alert("Please specify \"your interest of Exhibitions\".");
		    	theForm.myshow.focus();
		    	return (false);  		
		}
	  	else
	  	{
			for (j=0; j < theForm.myshow.length; j++)
			{
				if (theForm.myshow.options[j].selected)
				{
		  			if (theForm.show_list.value != "")
		  				theForm.show_list.value += ",";
		
					theForm.show_list.value += theForm.myshow.options[j].value;  						
				}
			}  	
	  	}
	}

	if (theForm.ch2.value == "1")
	{
		ChkPub1 = 0;
	  	for (i=1; i <= 5; i++)
	  	{
	  		tmpV = "theForm.pubi"+i+".checked";
	  		if (eval(tmpV))
				ChkPub1 = 1;
		}
	  	
	  	if (ChkPub1 == 0)
	  	{
		    	alert("Please specify \"your interest of Industry\".");
		    	theForm.pubi1.focus();
		    	return (false);  		
		}
	
		ChkPub2 = 0;
	  	for (i=1; i <= 3; i++)
	  	{
	  		tmpV = "theForm.pubc"+i+".checked";
	  		if (eval(tmpV))
				ChkPub2 = 1;
		}
	  	
	  	if (ChkPub2 == 0)
	  	{
		    	alert("Please specify \"your interest of Publication\".");
		    	theForm.pubc1.focus();
		    	return (false);  		
		}
	}

	if (theForm.ch3.value == "1")
	{
		ChkWeb1 = 0;
	  	for (i=1; i <= 2; i++)
	  	{
	  		tmpV = "theForm.webc"+i+".checked";
	  		if (eval(tmpV))
				ChkWeb1 = 1;
		}
	  	
	  	if (ChkWeb1 == 0)
	  	{
		    	alert("Please specify \"your interest of Online Services\".");
		    	theForm.webc1.focus();
		    	return (false);  		
		}
	}
			
	return (true);
}

function validate_search(theForm)
{
	FormInput = 0
	if (theForm.myIndustry_id.options[theForm.myIndustry_id.selectedIndex].value != "")	
		FormInput = 1;
	if (theForm.myCountry_id.options[theForm.myCountry_id.selectedIndex].value != "")	
		FormInput = 1;
		
	if (FormInput == 0)
	{
		alert("Please select any one of the search criteria.");
		theForm.myIndustry_id.focus();
		return (false);		
	}			
	else		
		return (true);
}

function validPubAdv(theForm)
{
	if (theForm.mLName.value == "")
  	{
    		alert("Please enter \"Last name\".");
    		theForm.mLName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mLName, 'Last name', 1) == false)
	    		return (false);
	}  	

	if (theForm.mFName.value == "")
  	{
    		alert("Please enter \"First name\".");
    		theForm.mFName.focus();
    		return (false);
  	}
	else
	{
		if (checkNameN(theForm.mFName, 'First name', 1) == false)
	    		return (false);
	} 

	if (theForm.mEmail.value == "")
  	{
    		alert("Please enter \"Email address\".");
    		theForm.mEmail.focus();
    		return (false);
  	}

	if (theForm.mCname.value == "")
  	{
    		alert("Please enter \"Company name\".");
    		theForm.mCname.focus();
    		return (false);
  	}	
}

function validPubCorp(theForm)
{
	ChkNew1 = 0;
	for (i=0; i <= 3; i++)
	{
	  	tmpV = "theForm.newc1["+i+"].checked";
	  	if (eval(tmpV))
			ChkNew1 = 1;
	}
	  	
	if (ChkNew1 == 0)
	{
		alert("Please specify \"Interest\".");
		theForm.newc1[0].focus();
		return (false);  		
	}
	
	ChkNew2 = 0;
	for (i=0; i <= 4; i++)
	{
	  	tmpV = "theForm.newc2["+i+"].checked";
	  	if (eval(tmpV))
			ChkNew2 = 1;
	}
	  	
	if (ChkNew2 == 0)
	{
		alert("Please specify \"Magazine\".");
		theForm.newc2[0].focus();
		return (false);  		
	}
	
	if (ChkNew1==1 && ChkNew2==1)
	{
		//check value and redirect
		if ((theForm.newc1[0].checked) || (theForm.newc1[1].checked))
		{
			//to advertise
			if (theForm.newc2[0].checked)
			{
				//CAJ
				location.replace("/pub/en/iframe/advenquiry.asp?mag=CAJ");
				return (false);
			}
			else if (theForm.newc2[1].checked)
			{
				//CMJ
				location.replace("/pub/en/iframe/advenquiry.asp?mag=CMJ");
				return (false);
			}
			else if (theForm.newc2[2].checked)
			{
				//CPRJ
				location.replace("/pub/en/iframe/advenquiry.asp?mag=CPRJ");
				return (false);
			}
			else if (theForm.newc2[3].checked)
			{
				//PP
				location.replace("/pub/en/iframe/advenquiry.asp?mag=PP");
				return (false);
			}
			else if (theForm.newc2[4].checked)
			{
				//ATA CTA
				location.replace("/pub/en/iframe/advenquiry.asp?mag=ATACTA");
				return (false);
			}			
		}
		else if (theForm.newc1[2].checked)
		{
			//press
			if (theForm.newc2[0].checked)
			{
				//CAJ
				parent.location.href = "mailto:cmj.caj@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for China Automotive Journal (CAJ)"
				return (false);
			}
			else if (theForm.newc2[1].checked)
			{
				//CMJ
				parent.location.href = "mailto:cmj.caj@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Chinamac Journal (CMJ)"
				return (false);
			}
			else if (theForm.newc2[2].checked)
			{
				//CPRJ
				parent.location.href = "mailto:cprj.pp@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for China Plastic & Rubber Journal (CPRJ)"
				return (false);
			}
			else if (theForm.newc2[3].checked)
			{
				//PP
				parent.location.href = "mailto:cprj.pp@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Packaging Pro (PP)"
				return (false);
			}
			else if (theForm.newc2[4].checked)
			{
				//ATA CTA
				parent.location.href = "mailto:cta.ata@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Journal for Asia on Textile & Apparel (ATA) / China Textile & Apparel Journal (CTA)"
				return (false);
			}												
		}
		else if (theForm.newc1[3].checked)
		{
			//further info
			if (theForm.newc2[0].checked)
			{
				//CAJ
				parent.location.replace("/pub/tw/caj/enquiry2.asp");
				return (false);
			}
			else if (theForm.newc2[1].checked)
			{
				//CMJ
				parent.location.replace("/pub/tw/cmj/enquiry2.asp");
				return (false);
			}
			else if (theForm.newc2[2].checked)
			{
				//CPRJ
				parent.location.replace("/pub/tw/cprj/enquiry2.asp");
				return (false);
			}
			else if (theForm.newc2[3].checked)
			{
				//PP
				parent.location.replace("/pub/tw/pp/enquiry2.asp");
				return (false);
			}
			else if (theForm.newc2[4].checked)
			{
				//ATA CTA
				parent.location.replace("/pub/en/ata/enquiry2.asp");
				return (false);
			}			
		}
	}		
}

function validPubMag(theForm)
{
	ChkNew1 = 0;
	for (i=0; i <= 3; i++)
	{
	  	tmpV = "theForm.newc1["+i+"].checked";
	  	if (eval(tmpV))
			ChkNew1 = 1;
	}
	  	
	if (ChkNew1 == 0)
	{
		alert("Please specify \"Interest\".");
		theForm.newc1[0].focus();
		return (false);  		
	}
	
	if (ChkNew1==1)
	{
		//check value and redirect
		if ((theForm.newc1[0].checked) || (theForm.newc1[1].checked))
		{
			//to advertise
			if (theForm.mag.value == "CAJ")
			{
				//CAJ
				parent.location.replace("/pub/en/caj/enquiry3.asp");
				return (false);
			}
			else if (theForm.mag.value == "CMJ")
			{
				//CMJ
				parent.location.replace("/pub/en/cmj/enquiry3.asp");
				return (false);
			}
			else if (theForm.mag.value == "CPRJ")
			{
				//CPRJ
				parent.location.replace("/pub/en/cprj/enquiry3.asp");
				return (false);
			}
			else if (theForm.mag.value == "PP")
			{
				//PP
				parent.location.replace("/pub/en/pp/enquiry3.asp");
				return (false);
			}
			else if (theForm.mag.value == "ATA")
			{
				//ATA CTA
				parent.location.replace("/pub/en/ata/enquiry3.asp");
				return (false);
			}
			else if (theForm.mag.value == "CTA")
			{
				//ATA CTA
				parent.location.replace("/pub/en/cta/enquiry3.asp");
				return (false);
			}			
		}
		else if (theForm.newc1[2].checked)
		{
			//press
			if (theForm.mag.value == "CAJ")
			{
				//CAJ
				parent.location.href = "mailto:cmj.caj@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for China Automotive Journal (CAJ)"
				return (false);
			}
			else if (theForm.mag.value == "CMJ")
			{
				//CMJ
				parent.location.href = "mailto:cmj.caj@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Chinamac Journal (CMJ)"
				return (false);
			}
			else if (theForm.mag.value == "CPRJ")
			{
				//CPRJ
				parent.location.href = "mailto:cprj.pp@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for China Plastic & Rubber Journal (CPRJ)"
				return (false);
			}
			else if (theForm.mag.value == "PP")
			{
				//PP
				parent.location.href = "mailto:cprj.pp@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Packaging Pro (PP)"
				return (false);
			}
			else if ((theForm.mag.value == "ATA") || (theForm.mag.value == "CTA"))
			{
				//ATA CTA
				parent.location.href = "mailto:cta.ata@adsale.com.hk?subject=Enquiry form - I am interested to send you our news / press release for Journal for Asia on Textile & Apparel (ATA) / China Textile & Apparel Journal (CTA)"
				return (false);
			}													
		}
		else if (theForm.newc1[3].checked)
		{
			//further info
			if (theForm.mag.value == "CAJ")
			{
				//CAJ
				parent.location.replace("/pub/tw/caj/enquiry2.asp");
				return (false);
			}
			else if (theForm.mag.value == "CMJ")
			{
				//CMJ
				parent.location.replace("/pub/tw/cmj/enquiry2.asp");
				return (false);
			}
			else if (theForm.mag.value == "CPRJ")
			{
				//CPRJ
				parent.location.replace("/pub/tw/cprj/enquiry2.asp");
				return (false);
			}
			else if (theForm.mag.value == "PP")
			{
				//PP
				parent.location.replace("/pub/tw/pp/enquiry2.asp");
				return (false);
			}
			else if (theForm.mag.value == "ATA")
			{
				//ATA CTA
				parent.location.replace("/pub/en/ata/enquiry2.asp");
				return (false);
			}
			else if (theForm.mag.value == "CTA")
			{
				//ATA CTA
				parent.location.replace("/pub/tw/cta/enquiry2.asp");
				return (false);
			}			
		}
	}		
}

function validate_pubreg(theForm,atWhere)
{
		if (!theForm.IsPrint.checked && !theForm.IsEmail.checked)
  		{
    			alert("Please enter \"magazine version\".");
    			theForm.IsPrint.focus();
    			return (false);
  		}

	if (theForm.Gender_id.options[theForm.Gender_id.selectedIndex].value == "0")	
  	{
    		alert("Please enter \"Salutation\".");
    		theForm.Gender_id.focus();
    		return (false);
  	}
  	
	// company information
	if (theForm.mFName.value == "")
  	{
    		alert("Please enter \"Name\".");
    		theForm.mFName.focus();
    		return (false);
  	}
  	
		if (theForm.Gender_id.options[theForm.Gender_id.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Salutation\".");
	    		theForm.Gender_id.focus();
	    		return (false);
	  	}
	
	if (theForm.mEmail.value == "")
  	{
    		alert("Please enter \"Email address\".");
    		theForm.mEmail.focus();
    		return (false);
  	}
		else
		{
			ChkEmail1 = 0;
			ChkEmail2 = 0;
			for (j=0; j < theForm.mEmail.value.length; j++)
			{
				if (theForm.mEmail.value.charAt(j) == "@")
					ChkEmail1 = 1;
				if (theForm.mEmail.value.charAt(j) == ".")
					ChkEmail2 = 1;				
			}
			
		  	if (ChkEmail1 == 0 || ChkEmail2 == 0)
		  	{
			    	alert("Not a valid email address.");
			    	theForm.mEmail.focus();
			    	return (false);  		
			}  			
		}  	

	if (theForm.Title_id.options[theForm.Title_id.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Title/Position\".");
    		theForm.Title_id.focus();
    		return (false);
  	}
  	else if (theForm.Title_id.selectedIndex == (theForm.Title_id.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Title_other.value == "")
  		{
	    		alert("Please specify your \"Title/Position\".");
	    		theForm.Title_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.department.options[theForm.department.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Department\".");
    		theForm.department.focus();
    		return (false);
  	}
  	else if (theForm.department.selectedIndex == (theForm.department.length-1))
  	{
  		// select others, but didn't fill in the text box
  		if (theForm.Dept_other.value == "")
  		{
	    		alert("Please specify your \"Department\".");
	    		theForm.Dept_other.focus();
	    		return (false);
  		}
  	}

	if (theForm.e_mCname.value == "")
  	{
    		alert("Please enter \"Company name (English)\".");
    		theForm.e_mCname.focus();
    		return (false);
  	}

	if (theForm.mCadd1.value == "")
  	{
    		alert("Please enter \"Company address\".");
    		theForm.mCadd1.focus();
    		return (false);
  	}
  	else if (checkaddr(theForm.mCadd1) == false)
  	{
  		return false;
  	}

	if (theForm.Country_id.options[theForm.Country_id.selectedIndex].value == "")	
  	{
    		alert("Please enter \"Country\".");
    		theForm.Country_id.focus();
    		return (false);
  	}
  	else if (theForm.Country_id.selectedIndex == 44)	
  	{
  		if (theForm.Province_id.options[theForm.Province_id.selectedIndex].value == 0)
  		{
	    		alert("Please enter \"Province\".");
	    		theForm.Province_id.focus();
	    		return (false);
  		} 
  		
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("Please enter \"Postal Code\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}
  	else if (theForm.Country_id.selectedIndex == 44)	
  	{
		if (theForm.mCpostal.value == "")
	  	{
	    		alert("Please enter \"Postal Code\".");
	    		theForm.mCpostal.focus();
	    		return (false);
	  	}  		
	}

	// telephone number
	if (theForm.mTelAC.value == "")
  	{
    		alert("Please enter \"area code\".");
    		theForm.mTelAC.focus();
    		return (false);
  	}
  	else
  	{
		if (!isNum(theForm.mTelAC)) {
          		alertBox("Please use digits (0-9)", theForm.mTelAC)
          		return false;
    		}  		
  	}

	if (theForm.mTel.value == "")
  	{
    		alert("Please enter \"number\".");
    		theForm.mTel.focus();
    		return (false);
  	}
  	else
	{
		if (checkTel(theForm.mTel) == false)
	    		return (false);
	}  	
	
		ChkCh1 = 0;
		for (i=0; i < theForm.mylnofbiz.length; i++)
		{
			if (theForm.mylnofbiz.options[i].selected)
			{
				ChkCh1 = 1;					
			}
		}
	  	
	  	if (ChkCh1 == 0)
	  	{
		    	alert("Please specify \"Product Categories\".");
		    	theForm.mylnofbiz.focus();
		    	return (false);  		
		}
	  	else
	  	{
	  		theForm.lnofbiz_list.value = "";
	  		
			for (j=0; j < theForm.mylnofbiz.length; j++)
			{
				if (theForm.mylnofbiz.options[j].selected)
				{
		  			if (theForm.lnofbiz_list.value != "")
		  				theForm.lnofbiz_list.value += ",";
		
					theForm.lnofbiz_list.value += theForm.mylnofbiz.options[j].value;  						
				}
			}  	
	  	}	

	if (theForm.ProductAdv.value == "")
  	{
    		alert("Please enter \"Major Product / Service\".");
    		theForm.ProductAdv.focus();
    		return (false);
  	}
	
	if (atWhere == 5)
	{
  	  	  	
		if (theForm.bizNature.options[theForm.bizNature.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Business nature\".");
	    		theForm.bizNature.focus();
	    		return (false);
	  	}
	  	else if (theForm.bizNature.selectedIndex == (theForm.bizNature.length-1))
	  	{
	  		// select others, but didn't fill in the text box
	  		if (theForm.bizNature_other.value == "")
	  		{
		    		alert("Please specify \"Business nature\".");
		    		theForm.bizNature_other.focus();
		    		return (false);
	  		}
	  	}
	  	  	  	
		if (theForm.Ownership.options[theForm.Ownership.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Ownership\".");
	    		theForm.Ownership.focus();
	    		return (false);
	  	}
	  	else if (theForm.Ownership.selectedIndex == (theForm.Ownership.length-1))
	  	{
	  		// select others, but didn't fill in the text box
	  		if (theForm.Ownership_other.value == "")
	  		{
		    		alert("Please specify \"Ownership\".");
		    		theForm.Ownership_other.focus();
		    		return (false);
	  		}
	  	}
	  	  	  	
		if (theForm.noemp.options[theForm.noemp.selectedIndex].value == "")	
	  	{
	    		alert("Please enter \"Total No. of Employees\".");
	    		theForm.noemp.focus();
	    		return (false);
	  	}
	}
			
	return (true);
}		
