// APSIPA
// for reg.asp
function FormSubmit(sFormId,sTarget,sAction,sMethod)
{// form submit
	var x=document.getElementById(sFormId);
	if(x==null){return false;}
	x.target=sTarget;
	x.action=sAction;
	x.method=sMethod;
	x.submit();
	return true;
}
function DisplayAlertMsg(sAlertId,sMsg)
{
	var y=document.getElementById(sAlertId);
	if(y!=null){y.innerHTML=sMsg;}
}
function IsRadioNotEmtpy(radioObject,sAlertId,sMsg)
{// return true if the radio input is not empty. Otherwise, false.
// also show the alert message at the specific location.
	var b;var y;var i,N;
	try{
		if(radioObject!=null){
			N=radioObject.length;b=false;
			for(i=0;i<N && b==false;i++){
				if(radioObject[i].checked){b=true;}
			}
			y=document.getElementById(sAlertId);
			if(y!=null){y.innerHTML=b?"":sMsg;}
			return b;
		}else{return false;}
	}catch(err){
		s="Error.\n\n";
		//s+="IsRadioNotEmtpy(). " + err.description + "\n\n";
		s+=err.description + "\n\n";
		alert(s);
		return false;
	}
}
function IsSelectNotEmpty(sId,sNull,sAlertId,sMsg)
{// return true if the "select" input is not empty. Otherwise, false.
// also show the alert message at the specific location.
	var x;var b;var i;
	try{
		x=document.getElementById(sId);
		if(x!=null){
			i=x.options[x.selectedIndex].text.indexOf(sNull);
			b=(i==0)?false:true;//x.options[x.selectedIndex].value
			y=document.getElementById(sAlertId);
			if(y!=null){y.innerHTML=b?"":sMsg;}
			return b;
		}else{return false;}
	}catch(err){
		s="Error.\n\n";
		//s+="IsSelectNotEmpty(). " + err.description + "\n\n";
		s+=err.description + "\n\n";
		alert(s);
		return false;
	}
}
function IsTxtNotEmpty_main(sValue)
{// return true if not empty. Otherwise, false.
	if(sValue.length<1){return false;}
	return true;
}

function IsTxtLenChar(sId,sAlertId,sMsg, sMin, sMax)
{
	// return true if the lenght in between sMin and sMax. Otherwise, false.
// also show the alert message at the specific location.
	var b;var y;
	var x=document.getElementById(sId);
	if(x!=null){
		b=(x.value.length>=sMin && x.value.length<=sMax)?true:false;// validation
		y=document.getElementById(sAlertId);
		if(y!=null){y.innerHTML=b?"":sMsg;}
		return b;
	}else{return false;}
	
}
function IsTxtNotEmpty(sId,sAlertId,sMsg)
{// return true if not empty. Otherwise, false.
// also show the alert message at the specific location.
	var b;var y;
	var x=document.getElementById(sId);
	if(x!=null){
		b=(x.value.length>0)?true:false;// validation
		y=document.getElementById(sAlertId);
		if(y!=null){y.innerHTML=b?"":sMsg;}
		return b;
	}else{return false;}
}

function IsTxtNotEmpty2(sId,sAlertId,sMsg)
{// return true if not empty. Otherwise, false.
// also show the alert message at the specific location.
	var b;var y;
	var x=document.getElementById(sId);
	if(x!=null){
		b=(x.value.length>0)?true:false;// validation
		
		return b;
	}else{return false;}
}
function IsEmail_main(sValue)
{// return true if the email address is valid. Otherwise false.
	var s="";
	var i;
	try{
		i=sValue.indexOf("@");
		if(i<1){return false;}
		else{
			if(sValue.indexOf(".",i)<(i+2)){return false;}
		}
		return true;
	}catch(err){
		s="Error.\n\n";
		//s+="IsEmail_main(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
}
function IsEmail(sId,sAlertId,sMsg)
{// return true if the email address is valid. Otherwise false.
// also show the alert message at the specific location.
	var b;var y;
	var x=document.getElementById(sId);
	if(x!=null){
		b=IsEmail_main(x.value);
		y=document.getElementById(sAlertId);
		if(y!=null){y.innerHTML=b?"":sMsg;}
		return b;
	}else{return false;}
}
function IsPasswordSame_main(s1,s2)
{// return true if two passwords are same. Otherwise false.
	var s;var i,i2;
	try{
		i1=s1.indexOf(s2);
		i2=s2.indexOf(s1);
		if((i1==0) && (i2==0)){return true;}
		else{return false;}
	}catch(err){
		s="Error.\n\n";
		s+="IsPasswordSame_main(). " + err.description + "\n\n";
		alert(s);
		return false;
	}
}
function IsPasswordSame(sId1,sId2,sAlertId,sMsg)
{// return true if two passwords are same. Otherwise false.
// also show the alert message at the specific location.
	var y;var b=false;var i1,i2;
	var x1=document.getElementById(sId1);
	var x2=document.getElementById(sId2);
	if((x1!=null) && (x2!=null)){
		b=IsPasswordSame_main(x1.value,x2.value);
		y=document.getElementById(sAlertId);
		if(y!=null){y.innerHTML=b?"":sMsg;}
		return b;
	}else{return false;}
	return false;
}

////////////////////////////// 
/*
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))){ return false;}
    }
    // All characters are numbers.
    return true;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this;
}

function IsDateT(sYearId,sMonthId,sDayId,sAlertId)
{// is the date valid?
	var minYear=1800;
	var maxYear=2100;
	var iYear,iMonth,iDay;
	var daysInMonth = DaysArray(12);
	var y;var b=false;
	var x1=document.getElementById(sYearId);
	var x2=document.getElementById(sMonthId);
	var x3=document.getElementById(sDayId);
	if(x1!=null && x2!=null && x3!=null){
		y=document.getElementById(sAlertId);
		if ((isInteger(x1.value)==false) || (isInteger(x2.value)==false) || (isInteger(x3.value)==false)){
			if(y!=null){y.innerHTML="<< Please input a valid date!";}
			return false;
		}
		iYear=parseInt(x1.value,10);
		iMonth=parseInt(x2.value,10);
		iDay=parseInt(x3.value,10);
		if (iMonth<1 || iMonth>12){
			if(y!=null){y.innerHTML="<< Invalid month!";}
			return false;
		}
		if (iDay<1 || iDay>31 || (iMonth==2 && iDay>daysInFebruary(iYear)) || iDay > daysInMonth[iMonth]){
			if(y!=null){y.innerHTML="<< Invalid day!";}
			return false;
		}
		if (iYear==0 || iYear<minYear || iYear>maxYear){
			//if(y!=null){y.innerHTML="Please enter a valid 4 digit year between "+minYear+" and "+maxYear;}
			if(y!=null){y.innerHTML="<< Invalid year!";}
			return false;
		}
	}else{return false;}

	return true;
}
//////////////////////////////
function FormFirstValidationReg()
{// form validation for reg.asp
	var s;var x;var b,bb,b3,b4;var sEmpty,sEmail,sPassword,sLen;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";	
	//sEmail="<< Invalid email address!";
	sLen="<< Password must be 6-20 characters!";
	sPassword="<< Two passwords are different!";
	try{
		// empty validation
		bb=IsTxtNotEmpty("txtUserID","a_userID",sEmpty);b=b && bb;

		// email address validation
		//if(bb){bb=IsEmail("txtUserID","a_userID",sEmail);b=b && bb;}
		
		// password validation

		bb=IsTxtLenChar("txtPwd","a_pwd",sLen,6,20);b=b && bb;
		b3=IsTxtLenChar("txtPwd2","a_pwd2",sLen,6,20);b=b && b3;
		if(bb && b3){bb=IsPasswordSame("txtPwd","txtPwd2","a_pwd2",sPassword);b=b && bb;}

		// radio validation
		bb=IsRadioNotEmtpy(document.reg.member,"a_member",sEmpty);b=b && bb;	

		
	}catch(err){
		s="Error.\n\n";
		//s+="FormValidationReg(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}
//////////////////////////////
function FormValidationReg()
{// form validation for reg.asp
	var s;var x;var b,bb,b3,b4;var sEmpty,sEmail,sPassword,sLen,sBirth;
	var b5,b6,b7;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";
	sBirth="<< Invaild Date!";
	sEmail="<< Invalid email address!";
	sLen="<< Password must be 6-20 characters!";
	sPassword="<< Two passwords are different!";
	try{
		// empty validation
		bb=IsTxtNotEmpty("txtUserID","a_userID",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtFamName","a_famName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtGivenName","a_givenName",sEmpty);b=b && bb;
		//bb=IsTxtNotEmpty("txtUniversity","a_university",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAffiliation","a_affiliation",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtPosition","a_position",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAddline1","a_addline1",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCity","a_city",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtOrganName","a_OrganName",sEmpty);b=b && bb;

		// email address validation
		if(bb){bb=IsEmail("txtUserID","a_userID",sEmail);b=b && bb;}
		
		// password validation
		//bb=IsTxtNotEmpty("txtPwd","a_pwd",sEmpty);b=b && bb;
		//b3=IsTxtNotEmpty("txtPwd2","a_pwd2",sEmpty);b=b && b3;
		bb=IsTxtLenChar("txtPwd","a_pwd",sLen,6,20);b=b && bb;
		b3=IsTxtLenChar("txtPwd2","a_pwd2",sLen,6,20);b=b && b3;
		if(bb && b3){bb=IsPasswordSame("txtPwd","txtPwd2","a_pwd2",sPassword);b=b && bb;}

		// birth validation
		//bb=IsTxtNotEmpty("txtBirthDay","a_birth",sEmpty);b=b && bb;
		//b3=IsTxtNotEmpty("txtBirthMonth","a_birth",sEmpty);b=b && b3;
		//b4=IsTxtNotEmpty("txtBirthYear","a_birth",sEmpty);b=b && b4;
		b5=IsTxtNotEmpty2("txtBirthDay","","");//b=b && bb;
		b6=IsTxtNotEmpty2("txtBirthMonth","","");//b=b && b3;
		b7=IsTxtNotEmpty2("txtBirthYear","","");//b=b && b4;
		
		if(b5 && b6 && b7)
		{			
			bb=IsDateT("txtBirthYear","txtBirthMonth","txtBirthDay","a_birth");
			b=b && bb;
		}
		else
		{		
			if(b5 || b6 || b7)
			{
				DisplayAlertMsg("a_birth",sBirth);b=b && false;
							
			}
			else{DisplayAlertMsg("a_birth","");}
		}		

		// radio validation
		bb=IsRadioNotEmtpy(document.reg.gender,"a_gender",sEmpty);b=b && bb;
		bb=IsRadioNotEmtpy(document.reg.member,"a_member",sEmpty);b=b && bb;
		bb=IsRadioNotEmtpy(document.reg.addType,"a_addType",sEmpty);b=b && bb;
		
		bb=IsRadioNotEmtpy(document.reg.title,"a_Title",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdoTitleOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtOtherTitle","a_Title",sEmpty);b=b && bb;}
			}
		}
		
		// highDeg validation
		bb=IsRadioNotEmtpy(document.reg.highDeg,"a_highDeg",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdohighDegOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtHighDeg","a_highDeg",sEmpty);b=b && bb;}
			}
		}

		// select input validation
		bb=IsSelectNotEmpty("selectCountry","Please select a country","a_country",sEmpty);b=b && bb;
	}catch(err){
		s="Error.\n\n";
		//s+="FormValidationReg(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}

//////////////////////////////
function FormNextStdValidationReg()
{// form validation for reg.asp
	var s;var x;var b,bb,b3,b4;var sEmpty,sEmail,sBirth;
	var b5,b6,b7;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";
	sBirth="<< Invaild Date!";
	sEmail="<< Invalid email address!";

	try{
		// empty validation
		//bb=IsTxtNotEmpty("txtUserID","a_userID",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtFamName","a_famName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtGivenName","a_givenName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtUniversity","a_university",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAffiliation","a_affiliation",sEmpty);b=b && bb;
		//bb=IsTxtNotEmpty("txtPosition","a_position",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAddline1","a_addline1",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCity","a_city",sEmpty);b=b && bb;
		//bb=IsTxtNotEmpty("txtOrganName","a_OrganName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtEmail","a_email",sEmpty);b=b && bb;
		
		bb=IsTxtNotEmpty("txtCountry","a_country",sEmpty);b=b && bb;
		

		// email address validation
		if(bb){bb=IsEmail("txtEmail","a_email",sEmail);b=b && bb;}
		
		
		
		b5=IsTxtNotEmpty2("txtBirthDay","","");//b=b && bb;
		b6=IsTxtNotEmpty2("txtBirthMonth","","");//b=b && b3;
		b7=IsTxtNotEmpty2("txtBirthYear","","");//b=b && b4;
		
		if(b5 && b6 && b7)
		{			
			bb=IsDateT("txtBirthYear","txtBirthMonth","txtBirthDay","a_birth");
			b=b && bb;
		}
		else
		{		
			if(b5 || b6 || b7)
			{
				DisplayAlertMsg("a_birth",sBirth);b=b && false;
							
			}
			else{DisplayAlertMsg("a_birth","");}
		}		

		// radio validation
		bb=IsRadioNotEmtpy(document.regnext.gender,"a_gender",sEmpty);b=b && bb;		
		bb=IsRadioNotEmtpy(document.regnext.addType,"a_addType",sEmpty);b=b && bb;
		
		bb=IsRadioNotEmtpy(document.regnext.title,"a_Title",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdoTitleOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtOtherTitle","a_Title",sEmpty);b=b && bb;}
			}
		}
		
		// highDeg validation
		bb=IsRadioNotEmtpy(document.regnext.highDeg,"a_highDeg",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdohighDegOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtHighDeg","a_highDeg",sEmpty);b=b && bb;}
			}
		}

		// select input validation
		//bb=IsSelectNotEmpty("selectCountry","Please select a country","a_country",sEmpty);b=b && bb;
	}catch(err){
		s="Error.\n\n";
		//s+="FormValidationReg(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}

//////////////////////////////
function FormNextValidationReg()
{// form validation for reg.asp
	var s;var x;var b,bb,b3,b4;var sEmpty,sEmail,sPassword,sLen,sBirth;
	var b5,b6,b7;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";
	sBirth="<< Invaild Date!";
	sEmail="<< Invalid email address!";
	sLen="<< Password must be 6-20 characters!";
	sPassword="<< Two passwords are different!";
	try{
		// empty validation
		
		bb=IsTxtNotEmpty("txtFamName","a_famName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtGivenName","a_givenName",sEmpty);b=b && bb;		
		bb=IsTxtNotEmpty("txtAffiliation","a_affiliation",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtPosition","a_position",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAddline1","a_addline1",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCity","a_city",sEmpty);b=b && bb;
		//bb=IsTxtNotEmpty("txtOrganName","a_OrganName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtEmail","a_email",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCountry","a_country",sEmpty);b=b && bb;

		// email address validation
		if(bb){bb=IsEmail("txtEmail","a_email",sEmail);b=b && bb;}
		
		// birth validation
		//bb=IsTxtNotEmpty("txtBirthDay","a_birth",sEmpty);b=b && bb;
		//b3=IsTxtNotEmpty("txtBirthMonth","a_birth",sEmpty);b=b && b3;
		//b4=IsTxtNotEmpty("txtBirthYear","a_birth",sEmpty);b=b && b4;
		b5=IsTxtNotEmpty2("txtBirthDay","","");//b=b && bb;
		b6=IsTxtNotEmpty2("txtBirthMonth","","");//b=b && b3;
		b7=IsTxtNotEmpty2("txtBirthYear","","");//b=b && b4;
		
		if(b5 && b6 && b7)
		{			
			bb=IsDateT("txtBirthYear","txtBirthMonth","txtBirthDay","a_birth");
			b=b && bb;
		}
		else
		{		
			if(b5 || b6 || b7)
			{
				DisplayAlertMsg("a_birth",sBirth);b=b && false;
							
			}
			else{DisplayAlertMsg("a_birth","");}
		}		

		// radio validation
		bb=IsRadioNotEmtpy(document.regnext.gender,"a_gender",sEmpty);b=b && bb;
		bb=IsRadioNotEmtpy(document.regnext.addType,"a_addType",sEmpty);b=b && bb;
		
		bb=IsRadioNotEmtpy(document.regnext.title,"a_Title",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdoTitleOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtOtherTitle","a_Title",sEmpty);b=b && bb;}
			}
		}
		
		// highDeg validation
		bb=IsRadioNotEmtpy(document.regnext.highDeg,"a_highDeg",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdohighDegOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtHighDeg","a_highDeg",sEmpty);b=b && bb;}
			}
		}

		// select input validation
		//bb=IsSelectNotEmpty("selectCountry","Please select a country","a_country",sEmpty);b=b && bb;
	}catch(err){
		s="Error.\n\n";
		//s+="FormValidationReg(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}
function GetCountry()
{// get the full name of the country
	var s;
	try{
		var x1=document.getElementById("selectCountry");
		var x2=document.getElementById("txtCountry2");
		if(x1!=null && x2!=null){
			x2.value=x1.options[x1.selectedIndex].text;// store in the hidden input
		}
	}catch(err){
		s="Error.\n\n";
		s+="GetCountry(). " + err.description + "\n\n";
		alert(s);
	}
}
function FormSubmitReg()
{// form submit for reg.asp
	var b;
	GetCountry();// get the full name of the country
	b=FormValidationReg();
	if(b==true){
		b=FormSubmit('reg','_self','ShowMemberInput.asp','post');
	}else{
		alert("Incorrect input!");
		window.location="#reg";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}

function FormNextSubmitReg()
{// form submit for reg.asp
	var b;
	GetCountry();// get the full name of the country
	b=FormNextValidationReg();
	if(b==true){
		b=FormSubmit('regnext','_self','ShowMemberInput.asp','post');
	}else{
		alert("Incorrect input!");
		window.location="#regnext";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}

function FormNextStdSubmitReg()
{// form submit for reg.asp
	var b;
	GetCountry();// get the full name of the country
	b=FormNextStdValidationReg();
	if(b==true){
		b=FormSubmit('regnext','_self','ShowMemberInput.asp','post');
	}else{
		alert("Incorrect input!");
		window.location="#regnext";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}

function FormFirstSubmitReg()
{// form submit for reg.asp
	var b;
	GetCountry();// get the full name of the country
	b=FormFirstValidationReg();
	if(b==true){
		b=FormSubmit('reg','_self','redirect.asp','post');
	}else{
		alert("Incorrect input!");
		window.location="#reg";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}

function FormSubmitLogin()
{// form submit for reg.asp
	var b;	
	b=FormValidationLogin();
	if(b==true){
		b=FormSubmit('login','_self','Showmemberlogin.asp','post');
	}else{
		alert("Incorrect input!");
		window.location="#login";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}

//////////////////////////////
function FormValidationLogin()
{// form validation for reg.asp
	var s;var x;var b,bb,b3;var sEmpty,sEmail;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";
	//sEmail="<< Invalid email address!";
	
	try{
		// empty validation
		bb=IsTxtNotEmpty("txtUserID","a_userID",sEmpty);b=b && bb;
		
		// email address validation
		//if(bb){bb=IsEmail("txtUserID","a_userID",sEmail);b=b && bb;}
		
		// password validation
		bb3=IsTxtNotEmpty("txtPwd","a_pwd",sEmpty);b=b && bb3;
			
		
	}catch(err){
		s="Error.\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}

function ButtonVisible(sId,sValue)
{// make the button visible or hidden
	var x=document.getElementById(sId);
	if(x!=null){x.style.visibility=sValue;}
}//<input type="button"   style="visibility:visible;" />
//<input type="button" style="visibility:hidden;" />

function hiddenFuct(sId)
{

	ButtonVisible(sId,"hidden");

}
function ButtonHKDVisible()
{
	var x,y,z;
	y=document.getElementById("ShowStdMember");
	if(y!=null){y.innerHTML="Student Member (HK $78) ";}	
	
	x=document.getElementById("ShowFullMember");
	if(x!=null){x.innerHTML="Full Member (HK $234) ";}
	
	z=document.getElementById("ShowLifeMember");
	if(z!=null){z.innerHTML="Life Member (HK $2,340) ";}
}

function ButtonUSDVisible()
{
	var x,y,z;
	y=document.getElementById("ShowStdMember");
	if(y!=null){y.innerHTML="Student Member (US $10) ";}	
	
	x=document.getElementById("ShowFullMember");
	if(x!=null){x.innerHTML="Full Member (US $30) ";}
	
	z=document.getElementById("ShowLifeMember");
	if(z!=null){z.innerHTML="Life Member (US $300) ";}
}
//// added on 2009-08-30 by Thomas
// modified on 2009-09-24 by wai
function FormValidationLoginEdit()
{// form validation for ShowMemberLogin.asp
	var s;var x;var b,bb,b3,b4;var sEmpty,sEmail,sPassword,sLen,sBirth;
	var b5,b6,b7;
	var i;
	b=true;
	// define the error message
	sEmpty="<< This field is required!";
	sBirth="<< Invaild Date!";
	sEmail="<< Invalid email address!";
	sLen="<< Password must be 6-20 characters!";
	sPassword="<< Two passwords are different!";
	try{
		// empty validation
		bb=IsTxtNotEmpty("txtFamName","a_famName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtGivenName","a_givenName",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAffiliation","a_affiliation",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtAddline1","a_addline1",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCity","a_city",sEmpty);b=b && bb;
		bb=IsTxtNotEmpty("txtCountry","a_country",sEmpty);b=b && bb;
		
		x=document.getElementById("txtMember");
		if(x!=null){
			i=x.value.indexOf("Student");
			if(i==0){bb=IsTxtNotEmpty("txtUniversity","a_university",sEmpty);b=b && bb;}
			else{bb=IsTxtNotEmpty("txtPosition","a_position",sEmpty);b=b && bb;}
		}

		// email address validation
		bb=IsTxtNotEmpty("txtEmail","a_email",sEmpty);b=b && bb;
		if(bb){bb=IsEmail("txtEmail","a_email",sEmail);b=b && bb;}
		
		// radio validation
		//bb=IsRadioNotEmtpy(document.formShowMemberLogin.gender,"a_gender",sEmpty);b=b && bb;// modified on 2009-09-24 by wai
		//bb=IsRadioNotEmtpy(document.formShowMemberLogin.addType,"a_addType",sEmpty);b=b && bb;// modified on 2009-09-24 by wai
		
		bb=IsRadioNotEmtpy(document.formShowMemberLogin.title,"a_title",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdoTitleOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtTitleOther","a_title",sEmpty);b=b && bb;}
				else{
					x=document.getElementById("txtTitleOther");
					if(x!=null){x.value="";}
				}
			}
		}
		
		// highDeg validation
		bb=IsRadioNotEmtpy(document.formShowMemberLogin.highDeg,"a_highDeg",sEmpty);b=b && bb;
		if(bb){
			x=document.getElementById("rdohighDegOther");
			if(x!=null){
				if(x.checked==true){bb=IsTxtNotEmpty("txtHighDegOther","a_highDeg",sEmpty);b=b && bb;}
				else{
					x=document.getElementById("txtHighDegOther");
					if(x!=null){x.value="";}
				}
			}
		}
		
		// password validation
	//	bb=IsPasswordSame("txtPwdNew","txtPwdNew2","a_pwd"," << Two passwords are not same!");b=b && bb;
	}catch(err){
		s="Error.\n\n";
		//s+="FormValidationReg(). " + err.description + "\n\n";
		s+= err.description + "\n\n";
		alert(s);
		return false;
	}
	return b;
}
//// added on 2009-08-30 by Thomas
function FormSubmitLoginEdit()
{// form submit for ShowMemberLogin.asp
	var b;
//	GetCountry();// get the full name of the country
	b=FormValidationLoginEdit();
	if(b==true){
	//	var r=confirm("Confirm to update?");
	//	if(r==true){b=FormSubmit('formShowMemberLogin','_self','ShowMemberLoginEditResult.asp','post');}
		var x=document.getElementById("flag_edit");
		if(x!=null){
			x.value="edit";
			
		//	b=IsPasswordSame("txtPwd","txtPwdNew","","");
		//	if(b==true){pwdOld=prompt("Please enter the password.");}
		//	else{pwdOld=prompt("Please enter the old password.");}
		
		//	var pwdOld;
		//	pwdOld=prompt("Please enter the password.");
		//	x=document.getElementById("txtPwdOld");
		//	if(x!=null){x.value=pwdOld;}
			var r=confirm("Confirm to update?");
			if(r==true){b=FormSubmit('formShowMemberLogin','_self','ShowMemberLoginEdit.asp','post');}
		}
		
	}else{
		alert("Incorrect input!");
	//	window.location="#formShowMemberLogin";
	//	b=FormSubmit('reg','_self','reg.asp','post');
	}
	return b;
}
// added on 209-09-02 by Thomas
function ChangeRadioDollarType()
{
	var s;
	var x;
	try{
		x=document.getElementById("rdoDollarTypeUSD");
		if(x!=null){if(x.checked==true){ButtonUSDVisible();}}
		x=document.getElementById("rdoDollarTypeHKD");
		if(x!=null){if(x.checked==true){ButtonHKDVisible();}}
	}catch(err){
		s="Error.\n\nChangeRadioDollarType( )";
		s+=err.description+"\n\n";
		alert(s);
	}
}
