﻿var dentons_App = angular.module('dentonsGlobalApp', ['ngPako']);



//dentons_App.controller('allPageSearch', ['$scope', '$sce', '$window', '$timeout', '$http', 'pako', function ($scope, $sce, $window, $timeout, $http, pako) {

//    var contextLanguage = document.querySelector("ContextLanguage").getAttribute('value');
//    var contextWebsite = document.querySelector("ContextWebsite").getAttribute('value');

//    $scope.modalDialog = [];
//    $scope.pageNo = 1;
//    $scope.s = [];
//    $scope.redirection_ModalDialog = [];
//    $scope.language_ModalDialog = [];

//    //Decompressor
//    $scope.GZipDecompressor = function (data) {

//        var convertData = window.atob(data);
//        var charData = convertData.split('').map(function (x) { return x.charCodeAt(0); });
//        var binData = new Uint8Array(charData);

//        var d = pako.inflate(binData, { to: "string" });
//        return d;
//    }

//    $scope.jumpToPage = function (_url) {
//        $window.location.href = _url;
//        //$window.location.reload();
//    }

//    $scope.setFocus = function (identifier) {
//        document.querySelector(identifier).focus();
//    }
//    $scope.setBlur = function (identifier) {
//        document.querySelector(identifier).blur();
//    }



//    $scope.htmlRenderer = function (text) {
//        if (text != undefined) {
//            if (text.length > 0) {
//                var text = angular.element('<textarea />').html(text).text();
//                return $sce.trustAsHtml(text);
//            }

//        }
//    }


//    $scope.mainSearchSuggestion = function (data) {
//        var pageSize = 5;
//        if (document.documentElement.clientWidth < 991) {
//            pageSize = 5;
//        }

//        var url = "/DentonsServices/GlobalSearch.svc/GetGlobalsuggestions?keyword=" + encodeURI(data) + "&contextlang=" +
//                    contextLanguage +
//                    "&contextsite=" + contextWebsite;
//        return $http({
//            url: url,
//            method: "GET",
//            headers: { 'Content-Type': 'application/json' }
//        })
//    }

//    //getting all autosuggestions

//    $scope.matchInputEntry;
//    var filterTextTimeout;
//    $scope.languageDetector = function () {
//        return document.querySelector("ContextLanguage").getAttribute('value');
//    }

//    $scope.callSuggestions = function (event) {

//        $scope.autoLimit = function (num) {
//            if ($scope.globalSuggestionIn.length > num) {
//                var storevalue = $scope.globalSuggestionIn.substr(0, num - 1);
//                storevalue = storevalue.substr(0, storevalue.lastIndexOf(" ") !== -1 ? storevalue.lastIndexOf(" ") : num);
//                if ($scope.globalSuggestionIn.substring(0, 1) == '"') {
//                    $scope.globalSuggestionIn = storevalue + '"';
//                }
//                else {
//                    $scope.globalSuggestionIn = storevalue;
//                }
//            }
//        }

//        if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
//            $scope.autoLimit(40);
//        } else {
//            $scope.autoLimit(126);
//        }

//        if (filterTextTimeout) { $timeout.cancel(filterTextTimeout); }

//        filterTextTimeout = $timeout(function () {


//            if (event.keyCode != 13 && $scope.globalSuggestionIn != $scope.matchInputEntry) {
//                if ($scope.globalSuggestionIn != undefined) {
//                    var par;
//                    if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
//                        if ($scope.globalSuggestionIn.length >= 1) {
//                            par = $scope.globalSuggestionIn;
//                            console.log(par);
//                            $scope.mainSearchSuggestion(par).then(
//                                    function (response) {
//                                        if (response.data.length > 0) {
//                                            $scope.allSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
//                                            console.log($scope.allSearchSuggestionList);
//                                        } else {
//                                            console.log("No data from API, data:" + response.data);
//                                        }
//                                    },
//                                    function (err) {
//                                        console.log(err);
//                                    }
//                            );
//                        }
//                    } else {
//                        if ($scope.globalSuggestionIn.length >= 3) {
//                            par = $scope.globalSuggestionIn;
//                            console.log(par);
//                            $scope.mainSearchSuggestion(par).then(
//                                    function (response) {
//                                        if (response.data.length > 0) {
//                                            $scope.allSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
//                                            console.log($scope.allSearchSuggestionList);
//                                        } else {
//                                            console.log("No data from API, data:" + response.data);
//                                        }
//                                    },
//                                    function (err) {
//                                        console.log(err);
//                                    }
//                            );
//                        } else {
//                            $scope.allSearchSuggestionList = [];
//                        }

//                    }

//                }

//                $scope.matchInputEntry = $scope.globalSuggestionIn;
//            }




//        }, 400);


//    }

//    $scope.mainAutosuggestionsNow = function (e) {

//        if (e !== undefined) {
//            e.preventDefault();
//        }


//        if ($scope.globalSuggestionIn !== undefined && $scope.globalSuggestionIn.length > 0) {
//            var global_url = document.querySelector("GlobalSearchURL").getAttribute('url').trim();
//            //$window.search('Filters', '=&Regions=&Keywords=' + $scope.globalSuggestionIn);

//            var go_url = global_url + "?Filters=" + encodeURIComponent('&regionid=&Keywords=') + encodeURIComponent($scope.globalSuggestionIn);
//            $window.location.href = go_url;
//            if (($window.location.origin + $window.location.pathname) == global_url) {
//                //$window.location.reload();
//            }
//        } else {
//            $window.location.href = document.querySelector("input[id$='hdSearchResultItem']").value.trim();

//        }


//    }

//    $scope.highlightKeywordsGlobal = function (textToHighlight, keywords) {

//        var stringToArray = function (input) {
//            if (input) {
//                return input.match(/\S+/g);
//            }
//            else {
//                return [];
//            }
//        };

//        var getRegexPattern = function (keywordArray, exact) {
//            //var pattern = "(^|\\B|\\b)(" + keywordArray.join("|") + ")";
//            //var pattern = "((?:\\s|^)(" + keywordArray.join(" ") + ")(?:\\s|$))";
//            var chLang = (document.querySelector("ContextLanguage").getAttribute('value') == "zh-CN" || document.querySelector("ContextLanguage").getAttribute('value') == "ko-KR") ? true : false;  //changes by pinky SNR-2864
//            if (exact == null) {
//                //var pattern = "((?:^|\\s)(" + keywordArray.join("|") + ")(?:$|))";
//                if (chLang) {
//                    var pattern = "(" + keywordArray.join('') + ")";
//                } else {
//                    var pattern = "((?:^|\\s|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\|,.<>\\/?]|[\u201C])(" + keywordArray.join("|") + ")(?:[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?\]|[\u201D]|$|))";
//                }

//            } else {

//                if (chLang) {
//                    var pattern = "(" + keywordArray.join('') + ")";
//                } else {
//                    var pattern = "(?:\\s|^|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201C])(" + keywordArray.join(" ") + ")(?:\\s|$|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201D])";
//                }

//            }


//            return new RegExp(pattern, "gi");
//        };
//        var filteredText = textToHighlight;
//        if (keywords !== "") {
//            var exact = null;
//            if (keywords.indexOf("\"") !== -1) {
//                exact = 1;
//                keywords = keywords.replace(/\"/gi, '');
//            }
//            var keywordList = stringToArray(keywords);

//            var pattern = getRegexPattern(keywordList, exact);
//            //console.log(pattern);
//            if (textToHighlight != undefined) {
//                filteredText = textToHighlight.replace(pattern, '<span class="highlighted-1">$&</span>');
//                return $sce.trustAsHtml(filteredText);
//            }
//        }
//    }

//    $scope.closeGlobalHeaderSuggestion = function (event) {
//        var area_input = document.querySelector('.right.colored input');
//        var area_list = document.querySelector('ul.allpages-searchbar-list');


//        if ((event.target != area_input) && event.target != area_list && event.target.offsetParent != area_list) {
//            $timeout(function () {
//                $scope.globalSuggestionIn = "";
//            }, 0);
//        }
//    }

//    document.onclick = function (event) {
//        $scope.closeGlobalHeaderSuggestion(event);
//    }


//    //--------------- calculation Logic ---------------------------

//    $scope.preventDefault = function (event) {
//        event.preventDefault();
//        event.stopImmediatePropagation();
//        event.stopPropagation();
//    }



//    $scope.modalOpen = false;

//    $scope.replaceAutoModalData = function (id, key, replace) {
//        //var p = document.querySelector(id).innerText;
//        //var regex = /\$redirectingsite/gi;
//        //document.querySelector(id).innerText = (p.replace(regex, replace));
//        document.querySelector(id).querySelector('span.MicrositeAlertText').innerText = replace;
//    }

//    $scope.openModalPopUpCommon = function (suggestion) {

//        $scope.modalOpenData = suggestion;

//        if (suggestion.globalRedirectUrl !== null && suggestion.globalRedirectUrl !== undefined) {
//            if (suggestion.globalRedirectUrl.length > 4) {
//                suggestion['linkUrl'] = suggestion.globalRedirectUrl;
//            }

//        }

//        if ($scope.modalOpenData.showSiteRedirectionDisclaimer == true || $scope.modalOpenData.showSiteRedirectionDisclaimer == "true") {


//            $scope.replaceAutoModalData("#MicrositeDisclaimer .repeat-lightbg p", "$redirectingsite", $scope.modalOpenData.redirectedWebsite);

//            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
//            document.querySelector('#MicrositeDisclaimer').style.display = 'block';
//            document.querySelector('#MicrositeDisclaimer .lightbox1').style.display = 'block';
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('target', '_blank');
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

//        } else if ($scope.modalOpenData.showLangDisclaimer == true || $scope.modalOpenData.showLangDisclaimer == "true") {

//            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
//            document.querySelector('#lang_Disclaimer').style.display = 'block';
//            document.querySelector('#lang_Disclaimer').parentElement.style.display = 'block';

//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('target');
//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

//        } else if (($scope.modalOpenData.showSiteRedirectionDisclaimer == false || $scope.modalOpenData.showSiteRedirectionDisclaimer == "false") && ($scope.modalOpenData.showLangDisclaimer == false || $scope.modalOpenData.showLangDisclaimer == "false")) {

//            $window.location.href = $scope.modalOpenData.linkUrl;
//            if (($window.location.origin + $window.location.pathname) == $scope.modalOpenData.linkUrl.split('?')[0]) {
//                // $window.location.reload();
//            }
//        }

//    }





//}]);


////PEOPLE SEARCH MEGA MENU SEARCH && HOME PAGE SEARCH

//var dentons_PeopleSearchMegaMenuApp = angular.module('App_MegamenuPeopleSearch', ['ngPako']);

//dentons_PeopleSearchMegaMenuApp.controller('Ctr_MegamenuPeopleSearch', ['$scope', '$sce', '$window', '$timeout', '$http', 'pako', function ($scope, $sce, $window, $timeout, $http, pako) {

//    var contextLanguage = document.querySelector("ContextLanguage").getAttribute('value');
//    var contextWebsite = document.querySelector("ContextWebsite").getAttribute('value');

//    $scope.modalDialog = [];
//    $scope.pageNo = 1;
//    $scope.s = [];
//    $scope.redirection_ModalDialog = [];
//    $scope.language_ModalDialog = [];

//    //Decompressor
//    $scope.GZipDecompressor = function (data) {

//        var convertData = window.atob(data);
//        var charData = convertData.split('').map(function (x) { return x.charCodeAt(0); });
//        var binData = new Uint8Array(charData);

//        var d = pako.inflate(binData, { to: "string" });
//        return d;
//    }

//    $scope.setFocus = function (identifier) {
//        document.querySelector(identifier).focus();

//    }
//    $scope.setBlur = function (identifier) {
//        document.querySelector(identifier).blur();
//    }

//    $scope.closeAutosuggestion = function () {

//        $timeout(function () {
//            $scope.listFocus = false;
//        }, 300);

//    }

//    $scope.htmlRenderer = function (text) {
//        if (text != undefined) {
//            if (text.length > 0) {
//                var text = angular.element('<textarea />').html(text).text();
//                return $sce.trustAsHtml(text);
//            }

//        }
//    }


//    $scope.mainSearchNow = function (event) {

//        if (event !== undefined) {
//            event.preventDefault();
//        }

//        if ($scope.s.mainSearch !== undefined && $scope.s.mainSearch.length > 0) {

//            //autosuggestion advance sector recognise
//            //var keys = document.querySelector('autosuggmatchids').getAttribute('keys').split('$');
//            //var suggestion = $scope.mainSearchSuggestionList.filter(function (x) { return x.title.trim().toUpperCase() == $scope.s.mainSearch.trim().toUpperCase() && (keys.filter(function (y) { return x.categoryID == y }).length > 0) });
//            //if (suggestion != undefined && suggestion.length > 0) {
//            //    $scope.s.mainSearch = '';
//            //    $scope.openModalPopUpCommon(suggestion[0]);
//            //} else {

//            //}

//            var global_url = document.querySelector("ourprofessional").getAttribute('url').trim();
//            //$window.search('Filters', '=&regionid=&Keywords=' + $scope.globalSuggestionIn);
//            var go_url = global_url + "?Filters=" + encodeURIComponent('&regionid=&sectorid=&practiceid=&positionid=&languageid=&inpid=&Keywords=') + encodeURIComponent($scope.s.mainSearch);
//            $window.location.href = go_url;
//            if (($window.location.origin + $window.location.pathname) == global_url) {
//                //$window.location.reload();
//            }
//        }

//    }

//    $scope.mainSearchSuggestion = function (par) {
//        var pageSize = 4;
//        if (document.documentElement.clientWidth < 991) {
//            pageSize = 4;
//        }

//        var url = "/DentonsServices/PeopleSearch.svc/MainSearchSuggestion?data=" + encodeURI(par) + "&contextLanguage=" + contextLanguage + "&contextSite=" + contextWebsite + "&pageNumber=1&pageSize=" + pageSize;
//        return $http({
//            url: url,
//            method: "GET",
//            headers: { 'Content-Type': 'application/json' }
//        })
//    }

//    $scope.highlightKeywordsGlobal = function (textToHighlight, keywords) {

//        var stringToArray = function (input) {
//            if (input) {
//                return input.match(/\S+/g);
//            }
//            else {
//                return [];
//            }
//        };

//        var getRegexPattern = function (keywordArray, exact) {
//            //var pattern = "(^|\\B|\\b)(" + keywordArray.join("|") + ")";
//            //var pattern = "((?:\\s|^)(" + keywordArray.join(" ") + ")(?:\\s|$))";
//            var chLang = (document.querySelector("ContextLanguage").getAttribute('value') == "zh-CN" || document.querySelector("ContextLanguage").getAttribute('value') == "ko-KR") ? true : false;  //changes by pinky SNR-2864
//            if (exact == null) {
//                //var pattern = "((?:^|\\s)(" + keywordArray.join("|") + ")(?:$|))";
//                if (chLang) {
//                    var pattern = "(" + keywordArray.join('') + ")";
//                } else {
//                    var pattern = "((?:^|\\s|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\|,.<>\\/?]|[\u201C])(" + keywordArray.join("|") + ")(?:[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?\]|[\u201D]|$|))";
//                }

//            } else {

//                if (chLang) {
//                    var pattern = "(" + keywordArray.join('') + ")";
//                } else {
//                    var pattern = "(?:\\s|^|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201C])(" + keywordArray.join(" ") + ")(?:\\s|$|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201D])";
//                }

//            }


//            return new RegExp(pattern, "gi");
//        };
//        var filteredText = textToHighlight;
//        if (keywords !== "") {
//            var exact = null;
//            if (keywords.indexOf("\"") !== -1) {
//                exact = 1;
//                keywords = keywords.replace(/\"/gi, '');
//            }
//            var keywordList = stringToArray(keywords);

//            var pattern = getRegexPattern(keywordList, exact);
//            //console.log(pattern);
//            if (textToHighlight != undefined) {
//                filteredText = textToHighlight.replace(pattern, '<span class="highlighted-1">$&</span>');
//                return $sce.trustAsHtml(filteredText);
//            }
//        }
//    }

//    //getting all main search suggestions
//    $scope.matchInputEntry;
//    $scope.languageDetector = function () {
//        return document.querySelector("ContextLanguage").getAttribute('value');
//    }
//    $scope.mainAutoSuggestion = function (event) {


//        $scope.autoLimit = function (num) {
//            if ($scope.s.mainSearch.length > num) {
//                var storevalue = $scope.s.mainSearch.substr(0, num - 1);
//                storevalue = storevalue.substr(0, storevalue.lastIndexOf(" ") !== -1 ? storevalue.lastIndexOf(" ") : num);
//                if ($scope.s.mainSearch.substring(0, 1) == '"') {
//                    $scope.s.mainSearch = storevalue + '"';
//                }
//                else {
//                    $scope.s.mainSearch = storevalue;
//                }
//            }
//        }

//        if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
//            $scope.autoLimit(40);
//        } else {
//            $scope.autoLimit(126);
//        }


//        if (event.keyCode != 13 && $scope.s.mainSearch != $scope.matchInputEntry) {
//            if ($scope.s.mainSearch != undefined) {
//                var par;
//                if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
//                    if ($scope.s.mainSearch.length >= 1) {
//                        par = $scope.s.mainSearch;
//                        console.log(par);
//                        $scope.mainSearchSuggestion(par).then(
//                                function (response) {
//                                    if (response.data.length > 0) {
//                                        $scope.mainSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
//                                        console.log($scope.mainSearchSuggestionList);
//                                    } else {
//                                        console.log("No data from API, data:" + response.data);
//                                    }
//                                },
//                                function (err) {
//                                    console.log(err);
//                                }
//                        );
//                    }
//                } else {
//                    if ($scope.s.mainSearch.length >= 3) {
//                        par = $scope.s.mainSearch;
//                        console.log(par);
//                        $scope.mainSearchSuggestion(par).then(
//                                function (response) {
//                                    if (response.data.length > 0) {
//                                        $scope.mainSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
//                                        console.log($scope.mainSearchSuggestionList);
//                                    } else {
//                                        console.log("No data from API, data:" + response.data);
//                                    }
//                                },
//                                function (err) {
//                                    console.log(err);
//                                }
//                        );
//                    } else {
//                        $scope.mainSearchSuggestionList = [];
//                    }

//                }

//            }

//            $scope.matchInputEntry = $scope.s.mainSearch;
//        }
//    }


//    $scope.closeSearchSuggestion = function (event) {
//        var area_input = document.querySelector('.searchbar');
//        var area_list = document.querySelector('ul.searchbar-list');

//        if ((event.target != area_input) && event.target != area_list) {
//            $timeout(function () {
//                $scope.listFocus = false;
//            }, 0);
//        }
//    }


//    //--------------- calculation Logic ---------------------------


//    $scope.modalOpen = false;

//    $scope.replaceAutoModalData = function (id, key, replace) {
//        //var p = document.querySelector(id).innerText;
//        //var regex = /\$redirectingsite/gi;
//        //document.querySelector(id).innerText = (p.replace(regex, replace));
//        document.querySelector(id).querySelector('span.MicrositeAlertText').innerText = replace;
//    }

//    $scope.openModalPopUpCommon = function (suggestion) {

//        $scope.modalOpenData = suggestion;

//        if (suggestion.globalRedirectUrl !== null && suggestion.globalRedirectUrl !== undefined) {
//            if (suggestion.globalRedirectUrl.length > 4) {
//                suggestion['linkUrl'] = suggestion.globalRedirectUrl;
//            }

//        }

//        if ($scope.modalOpenData.showSiteRedirectionDisclaimer == true || $scope.modalOpenData.showSiteRedirectionDisclaimer == "true") {


//            $scope.replaceAutoModalData("#MicrositeDisclaimer .repeat-lightbg p", "$redirectingsite", $scope.modalOpenData.redirectedWebsite);

//            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
//            document.querySelector('#MicrositeDisclaimer').style.display = 'block';
//            document.querySelector('#MicrositeDisclaimer .lightbox1').style.display = 'block';
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('target', '_blank');
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
//            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

//        } else if ($scope.modalOpenData.showLangDisclaimer == true || $scope.modalOpenData.showLangDisclaimer == "true") {

//            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
//            document.querySelector('#lang_Disclaimer').style.display = 'block';
//            document.querySelector('#lang_Disclaimer').parentElement.style.display = 'block';

//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('target');
//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
//            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

//        } else if (($scope.modalOpenData.showSiteRedirectionDisclaimer == false || $scope.modalOpenData.showSiteRedirectionDisclaimer == "false") && ($scope.modalOpenData.showLangDisclaimer == false || $scope.modalOpenData.showLangDisclaimer == "false")) {



//            $window.location.href = $scope.modalOpenData.linkUrl;
//            if (($window.location.origin + $window.location.pathname) == $scope.modalOpenData.linkUrl.split('?')[0]) {
//                //$window.location.reload();
//            }

//        }

//    }


//    $timeout(function () {
//        if (document.querySelectorAll('[ng-app]').length < 3) {
//            webAccessibility();
//        }
//    }, 0);

//}]);

//var dentons_PeopleSearchApp = angular.module('App_OurProfessional', ['ngPako']);

dentonsApp.controller('Ctr_OurProfessional', ['$scope', '$sce', '$window', '$timeout', '$http', 'pako', function ($scope, $sce, $window, $timeout, $http, pako) {
    var contextLanguage = document.querySelector("ContextLanguage").getAttribute('value');
    var contextWebsite = document.querySelector("ContextWebsite").getAttribute('value');

    $scope.modalDialog = [];
    $scope.pageNo = 1;
    $scope.s = [];
    $scope.redirection_ModalDialog = [];
    $scope.language_ModalDialog = [];

    //Decompressor
    $scope.GZipDecompressor = function (data) {

        var convertData = window.atob(data);
        var charData = convertData.split('').map(function (x) { return x.charCodeAt(0); });
        var binData = new Uint8Array(charData);

        var d = pako.inflate(binData, { to: "string" });
        return d;
    }

    $scope.setFocus = function (identifier) {
        document.querySelector(identifier).focus();

    }
    $scope.setBlur = function (identifier) {
        document.querySelector(identifier).blur();
    }

    $scope.onInputblur = function (identifier) {
        $timeout(function () {
            $scope.listFocus = false;
        }, 500);
        $(identifier).attr("aria-expanded", "false");
    }

    $scope.onSetFocus = function (identifier) {
        if ($scope.s.mainSearch && $scope.s.mainSearch.length > 0 && $scope.listFocus == true && $scope.mainSearchSuggestionList.length > 0) {
            $(identifier).attr("aria-expanded", "true");
        }
    }

    $scope.closeAutosuggestion = function () {

        $timeout(function () {
            $scope.listFocus = false;
        }, 300);

    }

    $scope.htmlRenderer = function (text) {
        if (text != undefined) {
            if (text.length > 0) {
                var text = angular.element('<textarea />').html(text).text();
                return $sce.trustAsHtml(text);
            }

        }
    }

    $scope.mainSearchSuggestion = function (par) {
        var pageSize = 4;
        if (document.documentElement.clientWidth < 991) {
            pageSize = 4;
        }

        var url = "/DentonsServices/PeopleSearch.svc/MainSearchSuggestion?data=" + encodeURI(par) + "&contextLanguage=" + contextLanguage + "&contextSite=" + contextWebsite + "&pageNumber=1&pageSize=" + pageSize;
        return $http({
            url: url,
            method: "GET",
            headers: { 'Content-Type': 'application/json' }
        })
    }

    $scope.mainSearchNow = function (event) {

        if (event !== undefined) {
            event.preventDefault();
        }




        if ($scope.s.mainSearch !== undefined && $scope.s.mainSearch.length > 0) {

            //autosuggestion advance sector recognise
            //var keys = document.querySelector('autosuggmatchids').getAttribute('keys').split('$');
            //var suggestion = $scope.mainSearchSuggestionList.filter(function (x) { return x.title.trim().toUpperCase() == $scope.s.mainSearch.trim().toUpperCase() && (keys.filter(function (y) { return x.categoryID == y }).length > 0) });
            //if (suggestion != undefined && suggestion.length > 0) {
            //    $scope.s.mainSearch = '';
            //    $scope.openModalPopUpCommon(suggestion[0]);
            //} else {

            //}

            var global_url = document.querySelector("ourprofessional").getAttribute('url').trim();
            //$window.search('Filters', '=&regionid=&Keywords=' + $scope.globalSuggestionIn);
            var go_url = global_url + "?Filters=" + encodeURIComponent('&regionid=&sectorid=&practiceid=&positionid=&languageid=&inpid=&Keywords=') + encodeURIComponent($scope.s.mainSearch);
            $window.location.href = go_url;
            if (($window.location.origin + $window.location.pathname) == global_url) {
                // $window.location.reload();
            }
        }


    }

    $scope.highlightKeywordsGlobal = function (textToHighlight, keywords) {

        var stringToArray = function (input) {
            if (input) {
                return input.match(/\S+/g);
            }
            else {
                return [];
            }
        };

        var getRegexPattern = function (keywordArray, exact) {
            //var pattern = "(^|\\B|\\b)(" + keywordArray.join("|") + ")";
            //var pattern = "((?:\\s|^)(" + keywordArray.join(" ") + ")(?:\\s|$))";
            var chLang = (document.querySelector("ContextLanguage").getAttribute('value') == "zh-CN" || document.querySelector("ContextLanguage").getAttribute('value') == "ko-KR") ? true : false;  //changes by pinky SNR-2864
            if (exact == null) {
                //var pattern = "((?:^|\\s)(" + keywordArray.join("|") + ")(?:$|))";
                if (chLang) {
                    var pattern = "(" + keywordArray.join('') + ")";
                } else {
                    var pattern = "((?:^|\\s|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\|,.<>\\/?]|[\u201C])(" + keywordArray.join("|") + ")(?:[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?\]|[\u201D]|$|))";
                }

            } else {

                if (chLang) {
                    var pattern = "(" + keywordArray.join('') + ")";
                } else {
                    var pattern = "(?:\\s|^|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201C])(" + keywordArray.join(" ") + ")(?:\\s|$|[!@#$₪₦₩₭¥₱£€£¢﷼%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/?]|[\u201D])";
                }

            }


            return new RegExp(pattern, "gi");
        };
        var filteredText = textToHighlight;
        if (keywords !== "") {
            var exact = null;
            if (keywords.indexOf("\"") !== -1) {
                exact = 1;
                keywords = keywords.replace(/\"/gi, '');
            }
            var keywordList = stringToArray(keywords);

            var pattern = getRegexPattern(keywordList, exact);
            //console.log(pattern);
            if (textToHighlight != undefined) {
                filteredText = textToHighlight.replace(pattern, '<span class="highlighted-1">$&</span>');
                return $sce.trustAsHtml(filteredText);
            }
        }
    }

    //getting all main search suggestions
    $scope.matchInputEntry;
    $scope.languageDetector = function () {
        return document.querySelector("ContextLanguage").getAttribute('value');
    }
    $scope.mainAutoSuggestion = function (event) {

        $scope.autoLimit = function (num) {
            if ($scope.s.mainSearch.length > num) {
                var storevalue = $scope.s.mainSearch.substr(0, num - 1);
                storevalue = storevalue.substr(0, storevalue.lastIndexOf(" ") !== -1 ? storevalue.lastIndexOf(" ") : num);
                if ($scope.s.mainSearch.substring(0, 1) == '"') {
                    $scope.s.mainSearch = storevalue + '"';
                }
                else {
                    $scope.s.mainSearch = storevalue;
                }
            }
        }

        if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
            $scope.autoLimit(40);
        } else {
            $scope.autoLimit(126);
        }

        if (event.keyCode != 13 && $scope.s.mainSearch != $scope.matchInputEntry) {
            if ($scope.s.mainSearch != undefined) {
                var par;
                if ($scope.languageDetector() == "zh-CN" || $scope.languageDetector() == "ko-KR") {  //changes by pinky SNR-2864
                    if ($scope.s.mainSearch.length >= 1) {
                        par = $scope.s.mainSearch;
                        console.log(par);
                        $scope.mainSearchSuggestion(par).then(
                                function (response) {
                                    if (response.data.length > 0) {
                                        $scope.mainSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
                                        console.log($scope.mainSearchSuggestionList);
                                    } else {
                                        console.log("No data from API, data:" + response.data);
                                    }
                                },
                                function (err) {
                                    console.log(err);
                                }
                        );
                    }
                } else {
                    if ($scope.s.mainSearch.length >= 3) {
                        par = $scope.s.mainSearch;
                        console.log(par);
                        $scope.mainSearchSuggestion(par).then(
                                function (response) {
                                    if (response.data.length > 0) {
                                        $scope.mainSearchSuggestionList = JSON.parse($scope.GZipDecompressor(response.data));
                                        console.log($scope.mainSearchSuggestionList);
                                        //$("[ng-controller='Ctr_OurProfessional'] .searchbar-x-control,[ng-controller='Ctr_OurProfessional'] .searchbar-cross-control").attr("tabindex", "-1");
                                        if ($scope.mainSearchSuggestionList.length) {
                                            $scope.listFocus = true;
                                            $("[ng-controller='Ctr_OurProfessional'] input.searchbar").attr("aria-expanded", "true");
                                        }
                                    } else {
                                        console.log("No data from API, data:" + response.data);
                                        //$("[ng-controller='Ctr_OurProfessional'] .searchbar-x-control,[ng-controller='Ctr_OurProfessional'] .searchbar-cross-control").attr("tabindex", "-1");
                                        $("[ng-controller='Ctr_OurProfessional'] input.searchbar").attr("aria-expanded", "true");
                                        
                                    }
                            },
                                function (err) {
                                    console.log(err);
                                }
                        );
                    } else {
                        $scope.mainSearchSuggestionList = [];
                        $("[ng-controller='Ctr_OurProfessional'] .searchbar-x-control,[ng-controller='Ctr_OurProfessional'] .searchbar-cross-control").attr("tabindex", "0");
                        $("[ng-controller='Ctr_OurProfessional'] input.searchbar").attr("aria-expanded", "false");
                    }

                }

            }

            $scope.matchInputEntry = $scope.s.mainSearch;
        }
    }

    $scope.tabKeyPressed = function (event) {
        if (event.keyCode == 9) {
            $scope.setListFocus(true, 500);
            //activeliFunction();
        }
    }



    $scope.closeSearchSuggestion = function (event) {
        var area_input = document.querySelector('.searchbar');
        var area_list = document.querySelector('ul.searchbar-list');

        if ((event.target != area_input) && event.target != area_list) {
            $timeout(function () {
                $scope.listFocus = false;
            }, 0);
        }
    }


    //--------------- calculation Logic ---------------------------

    $scope.modalOpen = false;

    $scope.replaceAutoModalData = function (id, key, replace) {
        //var p = document.querySelector(id).innerText;
        //var regex = /\$redirectingsite/gi;
        //document.querySelector(id).innerText = (p.replace(regex, replace));
        document.querySelector(id).querySelector('span.MicrositeAlertText').innerText = replace;
    }

    $scope.openModalPopUpCommon = function (suggestion) {

        $scope.modalOpenData = suggestion;

        if (suggestion.globalRedirectUrl !== null && suggestion.globalRedirectUrl !== undefined) {
            if (suggestion.globalRedirectUrl.length > 4) {
                suggestion['linkUrl'] = suggestion.globalRedirectUrl;
            }

        }



        if ($scope.modalOpenData.showSiteRedirectionDisclaimer == true || $scope.modalOpenData.showSiteRedirectionDisclaimer == "true") {


            $scope.replaceAutoModalData("#MicrositeDisclaimer .repeat-lightbg p", "$redirectingsite", $scope.modalOpenData.redirectedWebsite);

            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
            document.querySelector('#MicrositeDisclaimer').style.display = 'block';
            document.querySelector('#MicrositeDisclaimer .lightbox1').style.display = 'block';
            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('target', '_blank');
            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
            document.querySelector('#MicrositeDisclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

        } else if ($scope.modalOpenData.showLangDisclaimer == true || $scope.modalOpenData.showLangDisclaimer == "true") {

            document.querySelector('.lightboxBg').style.cssText = 'display:block;width:100%;height:3544px';
            document.querySelector('#lang_Disclaimer').style.display = 'block';
            document.querySelector('#lang_Disclaimer').parentElement.style.display = 'block';

            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('target');
            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').removeAttribute('onclick');
            document.querySelector('#lang_Disclaimer .accpt-btn .acceptbtn').setAttribute('href', $scope.modalOpenData.linkUrl);

        } else if (($scope.modalOpenData.showSiteRedirectionDisclaimer == false || $scope.modalOpenData.showSiteRedirectionDisclaimer == "false") && ($scope.modalOpenData.showLangDisclaimer == false || $scope.modalOpenData.showLangDisclaimer == "false")) {


            $window.location.href = $scope.modalOpenData.linkUrl;
            if (($window.location.origin + $window.location.pathname) == $scope.modalOpenData.linkUrl.split('?')[0]) {
                //$window.location.reload();
            }
        }


    }

    webAccessibility();


}]);


//GAEvent Event Track Code for Email me
//$scope.GaEventTrackCodeEmail = function (mail) {
//    console.log("Omnibug InnerLayout page 1");
//    dataLayer.push({
//        'event': 'click',
//        'category': 'Email Me',
//        'action': mail,
//        'label': window.location.pathname
//    });
//    console.log(dataLayer);
//}

//--------------------------------------------------



dentons_App.directive('ngenter', function () {
    return function (scope, element, attrs) {
        element.on('bind',"keydown keypress", function (event) {
            if (event.which === 13) {

                if ($('.searchbar-list li.active').length > 0) {
                    $('.searchbar-list li.active').click();
                    event.preventDefault();
                } else if ($('.allpages-searchbar-list a.active').length > 0) {
                    $('.allpages-searchbar-list a.active').click();
                    event.preventDefault();
                } else {
                    event.preventDefault();
                    scope.$apply(function () {
                        scope.$eval(attrs.ngenter);
                    });
                    event.preventDefault();
                }
            }
        });
    };
})

dentons_App.directive('ngesc', function () {
    return function (scope, element, attrs) {
        element.on('bind',"keydown keypress", function (event) {
            if (event.which === 27) {
                {
                    event.preventDefault();
                    scope.$apply(function () {
                        scope.$eval(attrs.ngesc);
                    });

                }
            }
        });
    };
});

/*Create ng-keycontact cookies on Click*/
$(document).on("click", "[ng-controller='subPageNavigationCTRL'] .subpage-navigation-link", function () {
    var $this = $(this);
    var contextItem = $("#currentContextID").attr("value");
    var contextLanguage = $("#currentContextLanguage").attr("value");
    var contextSite = $("#currentContextSite").attr("value");
    var contextUrl = window.location.href;
    var textValue = $this.find(".ng-binding").text();
    let date = new Date(Date.now() + 86400e3);
    date = date.toUTCString();
    fetch("https://dentons/DentonsServices/DentonsSubPageNavigation.asmx/GetSubPageNavigation?contextItem=" + contextItem + "&contextItemUrl=" + contextUrl + "&contextLanguage=" + contextLanguage + "&contextSite=" + contextSite)
        .then((response) => response.json())
        .then((data) => {
            for (var i = 0; i < data.subPageNavigation.length; i++) {
                if (data.subPageNavigation[i].title == textValue) {
                    document.cookie = 'ng-keycontact=' + data.subPageNavigation[i].Countryselection + '; Path=/; Expires=' + date;
                    document.cookie = 'ng-keycontact=' + data.subPageNavigation[i].Countryselection + '; Path=/;secure';
                }
            }
        });
});

//dentons_PeopleSearchMegaMenuApp.directive('ngenter', function () {
//    return function (scope, element, attrs) {
//        element.on('bind',"keydown keypress", function (event) {
//            if (event.which === 13) {

//                if ($('.searchbar-list li.active').length > 0) {
//                    $('.searchbar-list li.active').click();
//                    event.preventDefault();
//                } else {
//                    event.preventDefault();
//                    scope.$apply(function () {
//                        scope.$eval(attrs.ngenter);
//                    });

//                }
//            }
//        });
//    };
//})

//dentons_PeopleSearchMegaMenuApp.directive('ngesc', function () {
//    return function (scope, element, attrs) {
//        element.on('bind',"keydown keypress", function (event) {
//            if (event.which === 27) {
//                {
//                    event.preventDefault();
//                    scope.$apply(function () {
//                        scope.$eval(attrs.ngesc);
//                    });

//                }
//            }
//        });
//    };
//});

//dentons_PeopleSearchApp.directive('ngenter', function () {
//    return function (scope, element, attrs) {
//        element.on('bind',"keydown keypress", function (event) {
//            if (event.which === 13) {

//                if ($('.searchbar-list li.active').length > 0) {
//                    document.querySelector(".searchbar-list li.active").click();
//                    event.preventDefault();
//                } else {
//                    event.preventDefault();
//                    scope.$apply(function () {
//                        scope.$eval(attrs.ngenter);
//                    });
//                    event.preventDefault();
//                }
//            }
//        });
//    };
//})

//dentons_PeopleSearchApp.directive('ngesc', function () {
//    return function (scope, element, attrs) {
//        element.on('bind',"keydown keypress", function (event) {
//            if (event.which === 27) {
//                {
//                    event.preventDefault();
//                    scope.$apply(function () {
//                        scope.$eval(attrs.ngesc);
//                    });

//                }
//            }
//        });
//    };
//});

//bootstrapping global app

//function getScope(ctrlName) {
//    var sel = 'div[ng-controller="' + ctrlName + '"]';
//    return angular.element(sel).scope();
//}
//var $scope = getScope('globalPeopleSearch');








//Array.prototype.slice.call(document.querySelectorAll('[app-define]'), 0).forEach(function (e, i) {

//    if (e.offsetParent.className == "our-professional") {
//        e.setAttribute("ng-app", "dentonsPeopleSearchMegaMenuApp");
//    } else {
//        e.setAttribute("ng-app", "dentons_dentonsPeopleSearchApp");
//    }


//});

//$('[app-define]').each(function (i, e) {

//    if ($(this).parents(".our-professional").length == 1) {
//        $(this).attr("ng-app", "peopleSearchMegaMenuApp");
//        } else {
//        $(this).attr("ng-app", "peopleSearchApp");
//        }

//})

//function bootStrapNgApp(globalngapp, globalngappName) {
//    angular.bootstrap(globalngapp, [globalngappName]);
//}

//angular.element(document).ready(function () {
//    Array.prototype.slice.call(document.querySelectorAll('[ng-app]'), 0).forEach(function (e, i) {
//        var globalngapp = e;
//        var globalngappName = e.getAttribute('ng-app');
//        console.log("bootstraping ==> " + globalngapp + "--" + globalngappName);

//        if (i !== 0) {
//            setTimeout(function () {
//                bootStrapNgApp(globalngapp, globalngappName);
//            }, 0);

//        }



//    })

//});


//setTimeout(function () {
//    if (window.location.origin + window.location.pathname == $("[id$='{6C5E01CB-A271-40DA-BBC3-8DFC32AA64BA}']").attr('href')) {

//        //firing webAccessibility() from angular after filters load
//    } else {
//        webAccessibility();

//    }

//}, 500);


