    function getZipInfo(elementId_text, elementId_value)
    {
        document.getElementById(elementId_text).innerHTML="...loading...";
        var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        var origZipUrl = "/servlet/com.dnaFreight.web.ZipInfoTextServlet?zip=" + document.getElementById(elementId_value).value
        if (x) {
            x.onreadystatechange = function() {
                if (x.readyState == 4 && x.status == 200) {
                    var res = x.responseText;
                    if (res == "") {
                        document.getElementById(elementId_text).innerHTML = "Zip code is not found";
                    } else {
                        document.getElementById(elementId_text).innerHTML = res;
                    }
                }
            }
            x.open("post",  origZipUrl ,true);
            x.send(null);
        }
    }

    function getZipInfoCityState(elementIdCity_text, elementIdState_text, elementId_value)
    {
        var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        var origZipUrl = "/servlet/com.dnaFreight.web.ZipInfoTextServlet?zip=" + document.getElementById(elementId_value).value
        if (x) {
            x.onreadystatechange = function() {
                if (x.readyState == 4 && x.status == 200) {
                    var res = x.responseText;
                    if (res == "") {
                        document.getElementById(elementIdCity_text).value = "Zip code is not found";
                    } else {
                        cityState = res.split(" (");

                        document.getElementById(elementIdCity_text).value = cityState[0];
                        document.getElementById(elementIdState_text).value = cityState[1].replace(')','');
                        verifyAddressAjax();
                    }
                }
            }
            x.open("post",  origZipUrl ,true);
            x.send(null);
        }
    }
    function startLoadingIconAging() {
        document.getElementById('agingReportTd').innerHTML="Loading - please wait...<br/><img src='/images/ajax-loader.gif' />";
        document.location = '/Shipper.Secure/Billing/viewUserAgingReport.jsp';
    }




    // <!--
    if (document.images) {
      pic1= new Image();
      pic1.src="/images/ajax-loader.gif";
    }

    if (document.getElementById("j_username") != null) {
        document.getElementById("j_username").focus();
    } else {
        if (document.getElementById("orig_zip") != null) {
            document.getElementById("orig_zip").focus();
        }
    }
    function submitEdit() {
        if (document.productCatalogEditFrm.deleteProductCatalog.checked)
        {
            if (confirm("Are you sure? This action can not be undone...")) {
                document.productCatalogEditFrm.command.value = "delete";
            }
        }
        document.productCatalogEditFrm.submit();
    }
    function showLoading(submitElmntId, elementId) {
        document.getElementById(submitElmntId).style.hidden = true;
        document.getElementById(submitElmntId).style.visible = false;
        document.getElementById(elementId).innerHTML = "<img src='/images/ajax-loader.gif' />";
    }

    function openWindowQuote(url) {
        var today = new Date();
        var wName = "W" + today.getTime();
        var mywindow = window.open (url, wName,"location=1,status=1,scrollbars=1,width=250,height=330");
    }
    function startLoadingIcon() {
        document.getElementById('loadingDiv').innerHTML="<img src='/images/ajax-loader.gif' />";
        setTimeout("document.getElementById('loadingDiv').innerHTML=''", 4000);
    }
    
    function getZipInfoCityState(elementIdCity_text, elementIdState_text, elementId_value)
    {
        var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        var origZipUrl = "/servlet/com.dnaFreight.web.ZipInfoTextServlet?zip=" + document.getElementById(elementId_value).value
        if (x) {
            x.onreadystatechange = function() {
                if (x.readyState == 4 && x.status == 200) {
                    var res = x.responseText;
                    if (res == "") {
                        document.getElementById(elementIdCity_text).value = "Zip code is not found";
                    } else {
                        cityState = res.split(" (");

                        document.getElementById(elementIdCity_text).value = cityState[0];
                        document.getElementById(elementIdState_text).value = cityState[1].replace(')','');
                        verifyAddressAjax();
                    }
                }
            }
            x.open("post",  origZipUrl ,true);
            x.send(null);
        }
    }

    function onAddUser() {
		// put validation below
		var validation_pass = true;

		document.forms['frm'].fullname.value = makeNormalString(document.forms['frm'].fullname.value);
		document.forms['frm'].address.value = makeNormalString(document.forms['frm'].address.value);
		document.forms['frm'].address2.value = makeNormalString(document.forms['frm'].address2.value);
		document.forms['frm'].city.value = makeNormalString(document.forms['frm'].city.value);
		document.forms['frm'].company.value = makeNormalString(document.forms['frm'].company.value);
		document.forms['frm'].promo.value = makeNormalString(document.forms['frm'].promo.value);
		document.forms['frm'].notes.value = makeNormalString(document.forms['frm'].notes.value);

		if (document.forms['frm'].passwd.value != document.forms['frm'].passwd2.value) {
            document.forms['frm'].passwd2.selected=true;
			alert("Both password fields should be same"+'\n'+"Password must contain at least 6 characters");
            document.forms['frm'].passwd.focus(); return false;
		}
		if (!validateUsername(document.forms['frm'].username.value)) { document.forms['frm'].username.focus(); return false; }
		if (document.forms['frm'].passwd.value.length < 6) { alert("Password must contain at least 6 characters"); document.forms['frm'].passwd.focus(); return false; }
		if (document.forms['frm'].fullname.value.length < 1) { alert("Please enter the full name"); document.forms['frm'].fullname.focus(); return false; }
		if (document.forms['frm'].address.value.length < 1) { alert("Please enter the address"); document.forms['frm'].address.focus(); return false; }
		if (document.forms['frm'].city.value.length < 1) { alert("Please enter the city"); document.forms['frm'].city.focus(); return false; }
		if (!validateEMail(document.forms['frm'].email.value)) { document.forms['frm'].email.focus(); return false; }
		if (!validatePhone(document.forms['frm'].phone.value)) { document.forms['frm'].phone.focus(); return false; }
		if (!validateState(document.forms['frm'].state.value)) { document.forms['frm'].state.focus(); return false; }
		if (!validateZIP(document.forms['frm'].zip.value)) { document.forms['frm'].zip.focus(); return false; }

		if (document.forms['frm'].referred.value == "ps") {
			alert("Please select how did you hear about us?");
			document.forms['frm'].referred.focus();
			return false;
		}

		if (validation_pass) {
			document.forms['frm'].submit();
		}
	}


    function updateAddress()  {
		document.forms['updateAddressBookFrm'].companyname.value = makeNormalString(document.forms['updateAddressBookFrm'].companyname.value);
		document.forms['updateAddressBookFrm'].fullname.value = makeNormalString(document.forms['updateAddressBookFrm'].fullname.value);
		document.forms['updateAddressBookFrm'].address1.value = makeNormalString(document.forms['updateAddressBookFrm'].address1.value);
		document.forms['updateAddressBookFrm'].address2.value = makeNormalString(document.forms['updateAddressBookFrm'].address2.value);
		document.forms['updateAddressBookFrm'].city.value = makeNormalString(document.forms['updateAddressBookFrm'].city.value);
		document.forms['updateAddressBookFrm'].country.value = makeNormalString(document.forms['updateAddressBookFrm'].country.value);
		document.forms['updateAddressBookFrm'].fullname.value = makeNormalString(document.forms['updateAddressBookFrm'].fullname.value);

		if (document.forms['updateAddressBookFrm'].fullname.value.length<1) { alert("Please enter a first and last name"); document.forms['updateAddressBookFrm'].fullname.focus(); return false; }
		if (document.forms['updateAddressBookFrm'].address1.value.length<1) { alert("Please enter a valid address"); document.forms['updateAddressBookFrm'].address1.focus(); return false; }
		if (document.forms['updateAddressBookFrm'].city.value.length<1) { alert("Please enter a valid city"); document.forms['updateAddressBookFrm'].city.focus(); return false; }
		if (document.forms['updateAddressBookFrm'].country.value.length<1) { alert("Please enter a valid country: US"); document.forms['updateAddressBookFrm'].country.focus(); return false; }
		if (!validateState(document.forms['updateAddressBookFrm'].state.value)) { document.forms['updateAddressBookFrm'].state.focus(); return false; }
		if (!validateZIP(document.forms['updateAddressBookFrm'].zip.value)) { document.forms['updateAddressBookFrm'].zip.focus(); return false; }
		if (!validatePhone(document.forms['updateAddressBookFrm'].phone.value)) { document.forms['updateAddressBookFrm'].phone.focus(); return false; }
		if (document.forms['updateAddressBookFrm'].fax.value.length>0)
			if (!validatePhone(document.forms['updateAddressBookFrm'].fax.value))
				{ document.forms['updateAddressBookFrm'].fax.focus(); return false; }
		if (document.forms['updateAddressBookFrm'].email.value.length>0)
			if (!validateEMail(document.forms['updateAddressBookFrm'].email.value)) {
				document.forms['updateAddressBookFrm'].email.focus();
				return false;
			}
		document.forms['updateAddressBookFrm'].submit();
	}



    /*String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
    function getZipInfo()
    {
        var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        var origZipUrl = "/servlet/com.dnaFreight.web.ZipInfoTextServlet?zip=" + document.forms['frm'].zip.value;
        if (x) {
            x.onreadystatechange = function() {
                if (x.readyState == 4 && x.status == 200) {
                    // var el = document.getElementsByTagName("nothinghere");
                    var res = x.responseText;
                    if (res == "") {
                        alert("Zip code is not found");
                    } else {
                        document.forms['frm'].city.value = res.split("(")[0].trim();
                        document.forms['frm'].state.value = res.split("(")[1].substring(0,2);
                    }
                }
            }
            x.open("post", origZipUrl, true);
            x.send(null);
        }
    }*/

    // -->

