var _Type; var _Url; var _Data; var _ContentType; var _DataType; var _ProcessData; function CallService_Audit() { //var ii = 1; $.ajax({ type: _Type, //GET or POST or PUT or DELETE verb url: _Url, // Location of the service data: _Data, //Data sent to server contentType: _ContentType, // content type sent to server dataType: _DataType, //Expected data format from server processdata: _ProcessData, //True or False success: function (msg) {//On Successfull service call _Type = null; _Url = null; _Data = null; _ContentType = null; _DataType = null; _ProcessData = null; }, error: function (result) { // When Service call fails _Type = null; _Url = null; _Data = null; _ContentType = null; _DataType = null; _ProcessData = null; } }); } function CommonAudit_Service(type) { _Type = "POST"; _Url = "/Service.svc/AddCommonAuditRecord"; _Data = '{"domain": "mlsguide", "type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function ListingAudit_Service(mlsnum, type) { _Type = "POST"; _Url = "/Service.svc/AddListingAuditRecord"; _Data = '{"domain": "mlsguide","mlsnum": "' + mlsnum + '","type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function OfficeAudit_Service(mlsnum, type) { _Type = "POST"; _Url = "/Service.svc/AddOfficeAuditRecord"; _Data = '{"domain": "mlsguide","mlsnum": "' + mlsnum + '","type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function AgentAudit_Service(mlsnum, type) { _Type = "POST"; _Url = "/Service.svc/AddAgentAuditRecord"; _Data = '{"domain": "mlsguide","mlsnum": "' + mlsnum + '","type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function OfficeAuditByOfficeCode_Service(officeCode, type) { _Type = "POST"; _Url = "/Service.svc/AddOfficeAuditRecordByOfficeCode"; _Data = '{"domain": "mlsguide","officeCode": "' + officeCode + '","type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function CitySearchAudit_Service(cityName) { _Type = "POST"; _Url = "https://www.mlsguide.com/Service.svc/AddCitySearchAuditRecord"; _Data = '{"domain": "mlsguide","cityName": "' + cityName + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function AgentAuditByAgentCode_Service(agentCode, type) { _Type = "POST"; _Url = "/Service.svc/AddAgentAuditRecordByAgentCode"; _Data = '{"domain": "mlsguide","agentCode": "' + agentCode + '","type": "' + type + '"}'; _ContentType = "application/json; charset=utf-8"; _DataType = "json"; ProcessData = true; CallService_Audit(); } function SetSession_Service(name, value) { $.ajax({ type: "POST", url: "/Search.aspx/SetSession", data: '{"name": "' + name + '","value": "' + value + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function AddFavorite_Service(mlsNum) { $.ajax({ type: "POST", url: "/Search.aspx/AddFavorite", data: '{"mlsNum": "' + mlsNum + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function RemoveFavorite_Service(mlsNum) { $.ajax({ type: "POST", url: "/Search.aspx/RemoveFavorite", data: '{"mlsNum": "' + mlsNum + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function AddSearchSave_Service(searchCriteria,filterCriteria) { $.ajax({ type: "POST", url: "/Search.aspx/AddSearchSave", data: '{"searchCriteria": "' + searchCriteria + '","filterCriteria": "' + filterCriteria + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function RemoveSearchSave_Service(id) { $.ajax({ type: "POST", url: "/SavedSearches.aspx/RemoveSearchSave", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function SendNotificationSelecteSearchSave_Service(id, send) { $.ajax({ type: "POST", url: "/SavedSearches.aspx/SendNotificationSelect", data: '{"id": "' + id + '","send": "' + send + '"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function SendNotificationSelecteSearchSave_Service(id, send) { $.ajax({ type: "POST", url: "/SavedSearches.aspx/SendNotificationSelect", data: '{"id": "' + id + '","send": "'+ send +'"}', contentType: "application/json; charset=utf-8", dataType: "json" }); } function GetPropertyData_Service(id) { var time = new Date(); console.log("Begin data load: " + time.getMinutes() + ":" + time.getSeconds()); $(".property-modal-content").hide(); $(".property-modal").show(); $("#LoadingImage").show(); $.ajax({ type: "POST", url: "/Search.aspx/GetPropertyData", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var obj = result.d; document.title = obj.Title; $("#pAgentInfo").hide(); $("#pPrice-Price").hide(); $("#pVirtualTour").hide(); $("#pOpenHouses").hide(); $("#pFavorite").hide(); $("#pPrice-Price").html(obj.Price); $("#pMain-Address").html(obj.Address); $("#pMain-CityZip").html(obj.CityZip); $("#pMain-MLSNum").html(obj.MLSNum); $("#pMain-Description").html(obj.Description); $("#pRemark-Remark").html(obj.Remark); //Email $("#FdMLSNum").val(obj.MLSNum); $("#BrMLSNum").val(obj.MLSNum); $("#pOfficeName").html(obj.OfficeName); $("#pAgentNameLinkProp").attr("href", "#"); $("#pAgentNameLinkProp").attr("onclick", "showAgent('" + obj.AgentCode + "');return false;"); $("#pAgentNameProp").html(obj.AgentName); $("#pOfficePhone").hide(); $("#pOfficePhone2").hide(); $("#pBtnShowOfficePhone").attr("onclick", "showOfficePhoneProperty('" + obj.OfficeCode + "','" + obj.AgentCode + "');"); $("#pBtnShowOfficePhone").show(); $("#pBtnShowOfficePhone2").attr("onclick", "showOfficePhoneProperty2('" + obj.OfficeCode + "');"); $("#pBtnShowOfficePhone2").show(); if (obj.OfficePhone.length > 0) { $("#pOfficePhone").html(obj.OfficePhone); $("#pPanel_OfficePhone").show(); if (obj.StatusCat != "1") { $("#pOfficePhone2").html(obj.OfficePhone); $("#pPanel_OfficePhone2").show(); } else { $("#pPanel_OfficePhone2").hide(); } } else { $("#pPanel_OfficePhone").hide(); $("#pPanel_OfficePhone2").hide(); } $("#pCellPhone").hide(); $("#pBtnShowCellPhone").attr("onclick", "showCellPhoneProperty('" + obj.AgentCode + "');"); $("#pBtnShowCellPhone").show(); if (obj.CellPhone.length > 0) { $("#pCellPhone").html(obj.CellPhone); $("#pPanel_CellPhone").show(); } else { $("#pPanel_CellPhone").hide(); } if (obj.AgentImage.length > 0) { if (obj.AgentWebPage.length > 0) { $("#pAgentImageProp").attr("src", obj.AgentImage); $("#pAgentWebPageProp").attr("href", obj.AgentWebPage); } else { $("#pAgentImageProp").attr("src", obj.AgentImage); $("#pAgentWebPageProp").removeAttr("href"); } $(".p-agent-info-photo").show(); } else { $(".p-agent-info-photo").hide(); } if (obj.AgentType.length > 0) { $("#pPremierAgentTypeName").html("
" + obj.AgentType); } if (obj.OfficeImage.length > 0) { $("#pOfficeImageProp").attr("src", obj.OfficeImage); if (obj.OfficeWebPage.length > 0) { $("#pOfficeWebPageProp").attr("href", obj.OfficeWebPage); } else { $("#pOfficeWebPageProp").removeAttr("href"); } $("#pOfficePanelProp").show(); } else { $("#pOfficePanelProp").hide(); } if (obj.StatusCat == '1' && obj.OpenHouses) { var s = ''; var ln = obj.OpenHouses.length; for (var i = 0; i < ln; i++) { s += '

' + obj.OpenHouses[i].DayOfWeek + ' ' + obj.OpenHouses[i].Month + ' ' + obj.OpenHouses[i].Day + '
' + obj.OpenHouses[i].BeginTime + ' - ' + obj.OpenHouses[i].EndTime + '

'; } $("#pOpenHousesInfo").html(s); $("#pOpenHouses").show(); } else $("#pOpenHouses").hide(); if (obj.StatusCat == '1' && obj.OpenHousesLiveStreams) { s = ''; ln = obj.OpenHousesLiveStreams.length; for (i = 0; i < ln; i++) { s += '

' + obj.OpenHousesLiveStreams[i].DayOfWeek + ' ' + obj.OpenHousesLiveStreams[i].Month + ' ' + obj.OpenHousesLiveStreams[i].Day + '
' + obj.OpenHousesLiveStreams[i].BeginTime + ' - ' + obj.OpenHousesLiveStreams[i].EndTime + '

'; } $("#pLiveStreamsInfo").html(s); $("#pLiveStreams").show(); } else $("#pLiveStreams").hide(); if (obj.StatusCat == '1' && obj.OpenHouseLiveStream) { s = ''; ln = obj.OpenHouseLiveStream.length; if (ln > 0) { $("#pLiveStreamLink").attr("href", obj.OpenHouseLiveStream[0].LiveStreamURL); } $("#pLiveStream").show(); } else $("#pLiveStream").hide(); if (obj.Features) { var s = ''; var ln = obj.Features.length; for (var i = 0; i < ln; i++) { if (obj.StatusCat == 1 || obj.Features[i].Name != 'DaysOnMarket') { s += getFeatureHTML(obj.Features[i].Name, obj.Features[i].Value); } } $("#pFeaturesInfo").html(s); $("#pFeatures").show(); } else $("#pFeatures").hide(); if (obj.StatusCat == '1' && obj.VirtualTourURL) { $("#pVirtualTourLink").attr("href", obj.VirtualTourURL); $("#pVirtualTour").show(); } else { $("#pVirtualTourLink").attr("href", ""); $("#pVirtualTour").hide(); } $("#pImages").html(obj.ImagesList); $("#pImages").attr("data-images-count", obj.ImageCount); initImagesSlider(); $(".property-modal-content").show(); $("#LoadingImage").hide(); $("#pFavorite-Link").attr("data-mlsnum", obj.MLSNum); if (obj.OwnerLogged == 'true') { $("#pFavorite-Link").attr("onclick", "favoriteSwitch(this,'" + id + "'); return false;"); $("#pFavorite-Link").attr("data-favorite", obj.Favorite); if (obj.Favorite == 'true') $("#pFavorite-Image").attr("src", "images/heart.png"); else $("#pFavorite-Image").attr("src", "images/heart_outline.png"); } else { $("#pFavorite-Link").attr("onclick", "$('#modalFavoritesInfo').modal({backdrop: false, keyboard: false}) ; return false;"); $("#pFavorite-Link").attr("data-favorite", ""); $("#ppFavorite-Image").attr("src", "images/heart_outline.png"); } //Calculator if (obj.ClassCode == "S") { $("#LoanAmount").val(obj.ListPrice); $("#DownPayment").val(obj.ListPrice * 0.2); $("#InterestRate").val("5.0"); $("#NumberOfYears").val("20"); $("#MonthlyPayment").html(""); morgCalc(); $("#pMortgage").show(); } var time = new Date(); console.log("End data load: " + time.getMinutes() + ":" + time.getSeconds()); GetPrimeInterestRate_Service(); GetPropertyPriceTaxHistory_Service(id); GetRecentSold_Service(id); GetSimilarForSale_Service(id); ListingAudit_Service(id, 1); //GetPropAds_Service(); $("#pPrice-Class").html("OFF MARKET"); $(".p-agent-info-container").show(); if (obj.StatusCat == '1') { $("#pAgentInfo").show(); $("#pPrice-Price").show(); $("#pFavorite").show(); } else { $("#pPanel_CellPhone").hide(); if (obj.IsOfficeActive) { $("#pAgentInfo").show(); if (!obj.MemberRemainInOffice) $(".p-agent-info-container").hide(); } } if (obj.StatusCat == '1') { $("#pPrice-Class").html(obj.ClassName); } if (obj.StatusCat == '2') { if (obj.ClassCode == 'S') $("#pPrice-Class").html("SOLD"); else $("#pPrice-Class").html("RENTED"); $("#pPrice-Price").show(); } if (obj.StatusCat == '6') { $("#pPrice-Class").html("RENTED"); $("#pPrice-Price").show(); } } }); } function InitializeStreetViewMap() { var geocoder; var map; var panorama; var address = $("#pMain-Address").html() + ', ' + $("#pMain-CityZip").html(); //221 JANE, WEEHAWKEN NJ 07086 geocoder = new google.maps.Geocoder(); map = new google.maps.Map(document.getElementById("map_canvas"), { zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP }); geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), { position: results[0].geometry.location, pov: { heading: 34, pitch: 10, zoom: 1 } }); panorama.setVisible(true); map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } }); } function GetPropertyPriceTaxHistory_Service(id) { var time = new Date(); console.log(time.getMinutes() + ":" + time.getSeconds()); $.ajax({ type: "POST", url: "/Search.aspx/GetPropertyPriceTaxHistory", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var time = new Date(); console.log(time.getMinutes() + ":" + time.getSeconds()); var obj = result.d; if (obj.PriceHistory || obj.TaxHistory) { if (obj.PriceHistory) { var s = ''; var ln = obj.PriceHistory.length; for (var i = 0; i < ln; i++) { s += getPriceHistoryHTML(obj.PriceHistory[i].Date, obj.PriceHistory[i].Price, obj.PriceHistory[i].Address, obj.PriceHistory[i].AptNum); } if (ln > 0) { var ss = obj.PriceHistory[0].Address; if (obj.PriceHistory[0].AptNum.trim().length > 0) { ss += '  ' + obj.PriceHistory[0].AptNum } $("#pPriceHistoryAddress").html(ss); } $("#pPriceHistoryBody").html(s); $("#pPriceHistory").show(); } else $("#pPriceHistory").hide(); if (obj.TaxHistory) { var s = ''; var ln = obj.TaxHistory.length; for (var i = 0; i < ln; i++) { s += getTaxHistoryHTML(obj.TaxHistory[i].Year, obj.TaxHistory[i].Class, obj.TaxHistory[i].Assessment, obj.TaxHistory[i].AssessmentChange, obj.TaxHistory[i].Tax, obj.TaxHistory[i].TaxChange, obj.TaxHistory[i].TaxRatio, obj.TaxHistory[i].TaxRate); } if (ln > 0) { var ss = obj.TaxHistory[0].Address; if (obj.TaxHistory[0].AptNum.trim().length > 0) { ss += '  ' + obj.TaxHistory[0].AptNum } $("#pPriceHistoryAddress2").html(ss); } $("#pTaxHistoryBody").html(s); $("#pTaxHistory").show(); } else $("#pTaxHistory").hide(); $("#pPriceTaxHistory").show(); } else $("#pPriceTaxHistory").hide(); } }); } function getFeatureHTMLLine(title, value, image) { return '
'+title+'
' + value + '
'; } function getFeatureHTML(name, value) { var s = '
'; if (name == 'Type') { s += getFeatureHTMLLine('Type', value, 'house.png'); } if (name == 'Heating') { s += getFeatureHTMLLine('Heating', value, 'temperature.png'); } if (name == 'Cooling') { s += getFeatureHTMLLine('Cooling', value, 'aircon.png'); } if (name == 'DaysOnMarket') { s += getFeatureHTMLLine('Days on Market', value, 'sign.png'); } return s + '
'; } function getPriceHistoryHTML(date, price, address, aptnum) { return '' + date + '' + price + ''; } function getTaxHistoryHTML(year, prop_class, assessment, assessment_change, tax, tax_change, tax_ratio, tax_rate) { return '' + year + '' + prop_class + '' + tax + '' + tax_change + '' + assessment + '' + assessment_change + '' + tax_rate+ '' + tax_ratio + ''; } function GetRecentSold_Service(id) { if (!$("#pRecentSoldInfo").hasClass("tb-box-collapsed")) $("#pRecentSoldInfo").addClass("tb-box-collapsed"); $.ajax({ type: "POST", url: "/Search.aspx/GetRecentSold", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var i; for (i = 0; i < ln; i++) $("#pRecentSoldProp" + (i + 1) + "DataContainer").hide(); var obj = result.d; var ln = obj.length; if (ln > 0) if (obj[0].Status == 'S') $("#pRecentSoldHeader").html("Recent Sales"); else $("#pRecentSoldHeader").html("Recent Rentals"); for (i = 0; i < ln; i++) { $("#pRecentSoldProp" + (i + 1) + "Image").attr("src", obj[i].Image); $("#pRecentSoldProp" + (i + 1) + "DataContainerLine1").html(obj[i].Address); $("#pRecentSoldProp" + (i + 1) + "DataContainerLine2").html(obj[i].CityZip); $("#pRecentSoldProp" + (i + 1) + "DataContainerLine3").html(obj[i].SoldPrice); //if (obj[i].TaxRecordsLink) { // $("#pRecentSoldProp" + (i + 1) + "Link").attr("href", obj[i].TaxRecordsLink); //} else { // $("#pRecentSoldProp" + (i + 1) + "Link").removeAttr("href"); //} $("#pRecentSoldProp" + (i + 1) + "Link").attr("onclick", "showProperty(" + obj[i].MLS + "); return false;"); $("#pRecentSoldProp" + (i + 1) + "DataContainer").show(); } if (ln > 0) $("#pRecentSold").show(); else $("#pRecentSold").hide(); } }); } function GetSimilarForSale_Service(id) { if (!$("#pForSaleInfo").hasClass("tb-box-collapsed")) $("#pForSaleInfo").addClass("tb-box-collapsed"); $.ajax({ type: "POST", url: "/Search.aspx/GetSimilarForSale", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var i; for (i = 0; i < ln; i++) $("#pForSaleProp" + (i + 1) + "DataContainer").hide(); var obj = result.d; var ln = obj.length; for (i = 0; i < ln; i++) { $("#pForSaleProp" + (i + 1) + "Image").attr("src", obj[i].Image); $("#pForSaleProp" + (i + 1) + "Link").attr("onclick", "showProperty(" + obj[i].MLS + "); return false;"); $("#pForSaleProp" + (i + 1) + "DataContainerLine1").html(obj[i].Address); $("#pForSaleProp" + (i + 1) + "DataContainerLine2").html(obj[i].CityZip); $("#pForSaleProp" + (i + 1) + "DataContainerLine3").html(obj[i].Price); $("#pForSaleProp" + (i + 1) + "DataContainer").show(); } if (ln > 0) $("#pForSale").show(); else $("#pForSale").hide(); } }); } function GetAgentPropertiesData_Service(id) { $.ajax({ type: "POST", url: "/Search.aspx/GetAgentPropertiesInfo", data: '{"id" : "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var res = JSON.parse(result.d); var x = document.getElementById("aAgentPropertiesNest"); while (x.firstChild) { x.removeChild(x.firstChild); } x.style.display = 'none'; for (var i = 0; i < res.Properties.length; i++) { insertPropertyItemForAgentView(x, res.Properties[i]); } x.style.display = 'block'; } }); } function insertPropertyItemForAgentViewOld(nestObj, data) { if (nestObj) { var s; s = '
'; s += '
'; s += 'Listed By: ' + data.OfficeName; s += '
'; s += '
'; s += '
'; s += data.OpenHouse; s += '
'; s += '
'; s += data.AgentTypeName; s += '
'; s += '
'; s += '

' + data.PropTypeName + '

'; s += '

$' + data.Price + '

'; s += '
'; s += ''; s += ''; s += '
'; s += '
'; s += '

'; s += '' + data.Address + ', '; s += data.City + ', NJ ' + data.Zip; s += '

'; s += '

' + data.Beds + ' BR   ' + data.Baths + ' Full Baths

'; s += '
'; nestObj.innerHTML += s; } } function insertPropertyItemForAgentView(nestObj, data) { if (nestObj) { var s; s = '
'; s += '
'; s += 'Listed By: ' + data.OfficeName; s += '
'; s += '
'; s += '
'; s += data.OpenHouse; s += '
'; s += '
'; s += data.AgentTypeName; s += '
'; s += '
'; s += '

' + data.PropTypeName + '

'; s += '

$' + data.Price + '

'; s += '
'; s += '
'; if (data.OwnerLogged == 'true') { var image = data.Favorite == 'true' ? '/images/heart.png' : '/images/heart_outline.png'; s += ''; s += ''; s += ''; s += ''; } else { s += ''; s += ''; s += ''; s += ''; } s += '
'; s += ''; s += ''; s += '
'; s += '
'; s += '

'; s += '' + data.Address + ', '; s += data.City + ', NJ ' + data.Zip; s += '

'; s += '

' + data.Beds + ' BR   ' + data.Baths + ' Full Baths

'; s += '
'; nestObj.innerHTML += s; } } function GetAgentData_Service(id) { $(".agent-modal-content").hide(); $(".agent-modal").show(); $("#LoadingImage2").show(); GetAgentPropertiesData_Service(id); $.ajax({ type: "POST", url: "/Search.aspx/GetAgentData", data: '{"id": "' + id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { $('#AgentView').attr("data-agentcode", id); var obj = result.d; //document.title = obj.Title; if (obj.AgentImage) $("#aAgentImage").attr("src", obj.AgentImage); else $("#aAgnetImage").removeAttr("src"); $("#aAgentName").html(obj.AgentName); $("#aAgentAddress").html(obj.Address); $("#aAgentCity").html(obj.CityZip); $("#aOfficeName").html(obj.OfficeName); $("#aAgentBio").html(obj.AgentBio); if (obj.OfficePhone) $("#aAgentPhone_1").html(obj.OfficePhone); if (obj.CellPhone) { if (obj.OfficePhone) $("#aAgentPhone_2").html(obj.CellPhone); else $("#aAgentPhone_1").html(obj.CellPhone); } if (obj.OfficeImage) { $("#aOfficeImage").attr("src", obj.OfficeImage); if (obj.OfficeWebPage) $("#aOfficeLink").attr("href", obj.OfficeWebPage); else $("#aOfficeLink").removeAttr("href"); } else { $("#aOfficeImage").removeAttr("src"); $("#aOfficeLink").removeAttr("href"); } if (obj.EmailAddressExists) { $("#aContactAgentButton").css("display", "list-item"); } else { $("#aContactAgentButton").css("display", "none"); } if (obj.AgentWebPage) { $("#aWebPageLink").attr("href", "javascript:openAgentSite('" + obj.AgentWebPage + "','" + obj.AgentCode + "');"); $("#aWebPageButton").css("display", "list-item"); } else { $("#aWebPageLink").attr("href", ""); $("#aWebPageButton").css("display", "none"); } //Contact Agent $("#AgAgentName").html(obj.AgentName); $("#AgAgentCode").val(obj.AgentCode); $(".agent-modal-content").show(); $("#LoadingImage2").hide(); } }); } function GetPropAds_Service() { $.ajax({ url: "/ads.txt", success: function (result) { if ($("#ad_p_1").length) { $("#ad_p_1").html(""); postscribe('#ad_p_1', result); } } }); $.ajax({ url: "/ads.txt", success: function (result) { if ($("#ad_p_2").length) { $("#ad_p_2").html(""); postscribe('#ad_p_2', result); } } }); $.ajax({ url: "/ads.txt", success: function (result) { if ($("#ad_p_3").length) { $("#ad_p_3").html(""); postscribe('#ad_p_3', result); } } }); } function GenerateNewCaptcha_Service(name) { $.ajax({ type: "POST", url: "/Search.aspx/GenerateNewCaptcha", contentType: "application/json; charset=utf-8", dataType: "json", success: function () { if (name === 'Us') $('#CaptchaImageContainerUs').html($("")); if (name === 'Broker') $('#CaptchaImageContainerBroker').html($("")); if (name === 'Friend') $('#CaptchaImageContainerFriend').html($("")); if (name === 'Agent') $('#CaptchaImageContainerAgent').html($("")); if (name === 'REOffice') $('#CaptchaImageContainerREOffice').html($("")); if (name === 'Owner') $('#CaptchaImageContainerOwner').html($("")); } }); } function SendEmailToUs_Service() { $.ajax({ type: "POST", url: "/Search.aspx/SendEmailToUs", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"Name": "' + $("#CuFullName").val() + '","CompanyName": "' + $("#CuCompany").val() + '","CompanyCity": "' + $("#CuCompanyCity").val() + '","Phone": "' + $("#CuPhone").val() + '","Email": "' + $("#CuEmail").val() + '","Message": "' + $("#CuMessage").val() + '","Captcha": "' + $("#txtCuCaptchaText").val() + '","UserType": "' + $("#CuUserType").val() + '"}', success: function (result) { var res = result.d; if (res.length == 0) { res = "Email has been sent"; $("#CuFullName").val(""); $("#CuCompany").val(""); $("#CuCompanyCity").val(""); $("#CuPhone").val(""); $("#CuEmail").val(""); $("#CuMessage").val(""); $("#txtCuCaptchaText").val(""); $("#CuUserType").prop("selectedIndex", 0); } $("#CuMsgLabel").text(res); }, error: function (result) { $("#CuMsgLabel").text("Service error"); } }); } function SendEmailToFriend_Service() { $.ajax({ type: "POST", url: "/Search.aspx/SendEmailToFriend", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"NameFrom": "' + $("#FdFromName").val() + '","EmailFrom": "' + $("#FdFromEmail").val() + '","NameTo": "' + $("#FdToName").val() + '","EmailTo": "' + $("#FdToEmail").val() + '","Subject": "' + $("#FdEmailSubject").val() + '","Message": "' + $("#FdMessageBody").val() + '","Captcha": "' + $("#txtFdCaptchaText").val() + '","MLSNum": "' + $("#FdMLSNum").val() + '"}', success: function (result) { var res = result.d; if (res.length == 0) { res = "Email has been sent"; $("#FdFromName").val(""); $("#FdFromEmail").val(""); $("#FdToName").val(""); $("#FdToEmail").val(""); $("#FdEmailSubject").val(""); $("#FdMessageBody").val(""); $("#txtFdCaptchaText").val(""); } $("#FdMsgLabel").text(res); }, error: function (result) { $("#FdMsgLabel").text("Service error"); } }); } function SendEmailToBroker_Service() { $.ajax({ type: "POST", url: "/Search.aspx/SendEmailToBroker", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"Name": "' + $("#BrFullName").val() + '","Email": "' + $("#BrEmail").val() + '","Phone": "' + $("#BrPhone").val() + '","Message": "' + $("#BrMessage").val() + '","Captcha": "' + $("#txtBrCaptchaText").val() + '","MLSNum": "' + $("#BrMLSNum").val() + '","UserType": "' + $("#BrUserType").val() + '"}', success: function (result) { var res = result.d; if (res.length == 0) { res = "Email has been sent"; $("#BrFullName").val(""); $("#BrPhone").val(""); $("#BrEmail").val(""); $("#BrMessage").val(""); $("#txtBrCaptchaText").val(""); $("#BrUserType").prop("selectedIndex", 0); } $("#BrMsgLabel").text(res); }, error: function (result) { $("#BrMsgLabel").text("Service error"); } }); } function SendEmailToAgent_Service() { $.ajax({ type: "POST", url: "/Search.aspx/SendEmailToAgent", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"Name": "' + $("#AgFullName").val() + '","Email": "' + $("#AgEmail").val() + '","Phone": "' + $("#AgPhone").val() + '","Message": "' + $("#AgMessage").val() + '","Captcha": "' + $("#txtAgCaptchaText").val() + '","AgentCode": "' + $("#AgAgentCode").val() + '","UserType": "' + $("#AgUserType").val() + '"}', success: function (result) { var res = result.d; if (res.length == 0) { res = "Email has been sent"; $("#AgFullName").val(""); $("#AgPhone").val(""); $("#AgEmail").val(""); $("#AgMessage").val(""); $("#txtAgCaptchaText").val(""); $("#AgUserType").prop("selectedIndex", 0); } $("#AgMsgLabel").text(res); }, error: function (result) { $("#AgMsgLabel").text("Service error"); } }); } function SendEmailToREOffice_Service() { $.ajax({ type: "POST", url: "/FindOffice.aspx/SendEmailToREOffice", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"EmailFrom": "' + $("#ReEmailFrom").val() + '","EmailTo": "' + $("#ReEmailTo").val() + '","Subject": "' + $("#ReSubject").val() + '","Message": "' + $("#ReMessage").val() + '","Captcha": "' + $("#txtReCaptchaText").val() + '","UserType": "' + $("#ReUserType").val() + '"}', success: function (result) { var res = result.d; if (res.length == 0) { res = "Email has been sent"; $("#ReEmailFrom").val(""); $("#ReSubject").val(""); $("#ReMessage").val(""); $("#txtReCaptchaText").val(""); $("#ReUserType").prop("selectedIndex", 0); } $("#ReMsgLabel").text(res); }, error: function (result) { $("#ReMsgLabel").text("Service error"); } }); } function CreateOwnerAccount_Service() { var contactBy = 1; if ($("#rbOwPhone").is(":checked")) { contactBy = 2; } if ($("#rbOwEither").is(":checked")) { contactBy = 3; } $.ajax({ type: "POST", url: "/Default.aspx/CreateOwnerAccount", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"FirstName": "' + $("#OwFirstName").val() + '","LastName": "' + $("#OwLastName").val() + '","Password": "' + $("#OwPassword").val() + '","RetypePassword": "' + $("#OwRetypePassword").val() + '","Email": "' + $("#OwEmail").val() + '","Phone": "' + $("#OwPhone").val() + '","ContactBy": ' + contactBy + ',"Captcha": "' + $("#txtOwCaptchaText").val() + '"}', success: function (result) { var res = result.d; $("#OwMsgLabel").text(res); if (res.length == 0) { $("#OwcOwnerEmail").html($("#OwEmail").val()); $("#OwFirstName").val(""); $("#OwLastName").val(""); $("#OwPassword").val(""); $("#OwRetypePassword").val(""); $("#OwEmail").val(""); $("#OwPhone").val(""); $("#rbOwEmail").attr('checked', 'checked'); $("#txtOwCaptchaText").val(""); $("#modalOwnerSignup").modal('hide'); $("#modalOwnerConfirm").modal('show'); } }, error: function (result) { $("#OwMsgLabel").text("Service error"); } }); } function SendOwnerConfirmationEmail_Service() { $.ajax({ type: "POST", url: "/Default.aspx/SendOwnerConfirmationEmail", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { }, error: function (result) { } }); } function OwnerLogin_Service() { var autoLogin = ($("#cbOwnerAutoLogin").is(':checked')) ? "true" : "false"; $.ajax({ type: "POST", url: "/Default.aspx/OwnerLogin", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"LoginName": "' + $("#tbOwnerUserName").val() + '","Password": "' + $("#tbOwnerPassword").val() + '","AutoLogin": ' + autoLogin + '}', success: function (result) { var res = result.d; $("#ml_br_owner_error").html(res); $("#tbOwnerPassword").val(""); if (res.length == 0) { $("#tbOwnerUserName").val(""); //updateOwnerLoginStatus(true); //loginOwnerHide(); var str = ''; if ($("#PropertyView").css("display") == "block") str = 'Property=' + $("#pMain-MLSNum").text(); if ($("#AgentView").css("display") == "block") { if (str.length > 0) str += '&'; str += 'Agent=' + $("#AgentView").attr('data-agentcode'); } if (str.length > 0) document.location.search = str; else __doPostBack("", ""); } else { if (res == "Confirmation") { loginOwnerHide(); $("#ml_br_owner_error").html(""); $("#modalOwnerConfirm").modal('show'); } } }, error: function (result) { $("#ml_br_owner_error").html("Service error"); } }); } function IsOwnerAutoLogged_Service() { $.ajax({ type: "POST", url: "/Default.aspx/IsOwnerAutoLogged", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var obj = JSON.parse(result.d); if (obj.IsOwnerAutoLogged == 'true') { //updateOwnerLoginStatus(true); //$("#LoginMenu").css("display", "none"); __doPostBack("", ""); } else { $(".ml_main2").css("display", "block"); } } }); } function OwnerLogout_Service() { $.ajax({ type: "POST", url: "/Default.aspx/OwnerLogout", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { //updateOwnerLoginStatus(false); __doPostBack("", ""); }, error: function (result) { } }); } function SendOwnerUserName_Service(email) { $.ajax({ type: "POST", url: "/Default.aspx/SendOwnerUserName", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"Email": "' + email + '"}', success: function (result) { if (result.d.length == 0) { $("#lbOwnerUserNameMsg").text("Email has been sent"); $("#tbOwnerUserNameEmail").val(""); } else { $("#lbOwnerUserNameMsg").text(result.d); } }, error: function (result) { $("#lbOwnerUserNameMsg").text("Service error"); } }); } function NewMemberLogin_Service() { var autoLogin = "false"; var name = $("#tbUserName_2").val(); var pass = $("#tbPassword_2").val(); $.ajax({ type: "POST", url: "/Default.aspx/MemberLogin", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"LoginName": "' + name + '","Password": "' + pass + '","AutoLogin": ' + autoLogin + '}', success: function (result) { var res = result.d; $("#ml_br_error_2").html(res); $("#tbPassword_2").val(""); if (res.length == 0) { //loginHide(); $("#tbUserName_2").val(""); $('#modalAgentInfo').modal('hide'); Login_Service(name, pass, autoLogin); __doPostBack("MemberLogin", ""); } }, error: function (result) { $("#ml_br_error_2").html("Service error"); } }); } function MemberLogin_Service() { var autoLogin = ($("#cbAutoLogin").is(':checked')) ? "true" : "false"; var name = $("#tbUserName").val(); var pass = $("#tbPassword").val(); $.ajax({ type: "POST", url: "/Default.aspx/MemberLogin", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"LoginName": "' + name + '","Password": "' + pass + '","AutoLogin": ' + autoLogin + '}', success: function (result) { var res = result.d; $("#ml_br_error").html(res); $("#tbPassword").val(""); if (res.length == 0) { loginHide(); $("#tbUserName").val(""); Login_Service(name, pass, autoLogin); __doPostBack("MemberLogin", ""); } }, error: function (result) { $("#ml_br_error").html("Service error"); } }); } function IsMemberAutoLogged_Service() { $.ajax({ type: "POST", url: "/Default.aspx/IsMemberAutoLogged", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var obj = JSON.parse(result.d); if (obj.IsMemberAutoLogged == 'true') { $("#LoginMenu").css("display", "none"); __doPostBack("MemberLogin", ""); } else { $(".ml_main").css("display", "block"); } } }); } function SendMemberUserName_Service(email) { $.ajax({ type: "POST", url: "/Default.aspx/SendMemberUserName", contentType: "application/json; charset=utf-8", dataType: "json", data: '{"Email": "' + email + '"}', success: function (result) { if (result.d.length == 0) { $("#lbUserNameMsg").text("Email has been sent"); $("#tbUserNameEmail").val(""); } else { $("#lbUserNameMsg").text(result.d); } }, error: function (result) { $("#lbUserNameMsg").text("Service error"); } }); } function UpdateOfficeNameToBrEmailDlg_Service(id) { $.ajax({ type: "POST", url: "/Search.aspx/UpdateOfficeNameToBrEmailDlg", async: false, contentType: "application/json; charset=utf-8", dataType: "json", data: '{"id": "' + id + '"}', success: function (result) { $('#BrOfficeName').html(result.d); } }); } function UpdateOfficeNameToReEmailDlg_Service(id) { $.ajax({ type: "POST", url: "/Search.aspx/UpdateOfficeNameToReEmailDlg", async: false, contentType: "application/json; charset=utf-8", dataType: "json", data: '{"id": "' + id + '"}', success: function (result) { var obj = result.d; $('#ReOfficeName').html(obj.OfficeName); $('#ReEmailTo').val(obj.OfficeEmail); } }); } function GetPrimeInterestRate_Service() { $.ajax({ type: "POST", url: "https://www.commercialloandirect.com/rates-api.php", contentType: "application/x-www-form-urlencoded; charset=UTF-8", data: $.param({ Prime: "Y" }), success: function (result) { var html = $($.parseHTML(result)); var list = $(html.find("td.ratesCell")); $("#InterestRate").val(list[1].innerText.replace("%", "")); morgCalc(); } }); } function Login_Service(name, pass, autoLogin) { $.ajax({ type: "POST", url: "https://www.mlsguide.com/test/api/token/auth", data: '{"username": "' + name + '","password": "' + pass + '","grant_type": "password","auto_login": ' + autoLogin + '}', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var r = JSON.stringify(result); localStorage.setItem("auth", r); }, error: function (result) { console.error(error); } }); }