(function(){var API_SERVER_URL=location.origin;var API_BASE_URL=API_SERVER_URL+"/o/rest-api";if(!$("#contact_form").length)return false;$("#contact_form .form-control").on("change",function(){if(!$(this).hasClass("check"))$(this).addClass("check")});$('#contact_form [type\x3d"submit"]').on("click",function(){$("#contact_form .form-control").addClass("check")});$(window).on("load",function(){var recaptcha=$("#g-recaptcha-response");if(recaptcha.length){recaptcha.attr("required","required");recaptcha.attr("aria-hidden",
"true");recaptcha.attr("aria-label","do not use");recaptcha.attr("aria-readonly","true")}});contactFormSuccessBuild();$("#contact_form form").off().on("submit",function(e){e.preventDefault();var action=$(this).attr("action");var data=$(this).serialize();contactFormSender(action,data).then(function(resolve){if(typeof resolve.status==="boolean"&&resolve.status===true)contactFormResult("Your message has been sent successfully. We will contact with as soon as possible.");else contactFormResult("Failed to sent your message. Please verify that your message does not look like a spam message and please try again later.")},
function(reject){console.error("Contact form rejected: ",reject)});var formData=$(this).serializeArray();var categoryId=formData[3].value;var category=$(".form-control option[value\x3d"+categoryId+"]").text();if(formData[0].value==="true")fetchCurrentUser().then(function(currentUser){ga("send","event","Internal messaging","message sent to operator",category,{"dimension4":currentUser.country,"dimension5":currentUser.interests.toString(),"dimension6":currentUser.organizationType,transport:"beacon"})});
else{var companyName=$(".article .button--contact-us").data("company-name");fetchCurrentUser().then(function(currentUser){ga("send","event","Internal messaging","message sent to organization",category,{"dimension3":companyName,"dimension4":currentUser.country,"dimension5":currentUser.interests.toString(),"dimension6":currentUser.organizationType,transport:"beacon"})})}grecaptcha.reset()});if($(".article .button--contact-us").length){var button=$(".article .button--contact-us");button.on("click",function(){var companyName=
'"'+button.data("company-name")+'" ';var companyId=button.data("company-id");$('#contact_form input[label\x3d"contactOperator"]').val("false");$('#contact_form input[label\x3d"organizationId"]').val(companyId);$("#contact_form span.contact_form__company_name").text(companyName);var targetPosition=$("#contact_form").offset().top;$("html, body").stop(true,true).animate({scrollTop:targetPosition},1E3,"swing");return false})}function contactFormSender(action,data){var requestUrl=action;return $.ajax({method:"POST",
url:requestUrl,data:data,dataType:"json"})}function contactFormSuccessBuild(){if(!$(".contact-form__modal").length){var buttonCloseIcon='\x3ci class\x3d"eo-icon-cross"\x3e\x3c/i\x3e';var headerMsg="Thank You!";var contentMsg="Your message has been sent successfully. We will contact with as soon as possible.";var buttonTxtOk="Ok";var html="";html+='\x3cdiv class\x3d"contact-form__modal"\x3e';html+='\x3cdiv class\x3d"contact-form__modal-content"\x3e';html+='\x3cdiv class\x3d"contact-form__modal-header"\x3e';
html+="\x3cspan\x3e"+headerMsg+"\x3c/span\x3e";html+='\x3cbutton class\x3d"contact-form__modal_close_btn close_modal" aria-label\x3d"close"\x3e'+buttonCloseIcon+"\x3c/button\x3e ";html+="\x3c/div\x3e";html+="\x3cp\x3e"+contentMsg+"\x3c/p\x3e";html+='\x3cdiv class\x3d"text-right"\x3e\x3cbutton class\x3d"btn btn-primary button--force-color close_modal"\x3e'+buttonTxtOk+"\x3c/button\x3e";html+="\x3c/div\x3e";html+="\x3c/div\x3e";$("body").append(html);$(".contact-form__modal .close_modal").on("click",
function(){$(".contact-form__modal").removeClass("active");$("#contact_form .check").removeClass("check");$("#contact_form form input, #contact_form form select, #contact_form form textarea").not("input[name$\x3d'contactOperator']").not("input[name$\x3d'organizationId']").not("input[name$\x3d'senderName']").not("input[name$\x3d'senderEmail']").val("");$("#contact_form iframe").attr("src",$("#contact_form iframe").attr("src"))})}}function contactFormResult(message){$(".contact-form__modal-content p").text(message);
$(".contact-form__modal").addClass("active");setTimeout(function(){$(".contact-form__modal .close_modal").click()},4E3)}function fetchCurrentUser(){return $.ajax({method:"GET",url:API_BASE_URL+"/portal/currentUser"})}})();
$(document).ready(function(){let apiPath="/o/rest-api";function mainpageSearchInputHandler(){let $mainpageSearch=$("#header_search");let $mainpageSearchInput=$mainpageSearch.find(".autocomplete input");let searchCallDelay=300;let searchTimeoutId;let $suggestionsList=buildSuggestionsList();$mainpageSearchInput.on("input",function(event){if(event.target.value.length<2){removeChildren($suggestionsList);return}if(searchTimeoutId)clearTimeout(searchTimeoutId);searchTimeoutId=setTimeout(function(){getSuggestions(event.target.value,
"companies",0,5).then(function(resolve){let suggestions=resolve.items;removeChildren($suggestionsList);let $suggestionsItems=$(suggestions.map(function(item){return buildSuggestionsListItem(item)[0]}));$suggestionsList.append($suggestionsItems);$mainpageSearch.find(".autocomplete").append($suggestionsList);$suggestionsItems.click(function(event){let suggestion=$(this).data();$mainpageSearchInput.val(suggestion.title);$suggestionsList.empty()});$mainpageSearchInput.focus()},function(reject){console.error("Cannot fetch suggestions",
reject.responseText)})},searchCallDelay)}).on("blur",function(){setTimeout(function(){$(".list--suggestions").empty()},250)})}function buildSuggestionsList(){let $suggestionsList=$("\x3cul\x3e\x3c/ul\x3e");$suggestionsList.addClass("list list--suggestions suggestions");return $suggestionsList}function mapSuggestionType(rawType){rawType=rawType.toLowerCase();switch(rawType){case "companies":return"Company";default:console.error("Unknown type of article:",rawType);return""}}function buildSuggestionsListItem(suggestion){let $suggestionItem=
$("\x3cli\x3e\x3c/li\x3e");let $suggestionType=$("\x3cspan\x3e\x3c/span\x3e").addClass("suggestion_type").text(mapSuggestionType(suggestion.type)+": ");$suggestionItem.append($suggestionType,suggestion.title);$suggestionItem.addClass("list__item list__item--suggestion text-truncate");$suggestionItem.data(suggestion);return $suggestionItem}function removeChildren(list){list.empty()}function getSuggestions(phrase,type,from,limit){if(!phrase||!type||!Number.isInteger(from)||!Number.isInteger(limit)){console.log("Missing parameter(s) in getSuggetsions().");
return}let queryString="/africa/suggestions?like\x3d"+encodeURIComponent(phrase)+"\x26type\x3d"+encodeURIComponent(type)+"\x26from\x3d"+from+"\x26limit\x3d"+limit;return $.ajax({method:"GET",url:location.origin+apiPath+queryString})}$(".header__search_form_trigger").on("click touch",function(){let $navigationHeaderContainer=$("#portlet_com_eversis_esa_eomall_africa_search_headersearchbar_HeaderSearchBar");$navigationHeaderContainer.slideToggle()});mainpageSearchInputHandler()});
