/*
* Copyright © 2000-2017 Kohler Company. All Rights Reserved.
*/
function getFilterInputs(){var values="";return $("#myDiv .source:checked").each(function(){values+=""!=values?","+$(this).val():$(this).val()}),values}function ajaxForFilter(isTaxonomyKey){var getValues=getFilterInputs();""==getValues&&$("#koh-fifthFilterSeeAllCountry").prop("checked",!0);var globalprojectLazyLink=$("#globalprojectLazyLink").val();$.ajax({url:globalprojectLazyLink,cache:!1,data:{firstCheck:getValues,getTaxonomyVal:isTaxonomyKey},success:function(data){if(console.log("json data for list page--------",data),1==data.success){var globalProjectListSection=$("#globalProjectListSection"),checkTaxonomy=data.taxonomy;if(checkTaxonomy){var globalProjectmainList=$("#globalProjectmainList");withTaxonomyListing(data,globalProjectmainList)}else withOutTaxonomyListing(data,globalProjectListSection)}}})}function withTaxonomyListing(data,projectOuterDiv){projectOuterDiv.html(""),$("#globalProjectListSection").addClass("hide");var countryName=data.taxonomy,requiredFilters=data.availableCountryFilterList,projectCounries=data.newCountryMap;Object.size=function(obj){var key,size=0;for(key in obj)obj.hasOwnProperty(key)&&size++;return size};var size=Object.size(projectCounries);$("#myDiv input.source").prop("disabled",!1);var allAvailableFilters=[];$("div#myDiv input[type=checkbox]").each(function(){allAvailableFilters.push($(this).val())});for(var i=0;i<allAvailableFilters.length;i++)-1===jQuery.inArray(allAvailableFilters[i],requiredFilters)&&$("#koh-fifthFilter"+allAvailableFilters[i]).prop("disabled",!0).prop("checked",!1);if(size>0){var selectedVal=$("#country").val();$("#country").find("option").remove();for(var k in projectCounries)$("#country").append($("<option>",{value:k,text:projectCounries[k]}))}$("#country option").removeAttr("selected").filter("[value="+selectedVal+"]").attr("selected","selected").prop("selected",!0),$("#globalProjectCountry").find(".koh-project-country-title h3").text(countryName);var i,itemTitle,itemImage,itemPlace,itemHstLink,itemImageAlt,itemImageTitle,html="",items=data.globalprojectJson;for(i=0;i<items.length;i++)itemTitle=items[i].title,itemImage=items[i].image,itemPlace=items[i].place,itemHstLink=items[i].hstLink,itemImageAlt=items[i].imageAlt,itemImageTitle=items[i].imageTitle,html+='<div class="koh-project-display-items col-lg-4 col-md-4 col-sm-4 col-xs-12">',html+='<a href="'+itemHstLink+'">',html+='<div class="koh-project-display-items-inner">',html+=void 0!==itemImageTitle&&""!==itemImageTitle?'<img class="featured-box-image" src="'+itemImage+'"alt="'+itemImageAlt+'" title="'+itemImageTitle+'">':'<img class="featured-box-image" src="'+itemImage+'"alt="'+itemImageAlt+'">',html+='<div class="koh-project-display-content">',html+="<p>"+itemTitle+"</p><span>"+itemPlace+"</span></div>",html+="</div></a></div>";projectOuterDiv.append(html)}function withOutTaxonomyListing(data,projectOuterDiv){var k,country,html="",projects=data.globalprojectListJson,projectCounries=data.allcountriesInProjects,seeAllProjects=data.seeAllProjectLink;$("#country").find("option").remove(),$("#country").append($("<option>",{value:"",text:"Select"}));for(k in projectCounries)$("#country").append($("<option>",{value:k,text:projectCounries[k]}));$("#globalProjectListSection").html("");for(country in projects)html+='<div class="koh-project-display">',html+='<div class="koh-project-country-title"><h3 class="col-lg-6 col-md-6 col-sm-6 col-xs-12">'+projectCounries[country]+"</h3>",seeAllProjects.hasOwnProperty(country)&&(html+='<div class="koh-project-country-more-link col-lg-6 col-md-6 col-sm-6 col-xs-12"><span class="seeAllCountry" data-taxonomy="'+country+'">See All In '+projectCounries[country]+"</span></div>"),html+="</div>",projects.hasOwnProperty(country)&&$(projects[country]).each(function(i,value){html+='<div class="koh-project-display-items col-lg-4 col-md-4 col-sm-4 col-xs-12">',html+='<a href="'+value.hstLink+'">',html+='<div class="koh-project-display-items-inner">',html+='<img class="featured-box-image" src="'+value.image+'" alt="'+value.title+'">',html+='<div class="koh-project-display-content"><p>'+value.title+"</p><span>"+value.place+"</span></div>",html+="</div></a>",html+="</div>"}),html+="</div>";projectOuterDiv.append(html),console.log("countryHtml........"+globalProjectCountry),$("#globalProjectCountryListing").addClass("hide"),$("#globalProjectListSection").removeClass("hide")}$(document).on("change","#myDiv .source",function(){$("#koh-fifthFilterSeeAllCountry").prop("checked",!1),$("#seeCountryProject").remove();for(var countries=$("#country").find("option"),taxonomyInDetailPage="",i=0;i<=countries.length;i++)"selected"===countries.eq(i).attr("selected")&&(taxonomyInDetailPage=countries.eq(i).val());ajaxForFilter(taxonomyInDetailPage)}),$(document).on("change","#koh-fifthFilterSeeAllCountry",function(){$(".source").prop("checked",!1);for(var countries=$("#country").find("option"),taxonomyInDetailPage="",i=0;i<=countries.length;i++)"selected"===countries.eq(i).attr("selected")&&(taxonomyInDetailPage=countries.eq(i).val());ajaxForFilter(taxonomyInDetailPage)}),$(document).on("click",".seeAllCountry",function(){var getTaxonomyVal=$(this).data("taxonomy"),getValues=getFilterInputs();""==getValues?1==$("#koh-fifthFilterSeeAllCountry").prop("checked")?$("#koh-fifthFilterSeeAllCountry").prop("disabled",!1):$("#koh-fifthFilterSeeAllCountry").prop("disabled",!0):$("#koh-fifthFilterSeeAllCountry").prop("disabled",!1);var globalprojectLazyLink=$("#globalprojectLazyLink").val();$.ajax({url:globalprojectLazyLink,cache:!1,data:{firstCheck:getValues,getTaxonomyVal:getTaxonomyVal},success:function(data){if(console.log("json data for List Page--------",data),1==data.success){var globalProjectmainList=$("#globalProjectmainList");$("#globalProjectCountryListing").removeClass("hide"),$("#globalProjectListSection").addClass("hide");for(var countries=$("#country").find("option"),i=0;i<=countries.length;i++)countries.eq(i).val()===getTaxonomyVal&&countries.eq(i).attr("selected","selected");withTaxonomyListing(data,globalProjectmainList)}}})}),$(document).on("change","#country",function(e){var selectedCountry=$(this).val();$("#country option").removeAttr("selected").filter("[value="+selectedCountry+"]").attr("selected","selected").prop("selected",!0),$("#seeCountryProject").remove(),ajaxForFilter(selectedCountry)}),$(document).on("ready",function(){var baseUrl=window.location.pathname,currentTile=document.title;window.history.pushState({},currentTile,baseUrl)});