/* Minification failed. Returning unminified contents.
(2,14): run-time error CSS1031: Expected selector, found '='
(2,14): run-time error CSS1025: Expected comma or open brace, found '='
(2,167): run-time error CSS1019: Unexpected token, found '/'
(2,168): run-time error CSS1019: Unexpected token, found '/'
(2,169): run-time error CSS1019: Unexpected token, found ','
(2,184): run-time error CSS1031: Expected selector, found '='
(2,184): run-time error CSS1025: Expected comma or open brace, found '='
(4,16): run-time error CSS1031: Expected selector, found '='
(4,16): run-time error CSS1025: Expected comma or open brace, found '='
(6,44): run-time error CSS1031: Expected selector, found ';'
(6,44): run-time error CSS1025: Expected comma or open brace, found ';'
(9,19): run-time error CSS1031: Expected selector, found '='
(9,19): run-time error CSS1025: Expected comma or open brace, found '='
(12,21): run-time error CSS1031: Expected selector, found ';'
(12,21): run-time error CSS1025: Expected comma or open brace, found ';'
(15,21): run-time error CSS1031: Expected selector, found '='
(15,21): run-time error CSS1025: Expected comma or open brace, found '='
(18,17): run-time error CSS1031: Expected selector, found ';'
(18,17): run-time error CSS1025: Expected comma or open brace, found ';'
(21,24): run-time error CSS1031: Expected selector, found '='
(21,24): run-time error CSS1025: Expected comma or open brace, found '='
(22,25): run-time error CSS1031: Expected selector, found '='
(22,25): run-time error CSS1025: Expected comma or open brace, found '='
(23,25): run-time error CSS1031: Expected selector, found '='
(23,25): run-time error CSS1025: Expected comma or open brace, found '='
(24,27): run-time error CSS1031: Expected selector, found '='
(24,27): run-time error CSS1025: Expected comma or open brace, found '='
(25,1): run-time error CSS1019: Unexpected token, found '/'
(25,2): run-time error CSS1019: Unexpected token, found '/'
(25,30): run-time error CSS1031: Expected selector, found '='
(25,30): run-time error CSS1025: Expected comma or open brace, found '='
(26,30): run-time error CSS1031: Expected selector, found '='
(26,30): run-time error CSS1025: Expected comma or open brace, found '='
(27,30): run-time error CSS1031: Expected selector, found '='
(27,30): run-time error CSS1025: Expected comma or open brace, found '='
(28,26): run-time error CSS1031: Expected selector, found '='
(28,26): run-time error CSS1025: Expected comma or open brace, found '='
(30,19): run-time error CSS1031: Expected selector, found '='
(30,19): run-time error CSS1025: Expected comma or open brace, found '='
(31,1): run-time error CSS1019: Unexpected token, found '/'
(31,2): run-time error CSS1019: Unexpected token, found '/'
(32,20): run-time error CSS1031: Expected selector, found '='
(32,20): run-time error CSS1025: Expected comma or open brace, found '='
(34,29): run-time error CSS1031: Expected selector, found '='
(34,29): run-time error CSS1025: Expected comma or open brace, found '='
(35,35): run-time error CSS1031: Expected selector, found '='
(35,35): run-time error CSS1025: Expected comma or open brace, found '='
(36,32): run-time error CSS1031: Expected selector, found '='
(36,32): run-time error CSS1025: Expected comma or open brace, found '='
(37,28): run-time error CSS1031: Expected selector, found '='
(37,28): run-time error CSS1025: Expected comma or open brace, found '='
(38,31): run-time error CSS1031: Expected selector, found '='
(38,31): run-time error CSS1025: Expected comma or open brace, found '='
(39,24): run-time error CSS1031: Expected selector, found '='
(39,24): run-time error CSS1025: Expected comma or open brace, found '='
(40,27): run-time error CSS1031: Expected selector, found '='
(40,27): run-time error CSS1025: Expected comma or open brace, found '='
(41,32): run-time error CSS1031: Expected selector, found ';'
(41,32): run-time error CSS1025: Expected comma or open brace, found ';'
(42,34): run-time error CSS1031: Expected selector, found '='
(42,34): run-time error CSS1025: Expected comma or open brace, found '='
(43,32): run-time error CSS1031: Expected selector, found '='
(43,32): run-time error CSS1025: Expected comma or open brace, found '='
(57,10): run-time error CSS1031: Expected selector, found 'confirmDialog('
(57,10): run-time error CSS1025: Expected comma or open brace, found 'confirmDialog('
(137,10): run-time error CSS1031: Expected selector, found 'showDisclaimerDialog('
(137,10): run-time error CSS1025: Expected comma or open brace, found 'showDisclaimerDialog('
(161,10): run-time error CSS1031: Expected selector, found 'showProgress('
(161,10): run-time error CSS1025: Expected comma or open brace, found 'showProgress('
(188,10): run-time error CSS1031: Expected selector, found 'hideProgress('
(188,10): run-time error CSS1025: Expected comma or open brace, found 'hideProgress('
(196,10): run-time error CSS1031: Expected selector, found 'trim('
(196,10): run-time error CSS1025: Expected comma or open brace, found 'trim('
(210,10): run-time error CSS1031: Expected selector, found 'showDialog('
(210,10): run-time error CSS1025: Expected comma or open brace, found 'showDialog('
(225,10): run-time error CSS1031: Expected selector, found 'hideDialog('
(225,10): run-time error CSS1025: Expected comma or open brace, found 'hideDialog('
(237,10): run-time error CSS1031: Expected selector, found 'showMultipleBuildingAddress('
(237,10): run-time error CSS1025: Expected comma or open brace, found 'showMultipleBuildingAddress('
(258,10): run-time error CSS1031: Expected selector, found 'showParcelQuickViewDetail('
(258,10): run-time error CSS1025: Expected comma or open brace, found 'showParcelQuickViewDetail('
(332,10): run-time error CSS1031: Expected selector, found 'showSingleParcelInfoOnParcelQuickViewDetail('
(332,10): run-time error CSS1025: Expected comma or open brace, found 'showSingleParcelInfoOnParcelQuickViewDetail('
(399,84): run-time error CSS1002: Unterminated string: '"));
(460,1): run-time error CSS1019: Unexpected token, found '/'
(460,2): run-time error CSS1019: Unexpected token, found '/'
(462,10): run-time error CSS1031: Expected selector, found 'showGradingQuickView('
(462,10): run-time error CSS1025: Expected comma or open brace, found 'showGradingQuickView('
(470,10): run-time error CSS1031: Expected selector, found 'showGradingQuickViewDetail('
(470,10): run-time error CSS1025: Expected comma or open brace, found 'showGradingQuickViewDetail('
(496,10): run-time error CSS1031: Expected selector, found 'uniqRecords('
(496,10): run-time error CSS1025: Expected comma or open brace, found 'uniqRecords('
(517,10): run-time error CSS1031: Expected selector, found 'createGradingQuickViewContent('
(517,10): run-time error CSS1025: Expected comma or open brace, found 'createGradingQuickViewContent('
(616,10): run-time error CSS1031: Expected selector, found 'modifyLogPoint('
(616,10): run-time error CSS1025: Expected comma or open brace, found 'modifyLogPoint('
(632,10): run-time error CSS1031: Expected selector, found 'pageselectCallback('
(632,10): run-time error CSS1025: Expected comma or open brace, found 'pageselectCallback('
(657,10): run-time error CSS1031: Expected selector, found 'getOptionsFromForm('
(657,10): run-time error CSS1025: Expected comma or open brace, found 'getOptionsFromForm('
(684,10): run-time error CSS1031: Expected selector, found 'showMultipleParcelInfoOnParcelQuickViewDetail('
(684,10): run-time error CSS1025: Expected comma or open brace, found 'showMultipleParcelInfoOnParcelQuickViewDetail('
(766,84): run-time error CSS1002: Unterminated string: '"));
(769,84): run-time error CSS1002: Unterminated string: '"));
(780,10): run-time error CSS1031: Expected selector, found 'createParcelQuickViewContent('
(780,10): run-time error CSS1025: Expected comma or open brace, found 'createParcelQuickViewContent('
(875,11): run-time error CSS1030: Expected identifier, found 'extend('
(875,11): run-time error CSS1031: Expected selector, found 'extend('
(875,11): run-time error CSS1025: Expected comma or open brace, found 'extend('
(898,2): run-time error CSS1019: Unexpected token, found ')'
(898,3): run-time error CSS1019: Unexpected token, found ';'
(908,10): run-time error CSS1031: Expected selector, found 'showSlidingWindow('
(908,10): run-time error CSS1025: Expected comma or open brace, found 'showSlidingWindow('
(924,10): run-time error CSS1031: Expected selector, found 'closeSlidingWindow('
(924,10): run-time error CSS1025: Expected comma or open brace, found 'closeSlidingWindow('
(958,10): run-time error CSS1031: Expected selector, found 'hideSlidingWindow('
(958,10): run-time error CSS1025: Expected comma or open brace, found 'hideSlidingWindow('
(980,10): run-time error CSS1031: Expected selector, found 'showBuildingQuickViewDetail('
(980,10): run-time error CSS1025: Expected comma or open brace, found 'showBuildingQuickViewDetail('
(1076,10): run-time error CSS1031: Expected selector, found 'AssignPermitNumberToBuilding('
(1076,10): run-time error CSS1025: Expected comma or open brace, found 'AssignPermitNumberToBuilding('
(1303,10): run-time error CSS1031: Expected selector, found 'createBuildingAddressList('
(1303,10): run-time error CSS1025: Expected comma or open brace, found 'createBuildingAddressList('
(1338,1): run-time error CSS1019: Unexpected token, found '/'
(1338,2): run-time error CSS1019: Unexpected token, found '/'
(1339,10): run-time error CSS1031: Expected selector, found 'createBuildingAddressListForGrading('
(1339,10): run-time error CSS1025: Expected comma or open brace, found 'createBuildingAddressListForGrading('
(1375,1): run-time error CSS1019: Unexpected token, found '/'
(1375,2): run-time error CSS1019: Unexpected token, found '/'
(1376,10): run-time error CSS1031: Expected selector, found 'showMultipleBuildingAddressForGrading('
(1376,10): run-time error CSS1025: Expected comma or open brace, found 'showMultipleBuildingAddressForGrading('
(1400,10): run-time error CSS1031: Expected selector, found 'addressLocator('
(1400,10): run-time error CSS1025: Expected comma or open brace, found 'addressLocator('
(1442,10): run-time error CSS1031: Expected selector, found 'addressLocatorByAddress('
(1442,10): run-time error CSS1025: Expected comma or open brace, found 'addressLocatorByAddress('
(1476,10): run-time error CSS1031: Expected selector, found 'InitializeDialog('
(1476,10): run-time error CSS1025: Expected comma or open brace, found 'InitializeDialog('
(1502,10): run-time error CSS1031: Expected selector, found 'showHideTools('
(1502,10): run-time error CSS1025: Expected comma or open brace, found 'showHideTools('
(1601,10): run-time error CSS1031: Expected selector, found 'showPCISQuickView('
(1601,10): run-time error CSS1025: Expected comma or open brace, found 'showPCISQuickView('
(1615,80): run-time error CSS1002: Unterminated string: 's use display instead of visibility property to remove entire element
(1619,10): run-time error CSS1031: Expected selector, found 'hidePCISQuickView('
(1619,10): run-time error CSS1025: Expected comma or open brace, found 'hidePCISQuickView('
(1635,10): run-time error CSS1031: Expected selector, found 'enablePictometryfunctionality('
(1635,10): run-time error CSS1025: Expected comma or open brace, found 'enablePictometryfunctionality('
(1649,10): run-time error CSS1031: Expected selector, found 'activatePictometry('
(1649,10): run-time error CSS1025: Expected comma or open brace, found 'activatePictometry('
(1655,10): run-time error CSS1031: Expected selector, found 'enableMeasurementFunctionality('
(1655,10): run-time error CSS1025: Expected comma or open brace, found 'enableMeasurementFunctionality('
(1669,34): run-time error CSS1031: Expected selector, found '='
(1669,34): run-time error CSS1025: Expected comma or open brace, found '='
(1691,10): run-time error CSS1031: Expected selector, found 'createDatatable('
(1691,10): run-time error CSS1025: Expected comma or open brace, found 'createDatatable('
(1708,10): run-time error CSS1031: Expected selector, found 'createAdvancedDatatable('
(1708,10): run-time error CSS1025: Expected comma or open brace, found 'createAdvancedDatatable('
(1988,10): run-time error CSS1031: Expected selector, found 'createNormalDatatable('
(1988,10): run-time error CSS1025: Expected comma or open brace, found 'createNormalDatatable('
(2011,10): run-time error CSS1031: Expected selector, found 'disableHeaderToolbarElements('
(2011,10): run-time error CSS1025: Expected comma or open brace, found 'disableHeaderToolbarElements('
(2027,10): run-time error CSS1031: Expected selector, found 'enableHeaderToolbarElements('
(2027,10): run-time error CSS1025: Expected comma or open brace, found 'enableHeaderToolbarElements('
(2043,10): run-time error CSS1031: Expected selector, found 'naturalSort('
(2043,10): run-time error CSS1025: Expected comma or open brace, found 'naturalSort('
(2082,10): run-time error CSS1031: Expected selector, found 'disableAddPointFutureFunctionality('
(2082,10): run-time error CSS1025: Expected comma or open brace, found 'disableAddPointFutureFunctionality('
(2101,1): run-time error CSS1019: Unexpected token, found '/'
(2101,2): run-time error CSS1019: Unexpected token, found '/'
(2102,10): run-time error CSS1031: Expected selector, found 'removeAddPointFunctionalityForGradingFeatureClass('
(2102,10): run-time error CSS1025: Expected comma or open brace, found 'removeAddPointFunctionalityForGradingFeatureClass('
(2111,10): run-time error CSS1031: Expected selector, found 'removeAddPointFunctionalityForFeatureClass('
(2111,10): run-time error CSS1025: Expected comma or open brace, found 'removeAddPointFunctionalityForFeatureClass('
(2133,10): run-time error CSS1031: Expected selector, found 'openPageLoadDialog('
(2133,10): run-time error CSS1025: Expected comma or open brace, found 'openPageLoadDialog('
(2170,10): run-time error CSS1031: Expected selector, found 'openTermsOfuseDialog('
(2170,10): run-time error CSS1025: Expected comma or open brace, found 'openTermsOfuseDialog('
(2175,10): run-time error CSS1031: Expected selector, found 'openParcelAccordion('
(2175,10): run-time error CSS1025: Expected comma or open brace, found 'openParcelAccordion('
(2192,10): run-time error CSS1031: Expected selector, found 'openBuildingAccordion('
(2192,10): run-time error CSS1025: Expected comma or open brace, found 'openBuildingAccordion('
(2208,10): run-time error CSS1031: Expected selector, found 'toggleFeatureLayersVisibility('
(2208,10): run-time error CSS1025: Expected comma or open brace, found 'toggleFeatureLayersVisibility('
(2619,10): run-time error CSS1031: Expected selector, found 'setVisibilityOfLayers('
(2619,10): run-time error CSS1025: Expected comma or open brace, found 'setVisibilityOfLayers('
(2642,10): run-time error CSS1031: Expected selector, found 'openAuthenticationPopup('
(2642,10): run-time error CSS1025: Expected comma or open brace, found 'openAuthenticationPopup('
 */
/* Variable declaration for Parcel Quick View deatils and Building Quick View details popup*/
var ParcelID = '', address = '', parcelDetails, parcelTemplate, parcelButtons, buildingHtmlTemplate, buildingDetails, buildingTemplate, buildingid, featureBuildingID;//, isNormalUser = true;
/*By defaulty set doIdentify variable to true i.e. to know that identify task functionality is enabled***/
var doIdentify = true;
/* Variables for Pictometry functionality*/
var PictometryClickEvent, PictometryHandler;

/***********Declared the featureLength variable for getting the count of total no of parcel features******************/
var featureLength = 0;

/*****Declared the multipleFeatures variable for storing the multiple features while highlighting multiple parcels with paging*********/
var multipleFeatures;

/********Declared parcelTemplates array for storing the multiple parcel information ***********************/
var parcelTemplates = [];

/***Declared parcel symbol for highlighting parcel on map**/
var parcelSymbol;

/*******Declared variables for toggling the visibility of feature layers ***********************/
var isZoneLayerClicked = true;
var isRoadsLayerClicked = true;
var isSewerLayerClicked = true;
var isMethaneLayerClicked = true;
//var isHillsideLayerClicked = true;
var isFaultZonesLayerClicked = true;
var isTopographyLayerClicked = true;
var isCensorLayerClicked = true;

var visibleLayers = [];
//Commenting for production release
var gradingParcels = [];

var parcelProfileZoningInfo = '';
var parcelProfileGeographicalInfo = '';
var parcelProfileDocumentsInfo = '';
var parcelProfileOtherInfo = '';
var lastSelectedParcelFeature = "";
var gradingAddressList = "";
var isGradingPointClicked = false;
var gradingParcelSelectedSymbol;
var isGradingSelectParcelClicked = false;
var isClickHereForExistingBldg = false;


/*******Function for displaying popup**********/
/*
<param name="message">Message to be displayed in popup.</param>
<param name="buttonType">
1) pass "ok" to show the popup with OK button.
2) pass "cancel" to show the popup with Cancel button.
3) pass blank value to show both OK and Cancel buttons on popup.
</param>
<param name="showCircleCheckImage">If set to true then it appends circle check image before the message.</param>
<returns>Shows message or content in popup</returns>
*/
function confirmDialog(message, buttonType, showCircleCheckImage) {

    $('#pContent').empty();

    if (showCircleCheckImage) {
        $('#pContent').append("<span id='spIcon' class='ui-icon ui-icon-circle-check' style='float: left; margin: 0 7px 45px 0;'></span>" + message);
    }
    else {
        $('#pContent').append("<div>" + message + "</div>");
    }

    if (buttonType.toLowerCase() == "ok") {
        $("#dialog-confirm").dialog({
            resizable: false,
            height: "auto",
            width: "auto",
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close").blur();
            },
            buttons: [{
                text: "OK",
                tabIndex: -1,
                "class": 'ui-dialog-buttonset btn',
                click: function () {
                    $(this).dialog("close");
                }
            }]
        });
    }
    else if (buttonType.toLowerCase() = "cancel") {
        $("#dialog-confirm").dialog({
            resizable: false,
            height: popupHeight,
            width: popupWidth,
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close").blur();
            },
            buttons: [{
                text: "Cancel",
                "class": 'ui-dialog-buttonset btn',
                tabIndex: -1,
                click: function () {
                    $(this).dialog("close");
                }
            }]
        });
    }
    else {
        $("#dialog-confirm").dialog({
            resizable: false,
            height: popupHeight,
            width: popupWidth,
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close").blur();
            },
            buttons: [{
                text: "OK",
                "class": 'ui-dialog-buttonset btn',
                tabIndex: -1,
                click: function () {
                    $(this).dialog("close");
                }
            },
                     {
                         text: "Cancel",
                         "class": 'ui-dialog-buttonset btn',
                         tabIndex: -1,
                         click: function () {
                             $(this).dialog("close");
                         }
                     }]

        });
    }
}

/*************Function to show disclaimer message****************/
function showDisclaimerDialog(message) {
    $('#pContent').empty();
    $('#pContent').append("<div>" + message + "</div>");
    $("#dialog-confirm").dialog({
        resizable: false,
        height: "auto",
        width: 1000,
        modal: true,
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").blur();
        },
        buttons: [{
            text: "OK",
            tabIndex: -1,
            "class": 'ui-dialog-buttonset btn',
            click: function () {
                $(this).dialog("close");
            }
        }]
    });
}


/*************Function to show progress bar on loading****************/
function showProgress() {
    $.blockUI({
        message: '<span id="blockUIMessage">Please wait...</span>',
        css: {
            top: "50%",
            left: "38%",
            width: "22%",
            textAlign: "center",
            color: "#000",
            "font-size": "30px",
            border: "0px",
            backgroundColor: "transparent",
            padding: "8px",
            margin: 0,
            opacity: 1,
            cursor: "wait",
            "z-index": 1005
        },
        overlayCSS: {
            opacity: "0.25",
            "z-index": 1004
        }
    });

}

/************Function to hide progress bar**********************/
function hideProgress() {
    $.unblockUI();
}

/********************Function to trim the input string**************************/
/*<param name="stringToTrim">Input String.</param>
<returns>String without leading and trailing spaces.</returns>
*/
function trim(stringToTrim) {
    if (stringToTrim) {
        stringToTrim = String(stringToTrim);
        return stringToTrim.replace(/^\s+|\s+$/g, "");
    }
    else {
        return "";
    }
}

/*******Function for showing addresses in popup**********/
/*<param name="modal">Set to True for showing the Popup.</param>
<returns>Displying the partial address popup.</returns>
*/
function showDialog(modal) {
    $("#overlay").show();
    $("#dialog").fadeIn(300);

    if (modal) {
        $("#overlay").unbind("click");
    }
    else {
        $("#overlay").click(function (e) {
            hideDialog();
        });
    }
}

/*******Function for hiding partial addresse popup**********/
function hideDialog() {
    $("#overlay").hide();
    $("#dialog").fadeOut(300);

}

/*******Function for displaying multiple building addresses in popup (Parcel Quick view and Building Quick view )**********/
/*
<param name="lstAddress">comma seperated list of building address.</param>
<param name="length">no of addresses present in the address list.</param>
<returns>Shows address list in popup</returns>
*/
function showMultipleBuildingAddress(lstAddress, length) {
    var multipleAddress = '';
    var count = 0;
    if (lstAddress != null && lstAddress != "" && lstAddress != undefined) {
        var address = lstAddress.split(',');
        for (i = 0; i < address.length; i++) {
            count++;
            multipleAddress += count + ") " + address[i] + "<br>";
        }
        /*Show list of addresses in confirm box*/
        confirmDialog(multipleAddress, "ok", false)
    }
}


/*******************Function to show the parcel quick view details*********************/
/*
<param name="feature">feature class which contains all the information related to the feature.</param>
<param name="requestFromPCIS">chek if the request to this function is made from PCIS or not</param>
<returns>Sets parcel Infotemplate information variable named as parcelTemplate</returns>
*/
function showParcelQuickViewDetail(feature, requestFromPCIS) {
    $("#parcelContent").html("");
    $("#Pagination").css("display", "none");
    //Commenting for production release
    $('#lnkReportButtons').css("display", "block");

    if (requestFromPCIS &&  isNaN(PCIS_bld_id)) {
        $("#divPCISQuckiView").css("display", "block");
        $("#divPCISPopup").css("display", "block");
        $("#lnkPCISPopup").css("background", "#000");
        $("#lnkPCISPopup").css("border", "2px dotted white");
        $("#divParcelQuckiView").css("left", "969px");
        $("#divParcelQuckiView").css("top", "123px");
    } else if (IsRequestFromPCIS && bldgType == "" && PCIS_bld_id.toLowerCase() != "na" && PCIS_bld_id.toLowerCase() != "n/a" && App != "Grading") {
        map.addLayer(searchFeatureLayer);
        addToTOC(searchFeatureLayer, true);
        legendLayers.push({ layer: searchFeatureLayer, title: 'New Features' });

        //map.addLayer(searchBuildingFeatureUrl);
        //addToTOC(searchBuildingFeatureUrl, true);
        //legendLayers.push({ layer: searchBuildingFeatureUrl, title: 'New Building Features' });
        $("#divAddNewBuilding").css("display", "block");
        $("#btnAddNewBuilding").css("background", "#000");
        $("#btnAddNewBuilding").css("border", "2px dotted white");
        $('#lnkResidential').css('cursor', 'pointer');
        $('#lnkMultiapt').css('cursor', 'pointer');
        $('#lnkCommercial').css('cursor', 'pointer');


    }


    //parcelSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
    //                 new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
    //                   new Color([255, 0, 0]), 2),
    //                 new Color([255, 255, 0, 0.25]));
    parcelSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                   new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                     new Color([0, 255, 255]), 2),
                   new Color([0, 255, 255, 0.25]));

    gradingParcelSelectedSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                     new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                       new Color([255, 0, 0]), 2),
                     new Color([255, 255, 0, 0.25]));


    openParcelAccordion();

    if (feature != null && feature != "" && feature.length == undefined) {
        /*******Show single parcel information on parcel quick view details for address search and identify task*******************/
        showSingleParcelInfoOnParcelQuickViewDetail(feature, requestFromPCIS)
    }
    else if (feature != null && feature != "" && feature.length > 0) {
        /*************Show single parcel information on parcel quick view details************/
        if (feature.length == 1) {
            showSingleParcelInfoOnParcelQuickViewDetail(feature, requestFromPCIS)
        }
            /*************Show multiple parcel information on parcel quick view details************/
        else {

            showMultipleParcelInfoOnParcelQuickViewDetail(feature, requestFromPCIS)
        }
    }

}


/*******************Function to show the Single parcel information on parcel quick view details*********************/
/*
<param name="feature">feature class which contains all the information related to the feature.</param>
<param name="requestFromPCIS">chek if the request to this function is made from PCIS or not</param>
<returns>Shows single parcel information in the parcel quick view detail</returns>
*/
function showSingleParcelInfoOnParcelQuickViewDetail(feature, requestFromPCIS) {    
    $('#parcelContent').html("");
    $('#lnkReportButtons').html("");
    $('#zoningContent').html("");
    $('#geographicalContent').html("");
    $('#cityDocumentsContent').html("");
    $('#otherInfoContent').html("");
    parcelTemplate = "";
    parcelButtons = "";
    parcelProfileZoningInfo = "";
    parcelProfileGeographicalInfo = "";
    parcelProfileDocumentsInfo = "";
    parcelProfileOtherInfo = "";
    $('#lnkParcelInfo').html("Property Summary");
    /*******************create the content part of parcel quick view***************************/
    parcelTemplate = createParcelQuickViewContent(feature);

    //Commenting for production release
    if (App != "Grading") {
        /*Clear graphics from the Map*/
        map.graphics.clear();
    }

    


    if (isIdentifyTask && App == "Grading") {
        if (!isGradingSelectParcelClicked) {
            map.graphics.clear();
            gradingParcels.length = 0;
        }
        if ($.inArray(feature.attributes.PIN, ParcelIDs) == -1) {           
            feature.setSymbol(gradingParcelSelectedSymbol);
            /*add feature in the graphics of the map*/
            map.graphics.add(feature);
        }
        else {
            
            /*Set feature layer symbol*/
            feature.setSymbol(parcelSymbol);
            /*add feature in the graphics of the map*/
            map.graphics.add(feature);
        }
    }
    else {
        /*Set feature layer symbol*/
        feature.setSymbol(parcelSymbol);
        /*add feature in the graphics of the map*/
        map.graphics.add(feature);
    }


    gradingParcels.push(feature.attributes.PIN);
    lastSelectedParcelFeature = feature;
    isSelectedParcelClicked = false;
    isAddGradingPointClicked = false;



    if (requestFromPCIS) {
        map.setExtent(feature.geometry.getExtent(), true);
    }
    var point = new esri.geometry.Point(feature.attributes.LON, feature.attributes.LAT, new esri.SpatialReference({ wkid: 4326 }));


    //map.infoWindow.offsetY = 350;    
    //map.infoWindow.resize(300, 300);
    //map.infoWindow.setContent($("#quickViewAccordion").html().replace(/"/g, "'"));
    $("#divParcelQuckiView").draggable({ cursor: "move", containment: "#map", handle: ".parcelQuickViewHeader" });
    $('.divParcelQuckiView').css('cursor', 'move');
    $('#parcelContent').html(parcelTemplate);
    $('#zoningContent').html(parcelProfileZoningInfo);
    $('#geographicalContent').html(parcelProfileGeographicalInfo);
    $('#cityDocumentsContent').html(parcelProfileDocumentsInfo);
    $('#otherInfoContent').html(parcelProfileOtherInfo);

    $('#lnkReportButtons').html(parcelButtons);
    //$("div.title").html("");
    //map.infoWindow.show(point);
    //Commenting for production release
    if (App != "Grading") {
        //setDraggableInfoWindow();
        //showSlidingWindow('divParcelQuckiView', 'parcelContent', parcelTemplate, false);
        //closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');
    } else {
        //$("#divParcelQuckiView").css("display", "none");
        //$("#divParcelQuckiView").css("left", "969px");
        //$("#divParcelQuckiView").css("top", "123px");
        if (Group_ID != "" && Group_ID != undefined) {
            $("#divGradingLogQuickView").css("display", "block");
            $('#collapseOne').css("display", "none");
            $('#divBuildingQuickView').css("display", "none");
            $('#lnkReportButtons').css("display", "none");
            $('#collapseThree').addClass('in');

            if (updateFeature != undefined) {
                getGradingFeatureLayerInfoWindowContent("", updateFeature);
            }
            if (!requestFromPCIS) {
                $('#collapseOne').css("display", "block");
                $('#divZoningInfo').css("display", "block");
                $('#divGeographicalInfo').css("display", "block");
                $('#divDocumentInfo').css("display", "block");
                $('#divOtherInfo').css("display", "block");
                $('#lnkReportButtons').css("display", "block");
                $('#collapseThree').removeClass('in');
            }
            map.graphics.remove(graphic);
        }
        else {
            $("#divGradingLogQuickView").css("display", "block");
            $('#collapseOne').css("display", "block");
            $('#divBuildingQuickView').css("display", "none");
            $('#collapseThree').removeClass('in');
            map.graphics.remove(graphic);
        }
    }

    setDraggableInfoWindow();
    if (!requestFromPCIS) {
        showSlidingWindow('divParcelQuckiView', 'parcelContent', parcelTemplate, false);
        closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');
    }
    $("#selectedParcelCount").html(gradingParcels.length);


}

//Commenting for production release

function showGradingQuickView() {
    disableIdentifyTask();
    //dojo.disconnect(gradingPointQuickView);
    isAddGradingPointClicked = true;
    showSlidingWindow('divGradingQuckiView', 'parcelContent', parcelTemplate, false);
    closeSlidingWindow('btnCloseGradingView', 'divGradingQuckiView');
}

function showGradingQuickViewDetail(event, feature) {
    $('#gradingContent').html("");
    gradingTemplate = "";

    /*******************create the content part of parcel quick view***************************/
    gradingTemplate = createGradingQuickViewContent(event, feature);

    $("#divParcelQuckiView").draggable({ cursor: "move", containment: "#map", handle: ".parcelQuickViewHeader" });
    $('.divParcelQuckiView').css('cursor', 'move');
    $('#gradingContent').html(gradingTemplate);



    setDraggableInfoWindow();
    //$("#divParcelQuckiView").css("left", "770px");
    //$("#divParcelQuckiView").css("top", "275px");
    showSlidingWindow('divParcelQuckiView', 'gradingContent', gradingTemplate, false);
    closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');
    $('#collapseThree').addClass('in');
    $('#collapseThree').css('height', 'auto');

    map.graphics.remove(graphic);
    featureLogID = feature.attributes.LOG_ID;
    addAddressMarker(feature.geometry);
}

function uniqRecords(a, param, param1) {    
    if (param != "" && param1 != "") {
        return a.filter(function (item, pos, array) {
            return array.map(function (mapItem) {
                 return mapItem[param] || mapItem[param1];
            }).indexOf(item[param] || item[param1]) === pos;
        })
    } else if (param != "") {
        return a.filter(function (item, pos, array) {
            return array.map(function (mapItem) { return mapItem[param]; }).indexOf(item[param]) === pos;
        })
    }
    else if (param1 != "") {
        return a.filter(function (item, pos, array) {
            return array.map(function (mapItem) { return mapItem[param1]; }).indexOf(item[param1]) === pos;
        })
    }
}



function createGradingQuickViewContent(event, feature) {    
    var date = "";
    var reportType = "";
    var reportDate = "";
    var consultant = "";
    var logExtension = "";
    var address = "";
    var SIT_HSE_NBR = "";
    var SIT_STR_NAME = "";
    var SIT_STR_DIR = "";
    var SIT_STR_SUFF = "";
    var GetGradingData = $('#GetGradingData').val();
    var GetBuildingAddressesForGrading = $('#GetBuildingAddressesForGrading').val();
    $.ajax({
        url: GetGradingData,
        dataType: "json",
        data: { LogID: feature.attributes.LOG_ID },
        async: false,
        cache: false,
        success: function (data) {            
            if (data != undefined && data.length > 0) {                
                reportType = data[0].REPORT_TYPE;
                consultant = data[0].CONSULTANT;              
                date = eval(data[0].REPORT_DATE.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
                reportDate = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();                
                address = "<b>Address</b>:<br/>";                               
                
                logExtension = "<table style='width:100%;'><tr><td> <b>Log Extension</b></td><td> <b>Status</b></td></tr>"
                var uniqueAddress = uniqRecords(data, 'ADDRESS');
                
                for (var i = 0; i <= uniqueAddress.length - 1; i++) {                    
                    address += uniqueAddress[i].ADDRESS + "  <a target='_blank' style='cursor:pointer;color:blue;text-decoration:underline;' href='" + IDISDocumentsURL + "?SearchType=DCMT_ADDR&Address_txtAddressBegNo=" + uniqueAddress[i].SIT_HSE_NBR + "&Address_txtAddressStreetName=" + uniqueAddress[i].SIT_STR_NAME + "&Address_txtAddressDir=" + uniqueAddress[i].SIT_STR_DIR + "&Address_txtAddressSuffix=" + uniqueAddress[i].SIT_STR_SUFF + "&AppFrom=GIS'>IDIS Documents</a><br>";
                }
                
                var uniqueData = uniqRecords(data, 'LOG_EXTENSION', 'STATUS');
                
                for (var j = 0; j <= uniqueData.length - 1; j++) {
                    if (data[j].STATUS == "APPROVED" && data[j].LOG_EXTENSION != null) {
                        logExtension += "<tr><td>" + data[j].LOG_EXTENSION + "</td><td><span style='color:Green;'>" + data[j].STATUS + "</span></td></tr>";
                    } else if (data[j].STATUS == "DENIED" && data[j].LOG_EXTENSION != null) {
                        logExtension += "<tr><td>" + data[j].LOG_EXTENSION + "</td><td><span style='color:Red;'>" + data[j].STATUS + "</span></td></tr>";
                    } else if (data[j].STATUS == "REVIEW IN PROG" && data[j].LOG_EXTENSION != null) {
                        logExtension += "<tr><td>" + data[j].LOG_EXTENSION + "</td><td><span style='color:Orange;'>" + data[j].STATUS + "</span></td></tr>";
                    }
                    else if (data[j].LOG_EXTENSION != null) {
                        logExtension += "<tr><td>" + data[j].LOG_EXTENSION + "</td><td><span>" + data[j].STATUS + "</span></td></tr>";
                    }
                }


                logExtension += "</table>"

            }
        }
    });

    //$.ajax({
    //    url: GetBuildingAddressesForGrading,
    //    dataType: "json",
    //    data: { PIN: feature.attributes.PIN },
    //    async: false,
    //    cache: false,
    //    success: function (data) {
    //        /*Creates list of building addresses by passing the comma seperated address list*/
    //        createBuildingAddressListForGrading(data);
    //    }
    //});
    
    $('#quickViewAccordion').css("display", "block");
    var parcelProfileReport = '';
    gradingTemplate = "<b>Log #</b>: " + (feature.attributes.LOG_ID != null && feature.attributes.LOG_ID != undefined ? feature.attributes.LOG_ID : '') + "<br/>" +
                      logExtension +
                      (address != "" && address != undefined ? address : "") +
                      "<b>Report Date</b>: " + reportDate + "<br/>" +
                      "<b>Report Type</b>: " + reportType + " <br/>" +
                      "<b>Consultant</b>: " + consultant + " <br/>" +
                      //"<b>Status</b>: " + (status != undefined && status != "" ? status + " <br/>" : status + " <br/>") +
                      "<a href='" + GradingPDFLetters + feature.attributes.LOG_ID + "' target='_blank' ><b>Letters</b>:</a> <br/>" +
        "<a href='" + GradingPDFReports + feature.attributes.LOG_ID + "' target='_blank'><b>Reports</b>:</a>";
        //"<a href='" + GradingPDFMods + feature.attributes.LOG_ID + "' target='_blank'><b>Mods</b>:</a> ";

    if (LOG_ID != "") {
        gradingTemplate += "<div style='float:right;'><a id='btnModifyLogPoint' onClick='modifyLogPoint();' class='btn dropdown-toggle btn-demo-space leftBorder' style='font-size: 16px; padding-top: 8px; padding-left: 8px; padding-right: 8px; padding-bottom: 8px; margin-right: 8px;'>Modify Log</a></div>";
        addedGradingPointFeature = feature;
    }

    $('#collapseOne').css("display", "none");
    $('#divZoningInfo').css("display", "none");
    $('#divGeographicalInfo').css("display", "none");
    $('#divDocumentInfo').css("display", "none");
    $('#divOtherInfo').css("display", "none");
    $('#divBuildingQuickView').css("display", "none");
    $('#lnkReportButtons').css("display", "none");



    return gradingTemplate;
}

function modifyLogPoint() {
    showGradingQuickView();
    hideSlidingWindow('divParcelQuckiView');
    $("#gradingStepTwoQuickViewAccordion").css("display", "block");
    $("#gradingStepOneQuickViewAccordion").css("display", "none");
    $("#divMeasurementMessage").css("display", "none");
    $("#btnDeleteLogPoint").removeAttr("disabled");
    $("#divMeasurementMessage").html("");
    $("#btnAddPoint").attr("disabled", "disabled");
    isAddGradingPointClicked = true;
    doIdentify = false;
    isSelectedParcelClicked = false;
}


/**********************Function which is getting called on pagination of parcel quick view*************************************/
function pageselectCallback(page_index, jq) {

    // Get number of elements per pagionation page from form
    var items_per_page = 1;
    var max_elem = Math.min((page_index + 1) * items_per_page, featureLength);

    var newcontent = '';
    // Iterate through a selection of the content and build an HTML string
    for (var i = page_index * items_per_page; i < max_elem; i++) {
        newcontent += parcelTemplates[i];
        map.graphics.clear();
        multipleFeatures[i].setSymbol(parcelSymbol);
        map.graphics.add(multipleFeatures[i]);
        map.setExtent(multipleFeatures[i].geometry.getExtent(), true);

    }

    // Replace old content with new content
    $('#parcelContent').html(newcontent);

    //Prevent click eventpropagation
    return false;
}

/***************Function to set the pagination settings for parcel quick view**********************/
function getOptionsFromForm() {
    var opt = { callback: pageselectCallback };
    // Collect options from the text fields - the fields are named like their option counterparts

    opt["items_per_page"] = 1;
    opt["num_display_entries"] = 3;
    opt["prev_text"] = "Prev";
    opt["next_text"] = "Next";


    // Avoid html injections in this demo
    var htmlspecialchars = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }
    $.each(htmlspecialchars, function (k, v) {
        opt.prev_text = opt.prev_text.replace(k, v);
        opt.next_text = opt.next_text.replace(k, v);
    })
    return opt;
}



/*******************Function to show the multiple parcel information on parcel quick view details*********************/
/*
<param name="feature">feature class which contains all the information related to the feature.</param>
<param name="requestFromPCIS">chek if the request to this function is made from PCIS or not</param>
<returns>Shows multiple parcel information in the parcel quick view detail</returns>
*/
function showMultipleParcelInfoOnParcelQuickViewDetail(feature, requestFromPCIS) {
    $('#parcelContent').html("");
    $('#lnkReportButtons').html("");
    $('#zoningContent').html("");
    $('#geographicalContent').html("");
    $('#cityDocumentsContent').html("");
    $('#otherInfoContent').html("");
    $("#Pagination").css("display", "block");
    parcelTemplate = "";
    parcelButtons = "";
    parcelProfileZoningInfo = "";
    parcelProfileGeographicalInfo = "";
    parcelProfileDocumentsInfo = "";
    parcelProfileOtherInfo = "";
    $('#lnkParcelInfo').html("Property Summary");

    featureLength = feature.length;
    /**********************Assign feature to variable multipleFeatures for pagination in function pageselectCallback()******************************/
    multipleFeatures = feature;
    /*Clearing parcel template array which contains the parcel content information*/
    parcelTemplates.length = 0;


    /*******************create the content part of parcel quick view***************************/
    parcelTemplate = createParcelQuickViewContent(feature[0]);

    /*Clear graphics from the Map*/
    map.graphics.clear();

    /*Set feature layer symbol*/
    feature[0].setSymbol(parcelSymbol);

    /*add feature in the graphics of the map*/
    map.graphics.add(feature[0]);

    $("#divParcelQuckiView").draggable({ cursor: "move", containment: "#map", handle: ".parcelQuickViewHeader" });
    $('.divParcelQuckiView').css('cursor', 'move');
    $('#parcelContent').html(parcelTemplate);
    $('#lnkReportButtons').html(parcelButtons);
    $('#parcelContent').html(parcelTemplate);
    $('#zoningContent').html(parcelProfileZoningInfo);
    $('#geographicalContent').html(parcelProfileGeographicalInfo);
    $('#cityDocumentsContent').html(parcelProfileDocumentsInfo);
    $('#otherInfoContent').html(parcelProfileOtherInfo);

    if (feature.length > 0) {

        /**************Code for pagination in parcel quick view ********************/
        $("#Pagination").pagination({
            items: feature.length,
            itemsOnPage: 1,
            displayedPages: 5,
            edges: 0,
            cssStyle: 'compact-theme',
            onPageClick: function (pageNumber, event) {
                showProgress();
                parcelTemplate = createParcelQuickViewContent(feature[pageNumber - 1]);
                map.graphics.clear();
                feature[pageNumber - 1].setSymbol(parcelSymbol);
                var point = new esri.geometry.Point(feature[pageNumber - 1].attributes.LON, feature[pageNumber - 1].attributes.LAT, new esri.SpatialReference({ wkid: 4326 }));
                if (IsRequestFromPCIS) {
                    $('#divBuildingQuickView').css("display", "block");
                }

                map.graphics.add(feature[pageNumber - 1]);
                //map.setExtent(feature[pageNumber - 1].geometry.getExtent(), true);                
                //map.infoWindow.show(point, map.getInfoWindowAnchor(point));                
                $('#parcelContent').html(parcelTemplate);
                $('#lnkReportButtons').html(parcelButtons);
                showSlidingWindow('divParcelQuckiView', 'parcelContent', parcelTemplate, false);
                closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');

                hideProgress();
            },
        });

        showSlidingWindow('divParcelQuckiView', 'parcelContent', parcelTemplate, false);
        closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');
        //showSlidingWindow('divParcelQuckiView', 'parcelContent', parcelTemplate, false);
        //closeSlidingWindow('btnCloseParcelView', 'divParcelQuckiView');
    }

    //map.infoWindow.setContent($("#quickViewAccordion").html().replace(/"/g, "'"));
    //var point = new esri.geometry.Point(feature[0].attributes.LON, feature[0].attributes.LAT, new esri.SpatialReference({ wkid: 4326 }));
    //map.infoWindow.resize(300, 300);
    //map.infoWindow.setContent($("#quickViewAccordion").html().replace(/"/g, "'"));
    //map.infoWindow.show(point);
    //setDraggableInfoWindow();

}

/*******************Function to create parcel quick view content**************************/
/*
<param name="feature">feature class which contains all the information related to the feature.</param>
<returns>Sets parcel information variable named as parcelTemplate with corresponding parcel information</returns>
*/
function createParcelQuickViewContent(feature) {
    /*Making an ajax call to get the parcel information which is assigned to parcelDetails variable */
    //.attributes.PIN, feature.attributes.TRACT, feature.attributes.BLOCK, feature.attributes.LOT, feature.attributes.ARB, feature.attributes.CNCL_DIST  
    //$('#divParcelQuckiView').css("display", "none");    
    getParcelDetailsByParcelID(feature.attributes.PIN);
    $('#quickViewAccordion').css("display", "block");
    ParcelID = parcelDetails.PRCL_ID;
    bldgType = getURLVars()["bldgType"] !== undefined ? getURLVars()["bldgType"] : '';
    buildingid = getURLVars()["buildingid"] !== undefined ? getURLVars()["buildingid"] : '';
    var parcelProfileReport = '';

    /*Creates list of building addresses by passing the comma seperated address list*/
    createBuildingAddressList(parcelDetails.lstAddress);

    parcelTemplate = address +
             "<b>PIN</b>: " + (feature.attributes.PIN != null && feature.attributes.PIN != undefined ? feature.attributes.PIN : '') + "<br/>" +
             "<b>APN</b>: " + (feature.attributes.BOOK != null && feature.attributes.BOOK != undefined ? feature.attributes.BOOK + " " : '')
                            + (feature.attributes.PAGE != null && feature.attributes.PAGE != undefined ? feature.attributes.PAGE + " " : '')
                            + (feature.attributes.PARCEL != null && feature.attributes.PARCEL != undefined ? feature.attributes.PARCEL : '') + "<br/>" +
             "<b>Tract #</b>: " + (feature.attributes.TRACT != null && feature.attributes.TRACT != undefined ? feature.attributes.TRACT : '') + "<br/>" +
             "<b>Block</b>: " + (feature.attributes.BLOCK != "Null" && feature.attributes.BLOCK != undefined ? feature.attributes.BLOCK : '') + "<br/>" +
             "<b>Lot #</b>: " + (feature.attributes.LOT != null && feature.attributes.LOT != undefined ? feature.attributes.LOT : '') + "<br/>" +
             "<b>ARB</b>: " + (feature.attributes.ARB != "Null" && feature.attributes.ARB != undefined ? feature.attributes.ARB : ''); // + "<br/>" +
    //"<b>Zoning</b>: " + (parcelDetails.ZONING !== null ? parcelDetails.ZONING : '') + "<br/>" +
    //"<b>Council District</b>: " + (feature.attributes.CNCL_DIST !== null && feature.attributes.CNCL_DIST != undefined ? feature.attributes.CNCL_DIST : '') + "<br/>" +
    //"<b>Census Tract 2010</b>: " + (parcelDetails.CENSUS_TRACT !== null ? parcelDetails.CENSUS_TRACT : '') + "<br/>" +
    // "<b>Order(s) to Comply? (Y/N)</b>: " + (parcelDetails.ORD2CMPLY !== null ? parcelDetails.ORD2CMPLY : '') + "<br/>" +
    //"<b>Dept. Notification(s)? (Y/N)</b>: " + (parcelDetails.DEPT_NTFCTN !== null ? parcelDetails.DEPT_NTFCTN : '');    

    if (parcelDetails.parcelProfileReport != undefined) {

        if (parcelDetails.parcelProfileReport.ParcelBasics != null && parcelDetails.parcelProfileReport.ParcelBasics.length > 0) {
            $('#divZoningInfo').css("display", "block");
            for (i = 0; i < parcelDetails.parcelProfileReport.ParcelBasics.length - 1 ; i++) {
                var currentParcelBasics = '';
                var previousParcelBasics = '';
                if (i == 0) {
                    parcelProfileZoningInfo += "<b>" + parcelDetails.parcelProfileReport.ParcelBasics[parcelDetails.parcelProfileReport.ParcelBasics.length - 1].Description + "</b>: " + parcelDetails.parcelProfileReport.ParcelBasics[parcelDetails.parcelProfileReport.ParcelBasics.length - 1].Value + "<br/>";
                }
                currentParcelBasics = parcelDetails.parcelProfileReport.ParcelBasics[i].Description;
                parcelProfileZoningInfo += "<b>" + (previousParcelBasics != currentParcelBasics ? parcelDetails.parcelProfileReport.ParcelBasics[i].Description : "") + "</b>: " + parcelDetails.parcelProfileReport.ParcelBasics[i].Value + "<br/>";
                previousParcelBasics = parcelDetails.parcelProfileReport.ParcelBasics[i].Description;
            }
        }
        else {
            $('#divZoningInfo').css("display", "none");
        }

        if (parcelDetails.parcelProfileReport.ParcelGeo != null && parcelDetails.parcelProfileReport.ParcelGeo.length > 0) {
            $('#divGeographicalInfo').css("display", "block");
            for (i = 0; i < parcelDetails.parcelProfileReport.ParcelGeo.length ; i++) {
                parcelProfileGeographicalInfo += "<b>" + parcelDetails.parcelProfileReport.ParcelGeo[i].Description + "</b>: " + parcelDetails.parcelProfileReport.ParcelGeo[i].Value + "<br/>";
            }
        }
        else {
            $('#divGeographicalInfo').css("display", "none");
        }

        if (parcelDetails.parcelProfileReport.ParcelDocuments != null && parcelDetails.parcelProfileReport.ParcelDocuments.length > 0) {
            $('#divDocumentInfo').css("display", "block");
            var previousParcelDocuments = '';
            for (i = 0; i < parcelDetails.parcelProfileReport.ParcelDocuments.length ; i++) {
                currentParcelDocuments = parcelDetails.parcelProfileReport.ParcelDocuments[i].Description;
                parcelProfileDocumentsInfo += (previousParcelDocuments != currentParcelDocuments ? "<b>" + parcelDetails.parcelProfileReport.ParcelDocuments[i].Description + "</b>:<br/>" : "") + parcelDetails.parcelProfileReport.ParcelDocuments[i].Value + "<br/>";
                previousParcelDocuments = parcelDetails.parcelProfileReport.ParcelDocuments[i].Description;
            }
        }
        else {
            $('#divDocumentInfo').css("display", "none");
        }

        if (parcelDetails.parcelProfileReport.ParcelRelated != null && parcelDetails.parcelProfileReport.ParcelRelated.length > 0) {
            $('#divOtherInfo').css("display", "block");
            for (i = 0; i < parcelDetails.parcelProfileReport.ParcelRelated.length ; i++) {
                parcelProfileOtherInfo += "<b>" + parcelDetails.parcelProfileReport.ParcelRelated[i].Description + "</b>: " + parcelDetails.parcelProfileReport.ParcelRelated[i].Value + "<br/>";
            }
        }
        else {
            $('#divOtherInfo').css("display", "none");
        }
    }

    // parcelTemplate += parcelProfileReport;

    parcelButtons = "<p><a id='buttonViewParcelDetail' target='_blank' href='/StructuralInventory/ParcelDetail/ParcelDetail?PIN=" + feature.attributes.PIN + "' class='btn dropdown-toggle btn-demo-space'>" + (App != "Grading" ? "Permit & C of O Information" : "IDIS Documents") + "</a></p>";
    //(parcelDetails.ProfileID != 0 ? "<p><a id='buttonViewProfileReport' href='" + parcelDetails.ProfileReportUrl + parcelDetails.ProfileID + "' target='_blank' class='btn dropdown-toggle btn-demo-space'>Parcel <br/> Report</a></p>" : "<p><a id='buttonViewProfileReport' class='btn dropdown-toggle btn-demo-space'>Parcel <br/> Report</a></p>");
    //(IsRequestFromPCIS == false || (bldgType == "" || buildingid == "") ? "<p><a id='buttonViewBuildingDetail' style='margin-right:0px !important;' target='_blank' href='/StructuralInventory/ParcelDetail/ParcelDetail?PIN=" + feature.attributes.PIN + "&Type=B' class='btn dropdown-toggle btn-demo-space'>Building Information</a></p>" : "");

    if (IsRequestFromPCIS == true || (bldgType != "" || buildingid != "")) {
        $('#divBuildingQuickView').css("display", "none");
    }
    return parcelTemplate;
}

/*jquery function for sliding the div to the right and left side*/
jQuery.fn.extend({
    slideRight: function () {
        return this.each(function () {
            //jQuery(this).animate({ width: 'show' });
            jQuery(this).animate({ width: 'show' }, 1800, "linear");
        });
    },
    slideLeft: function () {
        return this.each(function () {
            //jQuery(this).animate({ width: 'hide' });
            jQuery(this).animate({ width: 'hide' }, 1800, "linear");
        });
    },
    slideToggleWidth: function () {
        return this.each(function () {
            var el = jQuery(this);
            if (el.css('display') == 'none') {
                el.slideRight();
            } else {
                el.slideLeft();
            }
        });
    }
});

/*******************Function to show sliding window*********************/
/*
<param name="wrapperDivID">This is outer div id.</param>
<param name="divContentID">This is inner content div id.</param>
<param name="divContent">This is content of inner div.</param>
<param name="IsMultipleParcels">If multiple parcel then set to true.</param>
<returns>Toggeles the div as Sliding Window</returns>
*/
function showSlidingWindow(wrapperDivID, divContentID, divContent, IsMultipleParcels) {
    if (!IsMultipleParcels) {
        $('#' + divContentID).html(divContent);
    }
    $('#' + wrapperDivID).css("display", "block");
    $('#collapseOne').scrollTop(0);
    $('#collapseTwo').scrollTop(0);

}

/*******************Function to close sliding window on button click*********************/
/*
<param name="closeButtonID">This is id of close button.</param>
<param name="wrapperDivID">This is outer div id.</param>
<returns>Closes the Sliding Window on button click</returns>
*/
function closeSlidingWindow(closeButtonID, wrapperDivID) {

    $('#' + closeButtonID).click(function () {

        /*******Clear the graphics from map*********/

        //Commenting for production release
        if (App != "Grading") {
            map.graphics.clear();
        }
        else {
            map.graphics.remove(graphic);
            addedGradingPointFeature = "";
            $("#btnDeleteLogPoint").attr("disabled", "disabled");
        }


        /*******Hide if any infowindow open on map*********/
        map.infoWindow.hide();
        /*******Hide/Slide left parcel quick view*********/
        $('#' + wrapperDivID).css("display", "none");

        parcelTemplate = "";
        gradingTemplate = "";
        $('#gradingContent').html("");
    });

}

/*******************Function to hide sliding window*********************/
/*
<param name="wrapperDivID">This is outer div id.</param>
<returns>Hides the Sliding Window</returns>
*/
function hideSlidingWindow(wrapperDivID) {
    /*******Clear the graphics from map*********/
    //Commenting for production release
    if (App != "Grading") {
        map.graphics.clear();
    }

    /*******Hide if any infowindow open on map*********/
    map.infoWindow.hide();
    /*******Hide/Slide left parcel quick view*********/
    //$('#' + wrapperDivID).slideLeft();
    $('#' + wrapperDivID).css("display", "none");
    parcelTemplate = "";
    gradingTemplate = "";
    $('#gradingContent').html("");
}

/*******************Function to show the building quick view details*********************/
/*
<param name="feature">feature class which contains all the information related to the feature.</param>
<returns>Sets building infotemplate information variable named as buildingTemplate</returns>
*/
function showBuildingQuickViewDetail(feature) {
    //Get only number part from the PCIS_bld_id
    $('#quickViewAccordion').css("display", "block");
    var bldg_ID = parseInt(PCIS_bld_id);
    var isNewBuildingID = false;
    if (!isNaN(PCIS_bld_id)) {
        /*If user enters the temporary building id then open infowindow for temporary building*/
        //Check temporary building id length it should be less than 12 digit because original building id length is starting from 12 digits
        //if (bldg_ID.toString().length < 12) {

        //    isNewBuildingID = true;
        //}
    }



    var formattedPermitNumber = null;
    /*Making an ajax call to get the parcel information which is assigned to parcelDetails variable */
    getBuildingDetailsByBuildingID(feature.attributes.BLD_ID);
    /*Creates list of building addresses by passing the comma seperated address list*/
    createBuildingAddressList(buildingDetails.lstAddress);

    /****Format the permit number for showing in messages****/
    if (permitid != "" && permitid.length == 15) {
        formattedPermitNumber = permitid.match(/\d{5}(?=\d{2,5})|\d+/g).join("-");
    }


    buildingTemplate = new InfoTemplate("<b>Building Quick View</b><br/>",
                                           address +
                                           "<b>Building ID</b>: " + (buildingDetails.BLDG_ID !== null ? buildingDetails.BLDG_ID : '') + "<br/>" +
                                           "<b>Zone</b>: " + (buildingDetails.Zone !== null ? buildingDetails.Zone : '') + "<br/>" +
                                           "<b>Use</b>: " + (buildingDetails.Use !== null ? buildingDetails.Use : '') + "<br/>" +
                                           "<b>Occupancy</b>: " + (buildingDetails.Occupancy !== null ? buildingDetails.Occupancy : '') + "<br/>" +
                                           "<b># of Units</b>: " + (buildingDetails.NoOfUnits !== null ? buildingDetails.NoOfUnits : '') + "<br/>" +
                                           "<b>Building SQFT</b>: " + (buildingDetails.BuildingArea !== null ? buildingDetails.BuildingArea : '') + "<br/>" +
                                           "<b>Stories</b>: " + (buildingDetails.Stories !== null ? buildingDetails.Stories : '') + "<br/>" +
                                           "<b>Building Height</b>: " + (buildingDetails.BuildingHeight !== null ? buildingDetails.BuildingHeight : '<br/>') + //+ "<br/>" +
                                           "<b>Parking (Total)</b>: " + (buildingDetails.ParkingTot !== null ? buildingDetails.ParkingTot : '<br/>') + //"<br/>" +
                                           "<b>Construction Type</b>: " + (buildingDetails.ConstructionType !== null ? buildingDetails.ConstructionType : '<br/>') +// "<br/>" +
                                           "<b>Order(s) to Comply? (Y/N)</b>: " + (buildingDetails.OrdersToComply !== null ? buildingDetails.OrdersToComply : '') + "<br/>" +
                                           //"<br/><br/><a target='_blank' href='/StructuralInventory/ParcelDetails/ParcelDetail?ID=" + BLD_ID + "&Type=B' style='background-color: #d3dce0;border: 1px solid #787878;cursor: pointer;font-size: 1.2em;font-weight: 600;padding: 7px;margin-right: 8px;width: auto;text-decoration:none;' title='View Details'>Details</a>" +
                                           (permitid != "" && IsRequestFromPCIS == true &&  isNewBuildingID == false ?
                                           "<b>Permit #</b>: " + formattedPermitNumber + "<br/><br/><a onclick ='AssignPermitNumberToBuilding(" + feature.attributes.BLD_ID + ", " + (feature.attributes.LAT != "Null" ? feature.attributes.LAT : ' ') + ", " + (feature.attributes.LON != "Null" ? feature.attributes.LON : ' ') + ");' class='buttonAssignPermit' title='Assign Permit to this Structure'>Assign Permit</a>" : ""));

    //$(".parcelQuickViewHeader").append((permitid != "" && IsRequestFromPCIS == true &&  isNewBuildingID == false ? "<a onclick ='AssignPermitNumberToBuilding(" + feature.attributes.BLD_ID + ", " + (feature.attributes.LAT != "Null" ? feature.attributes.LAT : ' ') + ", " + (feature.attributes.LON != "Null" ? feature.attributes.LON : ' ') + ");' class='buttonAssignPermit' title='Assign Permit to this Structure'>Assign Permit</a>" : ""));
    buildingHtmlTemplate = address +
                            "<b>Building ID</b>: " + (buildingDetails.BLDG_ID !== null ? buildingDetails.BLDG_ID : '') + "<br/>" +
                            "<b>Zone</b>: " + (buildingDetails.Zone !== null ? buildingDetails.Zone : '') + "<br/>" +
                            "<b>Use</b>: " + (buildingDetails.Use !== null ? buildingDetails.Use : '') + "<br/>" +
                            "<b>Occupancy</b>: " + (buildingDetails.Occupancy !== null ? buildingDetails.Occupancy : '') + "<br/>" +
                            "<b># of Units</b>: " + (buildingDetails.NoOfUnits !== null ? buildingDetails.NoOfUnits : '') + "<br/>" +
                            "<b>Building SQFT</b>: " + (buildingDetails.BuildingArea !== null ? buildingDetails.BuildingArea : '') + "<br/>" +
                            "<b>Stories</b>: " + (buildingDetails.Stories !== null ? buildingDetails.Stories : '') + "<br/>" +
                            "<b>Building Height</b>: " + (buildingDetails.BuildingHeight !== null ? buildingDetails.BuildingHeight : '<br/>') + //+ "<br/>" +
                            "<b>Parking (Total)</b>: " + (buildingDetails.ParkingTot !== null ? buildingDetails.ParkingTot : '<br/>') + //"<br/>" +
                            "<b>Construction Type</b>: " + (buildingDetails.ConstructionType !== null ? buildingDetails.ConstructionType : '<br/>') +// "<br/>" +
                            "<b>Order(s) to Comply? (Y/N)</b>: " + (buildingDetails.OrdersToComply !== null ? buildingDetails.OrdersToComply : '') + "<br/>"
    //"<br/><br/><a target='_blank' href='/StructuralInventory/ParcelDetails/ParcelDetail?ID=" + BLD_ID + "&Type=B' style='background-color: #d3dce0;border: 1px solid #787878;cursor: pointer;font-size: 1.2em;font-weight: 600;padding: 7px;margin-right: 8px;width: auto;text-decoration:none;' title='View Details'>Details</a>" +
    // (permitid != "" && IsRequestFromPCIS == true && PCIS_bld_id.toLowerCase() != "new" && isNewBuildingID == false ?
    //"<b>Permit #</b>: " + formattedPermitNumber + "<br/><br/><a onclick ='AssignPermitNumberToBuilding(" + feature.attributes.BLD_ID + ", " + (feature.attributes.LAT != "Null" ? feature.attributes.LAT : ' ') + ", " + (feature.attributes.LON != "Null" ? feature.attributes.LON : ' ') + ");' class='buttonAssignPermit' title='Assign Permit to this Structure'>Assign Permit</a>" : "");

    //buildingHtmlTemplate += (permitid != "" && IsRequestFromPCIS == true && isNewBuildingID == false ? '<b>Permit #</b>: ' + formattedPermitNumber + '<br/><br/><a onclick ="AssignPermitNumberToBuilding(\'' + feature.attributes.BLD_ID + '\', \'' + (feature.attributes.LAT != "Null" ? feature.attributes.LAT : '') + '\', \'' + (feature.attributes.LON != "Null" ? feature.attributes.LON : '') + '\');" class="buttonAssignPermit" title="Assign Permit to this Structure">Assign Permit</a>' : "");
    buildingHtmlTemplate += (permitid != "" && IsRequestFromPCIS == true && isNewBuildingID == false ? "<b>Permit #</b>: " + formattedPermitNumber:"" );
    //$(".parcelQuickViewHeader").append();
    $("#divAssignPermitNumber").html("");
    if (permitid != "" && IsRequestFromPCIS == true && isNewBuildingID == false) {
        $(".headerCloseButton").css("margin-top", "5px");

    }
    else {
        $(".headerCloseButton").css("margin-top", "0px");
    }
    $("#divAssignPermitNumber").append(permitid != "" && IsRequestFromPCIS == true && isNewBuildingID == false ? "<a onclick ='AssignPermitNumberToBuilding(" + feature.attributes.BLD_ID + ", " + (feature.attributes.LAT != "Null" ? feature.attributes.LAT : '') + ", " + (feature.attributes.LON != "Null" ? feature.attributes.LON : '') + ");' class='buttonAssignPermit' title='Assign Permit to this Structure'>Assign Permit</a>" : "");
    //$(".parcelQuickViewHeader").append("</div>");

    if (IsRequestFromPCIS && bldgType == "" && PCIS_bld_id.toLowerCase() != "na" && PCIS_bld_id.toLowerCase() != "n/a" && App != "Grading") {
        map.addLayer(searchFeatureLayer);
        addToTOC(searchFeatureLayer, true);
        legendLayers.push({ layer: searchFeatureLayer, title: 'New Features' });

        //map.addLayer(searchBuildingFeatureUrl);
        //addToTOC(searchBuildingFeatureUrl, true);
        //legendLayers.push({ layer: searchBuildingFeatureUrl, title: 'New Building Features' });
        $("#divAddNewBuilding").css("display", "block");
        $("#btnAddNewBuilding").css("background", "#000");
        $("#btnAddNewBuilding").css("border", "2px dotted white");
        $('#lnkResidential').css('cursor', 'pointer');
        $('#lnkMultiapt').css('cursor', 'pointer');
        $('#lnkCommercial').css('cursor', 'pointer');


    }

}

function AssignPermitNumberToBuilding(Layer_BLD_ID, Layer_LAT, Layer_LON) {    
    /****************Set variables for calling the Assign Permit to structure method for existing building or new building**************************/
    var IsExistingBuilding = false;
    var IsPCISAndMapBldgIDMatching = false;
    var url = $('#UrlAssignPermitNumberToBldg').val();
    var urlPermitNoExist = $('#ISPermitNumberExist').val();
    var formattedPermitNumber = null;
    var alertMessage = null;
    var successMessage = null;
    /**Building ID associated with Permit Number*/
    var permitBuildingID = null;

    /******************Check if PCIS building ID is new or existing***********************/
    /********If building ID contains number then the building ID is considered as existing building ID*******/
    if (PCIS_bld_id != "" && !isNaN(PCIS_bld_id)) {
        IsExistingBuilding = true;
    }

    /*******************Check if Building ID from PCIS and Map layer is same or not **********************************/
    if (PCIS_bld_id == Layer_BLD_ID) {
        IsPCISAndMapBldgIDMatching = true;
    }



    /****Format the permit number for showing in messages****/
    if (permitid != "" && permitid.length == 15) {
        formattedPermitNumber = permitid.match(/\d{5}(?=\d{2,5})|\d+/g).join("-");
    }


    /********Predefine the success message********/
    successMessage = "Permit " + formattedPermitNumber + " is successfully assigned to the structure ID " + Layer_BLD_ID;

    var permitParameters = { PermitNumber: formattedPermitNumber}
    var permitBldgParameters = { PermitNumber: formattedPermitNumber, BuildingId: PCIS_bld_id }
    /*******************Check if given permit number and building id present in PCIS.BLDG2PERMIT and SDE.FEATUREEDITS **************************/
    var isPermitBldgExists;
    $.ajax({
        url: IsPermitNoAndBldgIdExists,
        dataType: "json",
        data: permitBldgParameters,
        async: false,
        success: function (result) {
            isPermitBldgExists = result;            
        }
           
    });
     
    
    if (isPermitBldgExists) {        
        $('#pContent').empty();
        $('#pContent').append("<span id='spIcon' class='ui-icon ui-icon-alert' style='float: left; margin: 0 7px 82px 0;'></span>" + "Unable to reassign permit. Building point must first be deleted.");
        $("#dialog-confirm").dialog({
            resizable: false,
            height: "auto",
            width: 500,
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close").blur();
            },
            buttons: [{
                text: "OK",
                tabIndex: -1,
                "class": 'ui-dialog-buttonset btn',
                click: function () {
                    $(this).dialog("close");                    
                }
            }]

        });

        return false;
    }
    
    
    /*******************Check if given permit number is already assigned to any building**********************/
    $.ajax({
        url: urlPermitNoExist,
        dataType: "json",
        data: permitParameters,
        async: false,
        success: function (buildingID) {
            /*******returns building ID*******/
            /***********If building ID is present then the permit number is assigned to that building ID***********/
            if (buildingID != "") {
                permitBuildingID = buildingID;
                alertMessage = "This Permit " + formattedPermitNumber + " is already assigned to building ID " + buildingID + ". <br/><br/>Are you sure you want to assign this Permit " + formattedPermitNumber + " to building ID " + Layer_BLD_ID + "?";
            }
            else {

                /********************If building ID is present in the PCIS URL (Existing Building) and PCIS building ID not matches with Map Layer building ID***********************************************/
                if (IsExistingBuilding && !IsPCISAndMapBldgIDMatching) {
                    alertMessage = "This Permit " + formattedPermitNumber + " is already assigned to building ID " + buildingID + ". <br/><br/>Are you sure you want to assign this Permit " + formattedPermitNumber + " to building ID " + Layer_BLD_ID + "?";
                    //alertMessage = "Selected building ID does not match with the building ID sent from PCIS.<br /> Click \"OK\" to assign permit " + formattedPermitNumber + " to building ID " + Layer_BLD_ID + ".";
                }

                /********************If building ID is present in the PCIS URL (Existing Building) and PCIS building ID matches with Map Layer building ID***********************************************/
                if (IsExistingBuilding && IsPCISAndMapBldgIDMatching) {
                    alertMessage = "Are you sure you want to assign permit " + formattedPermitNumber + " to building ID " + Layer_BLD_ID + " ?";
                }

                /********************If building ID is not present in the PCIS URL (New Building) and PCIS building ID not matches with Map Layer building ID***********************************************/
                if (!IsExistingBuilding && !IsPCISAndMapBldgIDMatching) {
                    alertMessage = "Click \"OK\" to assign permit " + formattedPermitNumber + " to building ID " + Layer_BLD_ID + ".";
                }

            }
        }
    });


    var parameters = { LayerBldgID: Layer_BLD_ID, PermitNumber: formattedPermitNumber, permitBuildingID: permitBuildingID, UserID: userid, BldgLAT: Layer_LAT, BldgLON: Layer_LON };


    $('#pContent').empty();
    $('#pContent').append("<span id='spIcon' class='ui-icon ui-icon-alert' style='float: left; margin: 0 7px 82px 0;'></span>" + alertMessage);    
    
    if (permitBuildingID != Layer_BLD_ID) {        
        $("#dialog-confirm").dialog({
            resizable: false,
            height: "auto",
            width: 500,
            modal: true,
            open: function (event, ui) {
                $(".ui-dialog-titlebar-close").blur();
            },
            buttons: [{
                text: "OK",
                "class": 'ui-dialog-buttonset btn',
                tabIndex: -1,
                click: function () {
                    showProgress();
                    $.ajax({
                        url: url,
                        dataType: "json",
                        data: parameters,
                        //async: false,
                        success: function (result) {
                            if (result) {
                                hideProgress();
                                $('#pContent').empty();
                                $('#pContent').append("<span id='spIcon' class='ui-icon ui-icon-circle-check' style='float: left; margin: 0 7px 62px 0;'></span>" + successMessage);
                                $("#dialog-confirm").dialog({
                                    resizable: false,
                                    height: "auto",
                                    width: 500,
                                    modal: true,
                                    open: function (event, ui) {
                                        $(".ui-dialog-titlebar-close").blur();
                                    },
                                    buttons: [{
                                        text: "OK",
                                        tabIndex: -1,
                                        "class": 'ui-dialog-buttonset btn',
                                        click: function () {
                                            $(this).dialog("close");
                                            location.href = AppURL;
                                        }
                                    }]

                                });

                            }
                        }
                    });
                    $(this).dialog("close");
                }
            },
                       {
                           text: "Cancel",
                           "class": 'ui-dialog-buttonset btn',
                           tabIndex: -1,
                           click: function () {
                               $(this).dialog("close");
                           }
                       }]

        });
    }
    else {
        showProgress();
        $.ajax({
            url: url,
            dataType: "json",
            data: parameters,
            //async: false,
            success: function (result) {
                if (result) {
                    hideProgress();
                    $('#pContent').empty();
                    $('#pContent').append("<span id='spIcon' class='ui-icon ui-icon-circle-check' style='float: left; margin: 0 7px 62px 0;'></span>" + successMessage);
                    $("#dialog-confirm").dialog({
                        resizable: false,
                        height: "auto",
                        width: 500,
                        modal: true,
                        open: function (event, ui) {
                            $(".ui-dialog-titlebar-close").blur();
                        },
                        buttons: [{
                            text: "OK",
                            tabIndex: -1,
                            "class": 'ui-dialog-buttonset btn',
                            click: function () {
                                $(this).dialog("close");
                                location.href = AppURL;
                            }
                        }]

                    });

                }
            }
        });

    }

}



/*******************Function to create list of building addresses present in the parcel (Parcel Quick view and Building Quick view )*********************/
/*
<param name="lstAddress">comma seperated list of building addresses.</param>
<returns>Sets address variable with multiple addresses with html</returns>
*/
function createBuildingAddressList(lstAddress) {
    var count = 0;
    if (lstAddress !== null && lstAddress !== "" && lstAddress != undefined) {
        address = "<b>Address</b>: ";
        var buildingAddress = lstAddress.split(',');
        for (i = 0; i < 2; i++) {
            count++;
            if (buildingAddress.length == 1) {
                address += buildingAddress[i] + "<br>";
                break;
            }
            else {
                address += "<br>" + count + ") " + buildingAddress[i];
            }

        }

        if (buildingAddress.length > 2) {
            address += '<br><a id="lnkViewMoreAddress" onclick="showMultipleBuildingAddress(\'' + lstAddress + '\', \'' + buildingAddress.length + '\');" style="cursor:pointer;color:blue;text-decoration:underline;">View More Addresses</a><br>';
        }
        else if (buildingAddress.length == 2) {
            address += "<br>";
        }

    }
    else {
        address = "<b>Address</b>: <br>";
    }
}

/*******************Function to create list of building addresses present in the parcel (Grading Quick view )*********************/
/*
<param name="lstAddress">comma seperated list of building addresses.</param>
<returns>Sets address variable with multiple addresses with html</returns>
*/
//Commenting for production release
function createBuildingAddressListForGrading(lstAddress) {
    var count = 0;
    gradingAddressList = lstAddress;

    if (lstAddress !== null && lstAddress !== "" && lstAddress != undefined && lstAddress.length > 0) {
        address = "<b>Address</b>: ";
        for (i = 0; i < 2; i++) {
            count++;
            if (lstAddress.length == 1) {
                address += lstAddress[i].Address + " <a target='_blank' style='cursor:pointer;color:blue;text-decoration:underline;' href='" + IDISDocumentsURL + "?SearchType=DCMT_ADDR&Address_txtAddressBegNo=" + lstAddress[i].HSE_NBR + "&Address_txtAddressStreetName=" + lstAddress[i].STR_NM + "&Address_txtAddressDir=" + lstAddress[i].HSE_DIR_CD + "&Address_txtAddressSuffix=" + lstAddress[i].STR_SFX_CD + "&AppFrom=GIS'>IDIS Documents</a><br>";
                break;
            }
            else {
                address += "<br>" + count + ") " + lstAddress[i].Address + " <a target='_blank' style='cursor:pointer;color:blue;text-decoration:underline;' href='" + IDISDocumentsURL + "?SearchType=DCMT_ADDR&Address_txtAddressBegNo=" + lstAddress[i].HSE_NBR + "&Address_txtAddressStreetName=" + lstAddress[i].STR_NM + "&Address_txtAddressDir=" + lstAddress[i].HSE_DIR_CD + "&Address_txtAddressSuffix=" + lstAddress[i].STR_SFX_CD + "&AppFrom=GIS'>IDIS Documents</a>";
            }

        }

        if (lstAddress.length > 2) {
            address += '<br><a id="lnkViewMoreAddress" onclick="showMultipleBuildingAddressForGrading(\'' + lstAddress.length + '\');" style="cursor:pointer;color:#a4680f;text-decoration:underline;">View More Addresses</a><br>';
        }
        else if (lstAddress.length == 2) {
            address += "<br>";
        }

    }
    else {
        address = "<b>Address</b>: <br>";
    }
}

/*******Function for displaying multiple building addresses in popup (Grading Quick view )**********/
/*
<param name="length">no of addresses present in the address list.</param>
<returns>Shows address list in popup</returns>
*/
//Commenting for production release
function showMultipleBuildingAddressForGrading(length) {
    var multipleAddress = '';
    var count = 0;
    if (gradingAddressList != null && gradingAddressList != "" && gradingAddressList != undefined && gradingAddressList.length > 0) {

        for (i = 0; i < gradingAddressList.length; i++) {
            count++;
            multipleAddress += count + ") " + gradingAddressList[i].Address + " <a target='_blank' style='cursor:pointer;color:blue;text-decoration:underline;' href='" + IDISDocumentsURL + "?SearchType=DCMT_ADDR&Address_txtAddressBegNo=" + gradingAddressList[i].HSE_NBR + "&Address_txtAddressStreetName=" + gradingAddressList[i].STR_NM + "&Address_txtAddressDir=" + gradingAddressList[i].HSE_DIR_CD + "&Address_txtAddressSuffix=" + gradingAddressList[i].STR_SFX_CD + "&AppFrom=GIS'>IDIS Documents</a><br>";
        }
        /*Show list of addresses in confirm box*/
        confirmDialog(multipleAddress, "ok", false)
    }
}


/*************************Function for locating address on Map using Geocode Service or Address locator service from arc gis*************************************/
/*
<param name="streetnumber">Street Number.</param>
<param name="direction">Direction.</param>
<param name="street">Street.</param>
<param name="suffix">Suffix.</param>
<param name="zip">Zip.</param>
<returns>Redirects to the address point on map</returns>
*/
function addressLocator(streetnumber, direction, street, suffix, zip) {
    /***********Hide partial address search popup******************/
    hideDialog();
    var address = "";
    var messageText = document.getElementById("addresses");
    var divErrorMsgText = document.getElementById("divErrorMsg");
    /* If street or zip is empty, stop code.*/
    if (App != "Grading") {
        if (street == '' || zip === '') {
            return;
        }
        address = streetnumber + " " + direction + " " + street + " " + suffix + ", Los Angeles, CA, " + zip;
        var singleLineAddress = {
            "Single Line Input": decodeURI(address)
        };

        var locator = new Locator(getUrlByName("js_addressLocatorUrl"));
        locator.on("address-to-locations-complete", showResults);
        locator.outSpatialReference = map.spatialReference;
        var options = {
            address: singleLineAddress,
            outFields: ["search"]
        }

        locator.addressToLocations(options);
    }
    else {
        address = streetnumber + " " + direction + " " + street + " " + suffix;
        AddressSearch(address, divErrorMsgText, messageText);
    }




}

/*************************Function for locating address on Map using Geocode Service or Address locator service from arc gis*************************************/
/*
<param name="address">Address to be search on map or intersection text to be search on map.</param>
<param name="IsIntersectionSearch">Set to true for intersection search and false for address search.</param>
<returns>Redirects to the address point on map</returns>
*/
function addressLocatorByAddress(address, IsIntersectionSearch) {
    /***********Hide partial address search popup******************/
    hideDialog();
    IsRequestFromPCIS = false;
    var locator;

    /*Use different arcgis service for intersection search*/
    if (IsIntersectionSearch && IsIntersectionSearch != "") {
        locator = new Locator(getUrlByName("js_intersectionLocatorUrl"));
        locator.on("address-to-locations-complete", showResultsIntersection);
    }
        /*Use different arcgis service for address search*/
    else {
        locator = new Locator(getUrlByName("js_addressLocatorUrl"));
        locator.on("address-to-locations-complete", showResults);
    }

    var singleLineAddress = {
        "Single Line Input": decodeURI(address)
    };

    locator.outSpatialReference = map.spatialReference;
    var options = {
        address: singleLineAddress,
        outFields: ["txtSearch"]
    }
    locator.addressToLocations(options);


}


/* Function to Initialize JQuery Dialog.
 -------------------------------------------------------------------------------------------------------------------------------------------*/
function InitializeDialog(element, actionPath, title, height, width) {

    $(element).dialog({
        autoOpen: false,
        width: width,
        modal: true,
        title: title,
        height: height,
        resizable: false,
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").blur();
            $("#overlay").show();
            //Load the Partial View Here using Controller and Action
            $(element).empty();
            $(element).load(actionPath, function () {
                $(element).dialog('option', 'position', 'center');
            });
        },
        close: function () {
            $(this).dialog('close');
            $("#overlay").hide();
        }
    });
}

/*Show Hide Measurement and Pictometry tool*/
function showHideTools(divID) {
    switch (divID) {
        case "measurement":
            if ($('#' + divID).css('visibility') === 'hidden') {

                /***********enable measurement functionality********/
                enableMeasurementFunctionality();

                /************Hide Pictometry Tool********************/
                hidePictometryTool();

                /*****disable adding point feature functionality*****/
                disableAddPointFunctionality();

                /***********disable identifytask functionality********/
                disableIdentifyTask();

                hidePCISQuickView();
            }
            else {
                /***************Hide Measurement Tool****************/
                hideMeasurementTool();
                /***********enable identifytask functionality********/
                enableIdentifyTask();

            }

            break;

        case "pictometry":
            if (isPictometryClicked) {
                /*****disable adding point feature functionality*****/
                disableAddPointFunctionality();
                $("#lnkresidential").removeClass("active");
                $("#lnkmultiapt").removeClass("active");
                $("#lnkcommercial").removeClass("active");
                $("#divPictometryMessage").css("display", "block");
            }
            else {
                $("#divPictometryMessage").css("display", "none");
                $('#lnkPictometry').removeClass('active')
            }
            isPictometryClicked = !isPictometryClicked;
            if ($('#' + divID).css('display') === 'none') {

                /***************Hide Measurement Tool****************/
                hideMeasurementTool();

                /**************Enable pictometry functionality********/
                enablePictometryfunctionality();

                /***********disable identifytask functionality********/
                disableIdentifyTask();


            }
            else {

                /************Hide Pictometry Tool*******************/
                hidePictometryTool();
                /***********enable identifytask functionality********/
                enableIdentifyTask();
            }
            break;

        case "divContainerStreetView":
            if ($('#' + divID).css('display') === 'none') {

                $("#lnkresidential").removeClass("active");
                $("#lnkmultiapt").removeClass("active");
                $("#lnkcommercial").removeClass("active");
                $('#' + divID).css('display', 'block');

                /*****disable adding point feature functionality*****/
                disableAddPointFunctionality();

                /***********disable identifytask functionality********/
                disableIdentifyTask();
            }
            else {
                $('#' + divID).css("display", "none");
                /***********enable identifytask functionality********/
                enableIdentifyTask();
                $("#overlay").hide();

            }
            break;
        case "divPCISQuckiView":
            if ($('#' + divID).css('display') === 'none') {
                showPCISQuickView(divID);
            }
            else {
                hidePCISQuickView();
            }
            break;

    }
}

function showPCISQuickView(divID) {
    $('#' + divID).css('display', 'block');
    $("#lnkPCISPopup").css("background", "#000");
    $("#lnkPCISPopup").css("border", "2px dotted white");
    $("#btnAddNewBuilding").css("background", "#000");
    $("#btnAddNewBuilding").css("border", "2px dotted white");
    /***********Hide Parcel quick view popup******************/
    hideSlidingWindow('divParcelQuckiView');
    /***********Hide partial address search popup******************/
    hideDialog();

    //Hide measurement functionality
    hideMeasurementTool();
    //Hide and Disconnect the pictometry functionality
    // Let's use display instead of visibility property to remove entire element
    hidePictometryTool();
}

function hidePCISQuickView() {
    $('#divPCISQuckiView').css("display", "none");
    $("#lnkPCISPopup").css("background", "#22415d");
    $("#lnkPCISPopup").css("border", "");
    $("#btnAddNewBuilding").css("background", "#22415d");
    $("#btnAddNewBuilding").css("border", "");
    dojo.disconnect(pointDrawEnd);
    doIdentify = true;
    enableIdentifyTask();
    drawToolbar.deactivate();
    dojo.disconnect(selectFeaturePoint);
    map.infoWindow.hide();

}

/***************Function to enable pictometry functionality*******************/
function enablePictometryfunctionality() {

    PictometryHandler = map.on("click", function (evt, evt2) {

        if (!doIdentify) {
            $("#divPictometryMessage").css("display", "none");
            PictometryClickEvent = evt; // Enable Pictometry click here
            getPictometryURL();

        }
    });
}
/***********Function for opening the pictometry div and activating pictometry functionality**********/
/******This function is calle from function loadPictometryHost() present in InitializeMap.js *****/
function activatePictometry() {
    $('#pictometry').css('display', 'block');
    ConvertCoords(PictometryClickEvent.mapPoint.x, PictometryClickEvent.mapPoint.y, PictometryClickEvent.mapPoint.spatialReference);
}

/***************Function to enable measurement functionality*******************/
function enableMeasurementFunctionality() {

    $("#lnkresidential").removeClass("active");
    $("#lnkmultiapt").removeClass("active");
    $("#lnkcommercial").removeClass("active");
    $("#lnkMeasurement").css("background", "#000");
    $("#lnkMeasurement").css("border", "2px dotted white");

    $('#measurement').css('visibility', 'visible');
    $('#measurementDiv').css('display', 'block');

}

/**********************Function for removing duplicate values from array*****************************/
Array.prototype.removeDuplicates = function () {
    var input = this;
    var hashObject = new Object();

    for (var i = input.length - 1; i >= 0; i--) {
        var currentItem = input[i];

        if (hashObject[currentItem] == true) {
            input.splice(i, 1);
        }

        hashObject[currentItem] = true;
    }
    return input;
}

/***********Function for creating the datatable*************/
/*
<param name="tableId">table id to which we want to apply data table functionality.</param>
<param name="IsNormalDatatable">Set to true for normal datatable functionality and false for advanced datatable functionality.</param>
<returns>Returns Datatable</returns>
*/
function createDatatable(tableId, IsNormalDatatable) {

    if (IsNormalDatatable) {
        createNormalDatatable(tableId);
    }
    else {
        createAdvancedDatatable(tableId);
    }


}

/***********Function for creating advanced datatable*************/
/*
<param name="tableId">table id to which we want to apply advanced data table functionality.</param>
<returns>Returns Advanced Datatable</returns>
*/
function createAdvancedDatatable(tableId) {

    if (tableId == "tblPermitInfo") {
        /*Declared variable asInitVals is used below in the column filtering code*/
        var asInitVals = new Array();

        var oTableAdvanced = $('#' + tableId).dataTable({
            "bJQueryUI": true,
            "bInfo": false,
            //"bPaginate": false,
            //"bFilter": false,
            "bSort": true,
            "pagingType": "full_numbers",
            "oLanguage": {
                "sSearch": "Filter by keywords:",
                "sEmptyTable": ValidationMessages.emptyPermitInfoMessage
            },
            "sDom": 'T<"clear">lfrtip',
            "sPaginationType": "full_numbers",
            "lengthMenu": [5, 10, 25, 50, 100],
            "iDisplayLength": 5,
            //"order": [[5, "desc"], [1, "asc"]],
            "order": [[1, "asc"]],
            "aoColumnDefs": [
                { "bSortable": false, "aTargets": [6, 7] },
                {
                    "targets": [2],
                    "visible": false,
                    "searchable": false
                }
            ],
            "columns": [
                        null,
                         { "width": "15%" },
                        null,
                        null,
                        null,
                        null,
                       { "width": "8%" },
                        { "width": "20%" },
            ],
            /* START : Adds the CSV Export Functionality to the datatable*/
            "oTableTools": {
                /*Define the SWF file path*/

                "sSwfPath": "../Content/DataTables-1.10.4/swf/copy_csv_xls_pdf.swf",
                "aButtons": [
                     /*{
                         "sExtends": "print",
                         "sButtonText": "PRINT",
                         "mColumns": "visible",
                         "sTitle": "Permit Information",
                         //Export filtered records if any otherwise exports all records
                         "oSelectorOpts": { "filter": "applied", page: 'all' }

                     },

                       {
                           "sExtends": "pdf",
                           "mColumns": "visible",
                           "sPdfOrientation": "landscape",
                           "sTitle": "Permit Information",
                           //Export filtered records if any otherwise exports all records
                           "oSelectorOpts": { "filter": "applied", page: 'all' },
                           "fnClick": function (nButton, oConfig, flash) {                              
                               //alert($('#PermitDetailPDF').val());
                               //alert($("#hdnBuildingID").val());
                               //alert($("#hdnHouseID").val());
                               //alert($("#hdnPIN").val());

                               $.ajax({
                                   url: $('#PermitDetailPDF').val(),
                                   type: 'POST',
                                   data: { PIN: $("#hdnPIN").val(), buildingID: $("#hdnBuildingID").val(), HouseID: $("#hdnHouseID").val()},
                                   dataType: 'json',
                                   async: false,
                                   cache: false                                  
                               });

                           }
                       }*/
                ]
            },

            "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {

                var permitIDmatched = selectedPermitIDs.indexOf(aData[2]);

                if (permitIDmatched != -1) {
                    $(nRow).addClass('highlightRow');
                }
                //switch (aData[0]) {
                //    case 'AAAA':
                //        $(nRow).css('color', 'red')
                //        break;
                //    case 'BBBB':
                //        $(nRow).css('color', 'green')
                //        break;
                //    case 'CCCC':
                //        $(nRow).css('color', 'blue')
                //        break;
                //}
            }
        });

        return oTableAdvanced;

    }
    else if (tableId == "tblCofOInfo") {

        /*Declared variable asInitVals is used below in the column filtering code*/
        var asCofOInitVals = new Array();

        var oCofOTableAdvanced = $('#' + tableId).dataTable({
            "bJQueryUI": true,
            "bInfo": false,
            //"bPaginate": false,
            //"bFilter": false,
            "pagingType": "full_numbers",
            "lengthMenu": [5, 10, 25, 50, 100],
            "iDisplayLength": 5,
            "oLanguage": {
                "sSearch": "Filter by keywords:",
                "sEmptyTable": ValidationMessages.emptyCofOInfoMessage
            },
            "sDom": 'T<"clear">lfrtip',
            "order": [[5, "desc"]],
            "sPaginationType": "full_numbers",
            "aoColumnDefs": [
               {
                   "targets": [2],
                   "visible": false,
                   "searchable": false
               }
            ],
            "columns": [
                        null,
                         { "width": "8%" },
                        null,
                        null,
                        null,
                        null,
                       { "width": "25%" },
                        null
            ],
            //"aoColumnDefs": [{ "bSortable": false, "aTargets": [1, 5, 6] }],           
            /* START : Adds the CSV Export Functionality to the datatable*/
            "oTableTools": {
                /*Define the SWF file path*/

                "sSwfPath": "../Content/DataTables-1.10.4/swf/copy_csv_xls_pdf.swf",
                "aButtons": [

                ]
            },

            "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {

                var cofoIDmatched = selectedCofO.indexOf(aData[2]);

                if (cofoIDmatched != -1) {
                    $(nRow).addClass('highlightRow');
                }
                //switch (aData[0]) {
                //    case 'AAAA':
                //        $(nRow).css('color', 'red')
                //        break;
                //    case 'BBBB':
                //        $(nRow).css('color', 'green')
                //        break;
                //    case 'CCCC':
                //        $(nRow).css('color', 'blue')
                //        break;
                //}
            }


        });

    }
    else if (tableId == "tblCodeEnforcement") {
        /*Declared variable asInitVals is used below in the column filtering code*/
        var asCaseInitVals = new Array();
        var oCaseTableAdvanced = $('#' + tableId).dataTable({
            "bJQueryUI": true,
            "bInfo": false,
            "pagingType": "full_numbers",
            "lengthMenu": [5, 10, 25, 50, 100],
            "iDisplayLength": 5,
            "sPaginationType": "full_numbers",
            //"bPaginate": false,
            "oLanguage": {
                "sSearch": "Filter by keywords:",
                "sEmptyTable": ValidationMessages.emptyCodeEnforcementInfoMessage
            },
            "sDom": 'T<"clear">lfrtip',
            "aoColumnDefs": [{ "bSortable": false, "aTargets": [1, 3] }],
            /* START : Adds the CSV Export Functionality to the datatable*/
            "oTableTools": {
                /*Define the SWF file path*/
                "sSwfPath": "../Content/DataTables-1.10.4/swf/copy_csv_xls_pdf.swf",
                "aButtons": [
                    /* {
                         "sExtends": "print",
                         "sButtonText": "PRINT",
                         "mColumns": "visible",
                         "sTitle": "Code Enforcement Cases",
                         //Export filtered records if any otherwise exports all records
                         "oSelectorOpts": { "filter": "applied", page: 'all' }

                     },*/

                      /* {
                           "sExtends": "pdf",
                           "mColumns": "visible",
                           "sPdfOrientation": "landscape",
                           "sTitle": "Code Enforcement Cases",
                           //Export filtered records if any otherwise exports all records
                           "oSelectorOpts": { "filter": "applied", page: 'all' }
                       }*/
                ]
            },

        });


    }
    else {

        var oBuildingTableAdvanced = $('#' + tableId).dataTable({
            "bJQueryUI": true,
            "bFilter": false,
            "bInfo": false,
            "bPaginate": false,
            "bSort": false,
            "bLengthChange": false,
            "sDom": 'T<"clear">lfrtip',
            "oLanguage": {
                "sEmptyTable": ValidationMessages.emptyBuildSummaryInfoMessage
            },
            /* START : Adds the CSV Export Functionality to the datatable*/
            "oTableTools": {
                /*Define the SWF file path*/
                "sSwfPath": "../Content/DataTables-1.10.4/swf/copy_csv_xls_pdf.swf",
                "aButtons": [
                     /*{
                         "sExtends": "print",
                         "sButtonText": "PRINT",
                         "mColumns": "visible",
                         //"bHeader": false,
                         "sTitle": "Building Summary",
                         //Export filtered records if any otherwise exports all records
                         "oSelectorOpts": { "filter": "applied", page: 'all' }

                     },*/

                     /*  {
                           "sExtends": "pdf",
                           "sPdfOrientation": "landscape",
                           "mColumns": "visible",
                           "sTitle": "Building Summary",
                           //"bHeader": false,
                           //Export filtered records if any otherwise exports all records
                           "oSelectorOpts": { "filter": "applied", page: 'all' }
                       }*/
                ]
            }

            /* END : Adds the CSV Export Functionality to the datatable*/

        });
    }

}

/***********Function for creating normal datatable*************/
/*
<param name="tableId">table id to which we want to apply normal data table functionality.</param>
<returns>Returns Normal Datatable</returns>
*/
function createNormalDatatable(tableId) {

    /*Declared variable asInitVals is used below in the column filtering code*/
    var oTable = $('#' + tableId).dataTable({
        "sDom": 'T<"clear">lfrtip',
        "bJQueryUI": true,
        "bFilter": false,
        "bInfo": false,
        "bLengthChange": false,
        "bSort": false,
        "bPaginate": false,
        "oLanguage": {
            "sEmptyTable": "No data available"
        }


    });
    $('div.DTTT_container').eq(0).css('display', 'none')
    $('div.DTTT_container').eq(1).css('display', 'none')

}

/************************ Function to disable header toolbar buttons and other elements ******************************/
function disableHeaderToolbarElements() {
    $("#SearchTypes").prop("disabled", true);
    $("#txtSearch").prop("disabled", true);
    $("#btnOutAddress").prop("disabled", true);
    $("#btnOutAddress").css("background-color", "#a4680f");
    $("#btnLayers").prop("disabled", true);
    $("#btnTools").prop("disabled", true);
    $("#btnLinks").prop("disabled", true);
    $("#btnLegend").prop("disabled", true);



}


/************************ Function to enable header toolbar buttons and other elements ******************************/
function enableHeaderToolbarElements() {
    $("#SearchTypes").prop("disabled", false);
    $("#txtSearch").prop("disabled", false);
    $("#btnOutAddress").prop("disabled", false);
    $("#btnLayers").prop("disabled", false);
    $("#btnTools").prop("disabled", false);
    $("#btnLinks").prop("disabled", false);
    $("#btnLegend").prop("disabled", false);

}


/*
 * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
 * Author: Jim Palmer (based on chunking idea from Dave Koelle)
 */
function naturalSort(a, b) {
    var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
        sre = /(^[ ]*|[ ]*$)/g,
        dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
        hre = /^0x[0-9a-f]+$/i,
        ore = /^0/,
        i = function (s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s },
        // convert all to strings strip whitespace
        x = i(a).replace(sre, '') || '',
        y = i(b).replace(sre, '') || '',
        // chunk/tokenize
        xN = x.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0'),
        yN = y.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0'),
        // numeric, hex or date detection
        xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
        yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null,
        oFxNcL, oFyNcL;
    // first try and sort Hex codes or Dates
    if (yD)
        if (xD < yD) return -1;
        else if (xD > yD) return 1;
    // natural sorting through split numeric strings and default strings
    for (var cLoc = 0, numS = Math.max(xN.length, yN.length) ; cLoc < numS; cLoc++) {
        // find floats not starting with '0', string or 0 if not defined (Clint Priest)
        oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
        oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
        // handle numeric vs string comparison - number < string - (Kyle Adams)
        if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
            // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
        else if (typeof oFxNcL !== typeof oFyNcL) {
            oFxNcL += '';
            oFyNcL += '';
        }
        if (oFxNcL < oFyNcL) return -1;
        if (oFxNcL > oFyNcL) return 1;
    }
    return 0;
}

function disableAddPointFutureFunctionality() {

    document.getElementById("lnkresidential").style.cursor = "default";
    document.getElementById("lnkmultiapt").style.cursor = "default";
    document.getElementById("lnkcommercial").style.cursor = "default";

    $("#lnkresidential").removeClass("active");
    $("#lnkresidential").removeClass("highlight");
    $("#lnkmultiapt").removeClass("active");
    $("#lnkmultiapt").removeClass("highlight");
    $("#lnkcommercial").removeClass("active");
    $("#lnkcommercial").removeClass("highlight");

    dojo.disconnect(residentialClickEvent);
    dojo.disconnect(multiClickEvent);
    dojo.disconnect(commercialClickEvent);

}

//Commenting for production release
function removeAddPointFunctionalityForGradingFeatureClass() {
    /***********deactivate the add new point functionality*****************/
    doIdentify = true;
    disableAddPointFunctionality();

    //$("#lnkGrading").removeClass("active");
    //$("#lnkGrading").addClass("highlight");

}
function removeAddPointFunctionalityForFeatureClass() {
    /***********deactivate the add new point functionality*****************/
    doIdentify = true;
    disableAddPointFunctionality();
    var bldgType = getURLVars()["bldgType"] !== undefined ? getURLVars()["bldgType"] : '';

    if (bldgType.toLowerCase() == "r") {
        $("#lnkresidential").removeClass("active");
        $("#lnkresidential").addClass("highlight");
    }

    if (bldgType.toLowerCase() == "m") {
        $("#lnkmultiapt").removeClass("active");
        $("#lnkmultiapt").addClass("highlight");
    }

    if (bldgType.toLowerCase() == "c") {
        $("#lnkcommercial").removeClass("active");
        $("#lnkcommercial").addClass("highlight");
    }
}

function openPageLoadDialog(message, title, width) {

    $('#pContent').empty();

    if (title == "Contact us") {
        $('#pContent').append("<div style='text-align:center;margin-top:10px;margin-bottom-10px;'>" + message + "</div>");
    }
    else {
        $('#pContent').append("<div style='margin-top:10px;margin-bottom-10px;text-align:justify;'>" + message + "</div>");
    }
    var options = {
        buttons: {}
    };


    $("#dialog-confirm").dialog({
        resizable: false,
        height: "auto",
        width: width,
        title: title,
        modal: true,
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").blur();
        },

    });

    $("#dialog-confirm").dialog('option', options);

    $("#dialog-confirm").position({
        my: "center",
        at: "center",
        of: window
    });
}

/*********************Function for opening Tearms Of use Dialog***************************/
function openTermsOfuseDialog() {
    openPageLoadDialog(ValidationMessages.disclaimerMessage, "Terms of Use", 1000);
}


function openParcelAccordion() {
    $('#collapseTwo').removeClass('in');
    //$('#collapseTwo').removeClass('in');
    //$('#collapseThree').removeClass('in');
    //$('#collapseFour').removeClass('in');
    //$('#collapseFive').removeClass('in');
    $('#lnkParcel').removeClass('collapsed');
    $('#collapseOne').addClass('in');
    $('#collapseOne').css('height', 'auto');
    //$('#lnkZoning').addClass('collapsed');
    //$('#lnkGeographicalInfo').addClass('collapsed');
    //$('#lnkDocumentsInfo').addClass('collapsed');
    //$('#lnkOtherInfo').addClass('collapsed');
    $('#lnkBuilding').attr('href', '#');

}

function openBuildingAccordion() {
    if (IsRequestFromPCIS == true || (bldgType != "" || buildingid != "")) {
        $('#divBuildingQuickView').css("display", "block");
        $('#lnkBuilding').attr('href', '#collapseTwo');
        //$('#collapseOne').removeClass('in');
        $('#lnkBuilding').removeClass('collapsed');
        $('#collapseTwo').addClass('in');
        $('#collapseTwo').css('height', 'auto');
        $('#lnkParcel').addClass('collapsed');
    }
    else {
        openParcelAccordion();
    }

}

function toggleFeatureLayersVisibility(groupName) {
    if (map.getZoom() < 12) {
        map.setZoom(12);
        //var point = new esri.geometry.Point(-118.35, 34.05, new esri.SpatialReference({ wkid: 4326 }));
        //map.centerAndZoom(point, 12);
    }
    $('#trBaseMapHeader').css('display', 'none');
    visibleLayers.length = 0;
    switch (groupName) {
        case "Zoning":
            if (isZoneLayerClicked) {
                //isHillsideLayerClicked = true;                
                isMethaneLayerClicked = true;
                isRoadsLayerClicked = true;
                isSewerLayerClicked = true;
                isCensorLayerClicked = true;
                isFaultZonesLayerClicked = true;
                isTopographyLayerClicked = true;
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer_selected.png');
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                // $('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer.png');
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#selectedImgZoneLayer').css("display", "inline-block");
                $('#selectedImgSewerLayer').css("display", "none");
                $('#selectedImgMethaneLayer').css("display", "none");
                // $('#selectedImgHillSideLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#selectedImgTopographyLayer').css("display", "none");
                $('#selectedImgCensusLayer').css("display", "none");
                $('#selectedImgZoneLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                $('#tblCensus').css("display", "none");
                //$('#tblHillside').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#tblZoning').css("display", "table");
                $('#tblTopography').css("display", "none");

                //$('#imgZoneLayer').addClass('selectedImages');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$('#imgCensusLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", true);
                //$("#rdSewer").prop("checked", false);
                //$("#rdMethane").prop("checked", false);
                //$("#rdHillside").prop("checked", false);
                //$("#rdCensus").prop("checked", false);
                //$('#imgLayer').css('display', 'inline-block');                
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/zoning small icon.png');
                //visibleLayers.push(10);
                visibleLayers.push(9);
            }
            else {
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", false);
            }
            isZoneLayerClicked = !isZoneLayerClicked;
            break;
        case "Sewer":
            if (isSewerLayerClicked) {
                // isHillsideLayerClicked = true;
                isMethaneLayerClicked = true;
                isZoneLayerClicked = true;
                isRoadsLayerClicked = true;
                isCensorLayerClicked = true;
                isFaultZonesLayerClicked = true;
                isTopographyLayerClicked = true;
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer_selected.png');
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                //$('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer.png');
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#selectedImgSewerLayer').css("display", "inline-block");
                $('#selectedImgMethaneLayer').css("display", "none");
                // $('#selectedImgHillSideLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#selectedImgTopographyLayer').css("display", "none");
                $('#selectedImgCensusLayer').css("display", "none");
                $('#selectedImgSewerLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                $('#tblCensus').css("display", "none");
                //$('#tblHillside').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#tblSewer').css("display", "table");
                $('#tblTopography').css("display", "none");
                //$('#imgSewerLayer').addClass('selectedImages');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$('#imgCensusLayer').removeClass('selectedImages');                
                //$("#rdZoning").prop("checked", false);
                //$("#rdSewer").prop("checked", true);
                //$("#rdMethane").prop("checked", false);
                //$("#rdHillside").prop("checked", false);
                //$("#rdCensus").prop("checked", false);
                //$('#imgLayer').css('display', 'inline-block');
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/sewer small icon.png');
                //visibleLayers.push(11);
                //visibleLayers.push(12);
                //visibleLayers.push(13);
                //visibleLayers.push(14);
                visibleLayers.push(10);
                visibleLayers.push(11);
                visibleLayers.push(12);
                visibleLayers.push(13);
            }
            else {
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgSewerLayer').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$("#rdSewer").prop("checked", false);
            }
            isSewerLayerClicked = !isSewerLayerClicked;
            break;
        case "Methane":
            if (isMethaneLayerClicked) {
                //isHillsideLayerClicked = true;
                isZoneLayerClicked = true;
                isRoadsLayerClicked = true;
                isSewerLayerClicked = true;
                isCensorLayerClicked = true;
                isFaultZonesLayerClicked = true;
                isTopographyLayerClicked = true;
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer_selected.png');
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                // $('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer.png');
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#selectedImgSewerLayer').css("display", "none");
                $('#selectedImgMethaneLayer').css("display", "inline-block");
                $('#selectedImgTopographyLayer').css("display", "none");
                // $('#selectedImgHillSideLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#selectedImgCensusLayer').css("display", "none");
                $('#selectedImgMethaneLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                $('#tblCensus').css("display", "none");
                // $('#tblHillside').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#tblMethane').css("display", "table");
                $('#tblTopography').css("display", "none");
                //$('#imgMethaneLayer').addClass('selectedImages');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$('#imgCensusLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", false);
                //$("#rdSewer").prop("checked", false);
                //$("#rdMethane").prop("checked", true);
                //$("#rdHillside").prop("checked", false);
                //$("#rdCensus").prop("checked", false);
                //$('#imgLayer').css('display', 'inline-block');
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/methane small icon.png');
                
                //visibleLayers.push(17);
                //visibleLayers.push(18);
                //visibleLayers.push(19);
                visibleLayers.push(16);
                visibleLayers.push(17);
                visibleLayers.push(18);
            } else {
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgMethaneLayer').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$("#rdMethane").prop("checked", false);
            }
            isMethaneLayerClicked = !isMethaneLayerClicked;
            break;
            //case "Hillside":
            //    if (isHillsideLayerClicked) {
            //        isMethaneLayerClicked = true;
            //        isZoneLayerClicked = true;
            //        isRoadsLayerClicked = true;
            //        isSewerLayerClicked = true;
            //        isCensorLayerClicked = true;
            //        $('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer_selected.png');
            //        $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
            //        $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
            //        $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
            //        $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
            //        $('#selectedImgZoneLayer').css("display", "none");
            //        $('#selectedImgSewerLayer').css("display", "none");
            //        $('#selectedImgMethaneLayer').css("display", "none");
            //        $('#selectedImgHillSideLayer').css("display", "inline-block");
            //        $('#selectedImgCensusLayer').css("display", "none");
            //        $('#selectedImgHillSideLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
            //        $('#tblCensus').css("display", "none");
            //        $('#tblMethane').css("display", "none");
            //        $('#tblSewer').css("display", "none");
            //        $('#tblZoning').css("display", "none");
            //        $('#tblHillside').css("display", "table");
            //        //$('#imgHillsideLayer').addClass('selectedImages');
            //        //$('#imgZoneLayer').removeClass('selectedImages');
            //        //$('#imgSewerLayer').removeClass('selectedImages');
            //        //$('#imgMethaneLayer').removeClass('selectedImages');
            //        //$('#imgCensusLayer').removeClass('selectedImages');
            //        //$("#rdZoning").prop("checked", false);
            //        //$("#rdSewer").prop("checked", false);
            //        //$("#rdMethane").prop("checked", false);
            //        //$("#rdHillside").prop("checked", true);
            //        //$("#rdCensus").prop("checked", false);
            //        //$('#imgLayer').css('display', 'inline-block');
            //        //$('#imgLayer').attr('src', '/StructuralInventory/Images/hillside small icon.png');
            //        visibleLayers.push(15);
            //        visibleLayers.push(16);
            //    }
            //    else {
            //        $('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer.png');
            //        $('#imgLayer').css('display', 'none');
            //        $('#selectedImgHillSideLayer').css("display", "none");
            //        $('#tblHillside').css("display", "none");
            //        $('#trBaseMapHeader').css('display', 'table-row');
            //        //$('#imgHillsideLayer').removeClass('selectedImages');
            //        //$("#rdHillside").prop("checked", false);
            //    }
            //    isHillsideLayerClicked = !isHillsideLayerClicked;
            //    break;
        case "Census":
            if (isCensorLayerClicked) {
                // isHillsideLayerClicked = true;
                isMethaneLayerClicked = true;
                isZoneLayerClicked = true;
                isRoadsLayerClicked = true;
                isSewerLayerClicked = true;
                isFaultZonesLayerClicked = true;
                isTopographyLayerClicked = true;
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer_selected.png');
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                // $('#imgHillsideLayer').attr('src', '/StructuralInventory/Images/hillside_layer.png');
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#selectedImgSewerLayer').css("display", "none");
                $('#selectedImgMethaneLayer').css("display", "none");
                $('#selectedImgTopographyLayer').css("display", "none");
                // $('#selectedImgHillSideLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#selectedImgCensusLayer').css("display", "inline-block");
                $('#selectedImgCensusLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                // $('#tblHillside').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#tblTopography').css("display", "none");
                $('#tblCensus').css("display", "table");
                //$('#imgCensusLayer').addClass('selectedImages');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", false);
                //$("#rdSewer").prop("checked", false);
                //$("#rdMethane").prop("checked", false);
                //$("#rdHillside").prop("checked", false);
                //$("#rdCensus").prop("checked", true);
                //$('#imgLayer').css('display', 'inline-block');
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/census small icon.png');
                //visibleLayers.push(9);
                visibleLayers.push(8);
            }
            else {
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgCensusLayer').css("display", "none");
                $('#tblCensus').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgCensusLayer').removeClass('selectedImages');
                //$("#rdCensus").prop("checked", false);
            }
            isCensorLayerClicked = !isCensorLayerClicked;
            break;
        case "FaultZone":
            if (isFaultZonesLayerClicked) {
                isMethaneLayerClicked = true;
                isZoneLayerClicked = true;
                isRoadsLayerClicked = true;
                isSewerLayerClicked = true;
                isCensorLayerClicked = true;
                isTopographyLayerClicked = true;
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer_selected.png');
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#selectedImgSewerLayer').css("display", "none");
                $('#selectedImgMethaneLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "inline-block");
                $('#selectedImgCensusLayer').css("display", "none");
                $('#selectedImgTopographyLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                $('#tblCensus').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#tblTopography').css("display", "none");
                $('#tblFaultZones').css("display", "table");
                //$('#imgHillsideLayer').addClass('selectedImages');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$('#imgCensusLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", false);
                //$("#rdSewer").prop("checked", false);
                //$("#rdMethane").prop("checked", false);
                //$("#rdHillside").prop("checked", true);
                //$("#rdCensus").prop("checked", false);
                //$('#imgLayer').css('display', 'inline-block');
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/hillside small icon.png');
                //visibleLayers.push(15);
                //visibleLayers.push(16);
                visibleLayers.push(14);
                visibleLayers.push(15);
            }
            else {
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$("#rdHillside").prop("checked", false);
            }
            isFaultZonesLayerClicked = !isFaultZonesLayerClicked;
            break;
        case "Topography":
            if (isTopographyLayerClicked) {
                isMethaneLayerClicked = true;
                isZoneLayerClicked = true;
                isRoadsLayerClicked = true;
                isSewerLayerClicked = true;
                isCensorLayerClicked = true;
                isFaultZonesLayerClicked = true;
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer_selected.png');
                $('#imgZoneLayer').attr('src', '/StructuralInventory/Images/zoning_layer.png');
                $('#imgSewerLayer').attr('src', '/StructuralInventory/Images/sewer_layer.png');
                $('#imgMethaneLayer').attr('src', '/StructuralInventory/Images/methane_layer.png');
                $('#imgCensusLayer').attr('src', '/StructuralInventory/Images/census_layer.png');
                $('#imgFaultZoneLayer').attr('src', '/StructuralInventory/Images/Faultline_layer.png');
                $('#selectedImgZoneLayer').css("display", "none");
                $('#selectedImgSewerLayer').css("display", "none");
                $('#selectedImgMethaneLayer').css("display", "none");
                $('#selectedImgTopographyLayer').css("display", "inline-block");
                $('#selectedImgCensusLayer').css("display", "none");
                $('#selectedImgFaultZoneLayer').css("display", "none");
                $('#selectedImgTopographyLayer').attr('src', '/StructuralInventory/Images/right_tick.png');
                $('#tblCensus').css("display", "none");
                $('#tblMethane').css("display", "none");
                $('#tblSewer').css("display", "none");
                $('#tblZoning').css("display", "none");
                $('#tblFaultZones').css("display", "none");
                $('#tblTopography').css("display", "table");
                //$('#imgHillsideLayer').addClass('selectedImages');
                //$('#imgZoneLayer').removeClass('selectedImages');
                //$('#imgSewerLayer').removeClass('selectedImages');
                //$('#imgMethaneLayer').removeClass('selectedImages');
                //$('#imgCensusLayer').removeClass('selectedImages');
                //$("#rdZoning").prop("checked", false);
                //$("#rdSewer").prop("checked", false);
                //$("#rdMethane").prop("checked", false);
                //$("#rdHillside").prop("checked", true);
                //$("#rdCensus").prop("checked", false);
                //$('#imgLayer').css('display', 'inline-block');
                //$('#imgLayer').attr('src', '/StructuralInventory/Images/hillside small icon.png');
                //visibleLayers.push(20);
                visibleLayers.push(19);
            }
            else {
                $('#imgTopographyLayer').attr('src', '/StructuralInventory/Images/topography_layer.png');
                $('#imgLayer').css('display', 'none');
                $('#selectedImgTopographyLayer').css("display", "none");
                $('#tblTopography').css("display", "none");
                $('#trBaseMapHeader').css('display', 'table-row');
                //$('#imgHillsideLayer').removeClass('selectedImages');
                //$("#rdHillside").prop("checked", false);
            }
            isTopographyLayerClicked = !isTopographyLayerClicked;
            break;
    }

    setVisibilityOfLayers();

}

function setVisibilityOfLayers() {
    var currentLayer = ladbslayer;
    var subLayers = currentLayer.layerInfos;

    for (var i = 0; i < subLayers.length; i++) {
        var currentSubLayer = subLayers[i];

        if (currentSubLayer.defaultVisibility) {

            if (PCIS_bld_id != "" && bldgType != "") {
                visibleLayers.push(currentSubLayer.id);
            }
            //else if (currentSubLayer.id != 2) {
                visibleLayers.push(currentSubLayer.id);
            //}
        }
    }
    currentLayer.setVisibility(true);
    currentLayer.setVisibleLayers(visibleLayers);
}



function openAuthenticationPopup() {
    InitializeDialog('#requestViewModal', '@Url.Action("Authenticate", "Authentication")', 'Authentication', 'auto', 400);

    $("#requestViewModal").dialog("option", "dialogClass", "AuthenticationView");
    /* Open dialog box */
    $('#requestViewModal').dialog("open");
    return false;
}
