function Adr_CountryCode_Changed(country_code){var usa=country_code=='US';document.getElementById('Div_State').style.visibility=usa?"visible":"hidden";document.getElementById('Div_Province').style.visibility=!usa?"visible":"hidden";document.getElementById('Div_State').style.position=usa?"static":"absolute";document.getElementById('Div_Province').style.position=!usa?"static":"absolute"}function ValidatePromotionCode(){var valid_prm_codes="OENRB";if(document.frm.PromotionCode.value=='')return true;var codes=valid_prm_codes.split(',');for(var i=0;i!=codes.length;i++){if(codes[i].toLowerCase()==document.frm.PromotionCode.value.toLowerCase())return true}return false}function ValidateTempMembershipNum(val){if(val=='')return true;var re=/^\d*$/;if(!re.exec(val))return false;var x=val.substring(0,val.length-1);var y=x-parseInt(x/7)*7;if(y==val.substring(val.length-1,val.length))return true;return false}function Validate(){if(!ValidatePromotionCode()){alert("The promotion code you entered is not correct, please insert a valid promotion code. \n\n[Please leave the field blank if you don't have a promotion code.]");return false}if(!ValidateTempMembershipNum(document.frm.TempMembershipNumber.value)){alert("The temporary membership number inserted is not correct, please insert a correct temporary membership number. \n\n[Please leave the field blank if you don't have a temporary membership number.]");return false}if(document.frm.CustomerNamePrefix.value==''){alert('Please specify your title.');return false}if(document.frm.GenderCode.value==''){alert('Please specify your gender.');return false}if(document.frm.FName.value==''){alert('Please specify your first name.');return false}if(!/^[A-Za-z]+([\-\s][A-Za-z]+)*$/.exec(document.frm.FName.value)){alert('First name should be in English.');return false}if(document.frm.LName.value==''){alert('Please specify your last name.');return false}if(!/^[A-Za-z]+([\-\s][A-Za-z]+)*$/.exec(document.frm.LName.value)){alert('Last name should be in English.');return false}if(!/^([A-Za-z]+([\-\s][A-Za-z]+)*)?$/.exec(document.frm.MName.value)){alert('Middle name should be in English.');return false}if(document.frm.b_day.value==''||document.frm.b_month.value==''||document.frm.b_year.value==''){alert('Please specify your birth date.');return false}if(!verifyDate(document.frm.b_day.value+"/"+document.frm.b_month.value+"/"+document.frm.b_year.value)){alert('Wrong date provided for birth date.');return false}var dt=new Date();var b_date=new Date(document.frm.b_year.value,document.frm.b_month.value-1,document.frm.b_day.value);var per_year=365.25*24*60*60*1000;var d_diff=(dt-b_date)/per_year;if(parseInt(d_diff)<18){alert('You must be 18 years or above.');return false}if(document.frm.EMail.value==''){alert('Please specify your E-mail.');return false}if(!isValidEmail(document.frm.EMail.value)){alert('Please specify correct "E-mail."');return false}if(document.frm.Adr_AddrType.value==''){alert('Please specify your address type.');return false}if(document.frm.StreetAddress.value==''&&document.frm.POBox.value==''){alert('Please specify either your street address or P.O.Box.');return false}if(document.frm.PhoneType=='B'&&document.frm.Company.value==''){alert('Please specify your company name. It is required because you have specified your business address.');return false}if(document.frm.Adr_City.value==''){alert('Please specify your city.');return false}if(document.frm.Adr_CountryCode.value==''){alert('Please specify your address/country');return false}if((document.frm.Adr_CountryCode.value=='AO'||document.frm.Adr_CountryCode.value=='BF'||document.frm.Adr_CountryCode.value=='BH'||document.frm.Adr_CountryCode.value=='BI'||document.frm.Adr_CountryCode.value=='BJ'||document.frm.Adr_CountryCode.value=='BW'||document.frm.Adr_CountryCode.value=='CC'||document.frm.Adr_CountryCode.value=='CF'||document.frm.Adr_CountryCode.value=='CG'||document.frm.Adr_CountryCode.value=='CI'||document.frm.Adr_CountryCode.value=='CM'||document.frm.Adr_CountryCode.value=='DJ'||document.frm.Adr_CountryCode.value=='DZ'||document.frm.Adr_CountryCode.value=='ER'||document.frm.Adr_CountryCode.value=='ET'||document.frm.Adr_CountryCode.value=='GA'||document.frm.Adr_CountryCode.value=='GH'||document.frm.Adr_CountryCode.value=='GM'||document.frm.Adr_CountryCode.value=='GN'||document.frm.Adr_CountryCode.value=='GQ'||document.frm.Adr_CountryCode.value=='GW'||document.frm.Adr_CountryCode.value=='IR'||document.frm.Adr_CountryCode.value=='KE'||document.frm.Adr_CountryCode.value=='LR'||document.frm.Adr_CountryCode.value=='LS'||document.frm.Adr_CountryCode.value=='LY'||document.frm.Adr_CountryCode.value=='MA'||document.frm.Adr_CountryCode.value=='MG'||document.frm.Adr_CountryCode.value=='MR'||document.frm.Adr_CountryCode.value=='MU'||document.frm.Adr_CountryCode.value=='MW'||document.frm.Adr_CountryCode.value=='MZ'||document.frm.Adr_CountryCode.value=='NA'||document.frm.Adr_CountryCode.value=='NE'||document.frm.Adr_CountryCode.value=='NG'||document.frm.Adr_CountryCode.value=='RW'||document.frm.Adr_CountryCode.value=='SC'||document.frm.Adr_CountryCode.value=='SD'||document.frm.Adr_CountryCode.value=='SL'||document.frm.Adr_CountryCode.value=='SN'||document.frm.Adr_CountryCode.value=='SO'||document.frm.Adr_CountryCode.value=='SZ'||document.frm.Adr_CountryCode.value=='TD'||document.frm.Adr_CountryCode.value=='TN'||document.frm.Adr_CountryCode.value=='TR'||document.frm.Adr_CountryCode.value=='TZ'||document.frm.Adr_CountryCode.value=='UG'||document.frm.Adr_CountryCode.value=='VE'||document.frm.Adr_CountryCode.value=='ZM'||document.frm.Adr_CountryCode.value=='ZR'||document.frm.Adr_CountryCode.value=='ZW'||document.frm.Adr_CountryCode.value=='HK'||document.frm.Adr_CountryCode.value=='TW'||document.frm.Adr_CountryCode.value=='ZW'||document.frm.Adr_CountryCode.value=='KW'||document.frm.Adr_CountryCode.value=='QA'||document.frm.Adr_CountryCode.value=='AE'||document.frm.Adr_CountryCode.value=='YD'||document.frm.Adr_CountryCode.value=='JD'||document.frm.Adr_CountryCode.value=='LB'||document.frm.Adr_CountryCode.value=='SY'||document.frm.Adr_CountryCode.value=='KP')&&document.frm.POBox.value==''){alert('P.O.Box is mandatory for your country.');return false}else if(document.frm.Adr_CountryCode.value=='IL'||document.frm.Adr_CountryCode.value=='PK'||document.frm.Adr_CountryCode.value=='EG'||document.frm.Adr_CountryCode.value=='PS'){}else if(document.frm.Adr_CountryCode.value!='AO'&&document.frm.Adr_CountryCode.value!='BF'&&document.frm.Adr_CountryCode.value!='BH'&&document.frm.Adr_CountryCode.value!='BI'&&document.frm.Adr_CountryCode.value!='BJ'&&document.frm.Adr_CountryCode.value!='BW'&&document.frm.Adr_CountryCode.value!='CC'&&document.frm.Adr_CountryCode.value!='CF'&&document.frm.Adr_CountryCode.value!='CG'&&document.frm.Adr_CountryCode.value!='CI'&&document.frm.Adr_CountryCode.value!='CM'&&document.frm.Adr_CountryCode.value!='DJ'&&document.frm.Adr_CountryCode.value!='DZ'&&document.frm.Adr_CountryCode.value!='ER'&&document.frm.Adr_CountryCode.value!='ET'&&document.frm.Adr_CountryCode.value!='GA'&&document.frm.Adr_CountryCode.value!='GH'&&document.frm.Adr_CountryCode.value!='GM'&&document.frm.Adr_CountryCode.value!='GN'&&document.frm.Adr_CountryCode.value!='GQ'&&document.frm.Adr_CountryCode.value!='GW'&&document.frm.Adr_CountryCode.value!='IR'&&document.frm.Adr_CountryCode.value!='KE'&&document.frm.Adr_CountryCode.value!='LR'&&document.frm.Adr_CountryCode.value!='LS'&&document.frm.Adr_CountryCode.value!='LY'&&document.frm.Adr_CountryCode.value!='MA'&&document.frm.Adr_CountryCode.value!='MG'&&document.frm.Adr_CountryCode.value!='MR'&&document.frm.Adr_CountryCode.value!='MU'&&document.frm.Adr_CountryCode.value!='MW'&&document.frm.Adr_CountryCode.value!='MZ'&&document.frm.Adr_CountryCode.value!='NA'&&document.frm.Adr_CountryCode.value!='NE'&&document.frm.Adr_CountryCode.value!='NG'&&document.frm.Adr_CountryCode.value!='RW'&&document.frm.Adr_CountryCode.value!='SC'&&document.frm.Adr_CountryCode.value!='SD'&&document.frm.Adr_CountryCode.value!='SL'&&document.frm.Adr_CountryCode.value!='SN'&&document.frm.Adr_CountryCode.value!='SO'&&document.frm.Adr_CountryCode.value!='SZ'&&document.frm.Adr_CountryCode.value!='TD'&&document.frm.Adr_CountryCode.value!='TN'&&document.frm.Adr_CountryCode.value!='TR'&&document.frm.Adr_CountryCode.value!='TZ'&&document.frm.Adr_CountryCode.value!='UG'&&document.frm.Adr_CountryCode.value!='VE'&&document.frm.Adr_CountryCode.value!='ZM'&&document.frm.Adr_CountryCode.value!='ZR'&&document.frm.Adr_CountryCode.value!='ZW'&&document.frm.Adr_CountryCode.value!='HK'&&document.frm.Adr_CountryCode.value!='TW'&&document.frm.Adr_CountryCode.value!='ZW'&&document.frm.Adr_CountryCode.value!='KW'&&document.frm.Adr_CountryCode.value!='QA'&&document.frm.Adr_CountryCode.value!='AE'&&document.frm.Adr_CountryCode.value!='YD'&&document.frm.Adr_CountryCode.value!='JD'&&document.frm.Adr_CountryCode.value!='LB'&&document.frm.Adr_CountryCode.value!='SY'&&document.frm.Adr_CountryCode.value!='KP'&&document.frm.StreetAddress.value==''){alert('Street address is mandatory for your country.');return false}if((document.frm.Adr_CountryCode.value=='AO'||document.frm.Adr_CountryCode.value=='BF'||document.frm.Adr_CountryCode.value=='BH'||document.frm.Adr_CountryCode.value=='BI'||document.frm.Adr_CountryCode.value=='BJ'||document.frm.Adr_CountryCode.value=='BW'||document.frm.Adr_CountryCode.value=='CC'||document.frm.Adr_CountryCode.value=='CF'||document.frm.Adr_CountryCode.value=='CG'||document.frm.Adr_CountryCode.value=='CI'||document.frm.Adr_CountryCode.value=='CM'||document.frm.Adr_CountryCode.value=='DJ'||document.frm.Adr_CountryCode.value=='DZ'||document.frm.Adr_CountryCode.value=='EG'||document.frm.Adr_CountryCode.value=='ER'||document.frm.Adr_CountryCode.value=='ET'||document.frm.Adr_CountryCode.value=='GA'||document.frm.Adr_CountryCode.value=='GH'||document.frm.Adr_CountryCode.value=='GM'||document.frm.Adr_CountryCode.value=='GN'||document.frm.Adr_CountryCode.value=='GQ'||document.frm.Adr_CountryCode.value=='GW'||document.frm.Adr_CountryCode.value=='IR'||document.frm.Adr_CountryCode.value=='KE'||document.frm.Adr_CountryCode.value=='LR'||document.frm.Adr_CountryCode.value=='LS'||document.frm.Adr_CountryCode.value=='LY'||document.frm.Adr_CountryCode.value=='MA'||document.frm.Adr_CountryCode.value=='MG'||document.frm.Adr_CountryCode.value=='ML'||document.frm.Adr_CountryCode.value=='MR'||document.frm.Adr_CountryCode.value=='MU'||document.frm.Adr_CountryCode.value=='MW'||document.frm.Adr_CountryCode.value=='MZ'||document.frm.Adr_CountryCode.value=='NA'||document.frm.Adr_CountryCode.value=='NE'||document.frm.Adr_CountryCode.value=='NG'||document.frm.Adr_CountryCode.value=='RW'||document.frm.Adr_CountryCode.value=='SC'||document.frm.Adr_CountryCode.value=='SD'||document.frm.Adr_CountryCode.value=='SL'||document.frm.Adr_CountryCode.value=='SN'||document.frm.Adr_CountryCode.value=='SO'||document.frm.Adr_CountryCode.value=='SZ'||document.frm.Adr_CountryCode.value=='TD'||document.frm.Adr_CountryCode.value=='TN'||document.frm.Adr_CountryCode.value=='TR'||document.frm.Adr_CountryCode.value=='TZ'||document.frm.Adr_CountryCode.value=='UG'||document.frm.Adr_CountryCode.value=='VE'||document.frm.Adr_CountryCode.value=='ZM'||document.frm.Adr_CountryCode.value=='ZR'||document.frm.Adr_CountryCode.value=='ZW'||document.frm.Adr_CountryCode.value=='HK'||document.frm.Adr_CountryCode.value=='TW'||document.frm.Adr_CountryCode.value=='ZW'||document.frm.Adr_CountryCode.value=='KW'||document.frm.Adr_CountryCode.value=='QA'||document.frm.Adr_CountryCode.value=='AE'||document.frm.Adr_CountryCode.value=='YD'||document.frm.Adr_CountryCode.value=='JD'||document.frm.Adr_CountryCode.value=='LB'||document.frm.Adr_CountryCode.value=='SY'||document.frm.Adr_CountryCode.value=='KP'||document.frm.Adr_CountryCode.value=='PS')&&document.frm.Adr_PostCode.value==''){}else if(document.frm.Adr_PostCode.value==''){alert('Please specify your zip code.');return false}if(document.frm.Adr_CountryCode.value=='US'){if(document.frm.Adr_State.value==''){alert('Please specify your address/state/region.');return false}document.frm.Adr_StateProvince.value=document.frm.Adr_State.value}else{document.frm.Adr_StateProvince.value=document.frm.Adr_Province.value}if(document.frm.PhoneType.value==''){alert('Please specify your phone type.');return false}if(!ValidatePhone('H'))return false;if(document.frm.ChallengeAnswer.value==''){alert('Please specify your secret question and answer.');return false}if(document.frm.RefererMembershipNumber.value!=''&&!ValidateTempMembershipNum(document.frm.RefererMembershipNumber.value)){alert("The referrer's membership number you specified is not valid.");return false}if(document.frm.RefererMembershipNumber.value!=''&&(document.frm.RefererMembershipNumber.value==document.frm.TempMembershipNumber.value)){alert("Temporary membership number cannot be identical with referrer's membership number.");return false}if(!document.frm.Adr_TermsAndConditions.checked){alert('You need to agree to the terms and conditions for registration.');return false}var fields=new Array('Company','JbTitle','Adr_StateProvince','Adr_City','Adr_StreetAddressLine1','Adr_StreetAddressLine2','Adr_StreetAddressLine3','Adr_StreetAddressLine4');var fieldnames=new Array('Place of employment','Position','State (region)','City','Street address','Street address','Street address','Street address');for(var i=0;i<fields.length;++i){if(!/^[a-zA-Z?-??-???0-9\s\.,;:\(\)\[\]\"\'\/\\#~`%$^*!\-+=\|\?]*$/.exec(document.frm[fields[i]].value)){alert('Field "'+fieldnames[i]+'" should contain English letters, numbers and punctuation marks only');return false}}return true}function Validate2(){if(document.frm.Relationship1.value==''){alert('Please specify your Relationship with the 1st family member');return false}if(document.frm.LName1.value==''){alert('Please specify Last name (for the 1st family member)');return false}if(!/^[A-Za-z]+([\-\s][A-Za-z]+)*$/.exec(document.frm.LName1.value)){alert('Last name should be in English(for the 1st family member)');return false}if(document.frm.FName1.value==''){alert('Please specify your First name(for the 1st family member)');return false}if(!/^[A-Za-z]+([\-\s][A-Za-z]+)*$/.exec(document.frm.FName1.value)){alert('First name should be in English(for the 2nd family member)');return false}var birthdate=parseDate(document.frm.Date1.value);var dt=new Date();if(birthdate>dt){alert('Wrong data provided in birth date field(of the 1st family member)');return false}if((!document.frm.FName2.value=='')||(!document.frm.LName2.value=='')){if(document.frm['Relationship2'].value.length==''){alert('Please specify your Relationship with the 2nd family member');return false}if(document.frm.Date2.value==''){alert('Please specify birth date(for the 2nd family member)');return false}var birthdate2=parseDate(document.frm.Date2.value);var dt2=new Date();if(birthdate2>dt2){alert('Wrong data provided in birth date field(of the 2nd family member)');return false}}if((!document.frm.FName3.value=='')||(!document.frm.LName3.value=='')){if(document.frm['Relationship3'].value.length==''){alert('Please specify your Relationship with the 3rd family member');return false}if(document.frm.Date3.Value==''){alert('Please specify birth date (for the 3rd family member)');return false}var birthdate3=parseDate(document.frm.Date3.value);var dt3=new Date();if(birthdate3>dt3){alert('Wrong data provided in birth date field(of the 3rd family member)');return false}}if((!document.frm['FName4'].value.length=='')||(!document.frm['LName4'].value.length=='')){if(document.frm['Relationship4'].value.length==''){alert('Please specify your Relationship with the 4th family member');return false}if(document.frm.CustomerNamePrefix4.value==''){alert('Please specify Prefix(for the 4th family member)');return false}if(document.frm.Date4.value==''){alert('Please specify birth date(for the 2nd family member)');return false}var birthdate4=parseDate(document.frm.Date4.value);var dt4=new Date();if(birthdate4>dt4){alert('Wrong data provided in birth date field(of the 5th family member)');return false}}if((!document.frm['FName5'].value.length=='')||(!document.frm['LName5'].value.length=='')){if(document.frm['Relationship5'].value.length==''){alert('Please specify your Relationship with the 5th family member');return false}if(document.frm.CustomerNamePrefix5.value==''){alert('Please specify Prefix(for the 5th family member)');return false}if(document.frm.Date5.value==''){alert('Please specify dirth date(for the 2nd family member)');return false}var birthdate5=parseDate(document.frm.Date5.value);var dt5=new Date();if(birthdate5>dt5){alert('Wrong data provided in birth date field(of the 5th family member)');return false}}return true}function isValidEmail(email){return(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email)}var hashPhoneTypes=new Object();hashPhoneTypes['H']="Home telephone";hashPhoneTypes['B']="Business telephone";hashPhoneTypes['C']="Mobile telephone";hashPhoneTypes['F']="Fax number";function ValidatePhone(type){var prefix='Phn_'+type+'_';var isEmpty=document.frm[prefix+'CountryCode'].value.length==''||document.frm[prefix+'CityCode'].value.length==''||document.frm[prefix+'Number'].value.length=='';if(isEmpty){alert('Please specify your telephone address.');return false}if(!isEmpty){if(document.frm[prefix+'CountryCode'].value.length==''){alert('Please specify "'+hashPhoneTypes[type]+'/country code"');return false}if(document.frm[prefix+'CityCode'].value.length==''){alert('Please specify "'+hashPhoneTypes[type]+'/city code"');return false}if(document.frm[prefix+'Number'].value.length==''){alert('Please specify "'+hashPhoneTypes[type]+'/number"');return false}var re=/^\d*$/;if(!re.exec(document.frm[prefix+'CityCode'].value)){alert('Field "'+hashPhoneTypes[type]+'/city code" should contain numbers only');return false}if(!re.exec(document.frm[prefix+'Number'].value)){alert('Field "'+hashPhoneTypes[type]+'/number" should contain numbers only');return false}}return true}function verifyDate(str){if(/(\d\d)\/(\d\d)\/(\d\d\d\d)/.exec(str)){var year=parseInt(RegExp.$3,10);var month=parseInt(RegExp.$2,10)-1;var day=parseInt(RegExp.$1,10);var dt=new Date(year,month,1);dt.setDate(day);if(!(day=dt.getDate()&&month==dt.getMonth()&&year==dt.getFullYear()&&month>=0))return false;else return true}else{return false}}function parseDate(str){if(/(\d\d)\/(\d\d)\/(\d\d\d\d)/.exec(str)){var year=parseInt(RegExp.$3,10);var month=parseInt(RegExp.$2,10)-1;var day=parseInt(RegExp.$1,10);return new Date(year,month,day)}}
