
//Added as part of Messaging changes
var shpZipObj = null;
var cneZipObj = null;
var compId  = '';
var popupOpen = false;
var readOnlyFlag = false;

function zipObject(){
	this.zipMandatory='';
	this.zipFormate='';
	this.zipExample='';
	this.stateMandatory='';
}
//END Added as part of Messaging changes

function GenericAddressDTO(){
		this.id='';
		this.addressID='';
		this.addressType='';
		this.physicalAddressLine1='';
		this.physicalAddressLine2='';
		this.physicalAddressLine3='';
		this.mailingStreet='';
	    this.mailingPOBOX='';
	    this.mailingZip='';
		this.city='';
		this.state='';
		this.countryCode='';
		this.countryName='';
		this.place='';
		this.communicationID='';
		this.inactive='';
		this.action='';
		this.communicationList=new Array();
		this.addressString='';// Added by Faisal (S391544)
		//Added as part of Messaging Changes
		this.stateCode='';
		this.zipInd='';
		//END Added as part of Messaging Changes
	}

	function GenericCommunicationDTO(){
		this.id='';
        this.communicationID ='';
        this.communicationType = '';
        this.addressNumber = '';
        this.inactive ='';
        this.asnIndicator='';
        this.action='';
	}

    var isGroupCompanyInd='N';

    function setGroupCompanyInd(param) {
      isGroupCompanyInd=param;
    }

	//called onload
	function _address_getAddressArray(oParam){
		var finalString = oParam.hdnComponent.value;
//		alert("final string ---- "+finalString);
		if(finalString){
                colArrays=finalString.split('|');
				if(colArrays.length >0)
                    oParam.addressList=new Array();
                for(i=0;i<colArrays.length;i++){
					var addressDTO = new GenericAddressDTO();
					rowArray=colArrays[i].split('~');
					addressDTO.id=rowArray[0];
					addressDTO.addressID=rowArray[1];
					addressDTO.addressType=rowArray[2];
					addressDTO.physicalAddressLine1=rowArray[3];
					addressDTO.physicalAddressLine2=rowArray[4];
					addressDTO.physicalAddressLine3=rowArray[5];
					addressDTO.mailingStreet=rowArray[6];
					addressDTO.mailingPOBOX=rowArray[7];
					addressDTO.mailingZip=rowArray[8];
					addressDTO.city=rowArray[9];
					addressDTO.place=rowArray[10];
					addressDTO.state=rowArray[11];
					addressDTO.countryCode=rowArray[12];
					addressDTO.countryName=rowArray[13];
					addressDTO.communicationID=rowArray[14];
					addressDTO.inactive=rowArray[15];
					addressDTO.action=rowArray[16];
					addressDTO.addressString=finalString; // Added by Faisal (S391544)
//					alert("rowArray[17] ----- "+rowArray[17]);
					if(rowArray[17]){
						if(rowArray[17].length>0){
							var comArray=rowArray[17].split('#');
							for(j=0;j<comArray.length;j++){
								var comDTO = new GenericCommunicationDTO();
								if(comArray[j]){
									var comDTOArray=comArray[j].split('$');
									for(i = 0; i<comDTOArray.length; i++){
//										alert(comDTOArray[i]);
									}
									comDTO.id = comDTOArray[0];
									comDTO.communicationID = comDTOArray[1];
									comDTO.communicationType= comDTOArray[2];
									comDTO.addressNumber = comDTOArray[3];
									comDTO.isInactive= comDTOArray[4];
									comDTO.isAsnIndicator= comDTOArray[5];
									comDTO.action= comDTOArray[6];
									if(addressDTO.communicationList){
//										alert("inside if"+addressDTO.communicationList.length);
										addressDTO.communicationList[addressDTO.communicationList.length]=comDTO;
									}
								}

							}
						}
					}else{
							var comDTO = new GenericCommunicationDTO();
							comDTO.id = '';
							comDTO.communicationID = '';
							comDTO.communicationType= '';
							comDTO.addressNumber = '';
							comDTO.isInactive= '';
							comDTO.isAsnIndicator= '';
							addressDTO.communicationList[addressDTO.communicationList.length]=comDTO;
					}
					
					//Added as part of Messaging Changes
					//alert("rowArray[18] : "+rowArray[18]);
					addressDTO.stateCode=rowArray[18];
					addressDTO.zipInd=rowArray[19];
					//END Added as part of Messaging Changes


					oParam.addressList[oParam.addressList.length]=addressDTO;
				}
		}
	}

	//called on save
	function _address_getAddressString(oParam,canValidateFlag){
		var finalString="";
		strErrors='';
//		alert("oParam.addressList.length ----- "+oParam.addressList.length)
		if(canValidateFlag) {
			validateFlag=_addressComp_validate(oParam, true);			
		}
		for(i=0;i<oParam.addressList.length;i++){
			if(oParam.addressList[i]){

				finalString+=oParam.addressList[i].id
				+'~'+oParam.addressList[i].addressID
				+'~'+ oParam.addressList[i].addressType
				+'~'+ oParam.addressList[i].physicalAddressLine1
				+'~'+ oParam.addressList[i].physicalAddressLine2
				+'~'+ oParam.addressList[i].physicalAddressLine3
				+'~'+ oParam.addressList[i].mailingStreet
				+'~'+ oParam.addressList[i].mailingPOBOX
				+'~'+ oParam.addressList[i].mailingZip
				+'~'+ oParam.addressList[i].city
				+'~'+ oParam.addressList[i].place
				+'~'+ oParam.addressList[i].state
				+'~'+ oParam.addressList[i].countryCode
				+'~'+ oParam.addressList[i].countryName
				+'~'+ oParam.addressList[i].communicationID
				+'~'+ oParam.addressList[i].inactive
				+'~'+ oParam.addressList[i].action+'~'

				if(oParam.addressList[i].communicationList){
//					alert("oParam.addressList[i].communicationList"+oParam.addressList[i].communicationList.length);
					for(j=0; j<oParam.addressList[i].communicationList.length; j++){
						var addId=isBlank(oParam.addressList[i].communicationList[j].id)?" ":oParam.addressList[i].communicationList[j].id;
						var comId=isBlank(oParam.addressList[i].communicationList[j].communicationID)?" ":oParam.addressList[i].communicationList[j].communicationID;
						var addressValue=isBlank(oParam.addressList[i].communicationList[j].addressNumber)?" ":oParam.addressList[i].communicationList[j].addressNumber;
						var indicator =isBlank(oParam.addressList[i].communicationList[j].asnIndicator)?false:oParam.addressList[i].communicationList[j].asnIndicator;
						var inActive =isBlank(oParam.addressList[i].communicationList[j].inactive)?false:oParam.addressList[i].communicationList[j].inactive;
//						alert("addressValue-----"+addressValue);
//						alert("indicator-----"+indicator);
//						alert("inActive-----"+inActive);
						finalString+=addId+'$'+comId+'$'+oParam.addressList[i].communicationList[j].communicationType+'$'+addressValue+'$'+inActive+'$'+indicator+'$'+oParam.addressList[i].communicationList[j].action+'#';
					}
				}

				//Added as part of Messaging Changes
				//alert("oParam.addressList[i].stateCode : "+oParam.addressList[i].stateCode);
				finalString+='~'+ oParam.addressList[i].stateCode;
				finalString+='~'+ oParam.addressList[i].zipInd;
				//end 

				if(canValidateFlag) {
					if(validateFlag) {
						oParam.addressList[i].addressString = finalString;
					}
				}else {
					oParam.addressList[i].addressString = finalString;
				}
			}
		}
		//alert("finalString2 with communicaitons--- "+finalString);

		//alert("canValidateFlag--- "+canValidateFlag);
		if(canValidateFlag) {
			//validateFlag=_addressComp_validate(oParam, true);
			if(validateFlag)
				oParam.hdnComponent.value=finalString;
			return validateFlag;
		}else {
			oParam.hdnComponent.value=finalString;
		}
		//alert("WITHOUT VALIDATIONS");
		return true;
	}

	//called on lov call back
	function _address_setDetailsFromLov(oParam,lovArray){
		var addressDTO;
		if(oParam.addressList && oParam.addressList.length > 0) {
			addressDTO = oParam.addressList[0];
		}else {
			oParam.addressList = new Array();
			addressDTO = new GenericAddressDTO();
		}



		addressDTO.physicalAddressLine1=lovArray[3];
		addressDTO.physicalAddressLine2=lovArray[17];
		addressDTO.physicalAddressLine3='';
		addressDTO.mailingStreet=lovArray[4];
		addressDTO.mailingPOBOX=lovArray[5];
		addressDTO.mailingZip=lovArray[6];
		addressDTO.city=lovArray[8];
		addressDTO.place=lovArray[7];
		addressDTO.state=lovArray[9];
		addressDTO.countryCode=lovArray[10];
		//alert("lovArray[19] : "+lovArray[19]);
		addressDTO.stateCode=lovArray[19];
		//alert("lovArray[20] : "+lovArray[20]);
		addressDTO.zipInd=lovArray[20];
		addressDTO.countryName='';
		if(!isBlank(addressDTO.id)){
			oParam.addressList[0].action=2;
		}else {
			oParam.addressList[0].action=1;
		}
		var list = new Array();
		var comDTOTE = new GenericCommunicationDTO();
		var comDTOMOB = new GenericCommunicationDTO();
		var comDTOFAX = new GenericCommunicationDTO();
		var comDTOEMAIL = new GenericCommunicationDTO();
		//Added as part of FEB promote
		var comDTOSecEMAIL = new GenericCommunicationDTO();
		//END
		for(j=0;j<addressDTO.communicationList.length;j++){
			var tempDTO = addressDTO.communicationList[j];
			if(tempDTO.communicationType == _addressProperty.typePhone) {
				comDTOTE = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeMob) {
				comDTOMOB = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeFax) {
				comDTOFAX = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeEmail) {
				comDTOEMAIL = tempDTO;
			}
			//Added as part of FEB promote
			if(tempDTO.communicationType == _addressProperty.typeSecEmail) {
				comDTOSecEMAIL = tempDTO;
			}
			//END
		}
		comDTOTE.communicationType='TE';
		comDTOTE.addressNumber=lovArray[11];

		comDTOMOB.communicationType='MOB';
		comDTOMOB.addressNumber=lovArray[12];

		comDTOFAX.communicationType='FX';
		comDTOFAX.addressNumber=lovArray[14];

		comDTOEMAIL.communicationType='EMAIL';
		comDTOEMAIL.addressNumber=lovArray[13];
		
		//Added as part of FEB Promote
		comDTOSecEMAIL.communicationType='SECEMAIL';
		comDTOSecEMAIL.addressNumber='';
		//END
		
		list[list.length++]=comDTOTE;
		list[list.length++]=comDTOMOB;
		list[list.length++]=comDTOFAX;
		list[list.length++]=comDTOEMAIL;
		//Added as part of FEB Promote
		list[list.length++]=comDTOSecEMAIL;
		//END
		addressDTO.communicationList=list;
		oParam.addressList[0]=addressDTO;
	}
	
	function _address_assignFromStrArray(oParam,strArray){
		var addressDTO;
		if(oParam.addressList && oParam.addressList.length > 0) {
			addressDTO = oParam.addressList[0];
		}else {
			oParam.addressList = new Array();
			addressDTO = new GenericAddressDTO();
		}
		
		//alert("_address_assignFromStrArray : "+lovArray);
		addressDTO.physicalAddressLine1=strArray[3];
		addressDTO.physicalAddressLine2=strArray[4];
		addressDTO.physicalAddressLine3=strArray[5];
		addressDTO.mailingStreet=strArray[6];
		addressDTO.mailingPOBOX=strArray[7];
		addressDTO.mailingZip=strArray[8];
		addressDTO.city=strArray[9];
		addressDTO.place=strArray[10];
		addressDTO.state=strArray[11];
		addressDTO.stateCode='';
		addressDTO.zipInd='';
		addressDTO.countryCode=strArray[12];
		addressDTO.countryName=strArray[13];
		if(!isBlank(addressDTO.id)){
			oParam.addressList[0].action=2;
		}else {
			oParam.addressList[0].action=1;
		}
		var list = new Array();
		var comDTOTE = new GenericCommunicationDTO();
		var comDTOMOB = new GenericCommunicationDTO();
		var comDTOFAX = new GenericCommunicationDTO();
		var comDTOEMAIL = new GenericCommunicationDTO();
		//Added as part of FEB Promote
		var comDTOSecEMAIL = new GenericCommunicationDTO();
		//END
		for(j=0;j<addressDTO.communicationList.length;j++){
			var tempDTO = addressDTO.communicationList[j];
			if(tempDTO.communicationType == _addressProperty.typePhone) {
				comDTOTE = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeMob) {
				comDTOMOB = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeFax) {
				comDTOFAX = tempDTO;
			}
			if(tempDTO.communicationType == _addressProperty.typeEmail) {
				comDTOEMAIL = tempDTO;
			}
			//Added as part of FEB Promote
			if(tempDTO.communicationType == _addressProperty.typeSecEmail) {
				comDTOSecEMAIL = tempDTO;
			}
			//END
		}
		comDTOTE.communicationType='TE';
		comDTOTE.addressNumber=strArray[27];

		comDTOMOB.communicationType='MOB';
		comDTOMOB.addressNumber=strArray[34];

		comDTOFAX.communicationType='FX';
		comDTOFAX.addressNumber=strArray[41];

		comDTOEMAIL.communicationType='EMAIL';
		comDTOEMAIL.addressNumber=strArray[20];
		//alert("strArray : "+strArray);
		//Added as part of FEB Promote
		comDTOSecEMAIL.communicationType='SECEMAIL';
		comDTOSecEMAIL.addressNumber='';
		//END

		list[list.length++]=comDTOTE;
		list[list.length++]=comDTOMOB;
		list[list.length++]=comDTOFAX;
		list[list.length++]=comDTOEMAIL;
		//Added as part of FEB Promote
		list[list.length++]=comDTOSecEMAIL;
		//END
		addressDTO.communicationList=list;
		oParam.addressList[0]=addressDTO;
	}


	// on click image
	var popupObj;
	function _address_openAddress(oParam){
//		alert("oParam.title --- "+oParam.title);
		popupObj = new popupDTO(oParam.title);
		popupObj.isprocessing = false;
		popupObj.componentid = oParam.addressCompId;
		compId=oParam.addressCompId;
		//alert("compId : "+compId);
		var saveFlag = oParam.isReadOnly;
//		alert("isReadOnly ---- "+oParam.isReadOnly);
		popupObj.isSaveEnabled=(!saveFlag)?true:false;
		popupObj.data=create_Address_PopupContent(oParam);
		//popupObj.instanceNo=oParam.popUpInstance;
		popupObj.instanceNo=1;
		popupObj.height=300;
		popupObj.width=450;
		popupObj.top=250;
		popupObj.left=200;
		displayPopUp(popupObj);
//	this line commented for resolving CUT-218
//        _address_CityLOV.lovSingle=true; 
        _address_CityLOV.lovsearchval=oParam.addressList[0].city;
        
        //ADDED AS PART OF MESSAGING CHANGES
        _address_CityLOV.lovhidecols="4,5,6,7,8,10";
        popupOpen = true;
        readOnlyFlag = oParam.isReadOnly;
        //END ADDED AS PART OF MESSAGING CHANGES
        
        callLOVforData(_address_CityLOV);
        //Susan: Bug fix CLI-6306
        _address_CountryLOV.lovsearchval=oParam.addressList[0].countryCode;
        callLOVforData(_address_CountryLOV);
		//eval("popupObj.formpopup.cityCode.onchange()");
	}
	function create_Address_PopupContent(oParam){
//		alert("create_Address_PopupContent -----"+oParam);
		var containerTB = createTable(null,"","0","0","0","100%","100%");
		tbody = document.createElement("tbody");
		containerTB.appendChild(tbody);
		var tr = createTr();
		tbody.appendChild(tr);
        var td=createTd();
	    tr.appendChild(td);
	    var mainTB= getAddress_mainTable(oParam);
	    td.appendChild(mainTB);
		return containerTB;
	}

	function getAddress_mainTable(oParam){
//		alert("getAddress_mainTable -----"+oParam);
		var mnTB=createTable(null,"",null,null,"0","100%");
		tbody = document.createElement("tbody");
		mnTB.appendChild(tbody);
		var tr=createTr();
		tbody.appendChild(tr);
		var td=createTd(null,"borderall",null,null,null,"top");
	    tr.appendChild(td);

	    var contTB=createTable(null,"",null,null,"0","100%");
	    td.appendChild(contTB);
	    tbodycnt = document.createElement("tbody");
	    contTB.appendChild(tbodycnt);
	    var trcnt1=createTr();//first row
	    tbodycnt.appendChild(trcnt1);
	    var tdcnt1=createTd(null,"",null,null,null,null);
	    trcnt1.appendChild(tdcnt1);

	    var addnTB=getComponent_addressTable(oParam);
	    tdcnt1.appendChild(addnTB)
	    return mnTB;
	}

	function  _address_createTitleTB(text,tbwidth,td1w,td2w,td3w){
//			alert("address_createTitleTB -----");
		try{
			var titleTB=createTable(null,"","0","0","0",((tbwidth)?tbwidth:"100%"),"","");
			tbody=document.createElement("tbody");
			titleTB.appendChild(tbody);
			var tr=createTr();
			tbody.appendChild(tr);

			var td1=createTd(null,"borderbottom",((td1w)?td1w:"5%"),null,null,null,null,null,null,null);
			tr.appendChild(td1);
			var img1=createImage(null,"images/CellFiller.JPG",null,null,null);
			td1.appendChild(img1);

			var td2=createTd(null,"panelname",((td2w)?td3w:"10%"),"5",null,"middle",null,"2",null,null);
			tr.appendChild(td2);
			title=document.createTextNode(text);
			td2.appendChild(title);

			var td3=createTd(null,"borderbottom",((td3w)?td3w:"85%"),null,null,null,null,null,null,null);
			tr.appendChild(td3);
			var img2=createImage(null,"images/CellFiller.JPG",null,null,null);
			td3.appendChild(img2)

			var tr1=createTr();
			tbody.appendChild(tr1);
			var td4=createTd(null,"borderleft");
			tr1.appendChild(td4);
			var img3=createImage(null,"images/CellFiller.JPG");
			td4.appendChild(img3);

			var td5=createTd(null,"borderright");
			tr1.appendChild(td5);
			var img4=createImage(null,"images/CellFiller.JPG");
			td5.appendChild(img4);
		}catch(e){//alert(e.message);
		}
		return titleTB;
	}

	function getComponent_addressTable(oParam){
//		alert("getComponent_addressTable -----"+oParam);
		var consAdrsTB=createTable(null,"",null,null,"0","100%");
		tbody = document.createElement("tbody");
		consAdrsTB.appendChild(tbody);
		var tr=createTr();
		tbody.appendChild(tr);
		var td=createTd();
		tr.appendChild(td);
		var titleAddnTB= _address_createTitleTB(oParam.title,"100%","5%","80%","10%");
		td.appendChild(titleAddnTB);

		var addressDiv=createDiv();
		td.appendChild(addressDiv);

		addressDiv.innerHTML=getAddressContent_Table(oParam);
		td.appendChild(addressDiv);
		return consAdrsTB;
	}

    function getAddressContent_Table(oParam){
//    	alert("getAddressContent_Table -----"+oParam);
		var addressString="";

//		alert("oParam.isReadOnly--- "+oParam.isReadOnly);
    	var inputCss=(oParam.isReadOnly)?"inputsReadOnly":"inputs";
    	var strReadOnly= (oParam.isReadOnly)?"readOnly=\"true\"":'';





    	addressString+="<table width=\"100%\" align=\"center\" border=0 class=\"borderthree\">";
    	addressString+="<tr align=\"center\" >";





    	var street1="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Street Address1<font class=\"fntMandatory\">*</font></td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"  "+strReadOnly+"   title=\"Street Address1\" maxlength=\"35\" style=\"width:200px\" id=\"street1\" name=\"street1\" value=\""+oParam.addressList[0].physicalAddressLine1+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '35')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\"/></td>"
    	addressString+=street1+"</tr><tr>";

    	var street2="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Street Address2</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+" title=\"Street Address2\" maxlength=\"20\" style=\"width:200px\"  id=\"street2\" name=\"street2\" value=\""+oParam.addressList[0].physicalAddressLine2+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '35')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\" /></td>"
    	addressString+=street2+"</tr><tr>";
		
		var disclaimer="<td  width=\"35%\" align=\"left\" class=\"fntDisclaimerAddLine2\"></td><td  width=\"\" align=\"left\" class=\"fntDisclaimerAddLine2\">Street Address2 will not be a part of the FWB Message</td>"
    	addressString+=disclaimer+"</tr><tr align=\"center\">";

    	/* var street3="<td  width=\"35%\" align=\"left\" class=\"comp_txt\">Street Address3</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+" title=\"Street Address3\" maxlength=\"35\" style=\"width:200px\" id=\"street3\" name=\"street3\" value=\""+oParam.addressList[0].physicalAddressLine3+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '35')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\" /></td>"
    	addressString+=street3+"</tr><tr align=\"center\">"; */

    	var lovCityImg="<a href=\"javascript:_address_invokeCityLOV("+oParam.addressCompId+"_addressComp)\" ><img title=\"Click to view List of Cities\" src=\"images/ico_LOV.gif\" border=0 id=\"_address_CityLOV\"></a>"




		if(oParam.isReadOnly) lovCityImg="";

	var cityMandInital =(oParam.cityMandatory) ? "<font class=\"fntMandatory\">*</font>" : "";
    	var cityString="<td  width=\"35%\" align=\"left\" class=\"comp_txt\">City"+cityMandInital+"</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+"  title=\"City Code\" maxlength=\"3\" style=\"width:30px\" id=\"city\" name=\"city\" value=\""+oParam.addressList[0].city+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'CITY', '3')\" onblur=\"onBlur_FieldClassChange(this,'CITY','');onBlur_FieldLOV(this,_address_CityLOV)\" onfocus=\"onFocus_FieldClassChange(this,'CITY','');onFocus_FieldLOV(this,_address_CityLOV); cityOnchange=true\"/>&nbsp;" +
    			"<input type=\"input\" style=\"width:162px\" id=\"cityName\" title=\"City Name\"  class=\"inputsReadOnly\" readOnly=\"true\" name=\"cityName\" value=\"\" />"+lovCityImg+"</td></tr>"
    	addressString+=cityString+"<tr>";

    	var zip="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Zip/Postal Code</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+" title=\"Zip Code/PO BOX\" maxlength=\"9\" style=\"width:200px\"  id=\"zip\" name=\"zip\" value=\""+oParam.addressList[0].mailingZip+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'RESALPHANUM', '9')\" onblur=\"onBlur_FieldClassChange(this,'RESALPHANUM','')\"  onfocus=\"onFocus_FieldClassChange(this,'RESALPHANUM','')\" /></td>"
    	addressString+=zip+"</tr><tr align=\"center\">";

    	
    	var disclaimerStr = "Zip/Postal code will not appear on the printed and electronic version of Airwaybill"
        var disclaimerZip="<tr><td  width=\"35%\" align=\"left\" class=\"fntDisclaimerAddLine2\"></td><td  width=\"\" align=\"left\" class=\"fntDisclaimerAddLine2\"><div id=\"disclaimerStr\">"+disclaimerStr+"</div></td>"
        addressString+=disclaimerZip+"</tr>";
    	
    	
		var poBox="<td width=\"35%\" align=\"left\" class=\"comp_txt\">PO BOX</td><td width=\"65%\" align=\"left\"><input type=\"input\"  class=\""+inputCss+"\" "+strReadOnly+"  title=\"Post Office Box Number\" maxlength=\"9\" style=\"width:200px\" id=\"pobox\" name=\"pobox\" value=\""+oParam.addressList[0].mailingPOBOX+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'NUMBER', '9')\" onblur=\"onBlur_FieldClassChange(this,'NUMBER','')\" onfocus=\"onFocus_FieldClassChange(this,'NUMBER','')\" /></td>"
    	addressString+=poBox+"</tr><tr>";
    	
    	//Changed as part of Messaging Changes
    	var state="<td width=\"35%\"  align=\"left\" class=\"comp_txt\">State</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+"  title=\"State\" maxlength=\"9\" style=\"width:70px\" id=\"stateCode\" name=\"stateCode\" value=\""+oParam.addressList[0].stateCode+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '20')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\" />&nbsp;<input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+"  title=\"State\" maxlength=\"9\" style=\"width:122px\" id=\"state\" name=\"state\" value=\""+oParam.addressList[0].state+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '20')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\" /></td>"
    	//END Changes
    	addressString+=state+"</tr><tr>";
//CMS-282 added by Ajay
		var placeMandInital =(oParam.placeMandatory) ? "<font class=\"fntMandatory\">*</font>" : "";
    	var place="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Place"+placeMandInital+"</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\" "+strReadOnly+"  title=\"Place\" maxlength=\"17\" style=\"width:200px\" id=\"place\" name=\"place\" value=\""+oParam.addressList[0].place+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ALL', '20')\" onblur=\"onBlur_FieldClassChange(this,'ALL','')\" onfocus=\"onFocus_FieldClassChange(this,'ALL','')\" /></td>"
    	addressString+=place+"</tr><tr>";

//    	var lovCountryImg="<a href=\"javascript:_address_invokeCountryLOV("+oParam.addressCompId+"_addressComp)\" ><img title=\"Click to view List of Countries\" src=\"images/ico_LOV.gif\" border=0 id=\"_address_CountryLOV\"></a>"
		var lovCountryImg="";
    	if(oParam.isReadOnly) lovCountryImg="";
    	var countryCode="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Country<font class=\"fntMandatory\">*</font></td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\"inputsReadOnly\"  readOnly=\"true\" title=\"Country Code\" maxlength=\"2\" style=\"width:30px\" id=\"countryCode\" name=\"countryCode\" value=\""+oParam.addressList[0].countryCode+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'UCALPHA', '2')\" onblur=\"onBlur_FieldClassChange(this,'UCALPHA','')\"  onfocus=\"onFocus_FieldClassChange(this,'UCALPHA','')\" />&nbsp;"+
    	"<input type=\"input\" class=\"inputsReadOnly\"  readOnly=\"true\" style=\"width:162px\" id=\"countryName\" title=\"Country Name\"  name=\"countryName\" value=\""+oParam.addressList[0].countryName+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'ANY', '100')\"/>"+lovCountryImg+"</td></tr>"
    	addressString+=countryCode;






//    	alert("oParam.addressList[0].communicationList.length---------"+oParam.addressList[0].communicationList.length);




    	if(oParam.addressList[0].communicationList){
	    		if(oParam.addressList[0].communicationList.length>0){
	    			var emailValue='';
	    			var telValue='';
	    			var mobValue='';
	    			var faxValue='';
	    			//Added as part of FEB Promote
	    			var secEmailValue='';
	    			//END
	    			var formatToolTip="Country Code - City Code - Phone Number";
	    			for(i=0; i<oParam.addressList[0].communicationList.length; i++){
	//    				alert("--------heiiii -----------------"+oParam.addressList[0].communicationList[i].communicationType);
	    				if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeEmail){
					    	emailValue=oParam.addressList[0].communicationList[i].addressNumber;
	    				}


					    if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typePhone){
					    	telValue=oParam.addressList[0].communicationList[i].addressNumber;
					    }

					    if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeMob){
					    	mobValue=oParam.addressList[0].communicationList[i].addressNumber;
					    }

					    if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeFax){
					    	faxValue=oParam.addressList[0].communicationList[i].addressNumber;
					    }
					    
					    //Added as part of FEB Promote
					    if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeSecEmail){
					    	secEmailValue=oParam.addressList[0].communicationList[i].addressNumber;
	    				}
					    //END
	    			}

//	    			alert("emailValue ----"+emailValue);
//	    			alert("telValue ----"+telValue);
//	    			alert("mobValue ----"+mobValue);
//					alert("faxValue ----"+faxValue);

//CMS-284 added by Ajay
	    			
	    			//Haneesh Modification Start : Consignee Notification
				var emailMandInital =(oParam.emailMandatory) ? "<font class=\"fntMandatory\">*</font>" : "";
					//Haneesh commented below - OERL-88
	    			//var email="<tr><td width=\"35%\" align=\"left\" class=\"comp_txt\">Email ID"+emailMandInital+"</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"   "+strReadOnly+"  title=\"Email\" maxlength=\"25\" style=\"width:200px\" id=\"email\" name=\"email\" value=\""+emailValue+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onblur=\"onBlur_FieldClassChange(this,'EMAIL','')\" onfocus=\"onFocus_FieldClassChange(this,'EMAIL','')\" /></td>"
					//Haneesh added below - OERL-88 
						//Email ID maxlength increased as part of CR-514 
			    	var email="<tr><td width=\"35%\" align=\"left\" class=\"comp_txt\">Email ID"+emailMandInital+"</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"   "+strReadOnly+"  title=\"Email\" maxlength=\"50\" style=\"width:200px\" id=\"email\" name=\"email\" value=\""+emailValue+"\" onblur=\"onBlur_FieldClassChange(this,'EMAIL','');_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onfocus=\"onFocus_FieldClassChange(this,'EMAIL','')\" /></td>"
			    	addressString+=email+"</tr><tr>";
			    	
			    	//Added as part of FEB Promote
			    	var secEmail="<tr><td width=\"35%\" align=\"left\" class=\"comp_txt\">Secondary Email ID</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"   "+strReadOnly+"  title=\"Secondary Email\" maxlength=\"50\" style=\"width:200px\" id=\"secEmail\" name=\"secEmail\" value=\""+secEmailValue+"\" onblur=\"onBlur_FieldClassChange(this,'EMAIL','');_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onfocus=\"onFocus_FieldClassChange(this,'EMAIL','')\" /></td>"
			    	addressString+=secEmail+"</tr><tr>";
			    	//END
			    	
	    			//Haneesh Modification End
			    	//var email="<tr><td width=\"35%\" align=\"left\" class=\"comp_txt\">Email ID<font class=\"fntMandatory\">*</font></td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"   "+strReadOnly+"  title=\"Email\" maxlength=\"50\" style=\"width:200px\" id=\"email\" name=\"email\" value=\""+emailValue+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onblur=\"onBlur_FieldClassChange(this,'EMAIL','')\" onfocus=\"onFocus_FieldClassChange(this,'EMAIL','')\" /></td>"
				//	    	addressString+=email+"</tr><tr>";
			    	var tel="<td width=\"35%\" align=\"left\" class=\"comp_txt\">Tel No<font class=\"fntMandatory\">*</font></td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"   "+strReadOnly+"  title=\"Country Code - City Code - Phone Number\" maxlength=\"25\" style=\"width:200px\" id=\"tel\" name=\"tel\" value=\""+telValue+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onblur=\"onBlur_FieldClassChange(this,'PHONE','')\" onblur=\"onBlur_FieldClassChange(this,'PHONE','')\" onfocus=\"onFocus_FieldClassChange(this,'PHONE','')\" /></td>"
			    			addressString+=tel+"</tr><tr>";
				var mob="<td width=\"35%\" align=\"left\" noWrap class=\"comp_txt\">Mobile No.</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"  "+strReadOnly+" title=\"Country Code - City Code - Mob Number\"  maxlength=\"20\" style=\"width:200px\" id=\"mob\" name=\"mob\" value=\""+mobValue+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onblur=\"onBlur_FieldClassChange(this,'PHONE','')\" onfocus=\"onFocus_FieldClassChange(this,'PHONE','')\" /></td>"
					    	addressString+=mob+"</tr><tr>";
					var fax="<td width=\"35%\" align=\"left\" class=\"comp_txt\"> Fax No</td><td width=\"65%\" align=\"left\"><input type=\"input\" class=\""+inputCss+"\"  "+strReadOnly+"  title=\"Country Code - City Code - Fax Number\" maxlength=\"25\" style=\"width:200px\" id=\"fax\" name=\"fax\" value=\""+faxValue+"\" onchange=\"_address_upDateValues("+oParam.addressCompId+"_addressComp,this,'PHONE', '50')\" onblur=\"onBlur_FieldClassChange(this,'PHONE','')\" onfocus=\"onFocus_FieldClassChange(this,'PHONE','')\" /></td>"
					    	addressString+=fax+"</tr><tr>";
	    		}
    	}

    	return addressString;

    }
	var cityOnchange=true;
	function _address_upDateValues(oParam,obj,type, maxLen){
//		alert("obj.id --- "+obj.id);
		var str=obj.value;
		str=doCaseChange(obj,type,maxLen);

		if(obj.id=='city'){
//			alert("obj.id --- "+obj.id);
			if(isBlank(obj.value)){
				popupObj.formpopup.cityName.value='';
				popupObj.formpopup.countryCode.value='';
				popupObj.formpopup.countryName.value='';
			}else{
				_address_CityLOV.lovfldonchangedone = true;
				if(!_address_CityLOV.lovfldchange){
					if(cityOnchange){
						_address_CityLOV.lovfldMaxlength=3;
						_address_CityLOV.lovsearchval=obj.value;
//						_address_CityLOV.lovcriteria=obj.value;
						popupOpen = false;
						getLOV(_address_CityLOV);
					}
				}
			}
		}

		if(obj.id=='countryCode'){
			if(isBlank(obj.value)){
				popupObj.formpopup.countryName.value='';
			}
		}

		if(obj.id=='street1')
			oParam.addressList[0].physicalAddressLine1=str;
		if(obj.id=='street2')
			oParam.addressList[0].physicalAddressLine2=str;
		if(obj.id=='street3')
			oParam.addressList[0].physicalAddressLine3=str;
		if(obj.id=='city')
			oParam.addressList[0].city=str;
		if(obj.id=='zip')
			oParam.addressList[0].mailingZip=str.toUpperCase();
		if(obj.id=='pobox')
			oParam.addressList[0].mailingPOBOX=str;
		if(obj.id=='state')
			oParam.addressList[0].state=str;
		if(obj.id=='place')
			oParam.addressList[0].place=str;
		if(obj.id=='countryCode')
			oParam.addressList[0].countryCode=str;
		if(obj.id=='countryName')
			oParam.addressList[0].countryName=str;
		
		//Added as part of Messaging Changes
		//alert("Str : " + str);
		if(obj.id=='stateCode')
			oParam.addressList[0].stateCode=str;
		//END 

		if(obj.id=='email' || obj.id=='tel' || obj.id=='mob' || obj.id=='fax' ||obj.id=='secEmail'){
			if(oParam.addressList[0].communicationList){
//				alert("oParam.addressList[0].communicationList.length"+oParam.addressList[0].communicationList.length);

				for(i =0; i<oParam.addressList[0].communicationList.length; i++){
					if(obj.id=='email'){
						if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeEmail){
							oParam.addressList[0].communicationList[i].addressNumber=str;
							return true;
						}
					}

					if(obj.id=='tel'){
						if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typePhone){
							oParam.addressList[0].communicationList[i].addressNumber=str;
							return true;
						}

					}

					if(obj.id=='mob'){
						if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeMob){
							oParam.addressList[0].communicationList[i].addressNumber=str;
							return true;
						}
					}
					if(obj.id=='fax'){
						if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeFax){
							oParam.addressList[0].communicationList[i].addressNumber=str;
							return true;
						}
					}
					
					//Added as part of FEB Promote
					if(obj.id=='secEmail'){
						//alert("obj.id :"+obj.id);
						//alert("communicationType"+oParam.addressList[0].communicationList[i].communicationType);
						if(oParam.addressList[0].communicationList[i].communicationType==_addressProperty.typeSecEmail){
							oParam.addressList[0].communicationList[i].addressNumber=str;
							return true;
						}
					}
					//END
				}
			}
		}



	}

    function _address_invokeCityLOV(oParam){
		var str=oParam.addressList[0].city;
		address_CityLOV_onclick(str);
	}
	function address_CityLOV_call(obj,preCall){
        obj.lovsearchval=preCall;
        return true;
    }


	function address_CityLOV_callBack(arrData,isChecked){
//		alert("city clicked");
		try{
			cityCode=arrData[0];
			cityDesc=arrData[1];
			countryCode=arrData[2];
			countryDesc=arrData[3];
			
			if(isChecked){
				cityOnchange=false;
				eval("popupObj.formpopup.city.value=\""+cityCode+"\";");
				eval("popupObj.formpopup.cityName.value=\""+cityDesc+"\";");
				eval("popupObj.formpopup.countryCode.value=\""+countryCode+"\";");
				eval("popupObj.formpopup.countryName.value=\""+countryDesc+"\";");
				//Added as part of Messaging changes
				if(compId == 'consigneeAddress' || compId == 'shipperAddress' || compId == 'adrsComp'){
					try{
						//alert("arrData "+arrData);
						zipMandatory = arrData[6];
						stateMandatory =arrData[8];
						var stateCode=arrData[9];
						if(!stateCode)
							stateCode='';
						//alert("arrData "+arrData[9]);
						var state=arrData[10];
						if(!state)
							state='';
						if(compId == 'consigneeAddress' || compId == 'adrsComp'){
							cneZipObj = new zipObject();
							cneZipObj.zipExample=arrData[7];
							cneZipObj.zipFormate=arrData[5];
							cneZipObj.zipMandatory=zipMandatory;
							cneZipObj.stateMandatory=arrData[8];
						}else if(compId == 'shipperAddress'){
							shpZipObj = new zipObject();
							shpZipObj.zipExample=arrData[7];
							shpZipObj.zipFormate=arrData[5];
							shpZipObj.zipMandatory=zipMandatory;
							shpZipObj.stateMandatory=arrData[8];
						}
						
						if(zipMandatory == 'Y'){
							document.getElementById('disclaimerStr').innerHTML='';
						}else{
							var disclaimerStr = "Zip/Postal code will not appear on the printed and electronic version of Airwaybill"
							document.getElementById('disclaimerStr').innerHTML=disclaimerStr;
						}
						
						var stateCodeObj = document.getElementById('stateCode');
						var stateObj = document.getElementById('state');
						if(readOnlyFlag ||(!isBlank(stateCode) && stateMandatory == 'Y')){
							stateCodeObj.className="inputsReadOnly";
							stateCodeObj.readOnly=true;
						}else{
							stateCodeObj.className="inputs";
							stateCodeObj.readOnly=false;
						}
						
						if(readOnlyFlag ||(!isBlank(state) && stateMandatory == 'Y')){
							stateObj.className="inputsReadOnly";
							stateObj.readOnly=true;
						}else{
							stateObj.className="inputs";
							stateObj.readOnly=false;
						}
						//alert("popupOpen : "+popupOpen);
						var tempStateCode = eval("popupObj.formpopup.stateCode.value");
						//alert("tempStateCode : "+tempStateCode+", popupOpen : "+popupOpen);
						if(!popupOpen || isBlank(tempStateCode)){
							//alert("tempStateCode : "+tempStateCode+", popupOpen : "+popupOpen);
							eval("popupObj.formpopup.stateCode.value=\""+stateCode+"\";");
							eval("popupObj.formpopup.stateCode.onchange()");
						}
						
						var tempState = eval("popupObj.formpopup.state.value");
						if(!popupOpen || isBlank(tempState)){
							//alert("tempStateCode : "+tempStateCode+", popupOpen : "+popupOpen);
							eval("popupObj.formpopup.state.value=\""+state+"\";");
							eval("popupObj.formpopup.state.onchange()");
						}
						
						//alert("State Code : "+stateCode)
					}catch(e){
						alert("Error in address_CityLOV_callBack :"+e);
					}
				}
				//END Added as part of Messaging changes
				
				eval("popupObj.formpopup.city.onchange()");
				eval("popupObj.formpopup.countryCode.onchange()");

			}
		}catch(e){
		}
		
	}

    function _address_invokeCountryLOV(oParam){
		var str=oParam.addressList[0].countryCode;
		address_CountryLOV_onclick(str);
	}
	function address_CountryLOV_call(obj,preCall){
        obj.lovsearchval=preCall;
        return true;
    }
	function address_CountryLOV_callBack(arrData,isChecked){
		countryCode=arrData[0];
		countryDesc=arrData[1];
		if(isChecked){
			eval("popupObj.formpopup.countryCode.value=\""+countryCode+"\";");
			eval("popupObj.formpopup.countryName.value=\""+countryDesc+"\";");
			eval("popupObj.formpopup.countryCode.onchange()");
		}

	}

var _addressProperty = new _address_Properties();
function _address_Properties(){
	this.valNUMBER = "[This field accepts only Numerics 0 to 9]";
	this.valZip="[This field accepts only alphabets a to z, A to Z, Numerics 0 to 9, - and space]";
	this.valRESAPHANUM="[This field accepts only alphabets a to z, A to Z, Numerics 0 to 9, space, dot . and hyphens -]";
	this.valCITY="[This field accepts only 3 alphabets A to Z or number 0 to 9]";
	this.valALPHA="[This field accepts only alphabets a to z and A to Z]";
	this.valEMAIL="Enter valid Email";
	//Added as part of FEB Promote
	this.valSECEMAIL="Enter valid Secondary Email";
	//END
	this.mandatoryAddress1="Enter Street Address1";
	this.mandatoryCity="Enter City";
	this.mandatoryCountry="Enter Country";
	this.mandatoryCommunication="Enter Any of the communications Email/Phone/Mob/Fax";
	this.mandatoryPhone="Enter Telephone Number";
	this.mandatoryEmail="Enter Email ID";//Haneesh added : Consignee Notification
	this.lblStreetAddress1="Street Address1";
	this.lblStreetAddress2="Street Address2";
	this.lblStreetAddress3="Street Address3";
	this.lblCity="City";
	this.lblZip="Zip/Postal";
	this.lblPOBox="POBox";
	this.lblState="State";
	this.lblPlace="Place";
	this.lblCountry="Country";
	this.lblEmail="Email";
	//Added as part of FEB Promote
	this.lblSecEmail="Secondary Email";
	//END
	this.lblTelephone="Telephone";
	this.lblMobile="Mobile";
	this.lblFax="Fax";
	this.typeEmail="EMAIL";
	//Added as part of FEB Promote
	this.typeSecEmail="SECEMAIL";
	//END
	this.typePhone="TE";
	this.typeMob="MOB";
	this.typeFax="FX";
	this.valPHONE= "[This field accepts only plus sign +, Numerics 0 to 9 and hyphens -] and length should be greater than 3 digits";
	this.valALPHANUMWUNS		= "[This field accepts only characters a to z, A to Z, Numerics 0 to 9 and Underscore _]";
	this.valRESALPHANUM = "[This field accepts only alphabets a to z, A to Z, Numerics 0 to 9, space, dot . and hyphens -]";
	this.mandatoryPlace = "Enter Place";
}
var strErrors='';
var errMsg = null;
function _addressComp_validate(oParam, flag){
	//alert("_addressComp_validate flag--- "+flag);
	//alert("oParam.cityMandatory:::"+oParam.cityMandatory);
	strErrors='';
	errMsg = new   errorMessageDTO();
	if(oParam.addressList){

		//alert("_oParam.addressList.length--- "+oParam.addressList.length);
		for(i=0;i<oParam.addressList.length;i++){
				if(oParam.addressList[i]){
				
				    if (isGroupCompanyInd=='Y') {
					   break ;
					}
					if(isBlank(oParam.addressList[i].physicalAddressLine1)){
						errMsg.messages[errMsg.messages.length++]=_addressProperty.mandatoryAddress1;
					}else if(!validateDataType('ALL',oParam.addressList[i].physicalAddressLine1)){

							errMsg.messages[errMsg.messages.length++]=_addressProperty.lblStreetAddress1+" "+_addressProperty.valRESALPHANUM;
					}
					if(!(isBlank(oParam.addressList[i].physicalAddressLine2))){
						if(!validateDataType('ALL',oParam.addressList[i].physicalAddressLine2)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblStreetAddress2+" "+_addressProperty.valRESALPHANUM;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblStreetAddress2+" "+_addressProperty.valRESALPHANUM;
						}
					}

					if(!(isBlank(oParam.addressList[i].physicalAddressLine3))){
						if(!validateDataType('ALL',oParam.addressList[i].physicalAddressLine3)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblStreetAddress3+" "+_addressProperty.valRESALPHANUM;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblStreetAddress3+" "+_addressProperty.valRESALPHANUM;
						}
					}



















// S730321: Agent Integration city not mandatory for job created through Agent Integration
//alert("oParam.cityMandatory:::"+oParam.cityMandatory);
					if((oParam.cityMandatory) && isBlank(oParam.addressList[i].city)){
//						errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryCity;
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryCity;
						else
							errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.mandatoryCity;
					}else if((oParam.cityMandatory) && !validateDataType('CITY',oParam.addressList[i].city)){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=_addressProperty.lblCity+" "+_addressProperty.valCITY;
						else
							errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblCity+" "+_addressProperty.valCITY;
					}

//					alert("me inside 4"+strErrors);

					if(!(isBlank(oParam.addressList[i].mailingZip))){
						if(!validateDataType('RESALPHANUM',oParam.addressList[i].mailingZip)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblZip+" "+_addressProperty.valZip;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblZip+" "+_addressProperty.valZip;
						}
					}


					if(!(isBlank(oParam.addressList[i].mailingPOBOX))){
//						alert("oParam.addressList[i].mailingPOBOX -- "+oParam.addressList[i].mailingPOBOX);
						if(!validateDataType('NUMBER', oParam.addressList[i].mailingPOBOX)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblPOBox+" "+_addressProperty.valNUMBER;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblPOBox+" "+_addressProperty.valNUMBER;
						}

					}


					if(!(isBlank(oParam.addressList[i].state))){
						if(!validateDataType('ALL',oParam.addressList[i].state)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblState+" "+_addressProperty.valRESALPHANUM;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblState+" "+_addressProperty.valRESALPHANUM;
						}
					}
					//bug fix cut-1013
					if((oParam.placeMandatory) && (isBlank(oParam.addressList[i].place))){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length++]=_addressProperty.mandatoryPlace;
						else
							errMsg.messages[errMsg.messages.length++]=",  "+_addressProperty.mandatoryPlace;
					}else if(!(isBlank(oParam.addressList[i].place))){
						if(!validateDataType('ALL',oParam.addressList[i].place)){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblPlace+" "+_addressProperty.valRESALPHANUM;
							else
								errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblPlace+" "+_addressProperty.valRESALPHANUM;
						}
					}


					if(isBlank(oParam.addressList[i].countryCode)){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryCountry;
						else errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.mandatoryCountry;
					}else if(!validateDataType('UCALPHA',oParam.addressList[i].countryCode)){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=addressProperty.lblCountry+_addressProperty.valALPHA;
						else
							errMsg.messages[errMsg.messages.length]=",  "+addressProperty.lblCountry+" "+_addressProperty.valALPHA;
					}






















					var commincations='';
					if(oParam.addressList[i].communicationList){
						//alert("oParam.addressList[i].communicationList"+oParam.addressList[i].communicationList.length);
						for(j=0; j<oParam.addressList[i].communicationList.length; j++){
							//alert("oParam.addressList[i].communicationList[j].addressNumber "+oParam.addressList[i].communicationList[j].addressNumber);
							commincations+=oParam.addressList[i].communicationList[j].addressNumber;
						}
						//alert("commincations "+commincations);
					}
					//alert("isBlank(commincations) "+isBlank(commincations));
					
					// telephone required bugfix CUT-621 
					if(isBlank(commincations)){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryPhone;
						else
							errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.mandatoryPhone;
					}
					
				if(!isBlank(commincations)){
						for(j=0; j<oParam.addressList[i].communicationList.length; j++){
							if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typePhone){
								if(isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
								  if(errMsg.messages.length == 0)
									errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryPhone;
								  else
									errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.mandatoryPhone;
								}
							}
							//Haneesh Modification start : Consignee Notification
							if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeEmail){
								if((oParam.emailMandatory) && isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
									if(errMsg.messages.length == 0)
										errMsg.messages[errMsg.messages.length]=_addressProperty.mandatoryEmail;
									  else
										errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.mandatoryEmail;
								}
							}
							//Haneesh Modification end 
						}
							
					}
					// tel end ----------------------
					//Pravin - start
					/*if(isBlank(commincations)){
						if(errMsg.messages.length == 0)
							errMsg.messages[errMsg.messages.length]=_addressProperty.valEMAIL;
						else
							errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.valEMAIL;
					}
					
					if(!isBlank(commincations)){
						for(j=0; j<oParam.addressList[i].communicationList.length; j++){
							if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeEmail){
								if(isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
								  if(errMsg.messages.length == 0)
									errMsg.messages[errMsg.messages.length]=_addressProperty.valEMAIL;
								  else
									errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.valEMAIL;
								}
							}
						}
					}*/
					//Pravin - end					
					
					
					if(!isBlank(commincations)){
						for(j=0; j<oParam.addressList[i].communicationList.length; j++){
							if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeEmail){










								if(!isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
									if(!validateDataType('EMAIL',oParam.addressList[i].communicationList[j].addressNumber)){
										if(errMsg.messages.length == 0)
											errMsg.messages[errMsg.messages.length]=_addressProperty.lblEmail+" "+_addressProperty.valEMAIL;
										else
											errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblEmail+" "+_addressProperty.valEMAIL;;
									}
								}
							}else if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typePhone){
							  if(!isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
								if(!validateDataType('PHONE',oParam.addressList[i].communicationList[j].addressNumber)){
//									alert("not valid phone number--->");
									if(errMsg.messages.length == 0)
										errMsg.messages[errMsg.messages.length]=_addressProperty.lblTelephone+" "+_addressProperty.valPHONE;
									else
										errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblTelephone+" "+_addressProperty.valPHONE;;
								}
							  }
							}else if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeMob){
							  if(!isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
								if(!validateDataType('PHONE',oParam.addressList[i].communicationList[j].addressNumber)){
//									alert("not valid mob number--->");
									if(errMsg.messages.length == 0)
										errMsg.messages[errMsg.messages.length]=_addressProperty.lblMobile+" "+_addressProperty.valPHONE;
									else
										errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblMobile+" "+_addressProperty.valPHONE;;
								}
							  }
							}else if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeFax){
							  if(!isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
								if(!validateDataType('PHONE',oParam.addressList[i].communicationList[j].addressNumber)){
//									alert("not valid fax number--->");
									if(errMsg.messages.length == 0)
										errMsg.messages[errMsg.messages.length]=_addressProperty.lblFax+" "+_addressProperty.valPHONE;
									else
										errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblFax+" "+_addressProperty.valPHONE;;
								}
							  }
							}if(oParam.addressList[i].communicationList[j].communicationType==_addressProperty.typeSecEmail){
								if(!isBlank(oParam.addressList[i].communicationList[j].addressNumber)){
									if(!validateDataType('EMAIL',oParam.addressList[i].communicationList[j].addressNumber)){
										if(errMsg.messages.length == 0)
											errMsg.messages[errMsg.messages.length]=_addressProperty.lblSecEmail+" "+_addressProperty.valSECEMAIL;
										else
											errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblSecEmail+" "+_addressProperty.valSECEMAIL;;
									}
								}
							}
						}
					}


				}
				
				//Added as part of Messaging Changes
				if(isBlank(compId))
					compId=oParam.addressCompId;
				//alert("oParam.zipMandatoryChk :"+oParam.zipMandatoryChk);
				if((oParam.zipMandatoryChk) && (compId == 'consigneeAddress' || compId == 'shipperAddress' || compId == 'adrsComp')){
					try{
						//alert("Component ID : "+oParam.addressCompId);
						var zipMandatory = '';
						var zipFormate = '';
						var zipExample = '';
						var stateMandatory = '';
						if(cneZipObj != null && (oParam.addressCompId == 'consigneeAddress' || oParam.addressCompId =='adrsComp')){
							//alert("cneZipObj : "+cneZipObj);
							zipMandatory = cneZipObj.zipMandatory;
							zipFormate = cneZipObj.zipFormate;
							zipExample = cneZipObj.zipExample;
							stateMandatory = cneZipObj.stateMandatory;
						}else if(shpZipObj!=null && oParam.addressCompId == 'shipperAddress'){
							//alert("shpZipObj : "+shpZipObj);
							zipMandatory = shpZipObj.zipMandatory;
							zipFormate = shpZipObj.zipFormate;
							zipExample = shpZipObj.zipExample;
							stateMandatory = shpZipObj.stateMandatory;
						}
						//oParam.addressList[i].zipInd = zipMandatory; 
						//alert("zipMandatory : "+zipMandatory);
						//alert("oParam.addressList[i].zipInd : "+oParam.addressList[i].zipInd);
						var zipError = false;
						if((zipMandatory == 'Y' || oParam.addressList[i].zipInd == 'Y') && isBlank(oParam.addressList[i].mailingZip)){
							oParam.addressList[i].zipInd='Y';
							var errStrZip = "This country will not accept electronic messages unless the Zip/postal code data meets customs requirements. Failure to send a correct electronic message will result in fines. Please enter a valid Zip/postal code data in accordance with the ";
							if(isBlank(zipExample)){
								errStrZip+="country format";
							}else{
								errStrZip+=" following format : ' "+zipExample+" '";
							}
								
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=errStrZip;
							else
								errMsg.messages[errMsg.messages.length]=", "+errStrZip;
							zipError = true;
						}				
						if(!(isBlank(oParam.addressList[i].mailingZip)) && (zipMandatory == 'Y')){
							//alert("zipFormate  : "+zipFormate);
							if(!(isBlank(zipFormate))){
								var re = new RegExp(zipFormate);
								if(!(re.test(oParam.addressList[i].mailingZip))){
									if(errMsg.messages.length == 0)
										errMsg.messages[errMsg.messages.length]=_addressProperty.lblZip+" "+"[This country will not accept electronic messages unless the Zip/postal code data meets customs requirements. Failure to send a correct electronic message will result in fines. Please correct the Zip/postal code data in accordance with the following format: ' "+zipExample+"' ]";
									else
										errMsg.messages[errMsg.messages.length]=",  "+_addressProperty.lblZip+" "+"[This country will not accept electronic messages unless the Zip/postal code data meets customs requirements. Failure to send a correct electronic message will result in fines. Please correct the Zip/postal code data in accordance with the following format: ' "+zipExample+" ']";
									zipError = true;
								}
							}
						}
						
						if(stateMandatory == 'Y' && (isBlank(oParam.addressList[i].stateCode))){
							if(errMsg.messages.length == 0)
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblState+" Enter State Code";
							else
								errMsg.messages[errMsg.messages.length]=_addressProperty.lblState+" Enter State Code";
							zipError = true;
						}
						
						if(!zipError){
							zipMandatory='';
							zipFormate='';
							zipExample='';
							stateMandatory='';
						}
					}catch(e){
						//alert("ERROR : "+e);
					}
				}
				
				//END  Added as part of Messaging Changes
				
			}
		}
		if(flag){
//			alert("errMsg.messages.length--- "+errMsg.messages.length);
			if(errMsg.messages.length == 0)
				return true;
			else{
				for(i=0; i<errMsg.messages.length; i++){
					strErrors+=errMsg.messages[i];
				}
				alert(strErrors);
				return false;
			}
		}else
			return errMsg;
	}

	function _addressComp_reset_old(oParam){
//		alert(" --address reset --->");
//		alert("address list----> "+oParam.addressList);
		var addressList = new Array();
		var genericAddressDTO = new GenericAddressDTO();
		var communications = new Array();

		var emailCommunication = new GenericCommunicationDTO();
		emailCommunication.communicationType=_addressProperty.typeEmail;
		emailCommunication.action=1;
		communications[communications.length]=emailCommunication;


		var phoneCommunication = new GenericCommunicationDTO();
		phoneCommunication.communicationType=_addressProperty.typePhone;
		phoneCommunication.action=1;
		communications[communications.length]=phoneCommunication;

		var faxCommunication = new GenericCommunicationDTO();
		faxCommunication.communicationType=_addressProperty.typeFax;
		faxCommunication.action=1;
		communications[communications.length]=faxCommunication;

		var mobileCommunication = new GenericCommunicationDTO();
		mobileCommunication.communicationType=_addressProperty.typeMob;
		mobileCommunication.action=1;
		communications[communications.length]=mobileCommunication;
		
		//Added as part of FEB Promote
		var secEmailCommunication = new GenericCommunicationDTO();
		secEmailCommunication.communicationType=_addressProperty.typeSecEmail;
		secEmailCommunication.action=1;
		communications[communications.length]=secEmailCommunication;
		//END
		
		genericAddressDTO.communicationList=communications;
		genericAddressDTO.action=1;
		addressList[addressList.length]=genericAddressDTO;
		oParam.addressList=addressList;
		getAddressContent_Table(oParam);
	}
	
//	clear all the values
	function _addressComp_reset(oParam){
		var addressList = new Array();
		var genericAddressDTO = new GenericAddressDTO();
		genericAddressDTO.action=1;
		var communications = new Array();

		var phoneCommunication = new GenericCommunicationDTO();
		phoneCommunication.communicationType=_addressProperty.typePhone;
		phoneCommunication.action=1;
		
		var mobileCommunication = new GenericCommunicationDTO();
		mobileCommunication.communicationType=_addressProperty.typeMob;
		mobileCommunication.action=1;

		var faxCommunication = new GenericCommunicationDTO();
		faxCommunication.communicationType=_addressProperty.typeFax;
		faxCommunication.action=1;
		
		var emailCommunication = new GenericCommunicationDTO();
		emailCommunication.communicationType=_addressProperty.typeEmail;
		emailCommunication.action=1;
		
		var secEmailCommunication = new GenericCommunicationDTO();
		secEmailCommunication.communicationType=_addressProperty.typeSecEmail;
		secEmailCommunication.action=1;
		
		if(oParam.addressList){
		//alert("_oParam.addressList.length--- "+oParam.addressList.length);
			for(i=0;i<oParam.addressList.length;i++){
				if(oParam.addressList[i]){
					var prevAddressDTO = oParam.addressList[i];
					genericAddressDTO.addressID=prevAddressDTO.addressID;
					if(oParam.addressList[i].communicationList){
						for(j=0;j<prevAddressDTO.communicationList.length;j++){
							var prevCommunicationDTO = prevAddressDTO.communicationList[j];
							if(prevCommunicationDTO.communicationType == _addressProperty.typePhone) {
								phoneCommunication.communicationID = prevCommunicationDTO.communicationID;
								if(!isBlank(phoneCommunication.communicationID) && phoneCommunication.communicationID>0)
									phoneCommunication.action=0;
								continue;
							}else if(prevCommunicationDTO.communicationType == _addressProperty.typeMob) {
								mobileCommunication.communicationID = prevCommunicationDTO.communicationID;
								if(!isBlank(mobileCommunication.communicationID) && mobileCommunication.communicationID>0)
									mobileCommunication.action=0;
								continue;
							}else if(prevCommunicationDTO.communicationType == _addressProperty.typeFax) {
								faxCommunication.communicationID = prevCommunicationDTO.communicationID;
								if(!isBlank(faxCommunication.communicationID) && faxCommunication.communicationID>0)
									faxCommunication.action=0;
								continue;
							}else if(prevCommunicationDTO.communicationType == _addressProperty.typeEmail) {
								emailCommunication.communicationID = prevCommunicationDTO.communicationID;
								if(!isBlank(emailCommunication.communicationID) && emailCommunication.communicationID>0)
									emailCommunication.action=0;
								continue;
							}else if(prevCommunicationDTO.communicationType == _addressProperty.typeSecEmail) {
								secEmailCommunication.communicationID = prevCommunicationDTO.communicationID;
								if(!isBlank(secEmailCommunication.communicationID) && secEmailCommunication.communicationID>0)
									secEmailCommunication.action=0;
								continue;
							}
						}
					}
				}

			}
		}
		communications[communications.length]=phoneCommunication;
		communications[communications.length]=mobileCommunication;
		communications[communications.length]=faxCommunication;
		communications[communications.length]=emailCommunication;
		//Added as part of FEB Promote
		communications[communications.length]=secEmailCommunication;
		//END
		genericAddressDTO.communicationList=communications;
		addressList[addressList.length]=genericAddressDTO;
		oParam.addressList=addressList;
		getAddressContent_Table(oParam);
		
	}

		function getZipDataFromLOV(componentID,city){
			compId  = componentID;
			_address_CityLOV.lovsearchval=city;
			callLOVforData(_address_CityLOV);
		}

