<br><br>
<div id="viewContainer">
</div>


<script>$(".bottom-navigation-bar").remove(); $(".header").remove();</script>
<script>


    $$ = {};
    $$.UI = {};
    $$.UI.Table = {};
    $$.UI.Table.CreateTable = function (id, theadinnerhtml, bodyinnerhtml) { return CreateTable(id, theadinnerhtml, bodyinnerhtml); };
    $$.UI.Table.GenerateTheadFromArraySimple = function (array) { return GenerateTheadFromArraySimple(array); };
    $$.UI.Table.GenerateTableRowFromArraySimple = function (array) { return GenerateTableRowFromArraySimple(array); };
    $$.UI.ResetBrowserAndCache = function () { return ResetBrowserAndCache(); };
    $$.UI.formatCurrency = function (number, withdecimal = true) { return formatCurrency(number, withdecimal); };
    $$.UI.getDateInGMT8 = function () { return getDateInGMT8(); };
    $$.UI.RunFunctiononMutation = function (targetidToMonitor, callbackfunction) { return RunFunctiononMutation(targetidToMonitor, callbackfunction); };
    $$.UI.Element = {};
    $$.UI.Element.appendtobody = function (string) { return appendtobody(string); };
    $$.UI.Element.Exists = function (ElementIDtext) { ElementExists(ElementIDtext); };
    $$.UI.Element.RemovebyID = function (idstring) { return removeelementbyID(idstring); };
    $$.UI.Element.DeleteById = function (id) { return DeleteElementById(id); }
    $$.UI.Element.getHTML = function (idetext) { return getElementhtml(idtext); };
    $$.UI.Element.setHTML = function (idetext, html) { return setElementhtml(idtext, html); };
    $$.UI.Element.getValue = function (idetext) { return getElementvalue(idtext); };
    $$.UI.Element.setValue = function (idetext,) { return setElementvalue(idtext, value); };
    $$.UI.Validate = {};
    $$.UI.Validate.isValidEmail = function (email) { return isValidEmail(email); };
    $$.UI.Validate.hasValidMobileFormat = function (usernumber) { return hasValidMobileFormat(usernumber); };
    $$.UI.Modal = {};
    $$.UI.Modal.Create = function (modalid, modaltitle, modalbody, modalfooter, modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return createmodal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
    $$.UI.Modal.Show = function (idtxt) { return modalshow(idtxt); };
    $$.UI.Modal.Hide = function (idtxt) { return modalhide(); };
    $$.UI.Modal.CreateAndShow = function (modalid, modaltitle, modalbody, modalfooter = '', modalfooterclose = true, topclosebutton = true, modalbodyclass = 'modal-body', modalheaderclass = 'modal-header') { return CreateAndShowModal(modalid, modaltitle, modalbody, modalfooter, modalfooterclose, topclosebutton, modalbodyclass, modalheaderclass); };
    $$.UI.Modal.ModalQuickDismiss = function (modaltitle, modalbody, modalid = '', modaltohide = '', functiontodo = '', conditiontrue = true) { return ModalQuickDismiss(modaltitle, modalbody, modalid, modaltohide, functiontodo, conditiontrue) };
    $$.UI.Modal.ModalContinueCancel = function (modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext = 'Cancel', continuebuttontext = 'Continue', continuebuttoncss = 'btn btn-danger', cancelbuttoncss = 'btn btn-warning') { return ModalContinueCancel(modalid, modaltitle, modalbody, continuebuttononclick, cancelbuttontext, continuebuttontext, continuebuttoncss, cancelbuttoncss); };
    $$.UI.Modal.hide = function (modalid) { return hidemodal(modalid); };
    $$.UI.Modal.show = function (modalid) { return showmodal(modalid); };
    $$.UI.col = function (content = '', additionalclass = '') { return col(content, additionalclass); };
    $$.UI.row = function (content = '', additionalclass = '', hidden = false, style = '') { return row(content, additionalclass, hidden, style); };
    $$.UI.dualcolrow = function (colcontent1, colcontent2, rowclass = '', hidden = false, style = '') { return dualcolrow(colcontent1, colcontent2, rowclass, hidden, style); };
    $$.UI.Button = {};
    $$.UI.Button.Default = function (content, value = '', onclick = '', idtext = '', setclass = '', addtionaldata = '') { return button(content, value, onclick, idtext, setclass, addtionaldata); };
    $$.UI.Button.Warning = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonwarning(content, value, onclick, block, idtext, addclass, addtionaldata); };
    $$.UI.Button.Danger = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttondanger(content, value, onclick, block, idtext, addclass, addtionaldata); };
    $$.UI.Button.Primary = function (content, value = '', onclick = '', block = '', idtext = '', addclass = '', addtionaldata = '') { return buttonprimary(content, value, onclick, block, idtext, addclass, addtionaldata); };
    $$.UI.Button.HomeMenuButtons = function (buttonicon, buttonText, buttonGo, buttonVariabletoPass = '', iconwidth = '', iconheight = '', buttonstyle = '', buttononclick = '', divclass = '', divid = '', buttonid = '', textclass = '') { return HomeMenuButtons(buttonicon, buttonText, buttonGo, buttonVariabletoPass, iconwidth, iconheight, buttonstyle, buttononclick, divclass, divid, buttonid, textclass); };
    $$.UI.Input = {};
    $$.UI.Input.textInput = function (idtext = '', setclass = '', required = '', placeholder = '', value = '') { return textinput(idtext, setclass, required, placeholder, value); };
    $$.UI.Input.textFormControl = function (idtext = '', addclass = '', required = '', placeholder = '', value = '') { return textformcontrol(idtext, addclass, required, placeholder, value); };
    $$.UI.Card = {};
    $$.UI.Card.Create = function (cardtitle = '', cardid = '', cardtools = '', cardbodyid = '', cardbodytext = '', cardbodyclassadd = '', maincardstyle = '', titlecardhide = false) { return createCard(cardtitle, cardid, cardtools, cardbodyid, cardbodytext, cardbodyclassadd, maincardstyle, titlecardhide); };
    $$.UI.Card.Simple = function (title = '', text = '', id = '') { return CreateCardSimple(title, text, id); };
    $$.UIalt = {};
    $$.UIalt.hrefonclickButtonGO = function (pagename, pagedatastring = '') { return hrefonclickButtonGO(pagename, pagedatastring); };
    $$.UIalt.generateHTMLfromarray = function (prepend, append, array, func) { return generateHTMLfromarray(prepend, append, array, func); };
    $$.UIalt.imgiconuserdefault = function (imgsrc, imgwidth = '', imgheight = '', id = '') { return imgiconuserdefault(imgsrc, imgwidth, imgheight, id); };
    $$.UIalt.UICardStats = {};
    $$.UIalt.UICardStats.UICardStatsDetails = function (Title = '', number = 0, Unit = '', leftORright = 'left', numberid = '') { return UICardStatsDetails(Title, number, Unit, leftORright, numberid); };
    $$.UIalt.UICardStats.UIStatsDetailsArray = function (statsarray) { return UIStatsDetailsArray(statsarray); };
    $$.UIalt.BalanceCard = {};
    $$.UIalt.BalanceCard.UIBalance_WrapperfromArray = function (statsarray) { return UIBalance_WrapperfromArray(statsarray); };
    $$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item = function (maintitle = '', onclickstring = '', imgsrc = '', href = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '', imgwidth = '', imgheight = '') { return UIBalance_Wrapper_WalletFooter_Item(maintitle, onclickstring, imgsrc, href, subtitleline1, subtitleline2, subtitleline3, subtitleline4, imgwidth, imgheight); };
    $$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_Item_ButtonGO = function (maintitle, pagename, pagestring = '', iconclass = '', subtitleline1 = '', subtitleline2 = '', subtitleline3 = '', subtitleline4 = '') { return UIBalance_Wrapper_WalletFooter_Item_ButtonGO(maintitle, pagename, pagestring, iconclass, subtitleline1, subtitleline2, subtitleline3, subtitleline4); };
    $$.UIalt.BalanceCard.UIBalance_Wrapper_WalletFooter_ARRAY = function (balancewrapper_item_array) { return UIBalance_Wrapper_WalletFooter_ARRAY(balancewrapper_item_array); };
    $$.UIalt.BalanceCard.UIcreateBalanceBoxfromArray = function (statsarray, balancewrapper_item_array, style = 'border: solid 3px #000d88;') { return UIcreateBalanceBoxfromArray(statsarray, balancewrapper_item_array, style); };
    $$.UIalt.Services = {};
    $$.UIalt.Services.Button = function (imgiconsrc, title = '', onclick = '', href = '', bgcolor8 = false) { return UIServices_Button(imgiconsrc, title, onclick, href, bgcolor8); };
    $$.UIalt.Services.Button_GOTOPAGE = function (imgiconsrc, title, pagename, pagedatastring = '') { return UIServices_Button_GOTOPAGE(imgiconsrc, title, pagename, pagedatastring); };
    $$.UIalt.Services.FullDIV_GOTOPAGE_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_GOTOPAGE_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
    $$.UIalt.Services.FullDIV_ONCLICK_Array = function (title, viewallhref = '', viewallonclick = '', viewalltext = '', services_button_array) { return UIServices_FullDIV_ONCLICK_Array(title, viewallhref, viewallonclick, viewalltext, services_button_array); };
    $$.UIalt.Sidetext = {};
    $$.UIalt.Sidetext.UISideText_DualColumnButton = function (text, pagename, pagedatastring = '', imgsrc = '', imgwidth = '', imgheight = '') { return UISideText_DualColumnButton(text, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
    $$.UIalt.Sidetext.UISideText_DualColumnButton_Array = function (sidetext_button_dualcolumn_array) { return UISideText_DualColumnButton_Array(sidetext_button_dualcolumn_array); };
    $$.UIalt.UICardSimple = function (title, text = '', id = '') { return UICardSimple(title, text, id); };
    $$.UIalt.RecentSearchBar = {};
    $$.UIalt.RecentSearchBar.SearchBar = function (searchplaceholdertext, classtosearch, id, imgsrclefticon = '', imgsrcrighticon = '', imgwidth = '', imgheight = '') { return UIRecentSearchBar(searchplaceholdertext, classtosearch, id, imgsrclefticon, imgsrcrighticon, imgwidth, imgheight); };
    $$.UIalt.RecentSearchBar.Searchable_Button_GO = function (title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIRecentSearchable_Button_GO(title, subtitle, rightsidetext, classforsearch, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
    $$.UIalt.RecentSearchBar.Searchable_Button_GO_ARRAY = function (title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata = '', viewalltext = '') { return UIRecentSearchable_Button_GO_ARRAY(title, recentssearchablebuttonarray, viewallpagetarget, viewallpagedata, viewalltext); };
    $$.UIalt.UIListArrowButton_GO = function (title, subtitle, pagename, pagedatastring = '', imgsrc, imgwidth = '', imgheight = '') { return UIListArrowButton_GO(title, subtitle, pagename, pagedatastring, imgsrc, imgwidth, imgheight); };
    $$.UIalt.RecentSearchBar.SearchBox_with_BUTTONS_FULL = function (title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY = '', viewallpagetarget, viewallpagedata = '', viewalltext = '', classtosearch = '', searchid = '', searchplaceholdertext = '', searchlefticon = '', searchrighticon = '', imgwidth = '', imgheight = '') { return UISearchBox_with_BUTTONS_FULL(title, recentssearchablebuttonarray, UIListArrowButtonGOARRAY, viewallpagetarget, viewallpagedata, viewalltext, classtosearch, searchid, searchplaceholdertext, searchlefticon, searchrighticon, imgwidth, imgheight); };
    $$.UIalt.Input = {};
    $$.UIalt.Input.InputGroupCore = function (innerhtml = '', label = '', inputgroupid = '') { return UIinputgroupcore(innerhtml, label, inputgroupid); };
    $$.UIalt.Input.InputGroup = function (placeholder, type, id, label = '', classinput = '', spanclass = '', imginsteadofspan = '', required = false, textvalue = '') { return UIInputGroup(placeholder, type, id, label, classinput, spanclass, imginsteadofspan, required, textvalue); };
    $$.UIalt.Input.InputGroupSelect = function (id = '', label = '', optionsarray = '', spanclass = '', imginsteadofspan = '', selectedvalue = '') { return UIInputGroupSelect(id, label, optionsarray, spanclass, imginsteadofspan, selectedvalue); };
    $$.UIalt.Input.InputGroupDatePicker = function () { return UIInputGroupDatePicker(); };
    $$.UIalt.Input.ArraytoOptionforSelect = function (array, selectedvalue = '') { return UIArraytoOptionforSelect(array, selectedvalue); };
    $$.UIalt.Input.ReplaceCurrentOptionsSelect = function (selectid, optionsarray, selectedvalue = '') { return UIReplaceCurrentOptionsSelect(selectid, optionsarray, selectedvalue); };
    $$.UIalt.Input.InputGroupButton = function (buttontext, buttonclass = '', buttonid = '', onclick = '', buttonstyle = '') { return UIInputGroupButton(buttontext, buttonclass, buttonid, onclick, buttonstyle); };
    $$.UIalt.UISetDarkMode = function () { return UISetDarkMode(); };
    $$.UIalt.UIUpdateBodyHTML = function (html = '') { return UIUpdateBodyHTML(html); };
    $$.UIalt.changeTopbarTitle = function (title) { return changeTopbarTitle(title); };
    $$.StatusIntToString = function (Status) { return InttoStrDetailsFuncs.Status(Status); };
    $$.StatusPropertiesIntToString = function (Status) { return InttoStrDetailsFuncs.PropertyStatus(Status); };
</script>
<script>
    Target_Uploaded_Files = [];
    LoadDataPageFunc = {};
    LoadDataPageFunc.Settings = {};
    LoadDataPageFunc.PageTitle = 'Property Details';
    LoadDataPageFunc.currentTargetPage = 'ReferProperty';

    LoadDataPageFunc.URLs = {};
    LoadDataPageFunc.URLs.MainData = '/View/Property/Details';
    LoadDataPageFunc.URLs.AddLog = '/View/Property/Details/Logs/Add';
    LoadDataPageFunc.URLs.SubmitEdit = '/View/Property/Details/Edit/Submit';
    LoadDataPageFunc.URLs.ChangeStatus = '/View/Property/Details/ChangeStatus'

    LoadDataPageFunc.ids = {};
    LoadDataPageFunc.ids.ViewPropertyContainer = "viewContainer";
    LoadDataPageFunc.ids.ViewDetailsLogsContainer = 'ViewDetailsLogsContainer';
    LoadDataPageFunc.ids.ViewPropertyCard = 'ViewPropertyCard';
    LoadDataPageFunc.ids.ViewPropertyDetailsCardBody = 'ViewPropertyDetailsCardBody';
    LoadDataPageFunc.ids.PreviousLogsPage = 'prevBtnLogsPropertyDetailsPage';
    LoadDataPageFunc.ids.NextLogsPage = 'nextBtnLogsPropertyDetailsPage';
    LoadDataPageFunc.ids.ChangeStatus_Select = 'ViewPropertyDetails_ChangeStatus_Select';

    LoadDataPageFunc.onclicks = {};
    LoadDataPageFunc.onclicks.SubmitReferral = 'LoadDataPageFunc.EditDetails.NewReferralModal();';


    LoadDataPageFunc.Logs = {};
    LoadDataPageFunc.Logs.Pagination = {};


    LoadDataPageFunc.Logs.Pagination.cardsPerPage = 5;
    LoadDataPageFunc.Logs.Pagination.currentPage = 1;

    LoadDataPageFunc.Logs.LogRowCard = function (Date = '', content = '') {
        content = replaceLineBreaks(content);
        return (UICardSimple('', formatDateTimetoReadable(Date) + '<br><br><h4>' + content + '</h4>'));
    };

    LoadDataPageFunc.Logs.Pagination.PageArray = function () {
        return divideArrayIntoSets(LoadDataPageFunc.Logs.LogsCardRowHTMLArray, LoadDataPageFunc.Logs.Pagination.cardsPerPage);
    };

    LoadDataPageFunc.Logs.Pagination.Firstpage = 1;
    LoadDataPageFunc.Logs.Pagination.Lastpage = function () {
        return LoadDataPageFunc.Logs.Pagination.PageArray().length;
    };

    LoadDataPageFunc.Logs.LogsCardRowHTMLArray = [];


    LoadDataPageFunc.Logs.Pagination.FirstPageFound = function () {
        $('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
        $('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
    };
    LoadDataPageFunc.Logs.Pagination.LastPageFound = function () {
        $('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
        $('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
    };

    LoadDataPageFunc.Logs.Pagination.MiddlePageFound = function () {
        $('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', false);
        $('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', false);
    };

    LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound = function () {
        $('#' + LoadDataPageFunc.ids.NextLogsPage).prop('disabled', true);
        $('#' + LoadDataPageFunc.ids.PreviousLogsPage).prop('disabled', true);
    };

    LoadDataPageFunc.Logs.LogRowHtmlPage = function (page = 1) {
        if (page) { LoadDataPageFunc.Logs.Pagination.currentPage = page; }

        let arrayset = LoadDataPageFunc.Logs.Pagination.PageArray();
        let newpageindex = LoadDataPageFunc.Logs.Pagination.currentPage - 1;


        if (!isIndexAccessibleArray(arrayset, newpageindex)) {
            return false;
        }
        LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(page);

        let targetarr = arrayset[newpageindex];
        const htmlstr = targetarr.join('<br>');

        $('#' + LoadDataPageFunc.ids.ViewDetailsLogsContainer).html(htmlstr);
    };

    LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton = function (newpage) {
        if (newpage <= LoadDataPageFunc.Logs.Pagination.Firstpage) { LoadDataPageFunc.Logs.Pagination.FirstPageFound(); }
        else if (newpage >= LoadDataPageFunc.Logs.Pagination.LastPageFound()) {
            LoadDataPageFunc.Logs.Pagination.FirstPageFound();
        } else if (LoadDataPageFunc.Logs.Pagination.Lastpage() == 1) {
            LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
        } else if (newpage > LoadDataPageFunc.Logs.Pagination.Firstpage && newpage < LoadDataPageFunc.Logs.Pagination.Lastpage()) {
            LoadDataPageFunc.Logs.Pagination.MiddlePageFound();
        }

        if (LoadDataPageFunc.Logs.Pagination.Lastpage() === 1) {
            LoadDataPageFunc.Logs.Pagination.OnlyOnePageFound();
        }
    };

    LoadDataPageFunc.Logs.changePage = function (forwardORBackward) {
        if (!forwardORBackward) { return false; }

        let newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
        if (forwardORBackward === -1) { newpage = newpage - 1; }
        else if (forwardORBackward === 1) { newpage = newpage + 1; }
        if (newpage < LoadDataPageFunc.Logs.Pagination.Firstpage || newpage > LoadDataPageFunc.Logs.Pagination.Lastpage()) {
            newpage = LoadDataPageFunc.Logs.Pagination.currentPage;
            return false;
        }

        LoadDataPageFunc.Logs.Pagination.DetectAndTogglePageButton(newpage);
        LoadDataPageFunc.Logs.Pagination.currentPage = newpage;

        // Load the new page
        LoadDataPageFunc.Logs.LogRowHtmlPage(newpage);
    };


    LoadDataPageFunc.Logs.LogFullCard = function (obj) {
        if (!obj.logs) { return ''; }
        LoadDataPageFunc.LogsCardRowHTMLArray = [];
        let newlogfullarr = [];
        if (obj.logs && Array.isArray(obj.logs)) {
            newlogfullarr.push('<br><br><div id="' + LoadDataPageFunc.ids.ViewDetailsLogsContainer + '">');
            let logrow = '';

            const reversedLogs = [...obj.logs].reverse();

            for (let log of reversedLogs) {
                logrow = LoadDataPageFunc.Logs.LogRowCard(log[0], log[1]);
                LoadDataPageFunc.Logs.LogsCardRowHTMLArray.push(logrow);
                //    newlogfullarr.push(logrow);
            }
        }
        newlogfullarr.push('</div>');

        return newlogfullarr.join('');

    };

    LoadDataPageFunc.RefetchDataAndReload = function (istrue = true) {
        if (!istrue) { return false; }
        Preloaders.ViewPropertyDetailsData(currenttarget, false,
            function (response) {
                ReloadPage();
            }
        );
    };

    LoadDataPageFunc.DetailsCardControls = function () {
        let buttonLImaker = function (text, onclick, icon) {
            return `<li><a href="javascript:void(0);" onclick="${onclick}"><div class="icon-box "><img src="/assets/${icon}"></div>${text}</a></li>`;
        };
        let htmlarr = [`<div class="mt-5"><div class="tf-container">`];
        htmlarr.push('<ul class="box-service mt-3">');
        htmlarr.push(buttonLImaker('Interested', LoadDataPageFunc.onclicks.SubmitReferral, 'edit.png'));
        htmlarr.push(buttonLImaker('View More Properties', `window.location.href=window.location.origin+'/r/${LoadDataPageFunc.ReferralCode}'`, 'ListLeads.png'));
        htmlarr.push('</ul</div></div>');
        return htmlarr.join('');
    };

    LoadDataPageFunc.getReferralCode = function () {
    const urlObj = window.location.pathname;
    const segments = urlObj.split('/'); 
    const drIndex = segments.indexOf('dr');
    if (drIndex !== -1 && drIndex + 1 < segments.length) {
        return segments[drIndex + 1]; 
    }
    return null;
}



 

    LoadDataPageFunc.Details = {};
    LoadDataPageFunc.Details.Status = '';
    LoadDataPageFunc.ids.PhotosShowCard = 'PhotosCard';

    LoadDataPageFunc.PropertyDetailsCard = function (obj) {
        if (!obj) { return false; }

        let rowcoldetail = [];
        const imgwidth = '200px'; const imgheight = "200px";
        if (!obj) { rowcoldetail = 'No Data'; return createCard('Unknown', cardid = 'PropertyRowCard-' + rownum, '', cardbodyid = '', rowcoldetail, cardbodyclassadd = 'ListPropertyRow'); }

        let created = obj.created || false;
        let modified = obj.modified || false;
        let name = obj.name || false;
        let description = obj.description || false;
        let status = obj.status || false;
        let remarks = obj.remarks || false;
        let referralid = obj.referralid || false;
        let createdby = obj.createdby || false;
        let category = obj.category || '';
        let subcategory = obj.subcategory || '';
        let photourl = obj.photourl || false;
        let sqm = obj.sqm || false;
        let bedrooms = obj.bedrooms || false;
        let rooms = obj.rooms || false;
        let toilet = obj.toilet || false;
        let kitchen = obj.kitchen || false;
        let floors = obj.floors || false;
        let price = obj.price || false;
        let specs = obj.specs || false;
        let location = obj.location || false

        status = InttoStrDetailsFuncs.PropertyStatus(status);
        modified = formatDateTimetoReadable(modified);
        created = formatDateTimetoReadable(created);

        try { photourl = JSON.parse(photourl); } catch (e) { photourl = photourl; }

        //LoadDataPageFunc.Details.Status = Status;

        const AddDualColifValue = function (varstr, label) {
            if (varstr !== false && varstr !== null) {
                rowcoldetail.push(dualcolrow(label, varstr));
            }
        };

        rowcoldetail.push(createCard('', LoadDataPageFunc.ids.PhotosShowCard, '', LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, '', '', '', true));
        rowcoldetail.push('<br><br>');
        AddDualColifValue(subcategory, category);
        AddDualColifValue(location, 'Location');
        AddDualColifValue(sqm, 'Size');
        AddDualColifValue(bedrooms, 'Bedrooms');
        AddDualColifValue(rooms, 'Rooms');
        AddDualColifValue(toilet, 'Toilet');
        AddDualColifValue(kitchen, 'Kitchen');
        AddDualColifValue(floors, 'Floors');
        AddDualColifValue(price, 'Price');
        rowcoldetail.push('<br><br>');

        rowcoldetail.push(LoadDataPageFunc.DetailsCardControls());
        //rowcoldetail.push(LoadDataPageFunc.Logs.LogFullCard(obj));

        const finalRowColDetail = rowcoldetail.join('');

        let ViewPropertyCardDetails = createCard(name, LoadDataPageFunc.ids.ViewPropertyCard, created, LoadDataPageFunc.ids.ViewPropertyDetailsCardBody, cardbody = finalRowColDetail);
        return ViewPropertyCardDetails;
    };

    


    LoadDataPageFunc.LoadPhotosCard = async function () {
        let photosdiv = $('#' + LoadDataPageFunc.ids.PhotosShowCard);
        if (photosdiv.length === 0) { return false; }
        if (!LoadDataPageFunc.Details.photourl) { photosdiv.html('No Photos.<br>'); return false; }
        let photolist = JSON.parse(LoadDataPageFunc.Details.photourl);
        if (!photolist || photolist.length === 0) { photosdiv.html('No Photos.<br>'); return false; }
        let htmlbody = $(`<div class="splide" role="group" aria-label="photosSplide">
            <div class="splide__track">
		<ul class="splide__list">
		</ul> </div></div>`);
        const NewSplideLIImage = function (imgsrc) {
            return `<li class="splide__slide" onclick="ButtonGo('ViewAllPhotos','${currenttarget}');"><img src="${imgsrc}" style="max-width: 300px; 
            max-height: 300px; 
            width: auto; 
            height: auto;"></li>`;
        };
        let splidebody = htmlbody.find('ul');
        LoadDataPageFunc.PhotoBlobs = [];
        photolist.forEach(function (photo) {
            LoadAndCreateURLfromFileHash(photo).then(bloburl => {
                splidebody.append(NewSplideLIImage(bloburl));
                LoadDataPageFunc.PhotoBlobs.push(bloburl);
            });
        });

        photosdiv.html(htmlbody);

        new Splide('.splide').mount();
    };



   


    LoadDataPageFunc.vars = {};
    LoadDataPageFunc.vars.idprefix = 'ReferProperty';
    LoadDataPageFunc.ids.SubmitReferral = LoadDataPageFunc.vars.idprefix + '_ReferProperty';
    LoadDataPageFunc.EditDetails = {};

    LoadDataPageFunc.ids.EditDetailsMidfix = '-EditDetails';
    LoadDataPageFunc.ids.EditDetails_name = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyName';
    LoadDataPageFunc.ids.EditDetails_Description = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'PropertyDescription';
    LoadDataPageFunc.ids.EditDetails_Remarks = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Remarks';
    LoadDataPageFunc.ids.EditDetails_Location = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Location';
    LoadDataPageFunc.ids.EditDetails_Category = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Category';
    LoadDataPageFunc.ids.EditDetails_SubCategory = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'SubCategory';
    LoadDataPageFunc.ids.EditDetails_sqm = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'sqm';
    LoadDataPageFunc.ids.EditDetails_Bedrooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Bedrooms';
    LoadDataPageFunc.ids.EditDetails_Rooms = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Rooms';
    LoadDataPageFunc.ids.EditDetails_Toilet = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Toilet';
    LoadDataPageFunc.ids.EditDetails_Kitchen = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Kitchen';
    LoadDataPageFunc.ids.EditDetails_Floors = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Floors';
    LoadDataPageFunc.ids.EditDetails_Price = LoadDataPageFunc.vars.idprefix + LoadDataPageFunc.ids.EditDetailsMidfix + 'Price';

    LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone = 'newpropertydropzonephoto';
    LoadDataPageFunc.ids.EditDetailsReplacePhotosButton = 'EditDetailsreplacePhotos';

    LoadDataPageFunc.EditDetails.InitializePhotoDropZone = function () {
        Target_Uploaded_Files = [];
        myDropzone = null;
        currentDropzone = DropZoneFunc.InitializeDropZone('/File/Upload/Property', (response) => {
            if (response.length === 72) {
                Target_Uploaded_Files.push(response);
                LoadDataPageFunc.ShowPhotoClearButton();
            } else {
                currentDropzone.removeFile(currentDropzone.files[currentDropzone.files.length - 2]);
            }
        }, LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone, DropZoneFunc.AcceptedFilesString.images, 'file', maxfilesize = 100);
    };


    LoadDataPageFunc.ids.ClearPhotosButton = 'newpropertydropzoneclearbutton';

    LoadDataPageFunc.ShowPhotoClearButton = function () {
        $('#' + LoadDataPageFunc.ids.ClearPhotosButton).show();
    };
    LoadDataPageFunc.ClearPhotos = function () {
        DropZoneFunc.ClearDropzoneUpload();
        LoadDataPageFunc.HidePhotoClearButton();
    };

    LoadDataPageFunc.HidePhotoClearButton = function () {
        $('#' + LoadDataPageFunc.ids.ClearPhotosButton).hide();
    };

    LoadDataPageFunc.NewLeadsvalidateForm=function () {
        let fullname = $('#ReferProperty-SendDetailsFullname').val();
        let mobile = $('#ReferProperty-SendDetailsmobile').val();
        let landline = $('#ReferProperty-SendDetailslandline').val();
        let email = $('#ReferProperty-SendDetailsemail').val();
        let preferreddate = $('#ReferProperty-SendDetailspreferreddate').val();
        let preferredsite = $('#ReferProperty-SendDetailsPreferredSite').val();
        let ReferralCode = LoadDataPageFunc.ReferralCode;
        if (!fullname || !mobile || !email) { return false; }
        if (!hasValidMobileFormat(mobile)) { return false; }
        if (!isValidEmail(email)) { return false; }

        return { referralcode:ReferralCode, fullname: fullname, mobile: mobile, landline: landline, email: email, preferred_date: preferreddate, preferred_site: preferredsite };
    }

    LoadDataPageFunc.SubmitNewLead=function(){
        const ValidateData=LoadDataPageFunc.NewLeadsvalidateForm();
        if (!ValidateData) {
            ModalQuickDismiss('Invalid/Incomplete', 'The following are required<br><br>Fullname<br>11 Digits Mobile Number<br>Correct Email<br><br>Please Input the following properly if not done so. Thank you.');
            return false;
        }

        request.type('POST').data(ValidateData).url('/refer/submit').fromVarCache(false).success((response) => {
            
            if (response === true) {
                ModalQuickDismiss('Success', 'You will be contacted Shortly. Thank you.', 'NewLeadsModalSuccess', modaltohide = '', function () {
                    hidemodal('ReferProperty_ReferProperty');
                    ReloadPage();
                });
                
            }
            else if (response === false) {
                ModalQuickDismiss('Error', 'Unable to Submit. Try Again Later', 'NewPropertysModalError');
            }

        }).error((errorstring) => {
            ModalQuickDismiss('Error', 'An Error Occured<br>' + errorstring + '<br><br>Please Try Again Later');
        }).go()

    };

    LoadDataPageFunc.EditDetails.NewReferralModal = function () {
        Target_Uploaded_Files = [];
        $('#' + LoadDataPageFunc.ids.SubmitReferral).remove();

        const SubmitOnclick = '';
        const targetdiv = 'modal-body-' + LoadDataPageFunc.ids.SubmitReferral;
        let FormHTML = ReusableUIElements.NewLeadsGenerateUI(targetdiv, idprefix = LoadDataPageFunc.vars.idprefix + '-SendDetails', replace = false,
            '','','','','',LoadDataPageFunc.Details.hashkey,'LoadDataPageFunc.SubmitNewLead();',true);
        const footer = buttonprimary('Submit', '', onclick = 'LoadDataPageFunc.SubmitNewLead();');
        const modalhtml = $$.UI.Modal.Create(LoadDataPageFunc.ids.SubmitReferral, 'Contact Details', FormHTML, footer);
        $$.UI.Element.appendtobody(modalhtml);
        const replacePhotosButton = buttonprimary('Replace Photos', value = '', onclick = 'LoadDataPageFunc.EditDetails.ShowPhotoUploadButton();', block = '', LoadDataPageFunc.ids.EditDetailsReplacePhotosButton);
        $('#ViewProperty-EditDetailsNewPropertyPhotosInputGroup').append(replacePhotosButton);
        $('#' + LoadDataPageFunc.ids.EditDetailsUploadPhotoDropzone).hide();
        $('#ViewProperty-EditDetailsStatus-select-div-mb3').remove();
        $('label[for="ViewProperty-EditDetailsStatus-select-div-mb3"]').remove();


        Preloaders.Datalist.NewPropertyCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertyCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
        Preloaders.Datalist.NewPropertySubCategory(function () { ReqCachetoDatalist('/Datalist/NewPropertySubCategory', 'ViewProperty-EditDetailsSubCategory', replace = true); });
        $('#ReferProperty-SendDetailssubmit_Lead_button').hide();

        showmodal(LoadDataPageFunc.ids.SubmitReferral);

        requestWHash.type('POST').url('/NewLeads/Form/PreferredSitesOption').fromVarCache(true).success((response) => {
            UIReplaceCurrentOptionsSelect('ReferProperty-SendDetailsPreferredSite', response);
            $('#ReferProperty-SendDetailsPreferredSite').val(LoadDataPageFunc.Details.hashkey);
            $('#ReferProperty-SendDetailsPreferredSite').prop('disabled',true);
        }).go();


    };



    LoadDataPageFunc.EditDetails.GetChanges = function () {
        let objectdata = {};
        objectdata.target = currenttarget;
        const new_name = $('#' + LoadDataPageFunc.ids.EditDetails_name).val();
        const new_description = $('#' + LoadDataPageFunc.ids.EditDetails_Description).val();
        const new_remarks = $('#' + LoadDataPageFunc.ids.EditDetails_Remarks).val();
        const new_location = $('#' + LoadDataPageFunc.ids.EditDetails_Location).val();
        const new_category = $('#' + LoadDataPageFunc.ids.EditDetails_Category).val();
        const new_subcategory = $('#' + LoadDataPageFunc.ids.EditDetails_SubCategory).val();
        let new_sqm = Number($('#' + LoadDataPageFunc.ids.EditDetails_sqm).val());
        let new_bedroom = Number($('#' + LoadDataPageFunc.ids.EditDetails_Bedrooms).val());
        let new_rooms = Number($('#' + LoadDataPageFunc.ids.EditDetails_Rooms).val());
        let new_toilet = Number($('#' + LoadDataPageFunc.ids.EditDetails_Toilet).val());
        let new_kitchen = Number($('#' + LoadDataPageFunc.ids.EditDetails_Kitchen).val());
        let new_floors = Number($('#' + LoadDataPageFunc.ids.EditDetails_Floors).val());
        let new_price = Number($('#' + LoadDataPageFunc.ids.EditDetails_Price).val());

        let changes = 0;

        if (LoadDataPageFunc.Details.name !== new_name) { objectdata.name = new_name; changes++; }
        if (LoadDataPageFunc.Details.description !== new_description) { objectdata.description = new_description; changes++; }
        if (LoadDataPageFunc.Details.remarks !== new_remarks) { objectdata.remarks = new_remarks; changes++; }
        if (LoadDataPageFunc.Details.location !== new_location) { objectdata.location = new_location; changes++; }
        if (LoadDataPageFunc.Details.category !== new_category) { objectdata.category = new_category; changes++; }
        if (LoadDataPageFunc.Details.subcategory !== new_subcategory) { objectdata.subcategory = new_subcategory; changes++; }
        if (LoadDataPageFunc.Details.sqm !== new_sqm) { objectdata.sqm = new_sqm; changes++; }
        if (LoadDataPageFunc.Details.bedrooms !== new_bedroom) { objectdata.bedrooms = new_bedroom; changes++; }
        if (LoadDataPageFunc.Details.rooms !== new_rooms) { objectdata.rooms = new_rooms; changes++; }
        if (LoadDataPageFunc.Details.toilet !== new_toilet) { objectdata.toilet = new_toilet; changes++; }
        if (LoadDataPageFunc.Details.kitchen !== new_kitchen) { objectdata.kitchen = new_kitchen; changes++; }
        if (LoadDataPageFunc.Details.floors !== new_floors) { objectdata.floors = new_floors; changes++; }
        if (LoadDataPageFunc.Details.price !== new_price) { objectdata.price = new_price; changes++; }
        if (Target_Uploaded_Files.length > 0) { objectdata.photourl = JSON.stringify(Target_Uploaded_Files); changes++; }
        if (!changes) { return null; }
        if (!new_name || !new_description || !new_location || !new_sqm) {
            return false;
        }

        return objectdata;
    };


    LoadDataPageFunc.EditDetails.Submit = function () {

        let ChangesObject = LoadDataPageFunc.EditDetails.GetChanges();
        if (ChangesObject === null) { $$.UI.Modal.ModalQuickDismiss('No Changes', 'No Changes to Update!'); return false; }
        if (ChangesObject === false) { $$.UI.Modal.ModalQuickDismiss('', 'Incomplete Details!<br>The following are required!<br><br>Property Name<br>Description<br>Location<br>Size in sqm'); return false; }
        if (Target_Uploaded_Files.length == 0) { $$.UI.Modal.ModalQuickDismiss('', 'No New Photos Uploaded!<br>Previous Photos Would be used!',); }
        let SendUpdatedDetails = new RequestData(false);
        request
            .url(LoadDataPageFunc.URLs.SubmitEdit)
            .type(LoadDataPageFunc.Settings.RequestType)
            .fromVarCache(false)
            .data(ChangesObject)
            .success((response) => {
                if (!response) { return false; }
                const error = response.error || false;
                if (response !== true) {
                    if (error) { $$.UI.Modal.ModalQuickDismiss('Error', error); }
                    return false;
                } else if (response === true) {
                    LoadDataPageFunc.RefetchDataAndReload(true);
                    ReloadPage();
                    hidemodal(LoadDataPageFunc.ids.SubmitReferral);
                    $$.UI.Modal.ModalQuickDismiss('Success', 'Details Updated');
                }
            })
            .error((err) => {
                ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
            })
            .go();

    };


    LoadDataPageFunc.Settings = {};


    LoadDataPageFunc.Settings.RequestType = 'POST';
    LoadDataPageFunc.Settings.fromVarCache = true;
    LoadDataPageFunc.DefaultDatatoSend = function () {
        return { target: currenttarget };
    };
    LoadDataPageFunc.LoadMainDetails = {};
    LoadDataPageFunc.LoadMainDetails.OnSuccess = function (response) {
        if (!response) { ModalQuickDismiss('Error', 'No Data Loaded<br>'); return ''; }
        LoadDataPageFunc.PropertyCurrentDetails = response.Details;

        LoadDataPageFunc.Details = response.Details;
        $('#' + LoadDataPageFunc.ids.ViewPropertyContainer).html(LoadDataPageFunc.PropertyDetailsCard(response.Details));
        LoadDataPageFunc.Logs.LogRowHtmlPage();
        LoadDataPageFunc.LoadPhotosCard();
    };

    LoadDataPageFunc.LoadMainDetails.OnError = function (err) { ModalQuickDismiss('Error', 'Unable to Load<br>' + err); };



    LoadDataPageFunc.LoadMainDetails.LoadNow = function () {

        let request = new RequestData(false);
        request
            .url(LoadDataPageFunc.URLs.MainData)
            .type(LoadDataPageFunc.Settings.RequestType)
            .fromVarCache(LoadDataPageFunc.Settings.fromVarCache)
            .data(LoadDataPageFunc.DefaultDatatoSend())
            .success((response) => {

                if (typeof LoadDataPageFunc === 'undefined' || LoadDataPageFunc.currentTargetPage === 'undefined') {
                    return false;
                }
                //console.log(response);
                if (currentPage !== LoadDataPageFunc.currentTargetPage) { return false; }

                LoadDataPageFunc.LoadMainDetails.OnSuccess(response);
            })
            .error((err) => {
                ModalQuickDismiss('Error', 'Unable to Load<br>' + err);
            })
            .go();
    };


    LoadDataPageFunc.main = function () {
        LoadDataPageFunc.LoadMainDetails.LoadNow();

        changeTopbarTitle(LoadDataPageFunc.PageTitle);


    };
    LoadDataPageFunc.ReferralCode = '';
    if (typeof ReferralCode !== 'undefined') {
        LoadDataPageFunc.ReferralCode = ReferralCode;
        history.replaceState({}, "ReferProperty", "/p/ReferProperty/s/" + currenttarget + "/dr/" + ReferralCode);
    }
    if (typeof ReferralCode === 'undefined'){
        ReferralCode = LoadDataPageFunc.getReferralCode();
        LoadDataPageFunc.ReferralCode = ReferralCode;
    }
    



        $(document).ready(function () {
            LoadDataPageFunc.main();


        });



</script>