//-----------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// WebSphere Commerce
//
// (C) Copyright IBM Corp. 2006, 2010 All Rights Reserved.
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with
// IBM Corp.
//-----------------------------------------------------------------

/** 
 * @fileOverview This javascript is used by the store jsp's related to address creation and maintenance.
 * @version 1.0
 */

/**
 * The functions defined in this class enable address creation across the store.
 * @class The functions and variables defined in this class validate the form input field values entered by 
 * the customer. Another set of functions help in loading the UI for the state field when there is a change
 * in the country field. Another set of functions enable creating an address in the shopcart page and
 * guest user checkout page.
 */

ExtLogonHelper = {
		
		
		/** Flag which indicates whether 'submit button' is clicked or not. The value of this variable is set by the setIsSubmitClicked function.
		 */
		isSubmitClicked: "false",
		
		/*
		 * Stores the value of which email is validated like Register, Quick signup etc.
		 */
		emailValidationFormName: '',
	
	
	/**
	 * This function validates the address form independently from the order of the fields displayed on the form, i.e. independent from the locale.
	 * A hidden field named "fields" must be set in the jsp/jspf file that calls this method. The purpose of this hidden field is 
	 * to set all the mandatory input fields and the order of these fields displayed on each locale-specific address entry page, so that
	 * this method knows which input fields to validate and in which order it should validate them.
	 *
	 * assumptions:1. Mandatory fields use UPPER CASE, non-mandatory fields use lower case.
	 *	     	   2. The error messages used in this method are declared in the jsp/jspf files that call this method. 
	 * @param {string} form The name of the address form obtained from the page containing address input fields.
	 * @param {string} prefix The value is set to shipping or billing.
	 * 
	 * @return {boolean} return true if no error was found, or the hidden field "fields" were not set in the jsp/jspf file that calls this method,
	 * return false if form could not be found, or if there was an error validating a particular field.
	 */

	validateAddressForm: function(form,prefix){
		reWhiteSpace = new RegExp(/^\s+$/);
		if(prefix == null){prefix = ""};
		if(prefix){this.setStateDivName(prefix + "stateDiv")};
		if(form != null){
			var fields="";
			if(form["AddressForm_FieldsOrderByLocale"] != null && form["AddressForm_FieldsOrderByLocale"].value != null && form["AddressForm_FieldsOrderByLocale"].value != ""){
				fields = form["AddressForm_FieldsOrderByLocale"].value.split(",");
			}
			else if(document.getElementById("AddressForm_FieldsOrderByLocale").value!= null && document.getElementById("AddressForm_FieldsOrderByLocale").value!= ""){
				fields=document.getElementById("AddressForm_FieldsOrderByLocale").value.split(",");
			}
			var nickName = prefix + "nickName";
			var lastName = prefix + "lastName";
			var firstName = prefix + "firstName";
			var middleName = prefix + "middleName";
			var address1 = prefix + "address1";
			var address2 = prefix + "address2";
			var address3 = prefix + "address3";
			var city = prefix + "city";
			var state = prefix + "state";
			var country = prefix + "country";
			var zipCode = prefix + "zipCode";
			var email1 = prefix + "email1";
			var phone1 = prefix + "phone1";
			var mobilePhone1 = prefix + "mobilePhone1";
		    var returnAddressFlag = true;
			var gender = prefix + "gender";
			
			for(var i=0; i<fields.length; i++){
				var field = fields[i];
				if(field == "LAST_NAME" || field == "last_name"){
					form[lastName].value = trim(form[lastName].value);
					dojo.byId(form.lastName.id).style.borderColor="#E8E8E8";
					if(field == "LAST_NAME" && (form[lastName].value == "" || reWhiteSpace.test(form[lastName].value))){ 
					//	MessageHelper.formErrorHandleClient(form[lastName].id, MessageHelper.messages["ERROR_LastNameEmpty"]);
						setErrorDisplayMap(form[lastName].id,"ERROR_LastNameEmpty");
					//	return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(form[lastName].value, 30)){ 
					//	MessageHelper.formErrorHandleClient(form[lastName].id, MessageHelper.messages["ERROR_LastNameTooLong"]);
						setErrorDisplayMap(form[lastName].id,"ERROR_LastNameTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.IsValidName(form[lastName].value)){ 
					//	MessageHelper.formErrorHandleClient(form[lastName].id, MessageHelper.messages["ERROR_LastNameNotValid"]);
						setErrorDisplayMap(form[lastName].id,"ERROR_LastNameNotValid");
						//return false;
						returnAddressFlag = false;
					}
				}else if(field == "FIRST_NAME" || field == "first_name"){
					form[firstName].value = trim(form[firstName].value);
					
					dojo.byId(form[firstName].id).style.borderColor="#E8E8E8";
					
					if(field == "FIRST_NAME" && (form[firstName].value == "" || reWhiteSpace.test(form[firstName].value))){ 
						//MessageHelper.formErrorHandleClient(form[firstName].id, MessageHelper.messages["ERROR_FirstNameEmpty"]);
						setErrorDisplayMap(form[firstName].id,"ERROR_FirstNameEmpty");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(form[firstName].value, 30)){ 
						//MessageHelper.formErrorHandleClient(form[firstName].id, MessageHelper.messages["ERROR_FirstNameTooLong"]);
						setErrorDisplayMap(form[firstName].id,"ERROR_FirstNameTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.IsValidName(form[firstName].value)){ 
						//MessageHelper.formErrorHandleClient(form[firstName].id, MessageHelper.messages["ERROR_FirstNameNotValid"]);
						setErrorDisplayMap(form[firstName].id,"ERROR_FirstNameNotValid");
						//return false;
						returnAddressFlag = false;
					}
				}else if(field == "XDATE" || field == "xdate") {
					if(form.birthdayEnabled != null && form.birthdayEnabled.value == "true"){
						if(!MyAccountDisplay.validateBirthday(form)){
							//return;
							returnAddressFlag = false;
						}
					}
				}
				else if(field == "GENDER" || field == "gender") {
					if(!(document.getElementById('ja-gender-male').checked || document.getElementById('ja-gender-female').checked )){
						setErrorDisplayMap(document.getElementById('ja-gender-male'),"ERROR_GenderEmpty");
						//MessageHelper.formErrorHandleClient(document.getElementById('gender_name'), MessageHelper.messages["ERROR_GenderEmpty"]);
						//return false;
						returnAddressFlag = false;
					}
				}
				else if(field == "ADDRESS" || field == "address"){
					form[address1].value = trim(form[address1].value);
					form[address2].value = trim(form[address2].value);
					dojo.byId(form.address1.id).style.borderColor="#E8E8E8";
					dojo.byId(form.address2.id).style.borderColor="#E8E8E8";
					if(form[address3]!=null ){
						form[address3].value = trim(form[address3].value);
						dojo.byId(form.address3.id).style.borderColor="#E8E8E8";
					}
					
					if(!MessageHelper.isValidUTF8length(form[address1].value, 100)){ 
						//MessageHelper.formErrorHandleClient(form[address1].id, MessageHelper.messages["ERROR_AddressTooLong"]);
						setErrorDisplayMap(form[address1].id,"ERROR_AddressTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(form[address2].value, 100)){ 
					//	MessageHelper.formErrorHandleClient(form[address2].id, MessageHelper.messages["ERROR_AddressTooLong"]);
						setErrorDisplayMap(form[address2].id,"ERROR_AddressTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(form[address3]!=null ){
					if(!MessageHelper.isValidUTF8length(form[address3].value, 100)){ 
					//	MessageHelper.formErrorHandleClient(form[address3].id, MessageHelper.messages["ERROR_AddressTooLong"]);
						setErrorDisplayMap(form[address3].id,"ERROR_AddressTooLong");
						//return false;
						returnAddressFlag = false;
					}
					}
				}else if(field == "CITY" || field == "city"){
					form[city].value = trim(form[city].value);
					dojo.byId(form.city.id).style.borderColor="#E8E8E8";
					if(!MessageHelper.isValidUTF8length(form[city].value, 100)){
					//	MessageHelper.formErrorHandleClient(form[city].id, MessageHelper.messages["ERROR_CityTooLong"]);
						setErrorDisplayMap(form[city].id,"ERROR_CityTooLong");
						//return false;
						returnAddressFlag = false;
					}
				}else if(field == "ZIP" || field == "zip"){
					form[zipCode].value = trim(form[zipCode].value);
					dojo.byId(form.zipCode.id).style.borderColor="#E8E8E8";
	                    //check Jayjay's zip code for validation
						if(form[zipCode].value!=null && reWhiteSpace.test(form[zipCode].value) && !MessageHelper.isValidUTF8Minlength(form[zipCode].value, 4)){ 
						//	MessageHelper.formErrorHandleClient(form[zipCode].id, MessageHelper.messages["ERROR_ZipCodeTooShort"]);
							setErrorDisplayMap(form[zipCode].id,"ERROR_ZipCodeTooShort");
							//return false;
							returnAddressFlag = false;
						}			
                       //check Brazil's Consumer or Business fields for validation
				}else if(field == "COUNTRY/REGION" || field == "country/region"){
					form[country].value = trim(form[country].value);
					dojo.byId(form.country.id).style.borderColor="#E8E8E8";
					if(field == "COUNTRY/REGION" && (form[country].value == "" || reWhiteSpace.test(form[country].value))){ 
					//	MessageHelper.formErrorHandleClient(form[country].id, MessageHelper.messages["ERROR_CountryEmpty"]);
						setErrorDisplayMap(form[country].id,"ERROR_CountryEmpty");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(form[country].value, 128)){ 
					//	MessageHelper.formErrorHandleClient(form[country].id, MessageHelper.messages["ERROR_CountryTooLong"]);
						setErrorDisplayMap(form[country].id,"ERROR_CountryTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(form[country].value == "0") {
						setErrorDisplayMap(form[country].id, "ERROR_CountryEmpty");
						returnAddressFlag = false;
					}
				}else if(field == "STATE/PROVINCE" || field == "state/province"){
					var state = form[state];
					if(state == null || state == ""){
						state = document.getElementById(prefix + "stateDiv").firstChild;
					}
					state.value = trim(state.value);
					//dojo.byId(form.state.id).style.borderColor="#E8E8E8";
					if(form.id=='Register'){
						document.getElementById('WC_UserRegistrationUpdateForm_AddressEntryForm_FormInput_state_1').style.borderColor="#E8E8E8";
					}
					else{
						dojo.byId(form.state.id).style.borderColor="#E8E8E8";
					}
					if(field == "STATE/PROVINCE" && (state.value == null || state.value == "" ||state.value == "NA" || reWhiteSpace.test(state.value))){
					//	MessageHelper.formErrorHandleClient(state.id, MessageHelper.messages["ERROR_StateEmpty"]);
						setErrorDisplayMap(state.id,"ERROR_StateEmpty");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(state.value, 128)){
					//	MessageHelper.formErrorHandleClient(state.id, MessageHelper.messages["ERROR_StateTooLong"]);
						setErrorDisplayMap(state.id,"ERROR_StateTooLong");
						//return false;
						returnAddressFlag = false;
					}
				
				}else if(field == "EMAIL1" || field == "email1"){
					form[email1].value = trim(form[email1].value);
					dojo.byId(form.email1.id).style.borderColor="#E8E8E8";
					if(field == "EMAIL1" && (form[email1].value == "" || reWhiteSpace.test(form[email1].value))){
					//	MessageHelper.formErrorHandleClient(form[email1].id, MessageHelper.messages["ERROR_EmailEmpty"]);
						setErrorDisplayMap(form[email1].id,"ERROR_EmailEmpty");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidUTF8length(form[email1].value, 256)){ 
					//	MessageHelper.formErrorHandleClient(form[email1].id, MessageHelper.messages["ERROR_EmailTooLong"]);
						setErrorDisplayMap(form[email1].id,"ERROR_EmailTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.isValidEmail(form[email1].value)){
					//	MessageHelper.formErrorHandleClient(form[email1].id, MessageHelper.messages["ERROR_INVALIDEMAILFORMAT"]);
						setErrorDisplayMap(form[email1].id,"ERROR_INVALIDEMAILFORMAT");
						//return false;
						returnAddressFlag = false;
					}
				}else if(field == "PHONE1" || field == "phone1"){
					
					form[phone1].value = trim(form[phone1].value);
					dojo.byId(form.phone1.id).style.borderColor="#E8E8E8";
					if(!MessageHelper.isValidUTF8length(form[phone1].value, 25)){ 
					//	MessageHelper.formErrorHandleClient(form[phone1].id, MessageHelper.messages["ERROR_PhoneTooLong"]);
						setErrorDisplayMap(form[phone1].id,"ERROR_PhoneTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.IsValidPhone(form[phone1].value)){
					//	MessageHelper.formErrorHandleClient(form[phone1].id, MessageHelper.messages["ERROR_INVALIDPHONE"]);
						setErrorDisplayMap(form[phone1].id,"ERROR_INVALIDPHONE");
						//return false;
						returnAddressFlag = false;
					}
				}else if(field == "MOBILE1" || field == "mobile1"){
					
					form[mobilePhone1].value = trim(form[mobilePhone1].value);
					dojo.byId(form.mobilePhone1.id).style.borderColor="#E8E8E8";
					if(!MessageHelper.isValidUTF8length(form[mobilePhone1].value, 25)){ 
					//	MessageHelper.formErrorHandleClient(form[mobilePhone1].id, MessageHelper.messages["ERROR_PhoneTooLong"]);
						setErrorDisplayMap(form[mobilePhone1].id,"ERROR_PhoneTooLong");
						//return false;
						returnAddressFlag = false;
					}
					if(!MessageHelper.IsValidPhone(form[mobilePhone1].value)){
					//	MessageHelper.formErrorHandleClient(form[mobilePhone1].id, MessageHelper.messages["ERROR_INVALIDPHONE"]);
						setErrorDisplayMap(form[mobilePhone1].id,"ERROR_INVALIDPHONE");
						//return false;
						returnAddressFlag = false;
					}
				}
				else{
					console.debug("error: mandatory field name " + mandatoryField + " is not recognized.");
					return false;
				}
			}
			if(form[address1] != null && form[address2] != null){
				if (form[address1].value == "" && form[address2].value != "") {
		
					form[address1].value = form[address2].value;
					form[address2].value = "";
				}
			}
			if (returnAddressFlag == false) 
				{ //return false if any of the error messages are set
				  return false;
				}
			
			return true;  
		}
		return false; 
	},
	onChangeValidateRegFields:function(form,fieldName){
		var submitClicked = this.isSubmitClicked;
		
		if(form.name=='Register'){
			if(fieldName=='logonId')
			{
				if(form.logonId != null && form.logonId.value!= ""){
				    if(MessageHelper.isValidEmail(form.logonId.value)){
				    	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				    	if(reg.test(form.logonId.value)) {
				    		document.getElementById(form.logonId.id).className =  document.getElementById(form.logonId.id).className.split(" ",1);
				    	}else if(submitClicked==true){
				    		document.getElementById(form.logonId.id).className+=" rj-error";
				    	}
			    	}else if(submitClicked==true){
			    		document.getElementById(form.logonId.id).className+=" rj-error";
			    	}
				}else if(submitClicked==true){
		    		document.getElementById(form.logonId.id).className+=" rj-error";
				}
			}
			else if(fieldName=='logonPassword')
			{
				if(form.logonPassword != null && form.logonPassword.value != ""){
					if(MessageHelper.isValidUTF8Minlength(form.logonPassword.value, form.passwordMinLength.value)){ 
						if(MessageHelper.isValidUTF8length(form.logonPassword.value, form.passwordMaxLength.value)){  
				    		document.getElementById(form.logonPassword.id).className =  document.getElementById(form.logonPassword.id).className.split(" ",1);
				    	}else if(submitClicked==true){
					    	document.getElementById(form.logonPassword.id).className+=" rj-error";
					    }
			    	}else if(submitClicked==true){
				    	document.getElementById(form.logonPassword.id).className+=" rj-error";
					}
		    	}else if(submitClicked==true){
			    	document.getElementById(form.logonPassword.id).className+=" rj-error";
				}
			}
			else if(fieldName=='logonPasswordVerify')
			{
				if(form.logonPasswordVerify != null && form.logonPasswordVerify.value!= ""){
					if(form.logonPassword.value== form.logonPasswordVerify.value){ 
			    		document.getElementById(form.logonPasswordVerify.id).className =  document.getElementById(form.logonPasswordVerify.id).className.split(" ",1);
			    	}else if(submitClicked==true){
				    	document.getElementById(form.logonPasswordVerify.id).className+=" rj-error";
					}
				}
			}
			else if(fieldName=='userField2')
			{
				if(form.userField2!=null && form.userField2.value!= null && MessageHelper.IsValidName(form.userField2.value)){ 
					dojo.byId(form.userField2.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.userField2.id).className =  document.getElementById(form.userField2.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.userField2.id).className+=" rj-error";
				}
			}
			else if(fieldName=='lastName')
			{
				if(form.lastName.value!=null && form.lastName.value!=""){
					if(MessageHelper.isValidUTF8length(form.lastName.value, 30)){
						if(MessageHelper.IsValidName(form.lastName.value)){
							dojo.byId(form.lastName.id).style.borderColor="#E8E8E8";
				    		document.getElementById(form.lastName.id).className =  document.getElementById(form.lastName.id).className.split(" ",1);
				    	}else if(submitClicked==true){
					    	document.getElementById(form.lastName.id).className+=" rj-error";
						}
			    	}else if(submitClicked==true){
				    	document.getElementById(form.lastName.id).className+=" rj-error";
					}
				}else if(submitClicked==true){
			    	document.getElementById(form.lastName.id).className+=" rj-error";
				}
			}
			else if(fieldName=='firstName'){
				if(form.firstName.value!=null && form.firstName.value!=""){
					if(MessageHelper.isValidUTF8length(form.firstName.value, 30)){
						if(MessageHelper.IsValidName(form.firstName.value)){
							dojo.byId(form.firstName.id).style.borderColor="#E8E8E8";
				    		document.getElementById(form.firstName.id).className =  document.getElementById(form.firstName.id).className.split(" ",1);
				    	}else if(submitClicked==true){
					    	document.getElementById(form.firstName.id).className+=" rj-error";
						}
			    	}else if(submitClicked==true){
				    	document.getElementById(form.firstName.id).className+=" rj-error";
					}
		    	}else if(submitClicked==true){
			    	document.getElementById(form.firstName.id).className+=" rj-error";
				}
			}
			else if(fieldName=='birth_date'){
				if(form.birthdayEnabled != null && form.birthdayEnabled.value == "true"){
					if(form.birth_date.value!=null && form.birth_date.value!=""){
						if(form.birth_date.value <=31 && MessageHelper.IsNumeric(form.birth_date.value,false)&& form.birth_date.value!=0 ){
							dojo.byId(form.birth_date.id).style.borderColor="#E8E8E8";
							document.getElementById(form.birth_date.id).className =  document.getElementById(form.birth_date.id).className.split(" ",1);
				    	}else {
							document.getElementById(form.birth_date.id).className+=" rj-error";
						}
					}else {
						document.getElementById(form.birth_date.id).className =  document.getElementById(form.birth_date.id).className.split(" ",1);
					}
				}
			}
			else if(fieldName=='birth_month'){
				if(form.birthdayEnabled != null && form.birthdayEnabled.value == "true"){
					if(form.birth_month.value!=null && form.birth_month.value!=""){
						if(form.birth_month.value != 0 && form.birth_month.value <=12 && MessageHelper.IsNumeric(form.birth_month.value,false)){
							dojo.byId(form.birth_month.id).style.borderColor="#E8E8E8";
							document.getElementById(form.birth_month.id).className =  document.getElementById(form.birth_month.id).className.split(" ",1);
				    	}else {
							document.getElementById(form.birth_month.id).className+=" rj-error";
						}
					}else {
						document.getElementById(form.birth_month.id).className =  document.getElementById(form.birth_month.id).className.split(" ",1);
					}
				}
			}
			else if(fieldName=='birth_year'){
				if(form.birthdayEnabled != null && form.birthdayEnabled.value == "true"){
					if(form.birth_year.value!=null && form.birth_year.value!=""){
						if(MessageHelper.IsNumeric(form.birth_year.value,false) && (form.birth_year.value > 1900) && (form.birth_year.value.length == 4)){
							dojo.byId(form.birth_year.id).style.borderColor="#E8E8E8";
							document.getElementById(form.birth_year.id).className =  document.getElementById(form.birth_year.id).className.split(" ",1);
				    	}else {
							document.getElementById(form.birth_year.id).className+=" rj-error";
						}
					}else {
						document.getElementById(form.birth_year.id).className =  document.getElementById(form.birth_year.id).className.split(" ",1);
					}
				}
			}
			else if(fieldName=='address1'){
				if(MessageHelper.isValidUTF8length(form.address1.value, 100)){
					dojo.byId(form.address1.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.address1.id).className = document.getElementById(form.address1.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.address1.id).className+=" rj-error";
				}
			}
			else if(fieldName=='address2'){
				if(MessageHelper.isValidUTF8length(form.address2.value, 100)){
					dojo.byId(form.address2.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.address2.id).className = document.getElementById(form.address2.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.address2.id).className+=" rj-error";
				}
			}
			else if(fieldName=='address3'){
				if(MessageHelper.isValidUTF8length(form.address3.value, 100)){
					dojo.byId(form.address3.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.address3.id).className =  document.getElementById(form.address3.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.address3.id).className+=" rj-error";
				}
			}
			else if(fieldName=='zipCode'){
				if(MessageHelper.isValidUTF8Minlength(form.zipCode.value,4)){
					dojo.byId(form.zipCode.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.zipCode.id).className =  document.getElementById(form.zipCode.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.zipCode.id).className+=" rj-error";
				}				
			}
			else if(fieldName=='state'){
				if(form.state.value!=null && form.state.value != 'NA' ){
					dojo.byId(form.state.id).style.borderColor="#E8E8E8";
		    		document.getElementById(form.state.id).className =  document.getElementById(form.state.id).className.split(" ",1);
		    	}else if(submitClicked==true){
			    	document.getElementById(form.state.id).className+=" rj-error";
				}
			}
			else if(fieldName=='phone1'){
				if(MessageHelper.isValidUTF8length(form.phone1.value, 25)){
					if(MessageHelper.IsValidPhone(form.phone1.value)){
						dojo.byId(form.phone1.id).style.borderColor="#E8E8E8";
			    		document.getElementById(form.phone1.id).className =  document.getElementById(form.phone1.id).className.split(" ",1);
			    	}else {
				    	document.getElementById(form.phone1.id).className+=" rj-error";
					}
		    	}else {
					document.getElementById(form.phone1.id).className+=" rj-error";
				}
				if(form.phone1.value==null && form.phone1.value == "" ){
					document.getElementById(form.phone1.id).className =  document.getElementById(form.phone1.id).className.split(" ",1);
				}
			}
			else if(fieldName=='mobilePhone1'){
				if(MessageHelper.isValidUTF8length(form.mobilePhone1.value, 25)){
					if(MessageHelper.IsValidPhone(form.mobilePhone1.value)){
						dojo.byId(form.mobilePhone1.id).style.borderColor="#E8E8E8";
			    		document.getElementById(form.mobilePhone1.id).className =  document.getElementById(form.mobilePhone1.id).className.split(" ",1);
			    	}else {
				    	document.getElementById(form.mobilePhone1.id).className+=" rj-error";
					}
			    }else {
			    	document.getElementById(form.mobilePhone1.id).className+=" rj-error";
				}
				if(form.mobilePhone1.value==null && form.mobilePhone1.value == "" ){
					document.getElementById(form.mobilePhone1.id).className =  document.getElementById(form.mobilePhone1.id).className.split(" ",1);
				}
			}          
		}	
		return true;
	}		
}

