/*
JavaScript Document
Form Validation
Written: August 10th, 2006
Modified: September 19, 2007
FUNCTIONS:
	isNumeric - checks if string is a number
	isEmail - checks if string is in a proper email format
	checkRequiredDropDown - checks if a value has been selected for the drop down box
	ValidateDate - checks if the string is a valid date
	isDate - checks if the value is a valid date
	getDateFromFormat - get date string and format string if matches returns getTime() else returns 0
	_isInteger - used for parsing in getDateFromFormat
	_getInt - used for parsing in getDateFromFormat
	isPostalCode - checks if string is a valid Canadian Postal Code
	isBermudaPostalCode - checks if string is a valid Bermuda Postal Code
	areaTextCheck - checks the length of the TextArea, if longer then the max length an alert pops up
	addEvent - adds events to the object provided.
	checkRadioButtons - check radio buttons
	checkRadioOther - check radio buttons
	CheckNull - check if null
	isNull - checks if object has a blank value
	validatelogin - check the username and password entered on login*/	


	//Used to check if text is numerical
	function isNumeric(testNum) {
		var loopCounter=0;
		var IsNum= (testNum != "");
		var testchar;
		var DecimalFound = false;
	
		while ( (IsNum) && (loopCounter<testNum.length) ) {
			if ((testNum.substring(loopCounter,loopCounter+1) == ".") && (DecimalFound == false)) {
				loopCounter++;
				DecimalFound = true;
			} else {
				testchar=parseInt(testNum.substring(loopCounter,loopCounter+1));
				if (isNaN(testchar)) {
					IsNum=false;
				}
				loopCounter++;
			}
		}
		return IsNum;
	}

	//Used to check if text is a valid email
	function isEmail(string) {
		if (string == "" || string == null) {
			alert("You have not specified an email address");
			return false;
		} 
		else {
			if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
				return true;
			else {
				alert("The supplied email address seems malformed.\n\nPlease ensure that you have typed a valid email address.");
				return false;
			}
		}
	}

	//Checks if the selected value is blank, if it is blank then it has not found a proper value.
	function checkRequiredDropDown(dropDown){
		
		if (dropDown.options[dropDown.selectedIndex].value == "") {
		   return false;
		}
		return true;
		
	}


	function ValidateDate(selDay, selMonth, selYear) {
	
		//Check to see if user actually picked any numbers
		if(selDay.value == 'Day' || selMonth.value == 'Month' || selYear.value == 'Year'){
			return false;	
		}
		
		//Create Date variable
		var DateUsed = selDay.value + '/' + selMonth.value + '/' + selYear.value;
	
		//Check if DateUsed is a real date.  Checks for unusable dates such as 29FEB2005, 31APR2006 and so on, 
		//accepts 29FEB2008 (Leap year)
		if(isDate(DateUsed, 'dd/MM/yyyy')){
			return true;
		}
		else{
			return false;	
		}
		
	}

	function isDate(val,format) {
		var date=getDateFromFormat(val,format);
		if (date==0) { return false; }
		return true;
	}
	
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
	function getDateFromFormat(val,format) {
		val=val+"";
		format=format+"";
		var i_val=0;
		var i_format=0;
		var c="";
		var token="";
		var token2="";
		var x,y;
		var now=new Date();
		var year=now.getYear();
		var month=now.getMonth()+1;
		var date=1;
		var hh=now.getHours();
		var mm=now.getMinutes();
		var ss=now.getSeconds();
		var ampm="";
		
		while (i_format < format.length) {
			// Get next token from format string
			c=format.charAt(i_format);
			token="";
			while ((format.charAt(i_format)==c) && (i_format < format.length)) {
				token += format.charAt(i_format++);
				}
				
			// Extract contents of value based on format token
	
			if (token=="yyyy" || token=="yy" || token=="y") {
				if (token=="yyyy") { x=4;y=4; }
				if (token=="yy")   { x=2;y=2; }
				if (token=="y")    { x=2;y=4; }
				year=_getInt(val,i_val,x,y);
				if (year==null) { return 0; }
				i_val += year.length;
				if (year.length==2) {
					if (year > 70) { year=1900+(year-0); }
					else { year=2000+(year-0); }
					}
				}
			else if (token=="MMM"||token=="NNN"){
				month=0;
				for (var i=0; i<MONTH_NAMES.length; i++) {
					var month_name=MONTH_NAMES[i];
					if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
						if (token=="MMM"||(token=="NNN"&&i>11)) {
							month=i+1;
							if (month>12) { month -= 12; }
							i_val += month_name.length;
							break;
							}
						}
					}
				if ((month < 1)||(month>12)){return 0;}
				}
			else if (token=="EE"||token=="E"){
				for (var i=0; i<DAY_NAMES.length; i++) {
					var day_name=DAY_NAMES[i];
					if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
						i_val += day_name.length;
						break;
						}
					}
				}
			else if (token=="MM"||token=="M") {
				month=_getInt(val,i_val,token.length,2);
				if(month==null||(month<1)||(month>12)){return 0;}
				i_val+=month.length;}
			else if (token=="dd"||token=="d") {
				date=_getInt(val,i_val,token.length,2);
				if(date==null||(date<1)||(date>31)){return 0;}
				i_val+=date.length;}
			else if (token=="hh"||token=="h") {
				hh=_getInt(val,i_val,token.length,2);
				if(hh==null||(hh<1)||(hh>12)){return 0;}
				i_val+=hh.length;}
			else if (token=="HH"||token=="H") {
				hh=_getInt(val,i_val,token.length,2);
				if(hh==null||(hh<0)||(hh>23)){return 0;}
				i_val+=hh.length;}
			else if (token=="KK"||token=="K") {
				hh=_getInt(val,i_val,token.length,2);
				if(hh==null||(hh<0)||(hh>11)){return 0;}
				i_val+=hh.length;}
			else if (token=="kk"||token=="k") {
				hh=_getInt(val,i_val,token.length,2);
				if(hh==null||(hh<1)||(hh>24)){return 0;}
				i_val+=hh.length;hh--;}
			else if (token=="mm"||token=="m") {
				mm=_getInt(val,i_val,token.length,2);
				if(mm==null||(mm<0)||(mm>59)){return 0;}
				i_val+=mm.length;}
			else if (token=="ss"||token=="s") {
				ss=_getInt(val,i_val,token.length,2);
				if(ss==null||(ss<0)||(ss>59)){return 0;}
				i_val+=ss.length;}
			else if (token=="a") {
				if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
				else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
				else {return 0;}
				i_val+=2;}
			else {
				if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
				else {i_val+=token.length;}
				}
			}
		// If there are any trailing characters left in the value, it doesn't match
		if (i_val != val.length) { return 0; }
		// Is date valid for month?
		if (month==2) {
			// Check for leap year
			if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
				if (date > 29){ return 0; }
				}
			else { if (date > 28) { return 0; } }
			}
		if ((month==4)||(month==6)||(month==9)||(month==11)) {
			if (date > 30) { return 0; }
			}
		// Correct hours value
		if (hh<12 && ampm=="PM") { hh=hh-0+12; }
		else if (hh>11 && ampm=="AM") { hh-=12; }
		var newdate=new Date(year,month-1,date,hh,mm,ss);
		return newdate.getTime();
		}

// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
	function _isInteger(val) {
		
		var digits="1234567890";
		for (var i=0; i < val.length; i++) {
			if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
		return true;
		
	}
		
		
	function _getInt(str,i,minlength,maxlength) {
		
		for (var x=maxlength; x>=minlength; x--) {
			var token=str.substring(i,i+x);
			if (token.length < minlength) { return null; }
			if (_isInteger(token)) { return token; }
		}
		
		return null;
	
	}

	function isPostalCode(strPostalCode) {
	
		if (strPostalCode.search(/^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i) != -1)
			return true;
		else {
			alert("Incorrect Postal Code format.");
			return false;
		}
		
	}
	
	function isBermudaPostalCode(strPostalCode) {
	
		//Valid post office box - AA AA
		if (strPostalCode.search(/^\s*[a-z][a-z](\s)?[a-z][a-z]*$/i) != -1) {
			return true;
		}
		//Valid street address - AA 99
		else if(strPostalCode.search(/^\s*[a-z][a-z](\s)?\d\d*$/i) != -1) {
			return true;
		}
		else {
			alert("Incorrect bermuda Postal Code format.");
			return false;
		}
	
	}

	function areaTextCheck(field, maxlimit) {
		
		if (field.value.length >= maxlimit) {
			return false;
		}
		
		return true;		
	}


	//Used to add events to an object
	function addEvent(obj, evType, fn){
		
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, true);
			return true;
		} 
		else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} 
		else {
			return false;
		}
		
	}

	function checkRadioButtons(radObj) {
	
		var numOfButtons = radObj.length;
		var itemChecked = false;
		
		if (numOfButtons > 1) {
			for (var x=0; x<numOfButtons; x++) {
				if(radObj[x].checked == true){
					itemChecked = true;	
				}
			}
		}
		return itemChecked;
	}


	function checkRadioOther(radObj, radText) {
	
		var numOfButtons = radObj.length;
		
		if (numOfButtons > 1) {
			for (var x=0; x<numOfButtons; x++) {
				if(radObj[x].checked == true){
					if(radObj[x].value == 'Other' && radText.value == '') {
						return false;
					}
				}
			}
		}
		return true;
	}


	function CheckNull(theForm) {
		var i;
		var elm;
		var j;
	
		for(i=0; i<theForm.elements.length; i++) {
		
			var CheckName = theForm.elements[i].name;
			var CheckValue = theForm.elements[i].value;
			if(theForm.elements[i].type == 'text') {
				//Required must be in the id
				if(CheckName.indexOf('Required') != -1)
				{
					if(isNull(theForm.elements[i].value)){
						//elm = getElmById(theForm.elements[i].id);
						//alert(elm.innerHTML + " is required.");
	
						elm = getElmByTagName("LABEL")
	
						//Loop through Labels
						for (var j = 0; j < elm.length; j++) {
							if(elm[j].htmlFor == theForm.elements[i].id) {
								alert(elm[j].innerHTML + " is required");
							}
						} 
	   
						theForm.elements[i].focus();
						return true;
					}
				}
			}
		}	
		return false;
	}


	//Used for Required Fields
	function isNull(infield) {
		
		var strTest = new String(infield);
		
		if (strTest == "" || strTest.length == 0 || strTest == null) {
			return true;
		}
		
		return false;
		
	}


	function setCookie(name, value, expires) { 
	
		var today = new Date();
		today.setTime( today.getTime() );
		
		if ( expires ){
			expires = expires * 1000 * 60 * 60 * 24;
		}
		
		var expires_date = new Date( today.getTime() + (expires) );
		
		document.cookie = name + "=" + escape(value) + ( ( expires ) ? ";expires=" + expires_date.toGMTString(): "" ) ; 
		
	} 


	function validatelogin()  {
		
		if (isNull(document.loginform.username.value)) {
			alert("Please supply your username")
			document.loginform.username.focus();
			return false;
		}
		if (isNull(document.loginform.password.value)) {
			alert("Please supply your password")
			document.loginform.password.focus();
			return false;
		}
		if (document.loginform.rememberme.checked) {
			setCookie('UsernameMe',document.loginform.username.value, 365)
			setCookie('RememberMe','1', 365);
		}
		if (!document.loginform.rememberme.checked) {
			setCookie('UsernameMe','')
			setCookie('RememberMe','0');
		}
		
		setCookie('Usertemp',document.loginform.username.value, 1)
		return true;
	
	}



	// ****** Begin Validate New Business Inquiry ***************

	function check_polNum(fieldName) {
		var p, re, r; 
		p = fieldName.value;                // Declare variables.
		re = /^\d{4,9}$/;
		r = p.search(re); // Search the string.
		
		if (r < 0) {       
			alert("Please enter a number here. Policy Numbers, have a minimum of 4 digits and a maximum of 9 digits.");
			return false; 
		} 
		return true;
	}

	function check_Name(fieldName) {
		var p, re, r; 
		p = fieldName.value;                // Declare variables.
		re = /^[a-z,A-Z,',\s,\-]{1,15}$/;
		r = p.search(re); // Search the string.
		
		if (r < 0) {       
			alert("Please enter a name here. Names should have a minimum of 1 alphabets and a maximum of 15 alphabets.");
			return false; 
		} 
		return true;
	}

	function check_all() {
	   
		if ((document.searchform.lastname.value.length >= 1) && (document.searchform.policyNum.value.length > 2)){ 
			alert('Values have been entered for BOTH, Policy Number and Last Name. Please ONLY specify one parameter to begin the search!');
			document.searchform.policyNum.focus();
			return false;
		}
		
		if ((document.searchform.lastname.value.length >= 1) && (document.searchform.producerCode.value.length > 1)){
			alert('Values have been entered for BOTH, Last Name and Producer Code. Please ONLY specify one parameter to begin the search!');
			document.searchform.policyNum.focus();
			return false;
		}
		
		if ((document.searchform.policyNum.value.length > 2) && (document.searchform.producerCode.value.length > 1)){
			alert('Values have been entered for BOTH, Policy Number and Producer Code. Please ONLY specify one parameter to begin the search!');
			document.searchform.policyNum.focus();
			return false;
		}
		
		if (document.searchform.lastname.value.length > 0) {
			if (!check_Name(document.searchform.lastname)) {
				return false
			}
		}
		
		if (document.searchform.policyNum.value.length > 0) {
			if (!check_polNum(document.searchform.policyNum)) {
				return false
			}
		}
				  
	}

	// validate individual inquiry
	function check_all_ind(){
	
		var hVal = document.searchform.org_level;
		document.searchform.orgLevelName.value = hVal.options[hVal.selectedIndex].text;
	
		if (document.searchform.lastname.value == "" && document.searchform.policyNum.value == "" && document.searchform.producerCode.value == ""){
			alert('Please Enter either a Policy Number, Last Name or Producer Code to begin the search!');
			document.searchform.policyNum.focus();
			return false;
		}
		
		if (document.searchform.policyNum.value && document.searchform.producerCode.value && document.searchform.lastname.value){
			alert('Values have been entered for Policy Number, Last Name and Producer Code. Please ONLY specify one parameter to begin the search!');
			document.searchform.policyNum.focus();
			return false;
		}
		else{
			if (document.searchform.lastname.value && document.searchform.policyNum.value){
				alert('Values have been entered for BOTH, Policy Number and Last Name. Please ONLY specify one parameter to begin the search!');
				document.searchform.policyNum.focus();
				return false;
			}
			
			if (document.searchform.lastname.value && document.searchform.producerCode.value){
				alert('Values have been entered for BOTH, Last Name and Producer Code. Please ONLY specify one parameter to begin the search!');
				document.searchform.policyNum.focus();
				return false;
			}
			if (document.searchform.policyNum.value && document.searchform.producerCode.value){
				alert('Values have been entered for BOTH, Policy Number and Producer Code. Please ONLY specify one parameter to begin the search!');
				document.searchform.policyNum.focus();
				return false;
			}
		}
		
		if (document.searchform.lastname.value.length > 0) {
			if (!check_Name(document.searchform.lastname)) {
				return false
			}
		}
		 
		if (document.searchform.policyNum.value.length > 0) {
			if (!check_polNum(document.searchform.policyNum)) {
				return false
			}
		}
		
		
	}
	
	
	function check_all_docdownload() {
		var hVal;
		hVal = document.searchform.org_level;
		document.searchform.orgLevelName.value = hVal.options[hVal.selectedIndex].text;
	
		var sVal;
		sVal = document.searchform.statement_type;
	
		document.searchform.docTypeVal.value = sVal.options[sVal.selectedIndex].text;

	}
	


	function rtrim(argvalue) {
	
		while (1) {
			if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
			break;
			argvalue = argvalue.substring(0, argvalue.length - 1);
		}
		
		return argvalue;
	  
	}

	function get_lookupURL() {
	
		var orgSelect
		var  orgVal = document.searchform.org_level;
		orgSelect = orgVal.options[orgVal.selectedIndex].value;
		var lookup_URL = "lookup.asp?org_level=" + orgSelect;
		new_win = window.open(lookup_URL,'', 'width=440,height=400,left=20,top=20,resizable=yes,scrollbars=yes')
	 
	}
	
	
	// validate the delivery option selected on document download
	function validate_delivery(documentSelection){
	
		// ensure the user has selected a delivery option
		option = -1;
		for (i=documentSelection.delivery.length-1; i > -1; i--) {
			if (documentSelection.delivery[i].checked) {
				option = i;
			}
		}
		
		if (option == -1) {
			alert("Please select a delivery option");
			return false;
		}

	}
	
	
	// validate registration form
	function ValidateAll() {
		
		if (isNull(document.regform.FirstName.value)) {
			alert("Your first name must be entered");
			document.regform.FirstName.focus()
			return false;
		}
				
		if (isNull(document.regform.LastName.value) ) {
			alert("Your last name must be entered");
			document.regform.LastName.focus();
			return false;
		}
				
		var clientType = document.regform.Client_Type;
		
		if (clientType.options[clientType.selectedIndex].value == "") {
			alert("Please select your Client Type from the drop down list.");
			document.regform.Client_Type.focus();
			return false;
		}
		
		if (isNull(document.regform.Agent_Code.value) ) {
			alert("An MGA/Producer/Broker/Plan Code must be entered");
			document.regform.Agent_Code.focus();
			return false;
		}		
		
		if (isNull(document.regform.BusinessName.value) ) {
			alert("Your business name must be entered");
			document.regform.BusinessName.focus();		
			return false;
		}
		
		if (isNull(document.regform.BusinessAddress.value) ) {
			alert("Your business address must be entered");
			document.regform.BusinessAddress.focus();			
			return false;
		}
		
		if (isNull(document.regform.City.value) ) {
			alert("Your City must be entered");
			document.regform.City.focus()			
			return false;
		}
		
		var provinceCode = document.regform.Province;
		
		if (provinceCode.options[provinceCode.selectedIndex].value == "") {
			alert("Please select a Province.");
			document.regform.Province.focus();			
			return false;
		}
		
		if (isNull(document.regform.USER_EMAIL.value) ) {
			alert("Your E-Mail address must be entered");
			document.regform.USER_EMAIL.focus();			
			return false;
		}
		
		if (!isEmail(document.regform.USER_EMAIL.value)) {
			return false;
		}
		
		if (isNull(document.regform.AreaCode.value) ) {
			alert("An Area Code must be entered");
			document.regform.AreaCode.focus();			
			return false;
		}
		
		if (!testNum(document.regform.AreaCode.value) ) {
			return false;
		}
		
		if (isNull(document.regform.PhoneNumber.value) ) {
			alert("Your Phone Number must be entered");
			document.regform.PhoneNumber.focus();			
			return false;
		}
		
		if (!testNum(document.regform.PhoneNumber.value) ) {
			return false;
		}
		
		return true;
	
	}	
	
	function testNum(nVal) {
		
		var i, CVal;
		var ValidChars = "0123456789";
		
		for (i = 0; i < nVal.length; i++) { 
			CVal = nVal.charAt(i); 
			if (ValidChars.indexOf(CVal) == -1){
				alert("Please Enter a valid Area Code/Phone Number");
				return false;
			}
		}
		
		return true;
	
	}
	
	// validate email address entered - lost password
	function validateEmail(){
		
		if(isNull(document.lostpassword.email_addr.value)){
			alert('An email is required.');
			document.lostpassword.email_addr.focus();
			return false;
		}
	
		if (!isEmail(document.lostpassword.email_addr.value)) {
		   return false;
		}
		
		return true;	
	}

	
	// validate change password
	function validatechange() {
	
		goodString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	
		if(isNull(document.passchange.username.value)){
			alert('A Username is required.');	
			document.passchange.username.focus();
			return false;
		}
	
		if(isNull(document.passchange.password.value)){
			alert('A password is required.');	
			document.passchange.password.focus();
			return false;
		}
	
		if(isNull(document.passchange.newpassword.value)){
			alert('A new password is required.');	
			document.passchange.newpassword.focus();			
			return false;
		}
	
		if(isNull(document.passchange.confpassword.value)){
			alert('A confirm password is required.');	
			document.passchange.confpassword.focus();			
			return false;
		}
	
		if(document.passchange.newpassword.value != document.passchange.confpassword.value){
			alert('The new password does not equal the confirm password.');
			
			document.passchange.newpassword.value = "";
			document.passchange.confpassword.value = "";
			document.passchange.newpassword.focus();
			return false;
		}
	
		var strnewPassword = document.passchange.newpassword.value;
		var strTest;
	
		//if newpassword = confpassword, only need to check newpassword	
		for(var i = 0; i < strnewPassword.length; i++){
			strTest	= strnewPassword.substr(i, 1);
			if(goodString.indexOf(strTest) == -1){
				alert('You have used a character that is not allowed.');
				return false;
			}
		}
	
		return true;
	
	}
	
	// validate support form
	function validateSupport() {
		
		if (isNull(document.supform.UserName.value)) {
			alert("Your name must be entered");
			document.supform.UserName.focus();
			return false;
		}
		
		if (isNull(document.supform.EquiNet_ID.value)) {
			alert("Your EquiNet ID must be entered");
			document.supform.EquiNet_ID.focus();
			return false;
		}
		if (isNull(document.supform.EMAIL.value)) {
			
			if(isNull(document.supform.PhoneNumber1.value) || isNull(document.supform.PhoneNumber2.value) || isNull(document.supform.PhoneNumber3.value)){
				alert("An E-Mail address or phone number must be entered");
				document.supform.EMAIL.focus();
				return false;
			}
		}
		else{		
		
			if (!isEmail(document.supform.EMAIL.value)) {
				document.supform.EMAIL.focus();
				return false;
			}
	
		}
		
		return true;
		
	}	
	
	// validate number
	function isNumberKey(evt){
		
		var charCode = (evt.which) ? evt.which : event.keyCode;
		if (charCode > 31 && (charCode < 48 || charCode > 57)){
			return false;
		}
		return true;
		
	}
	  	
	
	function validatepwd(){
		CharString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
		var NewPass=document.firstloginform.newpassword.value;
	
		if (document.firstloginform.username.value == "") {
			alert("Please supply your username and current password");
			return false;
		}
		if (document.firstloginform.password.value == "") {
			alert("Please supply your username and current password");
			return false;
		}
		if (document.firstloginform.newpassword.value == "") {
			alert("Please supply the new password and confirmation password");
			return false;
		}
		if (document.firstloginform.confpassword.value == "") {
			alert("Please supply the new password and confirmation password");
			return false;
		}
		if (document.firstloginform.newpassword.value != document.firstloginform.confpassword.value) {
			alert("New password does not match confirmation password");
			return false;
		}
	
		if (document.firstloginform.newpassword.value == document.firstloginform.username.value) {
			alert("You can not use your username as your password");
			return false;
		}
		if (document.firstloginform.newpassword.value == 'equitable') {
			alert("You must change the default password");
			return false;
		}
		if (document.firstloginform.newpassword.value == 'EQUITABLE') {
			alert("You must change the default password");
			return false;
		}
	
	   ValidChar=0
	   Len=12
	   sw=0
	   for (i=1; i<=12 ;i++) {
			nchar=NewPass.substr(i,1);
			if (nchar=='') {
				Len=Len-1;
			} 
			if (nchar==' ') {
				Len=Len-1;
			}
			Found=CharString.indexOf(nchar);
			 if (Found<=0) {
				} else {
				  ValidChar=ValidChar+1;
				}
		}
	
		if (ValidChar!=Len) {
			alert("The password should contain only letters or digits");
			return false;
		}
		if (ValidChar<7) {
			alert("The password must be at least 8 characters long");
			return false;
		}

	}
	
	// ****** End Validate New Business Inquiry ***************
	
