                                   

 function calulateDistance(f, noloop) {

    $('#areacoderesult').html('');

    $("#ziperror").html('').fadeOut('slow');

    $.ajax({

                type : "GET",

                url : '/app/site/catalogcalulateDistance.do?ref='

                        + f.userInode.value + "&clientZip=" + f.clientzip.value

                        + "&zip=" + f.zip.value,

                dataType : "html",

                cache : true,

                success : function(html) {

                    $('#areacoderesult').html('');

                    var data = html.split("|");

                    if (data[0] == 'location_found') {
						
						if(!noloop)
	                        setDistance(data[1]);

                        tb_remove();

                    } else if (data[0] == 'select_city') {

                        $('#areacoderesult').html(data[1]).show();

                        tb_open_new('TB_inline?height=600&width=700&inlineId=areacoderesult');

                    } else if (html == 'error') {

                        $("#ziperror").html("Not found, please Try Again")

                                .fadeIn("slow");

                    } else {


                        $("#zipdistance_" + data[1]).html(data[0]).fadeIn(

                                "slow").fadeOut("slow").fadeIn("slow");

                    }

                }

            });

    return false;

}





function setDistance(data) {

    var address = data.split(",");

    var  zip = address.length > 2 ? $.trim(address[2]):data;

    for (i = 0; i < locationForms.length; i++) {

        locationForms[i].zip.value = zip;

        calulateDistance(locationForms[i], true);

    }

    for (i = 0; i < addressGeo.length; i++) {

        addressGeo[i].value = data;

    }

    for (i = 0; i < addressGeoDesc.length; i++) {

        addressGeoDesc[i].innerHTML = data;

    }

    $('#areacoderesult').fadeOut('slow');

    tb_remove();

}


function updateAllLocations() {
	
}
