function validate(year)
{		
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var tel = "0123456789- ";
	var ok = "yes";
    var temp = "";
    var temp1 = "";
	
	//User Login ID validate
	if(document.NEWMEMBER.Username.value == "") {
		alert("Please enter your Login ID!");
		document.NEWMEMBER.Username.focus();
		return false;
	}

    //check whether login name is valid
	for(var n=0; n<document.NEWMEMBER.Username.value.length; n++) {
		temp = document.NEWMEMBER.Username.value.substring(n,n+1);
		if(valid.indexOf(temp) == "-1") ok = "no";	
	}
	
	if(ok == "no") {
		alert("Login ID is invalid. Use only characters and numbers! ");
		ok = "yes";
		document.NEWMEMBER.Username.focus();
		return false;
	}
	
	//check whether login name is in a right range
	var len = document.NEWMEMBER.Username.value.length;
	if(len > 12 || len < 6) {
		alert("Login ID must contain 6 to 12 characters only!");
		document.NEWMEMBER.Username.focus();
		return false;
	}
		
	// password
	if(document.NEWMEMBER.Password.value == "") {
		alert("Please enter your Password!");
		document.NEWMEMBER.Password.focus();
		return false;
	}	
		
    	//check whether password is valid
	for(var n=0; n<document.NEWMEMBER.Password.value.length; n++) {
		temp = document.NEWMEMBER.Password.value.substring(n,n+1);
		if(valid.indexOf(temp) == "-1") ok = "no";	
	}
	
	if(ok == "no") {
		alert("Password is invalid. Use only characters and numbers! ");
		ok = "yes";
		document.NEWMEMBER.Password.focus();
		return false;
	}
		
	//User Password validate
	var plen = document.NEWMEMBER.Password.value.length;
	if(plen > 12 || plen < 6) {
		alert("Password must contain 6 to 12 characters only!");
		document.NEWMEMBER.Password.focus();
		return false;
	}
	

	// confirm password	
	if(document.NEWMEMBER.ConfirmPassword.value == "") {
		alert("Please confirm your Password!");
		document.NEWMEMBER.ConfirmPassword.focus();	
		return false;
	}

	var pw1 = document.NEWMEMBER.Password.value;
	var pw2 = document.NEWMEMBER.ConfirmPassword.value;
	if(pw1 != pw2) {
		alert("Incorrect match. Please confirm your Password again!");
		document.NEWMEMBER.ConfirmPassword.focus();
		return false;
	}	

	 // valify word
	 if(document.NEWMEMBER.txtWord.value == "") {
	 	alert("Please enter the text that show in the box! ");
	 	document.NEWMEMBER.txtWord.focus();
	  	return false;
	 }

	// hint  question
	if(document.NEWMEMBER.hintQuestion.value == "") {
		alert("Please select a hint question! ");
		document.NEWMEMBER.hintQuestion.focus();
	 	return false;
	}

	// hint answer
	temp1 = trim(document.NEWMEMBER.hintAnswer.value, 'both');
	if(temp1 == "") {
		alert("Please enter your hint answer! ");
		document.NEWMEMBER.hintAnswer.focus();
	 	return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Hint Answer field contains an extraordinarily long word! Please shorten it.");
		document.NEWMEMBER.hintAnswer.focus();
		return false;
	}

	//User Name validate
	temp1 = trim(document.NEWMEMBER.First_name.value, 'both');
	if(temp1 == "") {
		alert("Please enter your full name!");
		document.NEWMEMBER.First_name.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Full Name field contains an extraordinarily long word! Please shorten it.");
		document.NEWMEMBER.First_name.focus();
		return false;
	}
	
	//Gender validate
	if(document.NEWMEMBER.Title.value == "") {
		alert("Please select your gender!");
		document.NEWMEMBER.Title.focus();
		return false;
	}

	//nationality
	if(document.NEWMEMBER.nationality[1].checked){
		if(trim(document.NEWMEMBER.ic.value, 'both') != "") {
			alert("Identity Card No. for Malaysian only.")
			document.NEWMEMBER.ic.focus();
			return false;
		}
	}

	//birth date

	var bDay = parseInt(document.NEWMEMBER.bDay.value,10);
	var bMonth = parseInt(document.NEWMEMBER.bMonth.value,10);
	var bYear = parseInt(document.NEWMEMBER.bYear.value,10);	
	var aDaysInMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 
	// Check for leap year
	var iDaysInMonth=(bMonth!=2)?aDaysInMonth[bMonth-1]:
		((bYear%4==0 && bYear%100!=0 || bYear % 400==0)?29:28);

	if (bDay=="-1" && bMonth=="0" && bYear=="-1")
	{
	}
	else if (bDay!="-1" && bMonth=="0")
	{
	    alert("Please select the month you were born in!");
		document.NEWMEMBER.bMonth.focus();
	    return false;
	}
	else if (bDay!="-1" && bYear=="-1")
	{
	    alert("Please select the year you were born in!");
		document.NEWMEMBER.bYear.focus();
	    return false;
	}
	else if (bMonth!="0" && bDay=="-1")
	{
	    alert("Please select the date you were born in!");
		document.NEWMEMBER.bDay.focus();
	    return false;
	}
	else if (bYear!="-1" && bDay=="-1")
	{
	    alert("Please select the date you were born in!");
		document.NEWMEMBER.bDay.focus();
	    return false;
	}
	else if (bMonth!="0" && bYear=="-1")
	{
	    alert("Please select the year you were born in!");
		document.NEWMEMBER.bYear.focus();
	    return false;
	}	
	else if (bYear!="-1" && bMonth=="0")
	{
	    alert("Please select the year you were born in!");
		document.NEWMEMBER.bMonth.focus();
	    return false;
	}
	else if (!(bDay!="-1" && bMonth!="0" && bYear!="-1" && bDay<=iDaysInMonth))
	{
	    alert("Invalid date. Please re-enter your birthdate.");
		document.NEWMEMBER.bDay.focus();
	    return false;
	}
	else
	{
	  var crrYear = parseInt(year,10)-17; 
	  var entYear = parseInt(document.NEWMEMBER.bYear.value,10);
	  if (entYear > crrYear){	
		  alert("Registered member have to be at least 18 years old.");
		  document.NEWMEMBER.bYear.focus();	  
		  return false;
	  }
	}
	

	//Address1
	temp1 = trim(document.NEWMEMBER.StreetAddress1.value, 'both');
	if(temp1 == "") {
		alert("Please enter your home address!");
		document.NEWMEMBER.StreetAddress1.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Address field contains an extraordinarily long word! Please shorten it.");
		document.NEWMEMBER.StreetAddress1.focus();
		return false;
	}

	//Address2
	temp1 = trim(document.NEWMEMBER.StreetAddress2.value, 'both');
	if(temp1 == "") {
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Address field contains an extraordinarily long word! Please shorten it.");
		document.NEWMEMBER.StreetAddress2.focus();
		return false;
	}

	//City
	temp1 = trim(document.NEWMEMBER.city.value, 'both');
	if(temp1 ==""){
	       alert("Please enter your City!");
	       document.NEWMEMBER.city.focus();
	       return false;  
	}
	else if (!checkLongWord(temp1))
	{
		alert("The City field contains an extraordinarily long word! Please shorten it.");
		document.NEWMEMBER.city.focus();
		return false;
	}
	
	//zip
	temp1 = trim(document.NEWMEMBER.zip.value, 'both');
	if(temp1 == ""){
	      alert("Please enter your Postal Code!");
	      document.NEWMEMBER.zip.focus();
	      return false;
	}


	//country
	if(document.NEWMEMBER.Country.value == "0"){
		alert("Please select your Country!");
		document.NEWMEMBER.Country.focus();
		return false;
	}
	
	//state, province & country
	if((document.NEWMEMBER.Country.value == "130")&&(document.NEWMEMBER.state.value == "0")){
	  alert("Please select your State!");
	  document.NEWMEMBER.state.focus();
	  return false;
	} 
	if((document.NEWMEMBER.Country.value == "130")&&(document.NEWMEMBER.province.value != "")){
	  alert("Province is only required for non-Malaysian user only.");
	  document.NEWMEMBER.province.focus();
	  return false;
	} 
	if((document.NEWMEMBER.Country.value != "130")&&(document.NEWMEMBER.state.value != "0")){
	  alert("State field is only required for users from MALAYSIA only.");
	  document.NEWMEMBER.state.focus();
	  return false;
	} 

	//home phone
	if(trim(document.NEWMEMBER.homePhone1.value, 'both') == ""){
		alert("Please enter your contact number!");
		document.NEWMEMBER.homePhone1.focus();
		return false;
	}
	if(trim(document.NEWMEMBER.homePhone2.value, 'both') == ""){
		alert("Please enter your contact number!");
		document.NEWMEMBER.homePhone2.focus();
		return false;
	}

	if(document.NEWMEMBER.homePhone1.value != ""){
		for(var q=0; q<document.NEWMEMBER.homePhone1.value.length; q++) {
			temp = document.NEWMEMBER.homePhone1.value.substring(q,q+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Contact number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.homePhone1.focus();
			return false;
		}
	}
	if(document.NEWMEMBER.homePhone2.value != ""){
		for(var q=0; q<document.NEWMEMBER.homePhone2.value.length; q++) {
			temp = document.NEWMEMBER.homePhone2.value.substring(q,q+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Contact number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.homePhone2.focus();
			return false;
		}
	}

	//office phone
	if(document.NEWMEMBER.offPhone1.value != "" && document.NEWMEMBER.offPhone2.value == ""){
		alert("Alternate Contact number is invalid. Please check it! ");
		document.NEWMEMBER.offPhone2.focus();
		return false;
	}
	else if(document.NEWMEMBER.offPhone1.value == "" && document.NEWMEMBER.offPhone2.value != ""){
		alert("Alternate Contact number is invalid. Please check it! ");
		document.NEWMEMBER.offPhone1.focus();
		return false;
	}

	if(document.NEWMEMBER.offPhone1.value != ""){
		for(var p=0; p<document.NEWMEMBER.offPhone1.value.length; p++) {
			temp = document.NEWMEMBER.offPhone1.value.substring(p,p+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Alternate Contact number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.offPhone1.focus();
			return false;
		}
	}
	if(document.NEWMEMBER.offPhone2.value != ""){
		for(var p=0; p<document.NEWMEMBER.offPhone2.value.length; p++) {
			temp = document.NEWMEMBER.offPhone2.value.substring(p,p+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Alternate Contact number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.offPhone2.focus();
			return false;
		}
	}


	//fax
	if(document.NEWMEMBER.Fax1.value != "" && document.NEWMEMBER.Fax2.value == ""){
		alert("Fax number is invalid. Please check it! ");
		document.NEWMEMBER.Fax2.focus();
		return false;
	}
	else if(document.NEWMEMBER.Fax1.value == "" && document.NEWMEMBER.Fax2.value != ""){
		alert("Fax number is invalid. Please check it! ");
		document.NEWMEMBER.Fax1.focus();
		return false;
	}
	if(document.NEWMEMBER.Fax1.value != ""){
		for(var r=0; r<document.NEWMEMBER.Fax1.value.length; r++) {
			temp = document.NEWMEMBER.Fax1.value.substring(r,r+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Fax Number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.Fax1.focus();
			return false;
		}
	}
	if(document.NEWMEMBER.Fax2.value != ""){
		for(var r=0; r<document.NEWMEMBER.Fax2.value.length; r++) {
			temp = document.NEWMEMBER.Fax2.value.substring(r,r+1);
			if(tel.indexOf(temp) == "-1") ok = "no";	
		}
	
		if(ok == "no") {
			alert("Fax Number is invalid. Use only numbers! ");
			ok = "yes";
			document.NEWMEMBER.Fax2.focus();
			return false;
		}
	}

	// email
	temp1 = trim(document.NEWMEMBER.Email.value, 'both');
	if(temp1 == "") {
		alert("Please enter your email address! ");
		document.NEWMEMBER.Email.focus();
	 	return false;
	}

	//User Email validate
	if(document.NEWMEMBER.Email.value.indexOf("@") == -1){
		alert("Email address is invalid. Please re-enter your email address!");
		document.NEWMEMBER.Email.focus();
		return false;
	}


	if(document.NEWMEMBER.company.checked){
		
		//company name
		temp1 = trim(document.NEWMEMBER.cpnName.value, 'both');
		if(temp1 == "") {
			alert("Please enter your company name!");
			document.NEWMEMBER.cpnName.focus();
			return false;
		}
	
		//Address1
		temp1 = trim(document.NEWMEMBER.cpnAdd1.value, 'both');
		if(temp1 == "") {
			alert("Please enter your company address!");
			document.NEWMEMBER.cpnAdd1.focus();
			return false;
		}
		else if (!checkLongWord(temp1))
		{
			alert("The Address field contains an extraordinarily long word! Please shorten it.");
			document.NEWMEMBER.cpnAdd1.focus();
			return false;
		}
	
		//Address2
		temp1 = trim(document.NEWMEMBER.cpnAdd2.value, 'both');
		if(temp1 == "") {
		}
		else if (!checkLongWord(temp1))
		{
			alert("The Address field contains an extraordinarily long word! Please shorten it.");
			document.NEWMEMBER.cpnAdd2.focus();
			return false;
		}

		//City
		temp1 = trim(document.NEWMEMBER.cpnCity.value, 'both');
		if(temp1 ==""){
			   alert("Please enter your company city!");
			   document.NEWMEMBER.cpnCity.focus();
			   return false;  
		}
		else if (!checkLongWord(temp1))
		{
			alert("The City field contains an extraordinarily long word! Please shorten it.");
			document.NEWMEMBER.cpnCity.focus();
			return false;
		}
		
		//zip
		temp1 = trim(document.NEWMEMBER.cpnPosCod.value, 'both');
		if(temp1 == ""){
			  alert("Please enter your company Postal Code!");
			  document.NEWMEMBER.cpnPosCod.focus();
			  return false;
		}

		//country
		if(document.NEWMEMBER.cpnCountry.value == "0"){
			alert("Please select your Country!");
			document.NEWMEMBER.cpnCountry.focus();
			return false;
		}

		//state, province & country
		if((document.NEWMEMBER.cpnCountry.value == "130")&&(document.NEWMEMBER.cpnState.value == "0")){
		  alert("Please select your State!");
		  document.NEWMEMBER.cpnState.focus();
		  return false;
		} 
		if((document.NEWMEMBER.cpnCountry.value == "130")&&(document.NEWMEMBER.cpnProvince.value != "")){
		  alert("Province is only required for non-Malaysian user only.");
		  document.NEWMEMBER.cpnProvince.focus();
		  return false;
		} 
		if((document.NEWMEMBER.cpnCountry.value != "130")&&(document.NEWMEMBER.cpnState.value != "0")){
		  alert("State field is only required for users from MALAYSIA only.");
		  document.NEWMEMBER.cpnState.focus();
		  return false;
		} 
		//home phone
		if(trim(document.NEWMEMBER.cpnOPhone1.value, 'both') == ""){
			alert("Please enter your Office number!");
			document.NEWMEMBER.cpnOPhone1.focus();
			return false;
		}
		if(trim(document.NEWMEMBER.cpnOPhone2.value, 'both') == ""){
			alert("Please enter your Office number!");
			document.NEWMEMBER.cpnOPhone2.focus();
			return false;
		}

		if(document.NEWMEMBER.cpnOPhone1.value != ""){
			for(var q=0; q<document.NEWMEMBER.cpnOPhone1.value.length; q++) {
				temp = document.NEWMEMBER.cpnOPhone1.value.substring(q,q+1);
				if(tel.indexOf(temp) == "-1") ok = "no";	
			}
		
			if(ok == "no") {
				alert("Office number is invalid. Use only numbers! ");
				ok = "yes";
				document.NEWMEMBER.cpnOPhone1.focus();
				return false;
			}
		}
		if(document.NEWMEMBER.cpnOPhone2.value != ""){
			for(var q=0; q<document.NEWMEMBER.cpnOPhone2.value.length; q++) {
				temp = document.NEWMEMBER.cpnOPhone2.value.substring(q,q+1);
				if(tel.indexOf(temp) == "-1") ok = "no";	
			}
		
			if(ok == "no") {
				alert("Office number is invalid. Use only numbers! ");
				ok = "yes";
				document.NEWMEMBER.cpnOPhone2.focus();
				return false;
			}
		}

		//office phone
		if(document.NEWMEMBER.cpnFax1.value != "" && document.NEWMEMBER.cpnFax2.value == ""){
			alert("Fax number is invalid. Please check it! ");
			document.NEWMEMBER.cpnFax2.focus();
			return false;
		}
		else if(document.NEWMEMBER.cpnFax1.value == "" && document.NEWMEMBER.cpnFax2.value != ""){
			alert("Fax number is invalid. Please check it! ");
			document.NEWMEMBER.cpnFax1.focus();
			return false;
		}

	}

           	

	//acknowledegment
	if(document.NEWMEMBER.Acknowledgement.value == ""){
	  alert("Please select your acknowlwdegement!");
	  document.NEWMEMBER.Acknowledgement.focus();
	  return false;
	} 

	return true;
}

function validateCom(year)
{		
	var valid1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var tel = "0123456789- ";
	var ok1 = "yes";
	var temp = "";
	var temp1 = "";
/*
	var shipadds0 = document.Company_Admin.shipAdds[0].value;
	var shipadds1 = document.Company_Admin.shipAdds[1].value;
	var shipadds2 = document.Company_Admin.shipAdds[2].value;
*/
	////////
	// Company Information
	////////	

	//company name
	temp1 = trim(document.Company_Admin.txtCompanyName.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company name ! ");
		document.Company_Admin.txtCompanyName.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Name field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCompanyName.focus();
		return false;
	}
	
/*	//company reg. no.
	temp1 = trim(document.Company_Admin.txtCompanyReg.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company registration number ! ");
		document.Company_Admin.txtCompanyReg.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Registration Number field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCompanyReg.focus();
		return false;
	}
*/
	//company address
	temp1 = trim(document.Company_Admin.txtComAdd.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company address! ");
		document.Company_Admin.txtComAdd.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Address field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtComAdd.focus();
		return false;
	}

	//City
	temp1 = trim(document.Company_Admin.txtCity.value, 'both');
	if(temp1 ==""){
	  	       alert("Please enter the City!");
	  	       document.Company_Admin.txtCity.focus();
	  	       return false;  
	}
	else if (!checkLongWord(temp1))
	{
		alert("The City field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCity.focus();
		return false;
	}
	  
	//zip
	temp1 = trim(document.Company_Admin.txtPosCode.value, 'both');
	if(temp1 == ""){
		      alert("Please enter the Postal Code!");
		      document.Company_Admin.txtPosCode.focus();
		      return false;
	}

	//country
	if(document.Company_Admin.country.value == "0"){
		alert("Please select your Country!");
		document.Company_Admin.country.focus();
		return false;
	}
		
	 //malaysia cannot choose basic package  
	//  if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.cpnType.value == "1")){
	//      alert("Basic Member is a free servies applicable only to International/Non-Malaysian Companies.Please select your Country!");
	//      document.Company_Admin.country.focus();
	 //     return false;
	 //}  						

	 //state, province & country
	 if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.state.value == "0")){
	      alert("Please select your State!");
	      document.Company_Admin.state.focus();
	      return false;
	 } 
	 if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.txtProvince.value != "")){
	      alert("Province is only required for non-Malaysian user only.");
	      document.Company_Admin.txtProvince.focus();
	      return false;
	 } 
	 if((document.Company_Admin.country.value != "130")&&(document.Company_Admin.state.value != "0")){
	      alert("State field is only required for users from MALAYSIA only.");
	      document.Company_Admin.state.focus();
	      return false;
	 } 

	 
	       	
	//company phone
	 if(document.Company_Admin.txtComPhone.value == "") {
	 	alert("Please enter your company phone number! ");
	 	document.Company_Admin.txtComPhone.focus();
	 	return false;
	 }
	 for(var r=0; r<document.Company_Admin.txtComPhone.value.length; r++) {
	 	temp = document.Company_Admin.txtComPhone.value.substring(r,r+1);
	 	if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 }
	
	 if(ok1 == "no") {
	 	alert("Company phone number is invalid. Use only numbers! ");
	 	ok1 = "yes";
	 	document.Company_Admin.txtComPhone.focus();
	 	return false;
	 }

	 //company fax
	 if(document.Company_Admin.txtComFax.value != ""){
	 	for(var m=0; m<document.Company_Admin.txtComFax.value.length; m++) {
	 		temp = document.Company_Admin.txtComFax.value.substring(m,m+1);
	 		if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 	}
	 
	 	if(ok1 == "no") {
	 		alert("Office Fax Number is invalid. Use only numbers! ");
	 		ok1 = "yes";
	 		document.Company_Admin.txtComFax.focus();
	 		return false;
	 	}
	 }
	


     //All OK, proceed to the complete member information page
	return true;
//	document.Company_Admin.submit();
}

function validateCompCat(year)
{
/*	 // Check the industry
	 if(document.Company_Admin.Category.value == "") {
	 	alert("Please enter select your industry! ");
	 	document.Company_Admin.Category.focus();
	 	return false;
	 }
*/

/*	 // Check the industry
	 ind_size = Company_Admin.ind.length;
	 isSelected = false;
	 selectedSize = 0;
	 for ( i=0; i < ind_size; i++)
	 {
	 	if (Company_Admin.ind[i].selected)
	 	{ 
	 		isSelected = true;
	 		selectedSize++;
	 	}
	 }
	 if (!isSelected) 
	 {
	      alert("Please select your company industry!");
	      Company_Admin.ind.focus();
	      return false;
	 }
	 if(selectedSize>4)
	 {
	      alert("You can select only maximum 4 industry to list your company!");
	      Company_Admin.ind.focus();
	      return false;
	 }
*/
/*	 // check whether company desc length is in a right range 
	 var desclen = document.Company_Admin.txtCpnDesc.value.length;
	 if(desclen > 2000) {
	 	alert("Company description must contain not more than 2000 characters only!");
	 	document.Company_Admin.txtCpnDesc.focus();
	 	return false;
	 }
	
	// check on the file type that going to be uploaded
	if (document.Company_Admin.fileCpnLogo.value.length > 0) 
	{
	    if (document.Company_Admin.fileCpnLogo.value.length >= 200) 
		{
	        alert("Please keep your file path shorter than 200 characters");
	        document.Company_Admin.fileCpnLogo.focus();
	        return false;
	    }
	    
		var index = document.Company_Admin.fileCpnLogo.value.indexOf('.');
	    var ext = document.Company_Admin.fileCpnLogo.value.substring(index+1, document.Company_Admin.fileCpnLogo.value.length)
	    
	    if (ext!="jpg" && ext!="JPG" && ext!="gif" && ext!="GIF")
		{
	        alert("Uploaded file must have extension .jpg and .gif only");
	        document.Company_Admin.fileCpnLogo.focus();
	        return false;
	    }
	}
*/
/*
	//Shipping Addresses
	if (!checkLongWord(shipadds0))
	{
		alert("The Shipping Address 1 field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.shipAdds[0].focus();
		return false;
	}
	else if(!checkLongWord(shipadds1))
	{
		alert("The Shipping Address 2 field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.shipAdds[1].focus();
		return false;
	}
	else if(!checkLongWord(shipadds2))
	{
		alert("The Shipping Address 3 field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.shipAdds[2].focus();
		return false;
	}
	  
	if ((shipadds0==shipadds1 && shipadds0!="")||(shipadds1==shipadds2 && shipadds1!="")
	    ||(shipadds2==shipadds0 && shipadds2!=""))
	{
	   alert("Repeated shipping addresses found!");
     	   document.Company_Admin.shipAdds[0].focus();
     	   return false;		
	}
*/	 
   /*
    //Check business type
	
	if (document.Company_Admin.selBusiness.value == "0")
	{
		alert("Please specify your company's business type.");
		document.Company_Admin.selBusiness.focus();
		return false;
	}


	// Check services
	if (!document.Company_Admin.buyerRole.checked && !document.Company_Admin.sellerRole.checked)
	{
		alert("Please select your services!");
		document.Company_Admin.buyerRole.focus();
		return false;
	}
    
	*/
	
}

function validateCompMem(year)
{
	var valid1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var tel = "0123456789- ";
	var ok1 = "yes";
	var temp = "";
	var temp1 = "";

	// Check the industry
	 if(document.Company_Admin.Category.value == "") {
	 	alert("Please enter select your industry! ");
	 	document.Company_Admin.Category.focus();
	 	return false;
	 }
	//Check business type

	if (document.Company_Admin.selBusiness.value == "0")
	{
		alert("Please specify your company's business type.");
		document.Company_Admin.selBusiness.focus();
		return false;
	}

	//company name
	temp1 = trim(document.Company_Admin.txtCompanyName.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company name ! ");
		document.Company_Admin.txtCompanyName.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Name field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCompanyName.focus();
		return false;
	}
	
/*	//company reg. no.
	temp1 = trim(document.Company_Admin.txtCompanyReg.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company registration number ! ");
		document.Company_Admin.txtCompanyReg.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Registration Number field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCompanyReg.focus();
		return false;
	}
*/
	//company address
	temp1 = trim(document.Company_Admin.txtComAdd.value, 'both');
	if(temp1 == "") {
		alert("Please enter your company address! ");
		document.Company_Admin.txtComAdd.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Company Address field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtComAdd.focus();
		return false;
	}

	//City
	temp1 = trim(document.Company_Admin.txtCity.value, 'both');
	if(temp1 ==""){
	  	       alert("Please enter the City!");
	  	       document.Company_Admin.txtCity.focus();
	  	       return false;  
	}
	else if (!checkLongWord(temp1))
	{
		alert("The City field contains an extraordinarily long word! Please shorten it.");
		document.Company_Admin.txtCity.focus();
		return false;
	}
	 
	//zip
	temp1 = trim(document.Company_Admin.txtPosCode.value, 'both');
	if(temp1 == ""){
		      alert("Please enter the Postal Code!");
		      document.Company_Admin.txtPosCode.focus();
		      return false;
	}

	//country
	if(document.Company_Admin.country.value == "0"){
		alert("Please select your Country!");
		document.Company_Admin.country.focus();
		return false;
	}
	
	 //malaysia cannot choose basic package  
	//  if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.cpnType.value == "1")){
	//      alert("Basic Member is a free servies applicable only to International/Non-Malaysian Companies.Please select your Country!");
	//      document.Company_Admin.country.focus();
	 //     return false;
	 //}  						

	 //state, province & country
	 if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.state.value == "0")){
	      alert("Please select your State!");
	      document.Company_Admin.state.focus();
	      return false;
	 } 
	 if((document.Company_Admin.country.value == "130")&&(document.Company_Admin.txtProvince.value != "")){
	      alert("Province is only required for non-Malaysian user only.");
	      document.Company_Admin.txtProvince.focus();
	      return false;
	 } 
	 if((document.Company_Admin.country.value != "130")&&(document.Company_Admin.state.value != "0")){
	      alert("State field is only required for users from MALAYSIA only.");
	      document.Company_Admin.state.focus();
	      return false;
	 } 
      	
	//company phone
	if(document.Company_Admin.txtComPhone1.value == "") {
	 	alert("Please enter your company phone number! ");
	 	document.Company_Admin.txtComPhone1.focus();
	 	return false;
	 }
	 for(var r=0; r<document.Company_Admin.txtComPhone1.value.length; r++) {
	 	temp = document.Company_Admin.txtComPhone1.value.substring(r,r+1);
	 	if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 }
	
	 if(ok1 == "no") {
	 	alert("Company phone number is invalid. Use only numbers! ");
	 	ok1 = "yes";
	 	document.Company_Admin.txtComPhone1.focus();
	 	return false;
	 }

	 if(document.Company_Admin.txtComPhone.value == "") {
	 	alert("Please enter your company phone number! ");
	 	document.Company_Admin.txtComPhone.focus();
	 	return false;
	 }
	 for(var r=0; r<document.Company_Admin.txtComPhone.value.length; r++) {
	 	temp = document.Company_Admin.txtComPhone.value.substring(r,r+1);
	 	if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 }
	
	 if(ok1 == "no") {
	 	alert("Company phone number is invalid. Use only numbers! ");
	 	ok1 = "yes";
	 	document.Company_Admin.txtComPhone.focus();
	 	return false;
	 }

	 //company fax
	if(document.Company_Admin.txtComFax1.value != "" && document.Company_Admin.txtComFax.value == ""){
		alert("Office Fax Number is invalid. Please check it again! ");
		document.Company_Admin.txtComFax.focus();
	 	return false;
	}
	if(document.Company_Admin.txtComFax.value != "" && document.Company_Admin.txtComFax1.value == ""){
		alert("Office Fax Number is invalid. Please check it again! ");
		document.Company_Admin.txtComFax1.focus();
	 	return false;
	}
	
	if(document.Company_Admin.txtComFax1.value != ""){
	 	for(var m=0; m<document.Company_Admin.txtComFax1.value.length; m++) {
	 		temp = document.Company_Admin.txtComFax1.value.substring(m,m+1);
	 		if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 	}
	 
	 	if(ok1 == "no") {
	 		alert("Office Fax Number is invalid. Use only numbers! ");
	 		ok1 = "yes";
	 		document.Company_Admin.txtComFax1.focus();
	 		return false;
	 	}
	 }
	 if(document.Company_Admin.txtComFax.value != ""){
	 	for(var m=0; m<document.Company_Admin.txtComFax.value.length; m++) {
	 		temp = document.Company_Admin.txtComFax.value.substring(m,m+1);
	 		if(tel.indexOf(temp) == "-1") ok1 = "no";	
	 	}
	 
	 	if(ok1 == "no") {
	 		alert("Office Fax Number is invalid. Use only numbers! ");
	 		ok1 = "yes";
	 		document.Company_Admin.txtComFax.focus();
	 		return false;
	 	}
	 }

	 // Company Admin Information
	 
	 //User Login ID validate
	 if(document.Company_Admin.txtAdmLogin.value == "") {
	 	alert("Please enter your Login ID!");
	 	document.Company_Admin.txtAdmLogin.focus();
	 	return false;
	 }
	
	 // check whether login length is in a right range 
	 for(var n=0; n<document.Company_Admin.txtAdmLogin.value.length; n++) {
	 	temp = document.Company_Admin.txtAdmLogin.value.substring(n,n+1);
	 	if(valid1.indexOf(temp) == "-1") ok1 = "no";	
	 }
	 
	 if(ok1 == "no") {
	 	alert("Login ID is invalid. Use only characters and numbers! ");
	 	ok1 == "yes";
	 	document.Company_Admin.txtAdmLogin.focus();
	 	return false;
	 }
	
	 //check whether login name is in a right range
	 var len = document.Company_Admin.txtAdmLogin.value.length;
	 if(len > 12 || len < 6) {
	 	alert("Login ID must contain 6 to 12 characters only!");
	 	document.Company_Admin.txtAdmLogin.focus();
	 	return false;
	 }
	
	 // password
	 if(document.Company_Admin.txtAdmPass.value == "") {
	 	alert("Please enter your Password!");
	 	document.Company_Admin.txtAdmPass.focus();
	 	return false;
	 }	
	 	
	 // check whether password length is in a right range 
	 var plen = document.Company_Admin.txtAdmPass.value.length;
	 if(plen > 12 || plen < 6) {
	 	alert("Password must contain 6 to 12 characters only!");
	 	document.Company_Admin.txtAdmPass.focus();
	 	return false;
	 }
	 
	 //User Password validate
	 for(var n=0; n<document.Company_Admin.txtAdmPass.value.length; n++) {
	 	temp = document.Company_Admin.txtAdmPass.value.substring(n,n+1);
	 	if(valid1.indexOf(temp) == "-1") ok1 = "no";	
	 }
	 
	 if(ok1 == "no") {
	 	alert("Password is invalid. Use only characters and numbers! ");
	 	ok1 == "yes";
	 	document.Company_Admin.txtAdmPass.focus();
	 	return false;
	 }
	
	 // confirm password	
	 if(document.Company_Admin.txtAdmPass2.value == "") {
	 	alert("Please confirm your Password!");
	 	document.Company_Admin.txtAdmPass2.focus();	
	 	return false;
	 }
	
	 var pw1 = document.Company_Admin.txtAdmPass.value;
	 var pw2 = document.Company_Admin.txtAdmPass2.value;
	 if(pw1 != pw2) {
	 	alert("Incorrect match. Please confirm your Password again!");
	 	document.Company_Admin.txtAdmPass2.focus();
	 	return false;
	 }	
	
	 //Full Name validate
	 temp1 = trim(document.Company_Admin.txtfullName.value, 'both');
	 if(temp1 == "" ) {
	 	alert("Please enter your full name!");
	 	document.Company_Admin.txtfullName.focus();
	 	return false;
	 }
	 else if (!checkLongWord(temp1))
	 {
	 	alert("The Full Name field contains an extraordinarily long word! Please shorten it.");
	 	document.Company_Admin.txtfullName.focus();
	 	return false;
	 }
	
	 //Gender validate
	 if(document.Company_Admin.rGender.value == "" ) {
	 	alert("Please select your gender!");
	 	document.Company_Admin.rGender.focus();
	 	return false;
	 }

	 // email
	 temp1 = trim(document.Company_Admin.txtEmail.value, 'both');
	 if(temp1 == "") {
	 	alert("Please enter your Email Address! ");
	 	document.Company_Admin.txtEmail.focus();
	  	return false;
	 }
	
	 //User Email validate
	 if(document.Company_Admin.txtEmail.value.indexOf("@") == -1){
	 	alert("Email address is invalid. Please re-enter your email address!");
	 	document.Company_Admin.txtEmail.focus();
	 	return false;
	 }
	
	 // valify word
	 if(document.Company_Admin.txtWord.value == "") {
	 	alert("Please enter the text that show in the box! ");
	 	document.Company_Admin.txtWord.focus();
	  	return false;
	 }
	
	 // hint  question
	 if(document.Company_Admin.hintQuestion.value == "") {
	 	alert("Please select a hint question! ");
	 	document.Company_Admin.hintQuestion.focus();
	  	return false;
	 }

	 // hint answer
	 temp1 = trim(document.Company_Admin.hintAnswer.value, 'both');
	 if(temp1 == "") {
	 	alert("Please enter your hint answer! ");
	 	document.Company_Admin.hintAnswer.focus();
	  	return false;
	 }
	 else if (!checkLongWord(temp1))
	 {
	 	alert("The Hint Answer contains an extraordinarily long word! Please shorten it.");
	 	document.Company_Admin.txtfullName.focus();
	 	return false;
	 }
	
	  //acknowledegment
	  if(!document.Company_Admin.Acknowledgement.checked){
	       alert("You need to agree to eAsia2u Terms & Conditions in order to register in eAsia2u!");
	       document.Company_Admin.Acknowledgement.focus();
	       return false;
	  } 

     //All OK, proceed to the procregcom.jsp page
	return true;
}

function validateMem(year)
{		
	var valid2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var tel = "0123456789- ";
	var ok2 = "yes";
	var temp = "";
	var temp1 = "";
      	
    // Company Member Information
	
	//User Name validate
	temp1 = trim(document.CompanyMem.txtfullName.value, 'both');
	if(temp1 == "" ) {
		alert("Please enter the full name!");
		document.CompanyMem.txtfullName.focus();
		return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Full Name field contains an extraordinarily long word! Please shorten it.");
		document.CompanyMem.txtfullName.focus();
		return false;
	}
	
	//User Gender validate
	if(document.CompanyMem.rGender.value == "" ) {
		alert("Please select the gender!");
		document.CompanyMem.rGender.focus();
		return false;
	}
	
	
	//User Login ID validate
	if(document.CompanyMem.txtLogin.value == "") {
		alert("Please enter the Login ID!");
		document.CompanyMem.txtLogin.focus();
		return false;
	}

    // check whether login length is in a right range 
	for(var n=0; n<document.CompanyMem.txtLogin.value.length; n++) {
		temp = document.CompanyMem.txtLogin.value.substring(n,n+1);
		if(valid2.indexOf(temp) == "-1") ok2 = "no";	
	}
	
	if(ok2 == "no") {
		alert("Login ID is invalid. Use only characters and numbers! ");
		document.CompanyMem.txtLogin.focus();
		return false;
	}
	
	//check whether login name is in a right range
	var len = document.CompanyMem.txtLogin.value.length;
	if(len > 12 || len < 6) {
		alert("Login ID must contain 6 to 12 characters only!");
		document.CompanyMem.txtLogin.focus();
		return false;
	}

	// password
	if(document.CompanyMem.txtPass.value == "") {
		alert("Please enter the Password!");
		document.CompanyMem.txtPass.focus();
		return false;
	}	
		
	// check whether password length is in a right range 
	for(var n=0; n<document.CompanyMem.txtPass.value.length; n++) {
		temp = document.CompanyMem.txtPass.value.substring(n,n+1);
		if(valid2.indexOf(temp) == "-1") ok2 = "no";	
	}
	
	if(ok2 == "no") {
		alert("Password is invalid. Use only characters and numbers! ");
		document.CompanyMem.txtPass.focus();
		return false;
	}
	
	//User Password validate
	var plen = document.CompanyMem.txtPass.value.length;
	if(plen > 12 || plen < 6) {
		alert("Password must contain 6 to 12 characters only!");
		document.CompanyMem.txtPass.focus();
		return false;
	}
	
	// confirm password	
	if(document.CompanyMem.txtPass2.value == "") {
		alert("Please confirm the Password!");
		document.CompanyMem.txtPass2.focus();	
		return false;
	}

	var pw1 = document.CompanyMem.txtPass.value;
	var pw2 = document.CompanyMem.txtPass2.value;
	if(pw1 != pw2) {
		alert("Incorrect match with password, Please re-enter the password!");
		document.CompanyMem.txtPass2.focus();
		return false;
	}	
	
	
	// hint  question
	if(document.CompanyMem.hintQuestion.value == "") {
		alert("Please select a hint question! ");
		document.CompanyMem.hintQuestion.focus();
	 	return false;
	}
	
	// hint answer
	temp1 = trim(document.CompanyMem.hintAnswer.value, 'both');
	if(temp1 == "") {
		alert("Please enter your hint answer! ");
		document.CompanyMem.hintAnswer.focus();
	 	return false;
	}
	else if (!checkLongWord(temp1))
	{
		alert("The Hint Answer field contains an extraordinarily long word! Please shorten it.");
		document.CompanyMem.hintAnswer.focus();
		return false;
	}
	
	// email
	temp1 = trim(document.CompanyMem.txtEmail.value, 'both');
	if(temp1 == "") {
		alert("Please enter the Email Address! ");
		document.CompanyMem.txtEmail.focus();
	 	return false;
	}
	//User Email validate
	if(document.CompanyMem.txtEmail.value.indexOf("@") == -1){
		alert("Email address is invalid. Please re-enter the email address!");
		document.CompanyMem.txtEmail.focus();
		return false;
	}

	//office phone
	if(document.CompanyMem.txtMobile.value == ""){
	     alert("Please enter the mobile phone number!");
	     document.CompanyMem.txtMobile.focus();
	     return false;
	} 
	for(var p=0; p<document.CompanyMem.txtMobile.value.length; p++) {
		temp = document.CompanyMem.txtMobile.value.substring(p,p+1);
		if(tel.indexOf(temp) == "-1") ok2 = "no";	
	}
	
	if(ok2 == "no") {
		alert("Mobile phone number is invalid. Use only numbers! ");
		ok2 = "yes";
		document.CompanyMem.txtMobile.focus();
		return false;
	}

	//fax
	if(document.CompanyMem.txtFax.value != ""){
		for(var w=0; w<document.CompanyMem.txtFax.value.length; w++) {
			temp = document.CompanyMem.txtFax.value.substring(w,w+1);
			if(tel.indexOf(temp) == "-1") ok2 = "no";	
		}
	
		if(ok2 == "no") {
			alert("Fax Number is invalid. Use only numbers! ");
			ok2 = "yes";
			document.CompanyMem.txtFax.focus();
			return false;
		}
	}
     
     //state, province & country
      if((document.CompanyMem.selCountry.value == "130")&&(document.CompanyMem.selState.value == "0")){
           alert("Please select the State!");
           document.CompanyMem.selState.focus();
           return false;
      } 
	  
      if((document.CompanyMem.selCountry.value == "130")&&(document.CompanyMem.txtProvince.value != "")){
           alert("Province is only required for non-Malaysian user only.");
           document.CompanyMem.txtProvince.focus();
           return false;
      } 
	  	  	  
      if((document.CompanyMem.selCountry.value != "130")&&(document.CompanyMem.selState.value != "0")){
           alert("State field is only required for Malaysian user.");
           document.CompanyMem.selState.focus();
           return false;
      } 
	  
      if((document.CompanyMem.selCountry.value == "0")&&(document.CompanyMem.txtProvince.value != "")){
           alert("Please select the country where the province located.");
           document.CompanyMem.txtProvince.focus();
           return false;
      } 
     
     //home phone
     if(document.CompanyMem.txtHomePhone.value != ""){
     	for(var t=0; t<document.CompanyMem.txtHomePhone.value.length; t++) {
     		temp = document.CompanyMem.txtHomePhone.value.substring(t,t+1);
     		if(tel.indexOf(temp) == "-1") ok2 = "no";	
     	}
     
     	if(ok2 == "no") {
     		alert("Home phone number is invalid. Use only numbers! ");
     		ok2 = "yes";
     		document.CompanyMem.txtHomePhone.focus();
     		return false;
     	}
     }

     //mobile phone
     if(document.CompanyMem.txtMobile.value != ""){
     	for(var s=0; s<document.CompanyMem.txtMobile.value.length; s++) {
     		temp = document.CompanyMem.txtMobile.value.substring(s,s+1);
     		if(tel.indexOf(temp) == "-1") ok2 = "no";	
     	}
     
     	if(ok2 == "no") {
     		alert("Mobile phone number is invalid. Use only numbers! ");
     		ok2 = "yes";
     		document.CompanyMem.txtMobile.focus();
     		return false;
     	}
     }
     
     //	//birth date
 
     var bDay = parseInt(document.CompanyMem.bDay.value,10);
     var bMth = parseInt(document.CompanyMem.bMth.value,10)+1;
     var bYear = parseInt(document.CompanyMem.bYear.value,10);	
 
     var aDaysInMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
      
     // Check for leap year
     var iDaysInMonth=(bMth!=2)?aDaysInMonth[bMth-1]:
     		((bYear%4==0 && bYear%100!=0 || bYear % 400==0)?29:28);
  
	 if (bDay=="-1" && bMth=="0" && bYear=="-1")
	 {
	 }
	 else if (bDay!="-1" && bMth=="0")
	 {
	    alert("Please select the month you were born in!");
		document.CompanyMem.bMth.focus();
	    return false;
	 }
	 else if (bDay!="-1" && bYear=="-1")
	 {
	    alert("Please select the year you were born in!");
		document.CompanyMem.bYear.focus();
	    return false;
	 }
	 else if (bMth!="0" && bDay=="-1")
	 {
	    alert("Please select the date you were born in!");
		document.CompanyMem.bDay.focus();
	    return false;
	 }
	 else if (bYear!="-1" && bDay=="-1")
	 {
	    alert("Please select the date you were born in!");
		document.CompanyMem.bDay.focus();
	    return false;
	 }
	 else if (bMth!="0" && bYear=="-1")
	 {
	    alert("Please select the year you were born in!");
		document.CompanyMem.bYear.focus();
	    return false;
	 }	
	 else if (bYear!="-1" && bMth=="0")
	 {
	    alert("Please select the year you were born in!");
		document.CompanyMem.bMth.focus();
	    return false;
	 }
	 else if (!(bDay!="-1" && bMth!="0" && bYear!="-1" && bDay<=iDaysInMonth))
	 {
	    alert("Invalid date. Please re-enter the birthdate.");
		document.CompanyMem.bDay.focus();
	    return false;
	 }
	 else
	 {
		var crrYear = parseInt(year,10)-17; 
		var entYear = parseInt(document.CompanyMem.bYear.value,10);
		if (entYear > crrYear){	
		  alert("Registered member have to be at least 18 years old.");
		  document.CompanyMem.bYear.focus();	  
		  return false;
		}
	 }
	
     	
     //acknowledegment
     if(document.CompanyMem.rAck.value == ""){
          alert("Please select the acknowlwdegement!");
          document.CompanyMem.rAck.focus();
          return false;
     } 

     // rights
     rights_size = CompanyMem.rights.length;
     ischecked = false;
     for ( i=0; i < rights_size; i++)
     {
     	if (CompanyMem.rights[i].checked)
     	{ 
     		ischecked = true;
     		break; 
     	}
     }
     if (!ischecked) 
     {
          alert("Please select rights that need to be granted to this member!");
          CompanyMem.rights[0].focus();
          return false;
     }
    

     //All OK, proceed to the join.jsp page
	return true;
//	document.CompanyMem.submit();
}