$(document).ready(function () { if (document.getElementById("hdfDeliveryAddressId").value == '') { GetUserAddress(''); document.getElementById("divDeliveryAddress").style.display = "block"; document.getElementById("divUserAddress").style.display = "none"; document.getElementById("divCartDetails").style.display = "none"; document.getElementById("divRedeem").style.display = "none"; document.getElementById("divCoupon").style.display = "none"; } else { document.getElementById('divCartDetails').style.display = "block"; document.getElementById("divRedeem").style.display = "block"; document.getElementById("divCoupon").style.display = "block"; document.getElementById("divDeliveryAddress").style.display = "none"; document.getElementById("divUserAddress").style.display = "none"; document.getElementById("divNewAddress").style.display = "none"; } }); // To Get Delivery Address --- Start --- // function GetUserAddress(address) { var addressType = ''; var addressId = ''; if (address != '') { addressType = address.split("|")[0]; addressId = address.split("|")[1]; } $.ajax({ type: "POST", url: "/BuyItem.aspx/GetUserAddress", dataType: "json", data: JSON.stringify({ AddressId: addressId, AddressType: addressType }), contentType: "application/json; charset=utf-8", success: function (resp) { if (resp.d == null) { window.location = "/addnewdeliveryaddress/"; } else { bindUserAddress(resp); } }, error: function (xhr, status, error) { handleErrorMessage(xhr, error); //alert(errtext); } }); } function bindUserAddress(resp) { var addresslen = resp.d[0].AddressLists.length; var out = ""; var i; for (i = 0; i < addresslen; i++) { var address = resp.d[0].AddressLists[i].AddressItems[0]; out += "