var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

var weburl = window.location.host;
function showbumessage(title, text, buttontext, buttonaction) {
    $("#bumessagetitle").html(title);
    $("#bumessagetext").html(text);
    $("#bumessagebutton").html(buttontext);
//    $("#bumessagebutton").text(buttontext);

    $.fancybox({
        padding: 0,
        closeBtn: false,
        href: '#bumessage',
        wrapCSS: 'fancy-single fancy-form',
        scrolling: false
    });
}
//SRF 1698 (modalbox) Boon.
function showbumodalbox(modeltext, modeltitle, buttontextleft, buttontextright, buttonaction) {
    $("#bumodeltitle").html(modeltext);
    $("#bumodeltext").html(modeltitle);
    $("#bumessagebuttonleft").html(buttontextleft);
    $("#bumessagebuttonright").html(buttontextright);

    $.fancybox({
        padding: 0,
        closeBtn: false,
        href: '#bumodalbox',
        width: 500,
        wrapCSS: 'fancy-single fancy-form',
        scrolling: false
    });
}

//Ticket 1476. function used to check how many characters used in the given max limit and show the remaining characters
function textCounter(txtbox, Counterlbl, maxlimit) {
    // get the count field
    var countfield = document.getElementById(Counterlbl);
    var textboxValue = "";
    var textboxValueLength = "";
    // get the textarea value.
    textboxValue = txtbox.value;
    textboxValueLength = textboxValue.length;
    // get the no. of line breaks in the line
    var numberOfLineBreaks = (textboxValue.match(/\n/g) || []).length;
    // calculate no. of line breaks multiply 5 as text to be stored will have <br />
    textboxValueLength = textboxValueLength + (numberOfLineBreaks * 5);
    if (textboxValueLength  > maxlimit) {
        txtbox.value = textboxValue.slice(0, (maxlimit - textboxValueLength));
        return false;
    }
        // if maxlimit is reached then show the text in red color.
    else if (textboxValueLength == maxlimit) {
        $("#" + Counterlbl).css("color", "red");
        countfield.value = textboxValueLength;
    }
        // if textarea length is less than maxlimit then remove red color.
    else {
        $("#" + Counterlbl).css("color", "");
        countfield.value = textboxValueLength;
    }
    $("#" + Counterlbl).text(countfield.value + ' / ' + maxlimit);
}


// Checks to see if var is defined and has some value.
(function ($) {
    $.isBlank = function (obj) {
        return (!obj || $.trim(obj) === "");
    };
})(jQuery);

var _imagePath = "//" + weburl + "/Images/UserUploads/";
// website domain
if (weburl.toLowerCase().search("localhost") == 0) {
    WebsiteDomain = weburl.substring(0, weburl.indexOf(":")).toUpperCase();
    _webAPIUrl = "//" + weburl + "/api/propertySearch/";
    _SearchAgentwebAPIUrl = "//" + weburl + "/api/SearchAssistant/";
}
else {
    WebsiteDomain = weburl.substring(0, weburl.indexOf(".")).toUpperCase();
    _webAPIUrl = "//" + weburl + "/api/propertySearch/";
    _SearchAgentwebAPIUrl = "//" + weburl + "/api/SearchAssistant/";
}

	//Func to detect browser and verion
function msieversion() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");

    if (msie > 0)      // If Internet Explorer, return version number
	{
        return parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)));
	}
    else                 // If another browser, return 0
	{
        return 0;
	}
}

// Home buyer functionality 
function unSelectRadioName(radioName) {
    var list = $('[name="' + radioName + '"]');
    for (var i = 0; i < list.length; i++) {
        list[i].checked = false;
    }
    return '';
}

// Home buyer functionality 
function getSelectedValueFromRadioName( radioName ) {
    var list = $('[name="'+ radioName +'"]');
    var Checkdvalue;
    for (var i = 0; i < list.length; i++) {
        if (list[i].checked) {
            Checkdvalue = list[i];
            break;
        }
    }
    if (Checkdvalue) {
        return Checkdvalue.value;
    }
    return '';
}

/* Func returns &nbsp; if no value in variable */
function GetValueForDisplay(myvariable) {
	if (myvariable != null && myvariable != "") {
		return myvariable;
	}
	else 
	{
		return "&nbsp;";
	}
}
/* Show unknow if stories is 0 */
function GetValueForStories(myvariable) {
    if (myvariable != null && myvariable != "") {
        return myvariable;
    }
    else {
        return "Unknown";
    }
}

function ShowHideDiv(myVariable, divName) {
    if (myVariable== null || myVariable== '') {
        $("#"+divName).hide();
    } else {
        $("#"+divName).show();
    }
}
// Formats no as 111,111,111
function FormatThousands(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

function ShowNextPrev(count, currIndex, prevDiv, nextDiv) {
    $('#' + prevDiv).hide();
    $('#' + nextDiv).hide();
    if (count > 1 && currIndex > 0) {
        $('#' + prevDiv).show();
    }
    if (count != currIndex + 1 && count > 1) {
        $('#' + nextDiv).show();
    }
}
/*Func returns HTML string like 1 OF 1  for detail pages*/
function GetNavigatorForDetailPage(countOfProp, currIndex) {
    var navigatorVar = '';
    if (countOfProp == 0) {
        countOfProp = 1;
    }
    navigatorVar = (currIndex +1 )+ "&nbsp;<small> OF </small>&nbsp;" + countOfProp;
    return navigatorVar;
}
function GetFirstValidValue(val1, val2, val3, val4) {
    if (val1 != null && val1 != "") {
        return val1;
    } else if (val2 != null && val2 != "") {
        return val2;
    } else if (val3 != null && val3 != "") {
        return val3;
    } else  if (val4 != null && val4 != "") {
        return val4;
    }
}
function ShowSeparator(completionDate) {
    if (completionDate == '0001-01-01T00:00:00') {
        return false;
    } else {
        return true;
    }
}
function ReplaceWithBR(myVariable) {
    return myVariable.replace(/;/g, "<br>").replace(/\\n/g, "<br>").replace(/,/g, "<br>");
}

// maxrecipients 0 for unlimited.
// email value, max recipients number value
//Same logic as ValidateEmail
function ValidateEmailAlert(email, maxrecipients) {
    if (email == null || email == "") {
        alert('No Emails Entered');
        return false;
    }
    emailArr = email.split(",");
    if (emailArr.length == 0) {
        alert('No Emails Entered');
        return false;
    }
    if (maxrecipients > 0 && emailArr.length > maxrecipients) {
        alert('Max recipients allowed is ' + maxrecipients );
        return false;
    }

    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

    for (i = 0; i < emailArr.length; i++) {
        if (!emailReg.test(emailArr[i])) {
            alert('Invalid Email ' + emailArr[i] );
            return false;
        }
    }
    return true;
}

//Same logic as ValidateEmailAlert
// maxrecipients 0 for unlimited.
// email value, max recipients number value
function ValidateEmail(email, maxrecipients) {
    if (email == null || email == "") {
        showbumessage("<br/>", '<p style="color:white">No Emails Entered</p>', "okay", "");
        return false;
    }
    emailArr = email.split(",");
    if (emailArr.length == 0) {
        showbumessage("<br/>", '<p style="color:white">No Emails Entered</p>', "okay", "");
        return false;
    }
    if (maxrecipients > 0 && emailArr.length > maxrecipients) {
        showbumessage("<br/>", '<p style="color:white">Max recipients allowed is ' + maxrecipients + '</p>', "okay", "");
        return false;
    }

    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

    for (i = 0; i < emailArr.length; i++) {
        var EmailValidStatus = ValidateEmailFromMailGun(emailArr[i]);
        if (!emailReg.test(emailArr[i]) || !EmailValidStatus) {
            showbumessage("<br/>", '<p style="color:white">Invalid Email ' + emailArr[i] + '</p>', "okay", "");
            return false;
        }
    }
    return true;
}

function GetMonthYearStatus(completionDate) {
    var myVar;
    if (completionDate == '0001-01-01T00:00:00') {
        myVar="&nbsp;";
    }
    else {
        var d = [];
	d = completionDate.split('-');
        myVar = months[Number(d[1] - 1)] + "-" +d[0];
    }
    return myVar;
}
/* Func returns date in format mm/dd/yyyy @ hh:mm am/pm */
function GetFormattedDate(myvariable) {
    var formattedDate;
    myvariable.toString();
    myvariable = myvariable.replace('T', ' ');
    var r = myvariable.match(/^\s*([0-9]+)\s*-\s*([0-9]+)\s*-\s*([0-9]+)(.*)$/);
    var reshours = r[4].substring(1, 3);
    var resmin = r[4].substring(4, 6);
    var resssec = r[4].substring(7, 9);
    //Returns in this format: 03/17/2017 @ 12:00 AM CST
    if (reshours >= 12) { // For PM
        reshours = reshours - 12;
        if (reshours == 0) {
            reshours = 12;
        }
        formattedDate = r[2] + "/" + r[3] + "/" + r[1] + "&nbsp;@&nbsp;" + reshours + ":" + resmin + "&nbsp;PM CST";
    } else { // For AM
        if (reshours == 0) {
            reshours = 12;
        }
        formattedDate = r[2] + "/" + r[3] + "/" + r[1] + "&nbsp;@&nbsp;" + reshours + ":" + resmin + "&nbsp;AM CST";
    }
    return formattedDate;
}

/* Utility to display popup window in center of screen - arg title is ignored */
function PopupCenter(url, title, w, h) {
    // Fixes dual-screen position  Most browsers Firefox
    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

    width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
    height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
    var top = ((height / 2) - (h / 2)) + dualScreenTop;

    var newWindow = window.open(url, title, 'width=' + w + ', height=' + h + ', top=' + top + ', left=' + left + 'status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes').focus();
    if (typeof newWindow !== 'undefined'){
        newWindow.focus();
    }
    // Puts focus on the newWindow
//    if (newWindow newWindow.focus) {
  //      newWindow.focus();
 //   }
}
// Func to set seemore for text. 
function SetSeeMore( ) {
    $('.copy .seemoreremarks').readmore({
        maxHeight: 85,
        moreLink: '<a href="#">See More</a>',
        lessLink: '<a href="#">Close</a>'
    });
    $('.copy .seemoredirections').readmore({
        maxHeight: 70,
        moreLink: '<a href="#">See More</a>',
        lessLink: '<a href="#">Close</a>'
    });

    $('.copy .seemoresubdescription').readmore({
        maxHeight: 135,
        moreLink: '<a href="#">See More</a>',
        lessLink: '<a href="#">Close</a>'
    });
    $('.copy .seemoreschoolcomments').readmore({
        maxHeight: 70,
        moreLink: '<a href="#">See More</a>',
        lessLink: '<a href="#">Close</a>'
    });
}

/* Code to Format Phone number in the form of 999-999-9999  - BEGIN */
var zChar = new Array(' ', '(', ')', '-', '.');
var maxphonelength = 12;
var phonevalue1;
var phonevalue2;
var cursorposition;

function ParseForNumber1(object) {
    phonevalue1 = ParseChar(object.value, zChar);
}
function ParseForNumber2(object) {
    phonevalue2 = ParseChar(object.value, zChar);
}

function FormatPhoneUp(object, e) {

    if (e) {
        e = e
    } else {
        e = window.event
    }
    if (e.which) {
        var keycode = e.which
    } else {
        var keycode = e.keyCode
    }

    ParseForNumber1(object)

    if (keycode >= 48) {
        FormatPhone(object)
    }
}

function FormatPhoneDown(object, e) {
    if (e) {
        e = e
    } else {
        e = window.event
    }
    if (e.which) {
        var keycode = e.which
    } else {
        var keycode = e.keyCode
    }
    ParseForNumber2(object)
}

function GetCursorPosition() {

    var t1 = phonevalue1;
    var t2 = phonevalue2;
    var bool = false
    for (i = 0; i < t1.length; i++) {
        if (t1.substring(i, 1) != t2.substring(i, 1)) {
            if (!bool) {
                cursorposition = i
                bool = true
            }
        }
    }
}

function FormatPhone(object) {

    var p = phonevalue1

    p = p.replace(/[^\d]*/gi, "")

    if (p.length < 3) {
        object.value = p
    } else if (p.length == 3) {
        pp = p;
        d4 = p.indexOf('')
        d5 = p.indexOf(')')
        if (d4 == -1) {
            pp = "" + pp;
        }
        if (d5 == -1) {
            pp = pp + "-";
        }
        object.value = pp;
    } else if (p.length > 2 && p.length < 6) {
        p = "" + p;
        l30 = p.length;
        p30 = p.substring(0, 3);
        p30 = p30 + "-"

        p31 = p.substring(3, l30);
        pp = p30 + p31;

        object.value = pp;

    } else if (p.length >= 6) {
        p = "" + p;
        l30 = p.length;
        p30 = p.substring(0, 3);
        p30 = p30 + "-"

        p31 = p.substring(3, l30);
        pp = p30 + p31;

        l40 = pp.length;
        p40 = pp.substring(0, 7);
        p40 = p40 + "-"

        p41 = pp.substring(7, l40);
        ppp = p40 + p41;

        object.value = ppp.substring(0, maxphonelength);
    }

    GetCursorPosition()

    if (cursorposition >= 0) {
        if (cursorposition == 0) {
            cursorposition = 2
        } else if (cursorposition <= 2) {
            cursorposition = cursorposition + 1
        } else if (cursorposition <= 5) {
            cursorposition = cursorposition + 2
        } else if (cursorposition == 6) {
            cursorposition = cursorposition + 2
        } else if (cursorposition == 7) {
            cursorposition = cursorposition + 4
            e1 = object.value.indexOf(')')
            e2 = object.value.indexOf('-')
            if (e1 > -1 && e2 > -1) {
                if (e2 - e1 == 4) {
                    cursorposition = cursorposition - 1
                }
            }
        } else if (cursorposition < 11) {
            cursorposition = cursorposition + 3
        } else if (cursorposition == 11) {
            cursorposition = cursorposition + 1
        } else if (cursorposition >= 12) {
            cursorposition = cursorposition
        }

        var txtRange = object.createTextRange();
        txtRange.moveStart("character", cursorposition);
        txtRange.moveEnd("character", cursorposition - object.value.length);
        txtRange.select();
    }
}

function ParseChar(sStr, sChar) {
    if (sChar.length == null) {
        zChar = new Array(sChar);
    }
    else zChar = sChar;

    for (i = 0; i < zChar.length; i++) {
        sNewStr = "";

        var iStart = 0;
        var iEnd = sStr.indexOf(sChar[i]);

        while (iEnd != -1) {
            sNewStr += sStr.substring(iStart, iEnd);
            iStart = iEnd + 1;
            iEnd = sStr.indexOf(sChar[i], iStart);
        }
        sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);

        sStr = sNewStr;
    }

    return sNewStr;
}

/* Code to Format Phone number in the form of 999-999-9999  - END */

/* Pavan-SRF 1098- This function is used to redirect to a specified page. To redirect to page in wwwroot folder, it is not required to specify the path. */
function NavigateToURL(PageNameWithPath) {
    if (weburl.toLowerCase().search("localhost") == 0) {
        _urlToNavigate = "//" + weburl + "/" + PageNameWithPath;
    }
    else {
        _urlToNavigate = "//" + weburl + "/" + PageNameWithPath;
    }

    window.location.href = _urlToNavigate;
}

function GetPartnerRedirectURL(ele) {
    var userName = $(ele).val();
    if (userName != "") {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: _webAPIUrl + "GetPartnerRedirectURL?_Useremail=" + userName + "",
            dataType: "json",
            success: function (data) {

                if (data != "" && data.replace("https", "http") != location.protocol.replace("https", "http") + "//" + document.domain) {
                    window.location.href = data + "?UserEmail=" + userName;
                }
            },
            failure: function (errMsg) {
            }
        });
    }
}

// Function to check a valid url with valid query parameter. Url needs to start with http or https. Case insensitive
function isValidURL(URL)
{
    URL = URL.toLowerCase();
    var res = URL.match(/(http(s)?:\/\/.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
    return (res !== null);
};

//Common Method start Need to move to util
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//Function to determine whether div is visible on screen on scroll #1759
function funIsScrolledIntoView(elem) {
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $("#"+elem).offset().top;
    var elemBottom = elemTop + $("#" + elem).height();

    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
//#1836 Pravallika Record property as visible if not already done so 
var arrayOfVisibleRecordedProperties = [];
function isdivvisible(propertylist, inventorytype) {
    if (UserType != "" && UserType != null && UserType != undefined) {
        var propidlist = propertylist.split(',');
        for (var i = 0; i < propidlist.length; i++) {
            var id = propidlist[i];
            if (id != '' && id != undefined && id != null) {
                if (jQuery.inArray(id, arrayOfVisibleRecordedProperties) == -1) {
                    if (id.indexOf("C") != -1) {
                        var propid = id.substring(1);
                        if ($('#INV' + propid).isOnScreen()) {
                            arrayOfVisibleRecordedProperties.push(id);
                            RecordUserActivityOnCommunity(propid, ACTIVITY_TYPE_COMING_SOON_COMMUNITY_SEARCHES );
                        }
                    }
                    else if (id.indexOf("B") != -1) {
                        var propid = id.substring(1);
                        if ($('#INV' + propid).isOnScreen()) {
                            arrayOfVisibleRecordedProperties.push(id);
                            RecordUserActivityOnCustomBuilderProfile(propid, ACTIVITY_TYPE_CUSTOM_BUILDER_PROFILE_SEARCHES);
                        }
                    }
                    else {
                        if ($('#INV' + id).isOnScreen()) {
                            arrayOfVisibleRecordedProperties.push(id);
                            if (inventorytype == 'PROPERTY') {
                                RecordUserActivity(id, "PROPERTY", ACTIVITY_TYPE_PROPERTYSEARCHES);
                            }
                            else if (inventorytype == 'CBP') {                                
                                RecordUserActivityOnCustomBuilderProfile(id, ACTIVITY_TYPE_CUSTOM_BUILDER_PROFILE_SEARCHES);
                            }
                            else if (inventorytype == 'TOWER') {
                                RecordUserActivityOnCondoTower(id, ACTIVITY_TYPE_TOWER_SEARCHES);
                            }
                        }
                    }
                }
            }
        }
        //console.log('final array: ' + arrayOfVisibleRecordedProperties);
    }
}

// returns true if the element is visible. Else false.
// #1836 Pravallika
$.fn.isOnScreen = function () { 
    var win = $(window);

    var viewport = {
        top: win.scrollTop(),
        left: win.scrollLeft()
    };
    viewport.right = viewport.left + win.width();
    viewport.bottom = viewport.top + win.height();    
    var bounds = this.offset();
    if ( bounds != null && bounds != undefined ) {
        bounds.right = bounds.left + this.outerWidth();
        bounds.bottom = bounds.top + this.outerHeight();
        return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
    }
};

// function closewindow #1554
function funCloseWindow() {
    window.close();
    if (!window.closed) {
        window.parent.close();
    }
}

function LoadHomesList() { 
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: _webAPIUrl + "GetSearchableCitiesListForHomePAge",
        dataType: "json",
        success: function (data) {
            var remaininglength = data.length - 3 * (data.length / 3);
            var firstcollength = data.length / 3;
            if (remaininglength > 0) {
                firstcollength = firstcollength + 1;
            }
            var secondcollength = firstcollength + data.length / 3;
            if (remaininglength > 1) {
                secondcollength = secondcollength + 2;
            }
            var thirdcollength = data.length - secondcollength;
            $.each(data, function (i, val) {
                if (i <= firstcollength - 1) { 
                    $("#divFirstCityList").append('<div class="cityfont">' + val.CityName + '</a></div>');
                    $("#divFirstCityListMobile").append('<div  class="cityfont">' + val.CityName + '</a></div>');
                }
                if (i > firstcollength - 1 && i <= secondcollength - 1) {
                    $("#divSecondCityList").append('<div class="cityfont">' + val.CityName + '</a></div>');
                    $("#divSecondCityListMobile").append('<div class="cityfont">' + val.CityName + '</a></div>');
                }
                if (i > secondcollength) {
                    $("#divThirdCityList").append('<div class="cityfont"  >' + val.CityName + '</a></div>');
                    $("#divThirdCityListMobile").append('<div  class="cityfont">' + val.CityName + '</a></div>');
                }
            });
        }, failure: function (errMsg) {
            showbumessage("Error Message<br/><br/>", errMsg, "OKAY", "");
        }
    });
}
// Function to call ValidateEmailFromMailGun method
// showModal = Y: Here in this case system will show an error message modal popup
// showModal = N: Here in this case system will not show an error message modal popup
function ValidateEmailFromMailGun(email, showModal = 'y') {
    var _url = "//" + window.location.host + "/api/PropertySearch/";
    var validEmail = false
    $.ajax({
        type: "POST",
        async: false,
        contentType: "application/json; charset=utf-8",
        url: _url + "ValidateEmailFromMailGun?EmailToBeValidated=" + email,
        dataType: "json",
        success: function (data) {
            validEmail = data;
        },
        failure: function (errMsg) {
            validEmail = false;
        }
    });

    if (validEmail == false && showModal.toLocaleLowerCase() == 'y') {
        showbumessage("<br/>", '<p style="color:white">Invalid Email ' + email + '</p>', "okay", "");
    }
    return validEmail;
}

// Sairam - #2890 - 04/07/2022 - This JS method will record the activity done by a user.
function RecordActivity(ActivityType) {
    var weburl = window.location.host;
    var _webAPIUrl = "//" + weburl + "/api/PropertySearch/";
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: _webAPIUrl + "RecordBUUserActivity?ActivityType=" + ActivityType,
        success: function (data) {
        },
        failure: function (errMsg) {
        }
    });
}

// Pavan - #3003 - 03/28/2023 - This JS fucntion will show or hide the message "ADDITIONAL COSTS MAY APPLY" in builder portal page, builder account page, builder learn more page, builder full registration page.
function CheckBuilderType(SelectedDropdownId) {
    var BuilderType = $('#' + SelectedDropdownId).val();
    if (SelectedDropdownId == "sel-type" || SelectedDropdownId == "sel-Builder-Type") {
        if (BuilderType == '' || BuilderType == "BASIC") {
            $('#lblAdditionalCosts').hide();
        } else {
            $('#lblAdditionalCosts').show();
        }
    } else {
        if (BuilderType == '' || BuilderType == "BASIC") {
            $('#reg_lblAdditionalCosts').hide();
        } else {
            $('#reg_lblAdditionalCosts').show();
        }
    }
    if (BuilderType == 'SPECBUILDER') {
        $("#divCommunities").hide();
        $("#divSpecs").show();
        $("#divCondo").hide();
    } else if (BuilderType == 'PRODUCTIONBUILDER') {
        $("#divCommunities").show();
        $("#divSpecs").hide();
        $("#divCondo").hide();
    } else if (BuilderType == 'CONDODEVELOPER') {
        $("#divCommunities").hide();
        $("#divSpecs").hide();
        $("#divCondo").show();
    } else if (BuilderType == '' || BuilderType == 'CUSTOMBUILDER') {
        $("#divCommunities").hide();
        $("#divSpecs").hide();
        $("#divCondo").hide();
    }
    
}

// Teja - #2593 -Start
function CheckXMLFeedUrl(xmlfeedurl, fileName)
{
    var _webAPIUrl = "//" + weburl + "/api/PropertySearch/";
    var validXML = true;
    if (xmlfeedurl == '' || xmlfeedurl == null) {
        $("#txtBoxUrl").focus();
        showbumessage('<br/>', '<p>Please provide the URL from which XML Feed file can be downloaded</p>', 'OKAY', "");
        return false;
    }
    else {
        if (!isValidURL(xmlfeedurl)) {
            showbumessage('<br/>', '<p>Please provide a valid URL for XML Feed file to be downloaded</p>', 'OKAY', "");
            return false;
        }
        else {
            $.ajax({
                type: "POST",
                async: false,
                contentType: "application/json; charset=utf-8",
                url: _webAPIUrl + "CheckUrlValidXml?feedUrl=" + xmlfeedurl + '&filename=' + fileName,
                dataType: "json",
                success: function (data) {
                    if (data != "success") {
                        validXML = false;
                        showbumessage('<br/>', '<p>Please provide a valid URL for XML Feed.<br/>' + data + ' </p>', 'OKAY', "");
                        document.getElementById("msgtag").innerHTML = "<span class='text-danger'>Error: " + data + "</span>";
                    }
                }
            });
        }
    }
    return validXML;
}

function CheckBuilderFTP(xmlFTPSite, xmlFTPUserName, xmlFTPPassword, fileName, xmlFolderName)
{
    var _webAPIUrl = "//" + weburl + "/api/PropertySearch/";
    var validFTP = true;
    if (xmlFTPSite == '' || xmlFTPSite == null) {
        $("#txtBoxFTPSite").focus();
        showbumessage('<br/>', '<p>Please provide the FTP site details.</p>', 'OKAY', "");
        return false;
    }
    if (xmlFTPUserName == '' || xmlFTPUserName == null) {
        $("#txtBoxFTPUsername").focus();
        showbumessage('<br/>', '<p>Please provide the FTP site User name.</p>', 'OKAY', "");
        return false;
    }
    if (xmlFTPPassword == '' || xmlFTPPassword == null) {
        $("#txtBoxFTPPassword").focus();
        showbumessage('<br/>', '<p>Please provide the FTP site password.</p>', 'OKAY', "");
        return false;
    }
    $.ajax({
        type: "POST",
        async: false,
        contentType: "application/json; charset=utf-8",
        url: _webAPIUrl + "CheckFTPSiteWithFile?FtpSite=" + xmlFTPSite + '&userName=' + xmlFTPUserName + '&passWord=' + xmlFTPPassword + '&fileName=' + fileName + '&folderName=' + xmlFolderName,
        dataType: "json",
        success: function (data) {
            if (data.includes("success")) {
                validFTP = true;
                showbumessage('<br/>', '<p>' + data + ' </p>', 'OKAY', "");
            }
            else {
                validFTP = false;
                showbumessage('<br/>', '<p>Please provide valid ftp credentials for XML Feed.<br/>' + data + ' </p>', 'OKAY', "");
                document.getElementById("msgtag").innerHTML = "<span class='text-danger'>Error: " + data + "</span>";
                return false;
            }
        }
    });
    return validFTP;
}
// Teja - #2593 -End

function OpenChatbot(Id) {
    $("#" + Id).fancybox({
        padding: 0,
        closeBtn: true,
        fitToView: true,
        width: 400,
        wrapCSS: 'fancy-single fancy-form',
        helpers: {
            title: 'Voice Based AI Chatbot'
        },
        scrolling: true
    });
    $("#" + Id).attr("href", "../chatbot/BuVoicebot.aspx");
}