/*Checking function for ZONE1511
 --function changeDays(numb,date_form)
 --function numDaysIn(mth,yr)
 --function leapYear(yr)
 --function firstDayOfYear(yr)
 --function getFullYear(d)
 --function checkRequired(form)
 --function IsDigit(In_str)
 --function check_form_field(position)
 --function check_form_filed_reg(position)
 --function check_8digitnumber(position)
 --function check_otherdigitnumber(position)
 --function check_7digitnumber(position)
 --function check_exact_length_form(position,max_in)
 --function check_digit_form_field(position,max_in)
 --function check_email(position)
 --function check_NRIC(element)
 --function verify_home_member(form)
 --function verify_corp_member(form)
 --function verify_home_user(form)
 --function verify_corp_user(form)
 --function check_giro(form)
 --function check_customer(form)
 --function check_act(form)
 --function check_email_act(form)
 --function check_ecard(form)
 --function check_account(form)
 --function check_no_repeat(form,name)
 --function check_no_repeat_pins(form)
 --function check_pins(form)
 --function check-telno(form)
 --function check_phone_entry(form)
 --function check_password(form)
 --function check_login(form)
 --function check_referral(form)
 --function check_notification(form)
 --function check_cc(form)
 --function check_age(form)
 --function check_no_repeat_quickdial_no(form)
 --function check_quickdial(form)
 --function check_globaldial(form)
 --function check_globaldial_dest_mob(form) 
--function check_globaldial_ignore65(form) {
*/


//Start of checking DOB

function changeDays(numb,date_form) {
	if (memberSubtype!="E"){
		var mth = 1;
		if (date_form.dateOfBirthMM.selectedIndex != 0 || date_form.dateOfBirthMM != null)
			mth = date_form.dateOfBirthMM.selectedIndex-1;
		var cur = new Date();
		var yr = getFullYear(cur);
		if (date_form.dateOfBirthYY.selectedIndex != 0 || date_form.dateOfBirthYY != null)
			yr = date_form.dateOfBirthYY.selectedIndex+1899;
		var dy = date_form.dateOfBirthYY.selectedIndex+1;
		if (numb != 1) {
			numDays = numDaysIn(mth,yr);
			date_form.dateOfBirthDD.options.length = numDays+1;
			for (i=28;i<numDays+1;i++) {
				date_form.dateOfBirthDD.options[i].text = i;
		   		date_form.dateOfBirthDD.options[i].value = i.toString();
		 	}
		}
		day = date_form.dateOfBirthDD.selectedIndex+1;
	}
}

function numDaysIn(mth,yr) {
	if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
	else if ((mth==1) && leapYear(yr)) return 29;
	else if (mth==1) return 28;
	else return 31;
}

function leapYear(yr) {
	if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
		return true;
	else
		return false;
}

function firstDayOfYear(yr) {
	diff = yr - 401;
	return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}

function getFullYear(d) {
	yr = d.getYear();
	if (yr < 1000)
		yr+=1900;
	return yr;
}

//End of checking DOB


digits="0123456789";
small="abcdefghijklmnopqrstuvwxyz";
big="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
special=" .-_,&^#!`'@()'%;~=?*$";
reg="_.,&^#!`'@()'%*~=&?;";
e_mail="@._-";
bankspecial="_.,&^#!`'@()'%*~=&?;0123456789";
var invalid=" "
var msg=""

//Main function for signup, fields that are not found is the following list are required field

//Member Subtype = E is zone1511 express user
function checkRequired(form) {
	if (memberType==""){   //(special check for other forms.)
		var msg="";
		for (i=0; i<form.elements.length ; i++) {
			ename = form.elements[i].name;
			evalue = form.elements[i].value;
			if  (evalue=="")
			{
				return i;
			}
		} //end of for
		return i;
	} //end of if

	else if (memberSubtype!="E"){   //(Non-prepaid)
		var msg="";
		for (i=0; i<form.elements.length ; i++) {
			ename = form.elements[i].name;
			evalue = form.elements[i].value;
			if  ( (evalue=="" && ename!="fax" && (ename.indexOf("cli")< 0)
				&& ename!="accountName2"
				&& ename!="title"
				&& ename!="salute"
				//&& ename!="dateOfBirthDD" && ename!="dateOfBirthMM"
			        //&& ename!="dateOfBirthYY"
				&& ename!="referralNum"
				&& ename!="signUpCode"
				&& ename!="estate"
				&& ename!="houseNum"
				&& ename!="block"
				&& ename!="mailingAddress2" && ename!="mailingAddress3"
				&& ename!="memberType"
				&& ename!="sessionID"
				&& ename!="memberSubtype"
				&& ename!="paymentModeInd")
				||(evalue=="" && ename=="cli1"))
			{
				return i;
			}
		} //end of for
		return i;
	} //end of if

	else if (memberType=="I"){   //(Prepaid Individual)
		var msg="";
		for (i=0; i<form.elements.length ; i++) {
			ename = form.elements[i].name;
			evalue = form.elements[i].value;
			if ((evalue=="" && ename!="fax" && (ename.indexOf("cli")< 0)
				&& ename!="salute"
				&& ename!="title"
				&& ename!="referralNum"
				&& ename!="signUpCode"
				&& ename!="smsPhone"
//				&& ename!="emailAddress"
				&& ename!="estate"
				&& ename!="houseNum"
				&& ename!="block"
				&& ename!="memberType"
				&& ename!="sessionID"
				&& ename!="memberSubtype"
				&& ename!="paymentModeInd")
				||(evalue=="" && ename=="cli1"))
			{
				return i;
			} //end of if
		} //end of for
		return i;
	}//end of Else If member type = E

	else {
		if (memberType=="C"){   //(Prepaid Express )
			var msg="";
			for (i=0; i<form.elements.length ; i++) {
				ename = form.elements[i].name;
				evalue = form.elements[i].value;
				if  ( (evalue=="" && ename!="fax" && (ename.indexOf("cli")< 0)
					&& ename!="salute"
					&& ename!="title"
					&& ename!="referralNum"
					&& ename!="signUpCode"
					&& ename!="smsPhone"
					&& ename!="estate"
					&& ename!="houseNum"
					&& ename!="block"
					&& ename!="memberType"
					&& ename!="sessionID"
					&& ename!="memberSubtype"
					&& ename!="paymentModeInd")
					||(evalue=="" && ename=="cli1"))
				{
					return i;
				}
			} //end of for
			return i;
		} //end of if
	} //End of ELSE IF member type =S
}//end of function


//check it's Digit
function IsDigit(In_str) {
	var i, temp;
	for (i=0;i<In_str.length;i++) {
		temp=In_str.substring(i,i+1);
	if (digits.indexOf(temp)==-1)
		return (false);
	}
	return (true);
}

//Check alphanumeric input
function check_form_field(position) {
	if (position.value != "") {
		for (var i=0; i<position.value.length; i++) {
			temp= position.value.substring(i,i+1);
			if (special.indexOf(temp)!=-1)
				return (false);
		}
	}
	return (true);
}

//Check alphabet input
function check_alpha_field(position) {
	if (position.value != "") {
		for (var i=0; i<position.value.length; i++) {
			temp= position.value.substring(i,i+1);
			if (bankspecial.indexOf(temp)!=-1)
				return (false);
		}
	}
	return (true);
}



//Check alphanumeric input for business reg no.(allow Dash input)
function check_form_field_reg(position) {
	if (position.value != "") {
		for (var i=0; i<position.value.length; i++) {
			temp= position.value.substring(i,i+1);
			if (reg.indexOf(temp)!=-1)
				return (false);
		}
	}
	return (true);
}


//Check valid phone No, if no. start with 6 or 8 or 9 then 8 char required
function check_8digitnumber(position) {
	if ((position.value != "") && (position.value != "6031511")) {
		firstdigit=position.value.substring(1,0);
		if (check_length_form_field(position,8)){
		    if (!((firstdigit == "6") || (firstdigit == "9") || (firstdigit == "8") || (firstdigit == "3")))
			   return (false);
		}
	}
	return (true);
}


//Check valid phone No, if no. is 7 digit than remind user to add 6.
function check_7digitnumber(position) {
	if ((position.value != "") && (position.value != "6031511")) {
//		firstdigit=position.value.substring(1,0);
//		if ((firstdigit=="2") || (firstdigit=="3") || (firstdigit=="4") || (firstdigit=="5") || (firstdigit=="6") || (firstdigit=="7") || (firstdigit=="8")){
		   if (check_exact_length_form_field(position,7))
			   return (false);
//		}
	}
	return (true);
}

//Check phone no. for any other number less than 8 digit.
function check_otherdigitnumber(position){
	if ((position.value!="") && (position.value != "6031511")){
		firstdigit=position.value.substring(1,0);
		if (firstdigit=="1"){
			if (position.value.length < 8)
			return (false);
		} //End of if firstdigit condition
	}
	return (true);
}

//Check valid that fax number doesn't begin with a 9.
function check_fax(position){
	if (position.value != "") {
		firstdigit=position.value.substring(1,0);
		if (check_exact_length_form_field(position,8)) {
			if ( (firstdigit=="8") || (firstdigit=="9"))
			   return (false);
		}
	}
	return (true);
}

//Check Exact Input length
function check_exact_length_form_field(position,max_in) {
	if (position.value != "") {
		if (position.value.length != max_in) {
			return (false);
		}
		return (true);
	}
}


//Check Input length
function check_length_form_field(position,max_in) {
	if (position.value != "") {
		if (position.value.length < max_in) {
			return (false);
		}
		return (true);
	}
}

//Check input, make sure it is Digit
function check_digit_form_field(position) {
	if (position.value != "") {
		if (!IsDigit(position.value)) {
			return (false);
		}
		return (true);
	}
}

//checking for valid email input
function check_email(position) {
	if (position.value!=""){
		if (position.value.indexOf("@")<1)
			return (false);
		if ((position.value == "") || (position.value.indexOf("@") == -1))
			return (false);
		if (position.value.indexOf(invalid) > -1)
			return (false);
		if ((position.value.indexOf(".com")<5)&&(position.value.indexOf(".org")<5)
		  &&(position.value.indexOf(".gov")<5)&&(position.value.indexOf(".net")<5)
		  &&(position.value.indexOf(".mil")<5)&&(position.value.indexOf(".edu")<5)
		  &&(position.value.indexOf(".my")<5)&&(position.value.indexOf(".jp")<5)
		  &&(position.value.indexOf(".th")<5)&&(position.value.indexOf(".de")<5)
		  &&(position.value.indexOf(".uk")<5)&&(position.value.indexOf(".hk")<5)
		  &&(position.value.indexOf(".per")<5)&&(position.value.indexOf(".sg")<5)
		  &&(position.value.indexOf(".biz")<5)&&(position.value.indexOf(".be")<5)
		  &&(position.value.indexOf(".asia")<5)&&(position.value.indexOf(".ws")<5))

			return (false);
		return (true);
	}
}

//checking for Singaporean NRIC,FIN input
function check_NRIC(element) {
	var passport_ref = new Array ("","A","B","C","D","E","F","G","H","I","Z","J");
	var FIN_passport_ref = new Array ("","K","L","M","N","P","Q","R","T","U","W","X");

    element.value.toUpperCase();
    passportnum =  element.value;
    total= passportnum.substring(1,2) * 2  +
    passportnum.substring(2,3) * 7 +
    passportnum.substring(3,4) * 6 +
    passportnum.substring(4,5) * 5 +
    passportnum.substring(5,6) * 4 +
    passportnum.substring(6,7) * 3 +
    passportnum.substring(7,8) * 2 ;

    if (passportnum.substring(0,1)=='T' || passportnum.substring(0,1)=='G') total = total + 4;

	if (passportnum.substring(0,1)=='S' || passportnum.substring(0,1)=='T')
		checkdigit = passport_ref[11 - total%11] ;
	else
		checkdigit = FIN_passport_ref[11 - total%11] ;
	if (passportnum.substring(8,9)==checkdigit) return true;
	return false
}



//Checking home member personal information(for manage member profile)
//start here
function verify_home_member(form) {
	var msg="";

	//Fax
	input = form.fax;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
				msg =  " -Only numeric characters allowed for Fax No., eg 62468160.\n"  +msg;
				first_error="fax";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for Fax No., eg 62468160.\n"  +msg;
				first_error="fax";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Fax no. is invalid.\n"  +msg;
					first_error="fax";
				} else {
					if (!check_fax(input)){
						msg = " -A Fax No. should not start with 9. eg:61234567\n" + msg;
						first_error = "fax";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Fax No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "fax";
						}
					}
				}
			}
		}
	}

  	//Contact Phone
	input=form.contactPhone;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;
			first_error="contactPhone";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for contact no., eg 62468160.\n"  +msg;
				first_error="contactPhone";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Contact Phone no. is invalid.\n"  +msg;
					first_error="contactPhone";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -Your contact Phone No. should start with 6 or 8 or 9. eg:94123456\n" + msg;
						first_error = "contactPhone";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;

//							msg = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "contactPhone";
						}
					}
				}
			}
		}
	}

	//Postal Code
	input=form.postalCode;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Postal Code, eg 380125.\n"  +msg;
			first_error="postalCode";
		} else {
			if (!check_length_form_field(input,6)){
				msg =  " -Minimum 6 digits required for Postal Code. eg:380125.\n"  +msg;
				first_error="postalCode";
			}
		}
	}

  	//Email Address
	input=form.emailAddress;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid E-mail address should be used. eg:john@abcd.com.sg\n" + msg;
			first_error="emailAddress";
		}
    }

  	//Email Address for Correspondence
	input=form.emailAddressForCor;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid E-mail address should be used. eg:john@abcd.com.sg\n" + msg;
			first_error="emailAddressForCor";
		}
    }

    return (msg);
}
//Checking home user information (member profile)
//End here


//Checking corp user information(manage member profile)
//start here
function verify_corp_member(form) {
	var msg="";

	//Email Address
	input=form.emailAddress;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddress";
        }
    }

  	//Email Address for Correspondence
	input=form.emailAddressForCor;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid E-mail address should be used. eg:john@abcd.com.sg\n" + msg;
			first_error="emailAddressForCor";
		}
    }

    //Postal Code
	input=form.postalCode;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Postal Code, eg 380125.\n"  +msg;
			first_error="postalCode";
		} else {
			if (!check_length_form_field(input,6)){
				msg =  " -Minimum 6 digits required for Postal Code. eg:380125.\n"  +msg;
				first_error="postalCode";
			}
		}
	}


   //Fax
 	input = form.fax;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Fax No., eg 62468160.\n"  +msg;
			first_error="fax";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for Fax No., eg 62468160.\n"  +msg;
				first_error="fax";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Fax no. is invalid.\n"  +msg;
					first_error="fax";
				} else {
					if (!check_fax(input)){
						msg = " -A Fax No. should not start with 9. eg:61234567\n" + msg;
						first_error = "fax";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;

//							msg = " -Effective 1 Mar 2004 all 7 digit Fax No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "fax";
						}
					}
				}
			}
		}
	}

  	//Contact Phone
	input=form.contactPhone;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;
			first_error="contactPhone";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for contact no., eg 62468160.\n"  +msg;
				first_error="contactPhone";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Contact Phone no. is invalid.\n"  +msg;
					first_error="contactPhone";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -A Contact Phone no. should start with 6 or 8 or 9. eg:64123456\n" + msg;
						first_error = "contactPhone";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "contactPhone";
						}
					}
				}
			}
		}
    }
    return (msg);
}
//Checking corp user information (member profile)
//End here


//Checking home user personal information(signup)
//start here
function verify_home_user(form) {
	var msg="";

	//Fax
	input = form.fax;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Fax No., eg 62468160.\n"  +msg;
			first_error="fax";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for Fax No., eg 62468160.\n"  +msg;
				first_error="fax";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Fax no. is invalid.\n"  +msg;
					first_error="fax";
				} else {
					if (!check_fax(input)){
						msg = " -A 8 numeric character Fax No. should not start with 9. eg:64123456\n" + msg;
						first_error = "fax";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Fax No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "fax";
						}
					}
				}
			}
		}
    }

  	//Contact Phone
	input=form.contactPhone;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;
			first_error="contactPhone";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for contact no., eg 62468160.\n"  +msg;
				first_error="contactPhone";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Contact Phone no. is invalid.\n"  +msg;
					first_error="contactPhone";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -An 8 numeric character Contact Phone should start with 6 or 8 or 9. eg:91234567\n" + msg;
						first_error = "contactPhone";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "contactPhone";
						}
					}
				}
			}
		}
    }

  	//Email Address
	input=form.emailAddress;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddress";
		}
	}

	input=form.emailAddressForCor;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddressForCor";
		}
	}

	//Postal Code
	input=form.postalCode;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Postal Code, eg 380125.\n"  +msg;
			first_error="postalCode";
		} else {
			if (!check_length_form_field(input,6)){
				msg =  " -Minimum 6 digits required for Postal Code. eg:380125.\n"  +msg;
				first_error="postalCode";
			}
		}
	}


	//DOB
	if (memberSubtype!="E"){
		input = form.dateOfBirthDD;
		dob="";
		if (form.dateOfBirthDD.selectedIndex !=0)
			dob=form.dateOfBirthDD;
		if (form.dateOfBirthMM.selectedIndex !=0)
			dob=form.dateOfBirthMM;
		if (form.dateOfBirthYY.selectedIndex !=0)
			dob=form.dateOfBirthYY;

		if (dob!=""){
			if (form.dateOfBirthDD.selectedIndex == 0 || form.dateOfBirthMM.selectedIndex == 0 ||
			form.dateOfBirthYY.selectedIndex == "") {
				msg= " -A valid date of birth should be selected, eg 1978/JAN/18.\n" + msg;
				first_error = "dateOfBirthDD";
			}
		}
	}

	//Passport/FIN/NRIC
	input=form.passportNum;
	if (input.value!=""){
	    if (!check_form_field(input)){
			msg= " -Only alphanumeric characters allowed for NRIC/FIN No.\n" + msg
			first_error="passportNum";
		} else {
			if  (!check_NRIC(input)){
                msg =  " -Invalid NRIC/FIN No.\n"  +msg;
				first_error="passportNum";
			}
		}

	}
    return (msg);
}
//Checking home user personal information
//End here


//Checking corporate user(Signup)
//Start here
function verify_corp_user(form) {
	var msg="";

	//Email Address
	input=form.emailAddress;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddress";
		}
	}
    //Script added by Mendu on June-21-2001
    //One text field for email is added for Company users.
    //Email Address
	input=form.emailAddressForCor;
	if (input.value!="") {
		if (!check_email(input)) {
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddressForCor";
		}
	}
	//Postal Code
	input=form.postalCode;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Postal Code, eg 380125.\n"  +msg;
			first_error="postalCode";
		} else {
			if (!check_length_form_field(input,6)){
				msg =  " -Minimum 6 digits required for Postal Code. eg:380125.\n"  +msg;
				first_error="postalCode";
			}
		}
	}

	//fax
    input=form.fax;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Fax No., eg 62468160.\n"  +msg;
			first_error="fax";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for Fax No., eg 62468160.\n"  +msg;
				first_error="fax";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Fax no. is invalid.\n"  +msg;
					first_error="fax";
				} else {
					if (!check_fax(input)){
						msg = " -A 8 numeric character Fax No. should not start with 9. eg:64123456\n" + msg;
						first_error = "fax";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Fax No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "fax";
						}
					}
				}
			}
		}
    }

    //Contact Phone
    input=form.contactPhone;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;
			first_error="contactPhone";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for contact no., eg 62468160.\n"  +msg;
				first_error="contactPhone";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Contact Phone no. is invalid.\n"  +msg;
					first_error="contactPhone";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -An 8 numeric character contact no. should start with 6 or 8 or 9. eg:91234567\n" + msg;
						first_error = "contactPhone";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "contactPhone";
						}
					}
				}
			}
		}
    }

	//Business Reg Number
	input=form.businessRegNum;
	if (input.value!=""){
		if (!check_form_field_reg(input)){
			msg= " -Please enter a valid Business Registration No.\n" + msg
			first_error="businessRegNum";
		}
	}

	return (msg);
}
//Checking corporate user
//End here


//checking details of GIRO Applicant(Signup)
//Start Here
function check_giro(form) {
	var msg="";
	//Account Name 2
	input=form.accountName2;
	if (input!=""){
		if (!check_alpha_field(input)){
			msg= " -Please enter a valid Account Name(2).\n" ;
			first_error="accountName2";
		}
	}

	//Account Name
	input=form.accountName;
	if (input!=""){
		if (!check_alpha_field(input)){
			msg= " -Please enter a valid Account Name(1).\n" + msg;
			first_error="accountName";
		}
	}
	return (msg);
}
//checking details of GIRO Applicant
//End Here


//checking details of ecard should be entered(Introduce ZONE1511 To A Friend)
//Start Here
function checkRequiredEcard(form) {
	var msg="";

	for (i=0; i<form.elements.length ; i++) {
		if ((form.elements[i].value=="") && (form.elements[i].name!="fontColor" )&& (form.elements[i].name!="message2" )&& (form.elements[i].name!="message3" ))
			return (i);
	}
	return (i);
}
//checking details of ecard should be entered
//End Here


//checking required fields of contact customer care should be entered (Contact Customer Care)
//Start Here
function checkRequiredCustomer(form) {
	var msg="";

	for (i=0; i<form.elements.length ; i++) {
		if ((form.elements[i].value=="") && (form.elements[i].name!="telno" ) && (form.elements[i].name!="faq" ) && (form.elements[i].name != "faqExp") && (form.elements[i].name!="subject" ))
			return (i);
	}
	return (i);
	}
//checking details of contact customer care should be entered
//End Here

//checking details of contact customer care form (Contact Customer Care)
//start here
function check_customer(form) {
	var msg="";

	// Email Address
	input=form.email;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="email";
		}
	}

	//Contact Phone
    input=form.telno;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters allowed  for contact no. eg 62468160.\n"  +msg;
			first_error="telno";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 digits required for contact no., eg 62468160.\n"  +msg;
				first_error="telno";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The Contact Phone no. is invalid.\n"  +msg;
					first_error="telno";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -An 8 numeric character contact no.should start with 6 or 8 or 9. eg:94123456\n" + msg;
						first_error = "telno";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "telno";
						}
					}
				}
			}
		}
	}

	return (msg);
}
//checking details of contact customer care form
//End here


//check Required fields to fillin  (Manage Member Profile-Add New Account)
function check_act(form) {
	var msg="";
	for (i=0; i<form.elements.length ; i++) {
		ename = form.elements[i].name;
		evalue = form.elements[i].value;
		if  ( (evalue==""  && (ename.indexOf("telno")< 0)) ||(evalue=="" && ename=="telno1"))
			return i;
	}
	return i;
	//alert(i)
}

//checking details of email address of account(Manage Member Profile-Add New Account)
//Start Here
function check_email_act(form)
{
	var msg="";

	//Account Email Address
	input=form.emailAddress;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="emailAddress";
		}
	}

	return (msg);
}
//checking details of email address of account
//End Here


//checking details of ecard should be in correct format (Introduce ZONE1511 To A Friend)
//Start Here
function check_ecard(form)
{
	var msg="";

	//Sender Email Address
	input=form.senderEmail;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="senderEmail";
		}
    }

	//Recipient Email Address
	input=form.recipientEmail;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="recipientEmail";
        }
    }
	return (msg);
}
//checking details of ecard should be in correct format
//End Here


//checking details of account (Manage Member Profile-Add New Account)
//Start Here
function check_account(form)
{
	var msg="";

	//Account Email Address
	input=form.account_email;
	if (input.value!=""){
		if (!check_email(input)){
			msg = " -A valid Email Address should be used, eg john@abcd.com.sg\n" + msg;
			first_error="account_email";
		}
	}

	return (msg);
}
//checking details of account
//End Here


//Checking phone no.,make sure no repeating phone no. entered! (Manage Member Profile-Telephone No.)
//Start Here
function check_no_repeat(form,name)
{
	var msg="";
	var repeat=0;
	var searchname="";
	searchname = name;
	j = form.elements.length;
	for (k=0; k<j; k++) {
		ename = form.elements[k].name;
		evalue =form.elements[k].value;
		result = ename.indexOf(searchname)
		//if ((result!=-1) && (evalue!="")&& (ename!="contactPhone") && (ename!="fax"))
		if ((result!=-1) && (evalue!="")){
			for (m=0; m<j; m++){
				fname = form.elements[m].name;
				fvalue =form.elements[m].value;
				found = fname.indexOf(searchname)
				if ((found!=-1) && (fvalue!="")){
					if ((evalue==fvalue) && (ename!=fname) &&(result!=-1)){
						repeat++;
						first_error=form.elements[m].name;
					}
				}
			}
		}

	}

	if (repeat!=0) {
		msg=" -Same telephone number(s) found. Please enter again.\n";
	}
	return (msg);
	return (first_error);
}
//Checking phone no.,make sure no repeating phone no. entered!
//End Here


//Make sure no repeating telephone PIN entered!(Manage Member Profile-Telephone PINs.)
//Start Here
function check_no_repeat_pins(form) {
	var msg="";
	var repeat=0;
	j = form.elements.length;
	for (k=0; k<j; k++) {
		ename = form.elements[k].name;
		evalue =form.elements[k].value;
		result = ename.indexOf("pin")
		if ((result!=-1) && (evalue!="")){
			for (m=0; m<j; m++){
				fname = form.elements[m].name;
				fvalue =form.elements[m].value;
				found = fname.indexOf("pin")
				if ((found!=-1) && (fvalue!="")){
					if ((evalue==fvalue) && (ename!=fname)){
						repeat++;
						first_error=form.elements[m].name;
					}
				}
			}
		}

	}

	if (repeat!=0)
		msg=" -Same Telephone PIN(s) found, please enter again.\n";
	return (msg);
	return (first_error);
}
//Make sure no repeating telephone PIN entered!
//End Here


//Procedure to validate PINs entry(Manage Member Profile-Telephone Pins.)
function check_pins(form) {
	var msg="";
	var msg1="";
	var numDigitErr=0;
	var contNumErr=0;

	n =form.elements.length
	for (i=n-1; i>=0; i--) {
		ename = form.elements[i].name;
		result = ename.indexOf("pin")

		if (result !=-1) {
			input=form.elements[i];
			if (input.value != "") {
				if (!check_digit_form_field(input)) {
					numDigitErr++
					first_error=form.elements[i].name;
				} else {
					if (!check_length_form_field(input,3)){
						contNumErr++
						first_error=form.elements[i].name;
					}
				}
			}
		}
	}

    msg1 = check_no_repeat_pins(form)

	if (numDigitErr>0)
		msg =  " -Only numeric characters required for Telephone PIN. \n"  +msg;

	if (contNumErr>0)
		msg =  " -Minimum 3 required for Telephone PIN.\n"  +msg;

	return (msg +msg1);
}
//End of validation (PINs)



//Procedure to validate phone number entry (Manage Member Profile-Telephone No.)
function check_telno(form) {
	var msg="";
	var msg1="";
	var msg2="";
	var msg3="";
	var msg4="";
	var numDigitErr=0;
	var contNumErr=0;
	var conthpErr=0;

	n =form.elements.length
	for (i=n-1; i>=0; i--) {

		ename = form.elements[i].name;
		result = ename.indexOf("telno")

		if (result !=-1) {
			input=form.elements[i];
			if (input.value != "") {
				if (!check_digit_form_field(input)) {
					numDigitErr++
					first_error=form.elements[i].name;
				} else {
					if (!check_length_form_field(input,8)){
						contNumErr++
						first_error=form.elements[i].name;
					} else {
						if (!check_8digitnumber(input)){
							conthpErr++
							first_error=form.elements[i].name;
						}
					}
				}
			}
		}
	}

	telno="telno";
    msg1 = check_no_repeat(form,telno);

	if (numDigitErr>0)
		msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;

	if (contNumErr>0)
		msg =  " -Minimum 8 digits required for Telephone or Mobile no., eg 62468160.\n"  +msg;

	if (conthpErr>0)
		msg2 = " -Phone No. should start with 6 or 8 or 9. eg 64123456\n"


	return (msg +msg1+msg2);
}
//End of validation (Member-Phone Number)


//Procedure to validate phone number entry
function check_phone_entry(form) {
	var msg="";
	var msg1="";
	var msg2="";
	var msg3="";
	var msg4="";
	var numDigitErr=0;
	var contNumErr=0;
	var conthpErr=0;
	var conthomeErr=0;
	var contStartOne=0;

	n =form.elements.length
	for (i=n-1; i>=0; i--) {

		ename = form.elements[i].name;
		result = ename.indexOf("cli")

		if (result !=-1) {
			input=form.elements[i];
			if (input.value != "") {
				if (!check_digit_form_field(input)){
					numDigitErr++;
					first_error=form.elements[i].name;
				} else {
					if (!check_length_form_field(input,7)){
						contNumErr++;
						first_error=form.elements[i].name;
					} else {
						if (!check_otherdigitnumber(input)){
							contStartOne++
							first_error=form.elements[i].name;
						} else {
							if (!check_8digitnumber(input)){
								conthpErr++;
								first_error=form.elements[i].name;
							} else {
								if (!check_7digitnumber(input)){
									conthomeErr++
									first_error=form.elements[i].name;
								}
							}
						}
					}
				}
			}
		}
	}

	telno="cli";
	msg1 = check_no_repeat(form,telno)

	if (numDigitErr>0)
		msg =  " -Only numeric characters allowed for Telephone No., eg 62468160.\n"  +msg;

	if (contNumErr>0)
		msg =  " -Minimum 8 digits required for Telephone No., eg 62468160.\n"  +msg;

	if (conthpErr>0)
		msg2 = " -An 8 numeric character Phone No. should start with 6 or 8 or 9. eg:61234567\n" ;

	if (conthomeErr>0)
		msg3 = "  Please enter a 8-digit telephone number\n" + msg;
//		msg3 = " -Effective 1 Mar 2004 all 7 digit Phone No should start with a 6 or 8. eg:61234567\n" ;

	if (contStartOne>0)
		msg4= " -The Contact Phone no. is invalid\n";

	return (msg+ msg1+ msg2+msg3+msg4);
}
//End of validation (Phone Number)


//Procedure to check password
//Start here
function check_password(form) {
	var msg="";
	//password
	input=form.password;
	if (input.value!=""){
	    if (!check_form_field(input)){
			msg= " -Only alphanumeric characters required for your password.\n" + msg
			first_error = "password";
		}
	}

	if (input.value.length<4) {
		msg= " -Password must be a minimum of 4 characters.\n" + msg
		first_error = "password";
	}

	//confirm password
	input=form.password2;
	if (input.value!=""){
		if (form.password.value.toUpperCase() != form.password2.value.toUpperCase()){
			msg= " -Password' and 'Retype Password' data entries should be the same. Please try again.\n" + msg;
			first_error="password2";
		}
	}

	return (msg);
}

//Procedure to check password
//End here

function check_login(form) {
	var msg="";

	input=form.password;
	if (input.value!=""){
	    if (!check_form_field(input)){
			msg= " -Invalid input. Please login again.\n" + msg
			first_error = "password";
		}
	}

	input=form.membername;
	if (input.value!=""){
		if (!check_digit_form_field(input)){
			msg =  " -Only numeric characters required for telephone no.\n"  +msg;
			first_error="membername";
		} else {
			if (!check_length_form_field(input,7)){
				msg =  " -Minimum 8 numeric characters required for telephone no.\n"  +msg;
				first_error="membername";
			} else {
				if (!check_otherdigitnumber(input)){
					msg =  " -The telephone no. is invalid.\n"  +msg;
					first_error="membername";
				} else {
					if (!check_8digitnumber(input)){
						msg = " -An 8 numeric character telephone No. should start with 6 or 8 or 9. eg:41234567\n" + msg;
						first_error = "membername";
					} else {
						if (!check_7digitnumber(input)){
							msg = "  Please enter a 8-digit telephone number\n" + msg;
//							msg = " --Effective 1 Mar 2004 all 7 digit telephone No should start with a 6 or 8. eg:61234567\n" + msg;
							first_error = "membername";
						}
					}
				}
			}
		}
	}
	return (msg);
}


//Function to check referral
function check_referral(form) {
	var msg= "" ;
	var numErr=0;
	input=form.referralNum;
	if ((input.value != "") && (input.value != null)) {
		for (var i=0; i<input.value.length; i++) {
			temp= input.value.substring(i,i+1);
			if (special.indexOf(temp)!=-1)
				numErr++;
		}
	}

	if (numErr!=0) {
		msg= " -Only alphanumeric characters allowed for Referral No.\n" + msg;
		first_error="referralNum";
	}

	return (msg);
}
//End of validation (Referral Number)

//Function check notification
//Start Here
function check_notification(form){

	var msg ="";
   //input = document.form.notifcation;

   //SMS Notification method
   if (form.notification[0].checked){
		if (form.smsPhone.value==""){
			msg="-Your mobile phone no. must be an 8-digit number starting with 9,eg:91234567.\n" +msg;
			first_error ="sms";
	   }
       if (form.smsPhone.value!=""){
			if (!check_digit_form_field(form.smsPhone)){
				msg =  " -Only numeric characters required for handphone no.\n"  +msg;
				first_error="sms";
			} else {
				if (!check_length_form_field(form.smsPhone, 8)){
					msg = " -Your mobile phone no. must be an 8-digit number starting with 9,eg:91234567.\n" + msg;
					first_error = "sms";
				} else {
					firstdigit=form.smsPhone.value.substring(1,0);
					if (! (firstdigit=="9"||firstdigit=="8") ){
//					if ((firstdigit!="9") ){
						msg = " -Your mobile phone no. must be an 8-digit number starting with 9 or 8,eg:91234567,81234567.\n" + msg;
						first_error = "sms";
					}
				}//end of 3rd condition
			}// end of 2nd condition
		}// end of sms value not equals empty
	}//end of sms is checked


	//Email Notification Method
	if (form.notification[1].checked){
		if (form.emailAddress.value==""){
			msg ="-You have selected email for notification of auto top-up. Please enter your email address.\n" + msg;
			first_error="emailAddress";
		}

		if (form.emailAddress.value!=""){
			if (!check_email(form.emailAddress)){
				msg ="-You have selected email for notification of auto top-up. Please enter your email address.\n" + msg;
				first_error="emailAddress";
			}
		} //End of email value is not empty
	} //End of email is checked
	return (msg);
}
//End of validation (notification method)


//Check credit card info
//Start Here
function check_cc(form) {
	var msg="";
	var msg1="";
	var msg2="";
	var cnum=0;
	var ccnt=0;

	if ((form.dateOfExpirationMth.options[form.dateOfExpirationMth.selectedIndex].value !="" )&&
	  (form.dateOfExpirationYr.options[form.dateOfExpirationYr.selectedIndex].value !="" )) {

		if(!expired(form.dateOfExpirationMth.options[form.dateOfExpirationMth.selectedIndex].value,
		  form.dateOfExpirationYr.options[form.dateOfExpirationYr.selectedIndex].value ) ) { // check if entered date is already expired.
			first_error = "dateOfExpirationMth";
			msg1= " -Please select a valid Credit Card Expiration Date.\n" ;
		}
	}

	position=form.creditCardNum1;
	if (position.value!="") {
		if (!check_digit_form_field(position)){
			first_error="creditCardNum1";
			cnum++;
		}
	}

	position=form.creditCardNum2;
	if (position.value!="") {
		if (!check_digit_form_field(position)){
			first_error="creditCardNum2";
			cnum++;
	    }
	}

	position=form.creditCardNum3;
	if (position.value!="") {
		if (!check_digit_form_field(position)){
			first_error="creditCardNum3";
			cnum++;
	    }
	}

	position=form.creditCardNum4;
	if (position.value!="") {
		if (!check_digit_form_field(position)){
			first_error="creditCardNum4";
			cnum++;
	    }
	}

	if (cnum!=0)  msg= " -Only numeric characters allowed for Credit Card Number.\n" + msg;

	cardno = form.creditCardNum1.value + form.creditCardNum2.value + form.creditCardNum3.value + form.creditCardNum4.value;

	if (cardno == "4111111111111111") {
		first_error="creditCardNum1";
		return "-Invalid Credit Card Number!\n";
	}

	if ((cnum==0) && (cardno!="")) {
		msg2 = validateCard(cardno,form.creditCardType.selectedIndex);
		if (msg2!="")
   			first_error="creditCardNum1";
	}

	if (msg!="")
		first_error ="creditCardNum1";

	return (msg + msg1 + msg2);
}

function mod10( cardNumber ) { // LUHN Formula for validation of credit card numbers.
	var ar = new Array( cardNumber.length );
	var i = 0,sum = 0;
	for( i = 0; i < cardNumber.length; ++i ) {
		ar[i] = parseInt(cardNumber.charAt(i));
	}
	for( i = ar.length -2; i >= 0; i-=2 ) {	// you have to start from the right, and work back.
		ar[i] *= 2;							// every second digit starting with the right most (check digit)
		if( ar[i] > 9 ) ar[i]-=9;			// will be doubled, and summed with the skipped digits.
	}										// if the double digit is > 9, add those individual digits together
	for( i = 0; i < ar.length; ++i ) {
		sum += ar[i];						// if the sum is divisible by 10 mod10 succeeds
	}
	return (((sum%10)==0)?true:false);
}


function expired(month,year) {

	var now = new Date();
	var expiresIn = new Date(year,month,0,0,0);  // create an expired on date object with valid thru expiration date

	expiresIn.setMonth(expiresIn.getMonth()-1);  // adjust the month, to first day, hour, minute & second of expired month
	if( now.getTime() > expiresIn.getTime() )
		return false;
	return true
}

function validateCard(incardNumber,incardType) {
	// map selectedIndex to value
	var cardType = "";
	var cardNumber = new String(incardNumber);
	if ( incardType == 1 )
		cardType = "Master";
	else if (incardType == 2 )
		cardType = "Amex";
	else if (incardType == 3 )
		cardType = "Diners";
	else
		cardType = "Visa";
/*
	cardMonth = new String (++incardMonth);
	if ( cardMonth.length == 1 ) {
		cardMonth = "0" + cardMonth;
	}
	var cur = new Date();
	var yr = getFullYear(cur);
	cardYear = new String (yr+incardYear);
*/
//	if( cardNumber.length == 0 ) {  //most of these checks are self explanitory
//		return(" -Please enter a valid Credit Card Number.\n");
//	}

// remove spaces
	pos = cardNumber.indexOf(" ");
	while ( pos != -1 ) {
		cardNumber = cardNumber.substring(0, pos) + cardNumber.substring(pos+1) ;
		pos = cardNumber.indexOf(" ");
	}

	for( var i = 0; i < cardNumber.length; ++i ) {          // make sure the number is all digits.. (by design)
		var c = cardNumber.charAt(i);
		if( c < '0' || c > '9' ) {
			return(" -Please enter a valid Credit Card Number.  Use only digits or spaces.  Do not use hyphens.\n");
		}
	}
	var length = cardNumber.length;                 //perform card specific length and prefix tests

	if ( cardType == "")
		return(" -Invalid card type.\n");

	if ( cardType == "Master" ) {
		if( length != 16 ) {
			return(" -Please enter a valid MasterCard number.\n");
		}
		var prefix = parseInt( cardNumber.substring(0,2));
		if( prefix < 51 || prefix > 55) {
			return(" -Please enter a valid MasterCard Card number.\n");
		}
	}

	if ( cardType == "Diners" ) {
		if( length != 14 ) {
			return(" -Please enter a valid Diners Club Card number.\n");
		}
		var prefix = parseInt( cardNumber.substring(0,4));
		if(( prefix < 3000 || prefix > 3059) &&
		   ( prefix < 3600 || prefix > 3659) &&
		   ( prefix < 3800 || prefix > 3889) &&
		   ( prefix != 3095)) {
			return(" -Please enter a valid Diners Club Card number.\n");
		}
	}

	if ( cardType == "Amex" ) {
		if( length != 15 ) {
			return(" -Please enter a valid American Express Card number.\n");
		}
		var prefix = parseInt( cardNumber.substring(0,2));
		if( prefix != 34 && prefix != 37) {
			return(" -Please enter a valid American Express Card number.\n");
		}
	}

	if (cardType == "Visa") {
		if( length != 16 && length != 13 ) {
			return(" -Please enter a valid Visa Card number.\n");
		}
		var prefix = parseInt( cardNumber.substring(0,1));
		if( prefix != 4 ) {
			return(" -Please enter a valid Visa Card number.\n");
		}
	}

	if( !mod10( cardNumber ) ) {                                            // run the check digit algorithm
		return(" -Sorry!  This is not a valid card number.\n");

	}

	return ""; // at this point card has not been proven to be invalid
}
//credit card validation

//function to validate the user's age limit
function check_age(form,today)
{
	var thisDay = new Array();
	thisDay = today.split(" ");
	cAge_msg = "  Thank you for your interest in using ZONE1511\n" +
		  "  Regret to inform you that the legal age limit\n" +
		  "  for applicants is 21.\n"
	if (parseInt(form.dateOfBirthYY.value) == parseInt(thisDay[2])- 21)
	{
		if (parseInt(form.dateOfBirthMM.value) > parseInt(thisDay[1]))
			return cAge_msg;
		if (parseInt(form.dateOfBirthMM.value) == parseInt(thisDay[1]))
		{
			if (parseInt(form.dateOfBirthDD.value) > parseInt(thisDay[0]))
				return cAge_msg;
		}
	}
	return "";
}

//Make sure no repeating Quick Dial no entered!(My Special Features - QuickDial.)
//Start Here
function check_no_repeat_quickdial_no(form) {
	var msg="";
	var repeat=0;
	j = form.elements.length;
	for (k=0; k<j; k++) {
		ename = form.elements[k].name;
		evalue =form.elements[k].value;
		result = ename.indexOf("qd")
		if ((result!=-1) && (evalue!="")){
			for (m=0; m<j; m++){
				fname = form.elements[m].name;
				fvalue =form.elements[m].value;
				found = fname.indexOf("qd")
				if ((found!=-1) && (fvalue!="")){
					if ((evalue==fvalue) && (ename!=fname)){
						repeat++;
					}
				}
			}
		}

	}

	if (repeat!=0)
		msg=" -Same Quick Dial number found, please enter again.\n";
	return (msg);
}

//function to validate the quickdial details
function check_quickdial(form)
{
	var msg="";
	var msg1="";
	var numDigitErr=0;
	var contNumErr=0;
	var destNumErr=0;
	var nullErr=0;

	n =form.elements.length
	for (i=n-1; i>=0; i--) {
		ename = form.elements[i].name;
		result = ename.indexOf("qd")

		if (result !=-1) {
			input=form.elements[i];
			if (input.value != "") {
				if (!check_digit_form_field(input)) {
					numDigitErr++;
					first_error=form.elements[i].name;
				} else {
					if (!check_exact_length_form_field(input,2)){
						contNumErr++;
						first_error=form.elements[i].name;
					}
				}

				input1=form.elements[i + 1];
				if (input1.value != "") {
					if (!check_digit_form_field(input1)) {
						destNumErr++;
						first_error=form.elements[i].name;
					}
				} else {
					nullErr++;
					first_error=form.elements[i].name;
				}
			}
		}
	}

    msg1 = check_no_repeat_quickdial_no(form)

	if (numDigitErr>0)
		msg =  " -Only numeric characters required for Quick Dial Number.\n"  +msg;

	if (contNumErr>0)
		msg =  " -Minimum 2 digit required for Quick Dial Number.\n"  +msg;

	if (destNumErr>0)
		msg =  " -Only numeric characters required for Overseas Contact Number.\n" + msg;

	if (nullErr>0)
		msg =  " -Overseas Contact Number cannot be blank.\n"  +msg;

	return (msg +msg1);
}

//function to validate the globaldial details
function check_globaldial(form)
{
	var msg="";
	var alphaNumErr=0;
	var contNumErr=0;
	var destNumErr=0;
	var localNumErr=0;

	n = form.elements.length
	for (i=n-1; i>=0; i--) {
		ename = form.elements[i].name;
		result = ename.indexOf("pass")

		if (result !=-1) {
			input=form.elements[i];
			if (input.value!=""){
				if (!check_form_field(input)) {
					alphaNumErr++;
					first_error = form.elements[i].name;
				}

				if (input.value.length<4) {
					contNumErr++;
					first_error = form.elements[i].name;
				}
			}

		}

		result = ename.indexOf("dest");

		if (result !=-1) {
			input=form.elements[i];
			if (input.value != "") {
				if (input.value.substring(0,2)==65) {
					localNumErr++;
					first_error=form.elements[i].name;
				} else {
					if (!check_digit_form_field(input)) {
						destNumErr++;
						first_error=form.elements[i].name;
					}
				}
			}
		}
	}

	if (alphaNumErr>0)
		msg =  " -Only alphanumeric characters required for your password.\n"  +msg;

	if (contNumErr>0)
		msg =  "  -Password must be a minimum of 4 characters.\n"  +msg;

	if (destNumErr>0)
		msg =  " -Only numeric characters required for Overseas Contact Number.\n" + msg;

	if (localNumErr>0)
		msg =  " -Country code 65 cannot be use for Overseas Contact Number.\n" + msg;

	return (msg);
}

//End Here


//function to validate the globaldial details
function check_globaldial_ignore65(form) {
    var msg = "";
    var alphaNumErr = 0;
    var contNumErr = 0;
    var destNumErr = 0;
    var localNumErr = 0;
    var have65 = 0;
    var nohave65 = 0;

    n = form.elements.length
    for (i = n - 1; i >= 0; i--) {
        ename = form.elements[i].name;
        result = ename.indexOf("pass")

        if (result != -1) {
            input = form.elements[i];
            if (input.value != "") {
                if (!check_form_field(input)) {
                    alphaNumErr++;
                    first_error = form.elements[i].name;
                }

                if (input.value.length < 4) {
                    contNumErr++;
                    first_error = form.elements[i].name;
                }
            }

        }

        result = ename.indexOf("dest");

        if (result != -1) {
            input = form.elements[i];
            if (input.value != "") {
                if (input.value.substring(0, 2) == 65) {
                    have65++;
                    first_error = form.elements[i].name;

                } else {
                    nohave65++;
                    if (!check_digit_form_field(input)) {
                        destNumErr++;
                        first_error = form.elements[i].name;
                    }
                }
            }
        }
    }

    if (have65 > 0 && nohave65 > 0) {
        msg = "To use both ZONE GlobalDial & ZONE GlobalDial Plus concurrently, please create a different account for each access code."+msg;
    }
    if (alphaNumErr > 0)
        msg = " -Only alphanumeric characters required for your password.\n" + msg;

    if (contNumErr > 0)
        msg = "  -Password must be a minimum of 4 characters.\n" + msg;

    if (destNumErr > 0)
        msg = " -Only numeric characters required for Overseas Contact Number.\n" + msg;

    if (localNumErr > 0)
        msg = " -Country code 65 cannot be use for Overseas Contact Number.\n" + msg;

    return (msg);
}


//End Here

