function loadCSS(n,t,i,r){"use strict";var u=window.document.createElement("link"),e=t||window.document.getElementsByTagName("script")[0],f=window.document.styleSheets;u.rel="stylesheet",u.href=n,u.media="only x",r&&(u.onload=r),e.parentNode.insertBefore(u,e),u.onloadcssdefined=function(t){for(var r,i=0;i-1&&(r=!0);r?t():setTimeout(function(){u.onloadcssdefined(t)})};u.onloadcssdefined(function(){u.media=i||"all"});return u}function logResource(n){$.get("/resource/log/"+n)}var gadgetBinActive,visibleGadgetNumber,$featureBanner,featureId,badOpera,LC_API;$("body").mousedown(function(){gadgetBinActive||$("div#site-gadget-bin").hide()}),gadgetBinActive=!1,$("div#site-gadget-bin").hover(function(){gadgetBinActive=!0},function(){gadgetBinActive=!1}),visibleGadgetNumber=0,$(function(){function n(n){var i="/resource/thumbnail/"+n.pageId+"?gadgetId="+n.gadgetId,t;if(typeof n.pageId!="undefined")$("div#site-gadget-bin img#thumbnail").attr("src",i).show();else{t=$("div#gadget-default-thumbnail","div#site-gadget-bin");switch(n.gadgetClass){case"Knoema.HtmlTable":t.removeClass().addClass("table");break;case"Knoema.Map":t.removeClass().addClass("map");break;case"Knoema.BubbleChart":t.removeClass().addClass("bubble-chart");break;case"Knoema.Ranking":t.removeClass().addClass("ranking");break;case"Knoema.TreeMap":t.removeClass().addClass("treemap");break;case"Knoema.Chart":default:t.removeClass().addClass("chart")}$("div#site-gadget-bin img#thumbnail").hide()}}if($("a#gadget-bin-img").live("click",function(t){var r=$("div#site-gadget-bin"),i=Modernizr.localstorage?$.parseJSON(localStorage.getItem("Presentation")):null,f,e,u;return!i||!i.Content||i.Content.length==0?!1:(gadgetBinActive&&r.toggle(),f=t.pageX-($(window).innerWidth()-$("#site-header").outerWidth(!0))*.5-150,e=t.pageY+15,r.css("left",f),r.css("top",e),visibleGadgetNumber=0,n(i.Content[visibleGadgetNumber]),$("div#site-gadget-bin").toggle(),$("div#gadget-bin-body span.current-slide-number").text(visibleGadgetNumber+1),$("div#gadget-bin-body span.total-slide-number").text("/"+i.Content.length),u=r.find("li#create-presentation").find("span"),u.height()<15?u.css("margin-top",8):u.css("margin-top",0),!1)}),$("body").bind("addeSlide.gadget",function(n,t){var i,u,f,r,e;if(Modernizr.localstorage){if(i=$.parseJSON(localStorage.getItem("Presentation")),i&&i.Content){u=!1;for(f in i.Content)r=i.Content[f],r.pageId==t.pageId&&r.gadgetId==t.gadgetId&&Knoema.Utils.isEqual(r,t)&&(u=!0);u||i.Content.push(t)}else i={Content:[]},i.Content.push(t);i.Content.length>0&&($("div#gadget-bin-body span.current-slide-number").text(visibleGadgetNumber+1),$("div#gadget-bin-body span.total-slide-number").text("/"+i.Content.length)),e=$("a#gadget-bin-img"),e.css("display","inline-block"),localStorage.setItem("Presentation",JSON.stringify(i))}}),Modernizr.localstorage){var t=$.parseJSON(localStorage.getItem("Presentation"));t&&t.Content&&t.Content.lenght!=0?$("a#gadget-bin-img").css("display","inline-block"):$("a#gadget-bin-img").hide()}$("div#site-gadget-bin li#create-presentation").live("click",function(){var t,n;if(Modernizr.localstorage){if(t=$.parseJSON(localStorage.getItem("Presentation")),!t&&!t.Content)return!1;n=$("div#site-gadget-bin").find("#gadget-bin-presentation-form"),n.length>0&&(n.find("input#gadget-bin-presentation-form-id").val(""),n.find("input#gadget-bin-presentation-form-title").val(""),n.find("input#gadget-bin-presentation-form-description").val(""),n.find("input#gadget-bin-presentation-form-content").val(JSON.stringify(t.Content))),n.submit()}return!1}),$("div#site-gadget-bin li#clear").live("click",function(){return Modernizr.localstorage&&localStorage.removeItem("Presentation"),$("div#site-gadget-bin img#thumbnail").attr("src","").hide(),$("div#site-gadget-bin").toggle(),$("a#gadget-bin-img").hide(),!1});$("div#site-gadget-bin img#gadget-delete").on("click",function(){if(Modernizr.localstorage){var n=$.parseJSON(localStorage.getItem("Presentation"));n.Content.splice(visibleGadgetNumber,1),localStorage.setItem("Presentation",JSON.stringify(n)),visibleGadgetNumber=visibleGadgetNumber-1,n.Content.length>0?$("div#site-gadget-bin a#next-gadget").click():$("div#site-gadget-bin li#clear").click()}return!1});$("div#site-gadget-bin li#export").live("click",function(){var n=encodeURIComponent(Knoema.Utils.buildUrl(location.pathname+location.search,{action:"export"}));Knoema.Utils.isFeatureAvailable("export",function(t){var c=!Knoema.Utils.isAuthenticated()&&!Knoema.Utils.isCommunity(),r,e,u,s,i,f,h,o;if(c){document.location="/sys/login?returnUrl="+n;return}if(!t){gaTracker.TrackPageView(Knoema.Utils.buildUrl("/premium/activate",{returnUrl:n})),mixpanelTracker.track("Premium - Initiate",{Source:"Export",Format:"pptx","Resource Id":"GadgetBin"},function(){document.location="/premium?returnUrl="+n});return}if(r=Modernizr.localstorage?$.parseJSON(localStorage.getItem("Presentation")):null,!r&&!r.Content)return!1;e=$("div#site-gadget-bin").find("#gadget-bin-export-form"),u=[];for(s in r.Content)i=r.Content[s],f=i.options,f&&typeof f.getExportOptions=="function"?(h=f.getExportOptions("pptx"),h.fileFormatSupported&&u.push(i)):(i.gadgetClass=="Knoema.InfoCard"||i.gadgetClass=="Knoema.Chart"||i.gadgetClass=="Knoema.Text"||i.gadgetClass=="Knoema.BubbleChart"||i.gadgetClass=="Knoema.HtmlTable"&&typeof i.viewState.displayUnits=="boolean")&&u.push(i);if(u.length==0)return!1;e.find("input#gadget-bin-export-form-content").val(JSON.stringify(u)),o=!1,document.page&&document.page._isDraft==!0&&(document.page._isDraft=!1,o=!0),e.submit(),o&&window.setTimeout(function(){document.page._isDraft=!0},1e3)})}),$("div#site-gadget-bin a#next-gadget").bind("click",function(){if(Modernizr.localstorage){var t=$.parseJSON(localStorage.getItem("Presentation"));visibleGadgetNumber=visibleGadgetNumber+1,visibleGadgetNumber==t.Content.length&&(visibleGadgetNumber=0),$("div#gadget-bin-body span.current-slide-number").text(visibleGadgetNumber+1),$("div#gadget-bin-body span.total-slide-number").text("/"+t.Content.length),n(t.Content[visibleGadgetNumber])}}),$("div#site-gadget-bin a#prev-gadget").bind("click",function(){if(Modernizr.localstorage){var t=$.parseJSON(localStorage.getItem("Presentation"));visibleGadgetNumber=visibleGadgetNumber-1,visibleGadgetNumber==-1&&(visibleGadgetNumber=t.Content.length-1),$("div#gadget-bin-body span.current-slide-number").text(visibleGadgetNumber+1),$("div#gadget-bin-body span.total-slide-number").text("/"+t.Content.length),n(t.Content[visibleGadgetNumber])}})}); /*! loadCSS: load a CSS file asynchronously. [c]2014 @scottjehl, Filament Group, Inc. Licensed MIT */ $(function(){if($("#site-notifications").length>0){var n=function(){$.get("/notification/count",function(n){var i=n*1,t=$("#site-notifications"),r=t.find("span");i>0?(t.attr("style","display: inline-block !important;"),r.text(n)):t.hide()})};window.location.pathname.indexOf("/user")>-1?($.post("/notification/markasread",{userkey:$("#userKey").val()}),$(document).everyTime(6e4,n)):n()}$("#site-notifications").click(function(){return location="/user",!1}),$("a#subscriber").click(function(){var n=$(this),t=n.attr("href").substring(1);return $.post(t,function(i){var f=t.substring(1).split("/"),r,u;switch(f[0].toLowerCase()){case"tags":r="Tag",u=f[1];break;case"user":r="Person",u=f[1];break;default:r="Resource",u=f[0]}i==="subscribed"?(n.find("div").removeClass("tag-follow").addClass("tag-following"),mixpanelTracker.trackSubscribe(r,null,u)):i==="unsubscribed"&&(n.find("div").removeClass("tag-following").addClass("tag-follow"),mixpanelTracker.trackUnsubscribe(r,null,u))}),!1}),$("div.notification-date").each(function(){var n=$(this),t=Knoema.Utils.toLocaleShortDateAndTimeString(n.text());n.text(t)})}),$(function(){var n,t;Knoema.GlobalOptions||(n="/css/knoema/knoema.global.json",Knoema.Utils.getJsonWithSuppressAjaxError("/theme"+n,n,function(n){t(n)})),t=function(n){var t,i,f,r,u;if(Knoema.GlobalOptions=n,t=$("#page-themes"),i=t.data("pagetype"),i=="dsbrowser"||document.page&&document.page.isEditing()){f=Knoema.Utils.keys(n.pageThemes),r=new Knoema.ThemePicker({orientation:"left",defaultTheme:n.pageThemes[0].name});for(u in n.pageThemes)r.registerThemes([n.pageThemes[u].name]);r.showIcon(t,"general");$("#page-themes").on("themeChanged",function(n,t){return i!="dsbrowser"&&(document.page.setTheme(t.name),$(this).trigger("saveDraft")),!1});$("body").trigger("PageThemesLoaded")}}}),function(){function s(n){return n.substring(0,1).toLowerCase()+n.substring(1)}function h(t){if(t.length<6)return n(0,"too-short",$.R("~/Js/Shared/password.checker.js","Too short"));if(o.test(t))return n(1,"very-weak",$.R("~/Js/Shared/password.checker.js","Very weak"));var h=i.test(t),c=r.test(s(t)),l=u.test(t),a=f.test(t),v=e.test(t);return h&&c&&l||h&&a||c&&a||v?n(4,"strong",$.R("~/Js/Shared/password.checker.js","Strong")):h&&c||h&&l||c&&l?n(3,"good",$.R("~/Js/Shared/password.checker.js","Good")):n(2,"weak",$.R("~/Js/Shared/password.checker.js","Weak"))}function n(n,t,i){return{rate:n,messageKey:t,message:i}}function t(n){var i=h(n.value),t=$(n).closest("form").find("div#password-meter");t.show(),t.find("div.text").text(i.message),t.find("div.meter div").removeClass().addClass("password-meter-"+i.messageKey)}var i=/[a-z]/,r=/[A-Z]/,u=/[0-9]/,f=/[0-9].*[0-9]/,e=/[^a-zA-Z0-9]/,o=/^(.)\1+$/;$("body").on("keyup","div.form input#Password",function(n){t(n.target)});$("body").on("blur","div.form input#Password",function(n){t(n.target)})}(),$("a#page-bind").click(function(){var n,t;return n&&clearInterval(n),t=$("div#bind-dialog").knDialog({resizable:!1,modal:!0,width:400,buttons:{Apply:function(){var t=$(this),i=t.find("form");$("div#bind-dialog").trigger("checkUrl",[function(r){r&&$.post(i.attr("action"),i.serialize(),function(i){if(i=="wrong-url"){$("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-wrong").show();return}if(i=="not-allowed-url"){$("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-cant-be-used").show();return}if(i=="unavailable-url"){$("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-unavailable").show();return}n&&clearInterval(n),$("div#bind-dialog div.form input#url-old-value").val(""),t.dialog("close")})}])},Cancel:function(){$("div#bind-dialog div.form input#url-old-value").val(""),$(this).dialog("close")}}}),$("div#page-body").busy($.get($(this).attr("href")+"?__rnd="+Math.random(),function(i){t.html(i),$("div#bind-dialog div.form input#url-old-value").val($("div#bind-dialog div.form input#Url").val()),n=setInterval(function(){$("div#bind-dialog").trigger("checkUrl")},1e3)})),!1});$("body").on("postCheck","div#bind-dialog",function(n,t,i){if(t=="")return($("div#bind-dialog div.form span").hide(),i)?i(!0):void 0;$.post("/resource/checkbindurl",{url:t,__rnd:Math.random()},function(n){var t=n&&!0;if(t){if(i)return i(t);$("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-available").show()}else $("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-unavailable").show()})});$("body").on("checkUrl","div#bind-dialog",function(n,t){var i=$("div#bind-dialog div.form input#Url").val().toLowerCase(),r=$("div#bind-dialog div.form input#url-old-value").val(),u;if(i=$.trim(i),t==undefined){if(i==r)return;$("div#bind-dialog div.form input#url-old-value").val(i)}if(i!=""&&i!=r&&(u=/^((about|dev|help|legal|admin|atlas|market):|([a-z0-9]+[\/\-_]))*[a-z0-9]+$/,!u.test(i))){$("div#bind-dialog div.form span").hide(),$("div#bind-dialog div.form span#url-wrong").show();return}$("div#bind-dialog").trigger("postCheck",[i,t])});(function(){function s(n,t){var u=n[0],i=n[1],f=$(u+" select#access-level-select").val(),r=$.tmpl(i.name,t,{provider:i.provider});r.find("span[data-level='"+f+"']").addClass("active"),r.appendTo($("div#fb-granted-people ul")),e()}function e(){var n=[];$("div#fb-granted-people ul li").each(function(t,i){var r=$(i);r.find("span.active").length>0&&n.push({id:r.attr("data-id"),level:r.find("span.active").attr("data-level"),provider:r.attr("data-provider"),name:r.find("b.name").text(),registered:r.hasClass("registered-user")})}),$("div#sharing-dialog form input#Shares").val(JSON.stringify(n))}var u="Friends",i="",n=!1,r,h,o,t,f;$("span#page-sharing").click(function(){var t=$("div#sharing-menu"),r=$("div#verification-status"),i;return r.length>0&&(i=r.outerWidth(!0)+$("span#verify-shareoptions-seperator").outerWidth(!0),$("html").prop("dir")=="rtl"?t.css("right",i):t.css("left",i)),t.show(),!1}),$("div#sharing-menu").mousedown(function(){return!1}),$("body").mousedown(function(){$("div#sharing-menu").hide()}),$("div#sharing-menu li.public").click(function(){var n=$(this);$.post($("div#sharing-menu ul").data("href"),{IsPublic:!0,Id:$("input#Id").val()},function(){$("div#sharing-menu li.active").removeClass("active"),n.addClass("active"),$("span#page-sharing span.sharing-status").attr("title",$.R("~/Js/Shared/resource.share.js","Public")).removeClass("friends private"),document.page.checkAndShowPrivateDatasetWarningMessage($("input#Id").val()),$(document).trigger("setSocialBarEvent",!1)}),$("div#sharing-menu").hide()}),$("div#sharing-menu li.private").click(function(){function n(){$.post($("div#sharing-menu ul").data("href"),{IsPublic:!1,Id:$("input#Id").val()},function(n){$("div#sharing-menu li.active").removeClass("active"),n=="FriendsOnly"?$("span#page-sharing span.sharing-status").attr("title",$.R("~/Js/Shared/resource.share.js","Friends")).removeClass("private").addClass("friends"):n=="Private"&&($("span#page-sharing span.sharing-status").attr("title",$.R("~/Js/Shared/resource.share.js","Private")).removeClass("friends").addClass("private"),t.addClass("active"),$("div#private-dataset-warning-message").remove()),$(document).trigger("setSocialBarEvent",!0)}),$("div#sharing-menu").hide()}var t=$(this);$("input[name=ResourceType]").val()=="Dataset"?$.get("/premium/sharePrivately",function(t){t?n():mixpanelTracker.track("Premium - Initiate",{Source:"Share Resource","Resource Id":$("input#Id").val(),"Resource Title":$("input#Title").val()},function(){document.location="/premium?returnUrl="+encodeURIComponent(Knoema.Utils.buildUrl(location.pathname+location.search,{action:"privatedataset"}))})}):n()}),$("div#sharing-menu li.sh-options").click(function(){$("div#sharing-menu").hide(),$("#sharing-dialog").data("populateUserList",!0),u="",n=!1,$("div.sharing-div").hide();var t=$("div#sharing-dialog").knDialog({resizable:!1,modal:!0,width:495,buttons:[{id:"apply-share-settings",text:"Apply",click:function(){var r=$(this),i;$("#sharing-dialog").data("populateUserList",!0),n=!1,i=t.find("form"),$("div#sharing-dialog").trigger("applyUnsavedChanges",function(){$("#apply-share-settings").spinbutton("start",$.R("~/Js/Shared/resource.share.js","Applying")),$.post(i.attr("action"),i.serialize(),function(n){r.dialog("close"),$("div#private-dataset-warning-message").remove(),$status=$("span#page-sharing span.sharing-status");switch(n){case"Public":$status.attr("title",$.R("~/Js/Shared/resource.share.js","Public")).removeClass("friends private"),document.page.checkAndShowPrivateDatasetWarningMessage($("input#Id").val());break;case"FriendsOnly":$status.attr("title",$.R("~/Js/Shared/resource.share.js","Friends")).removeClass("private").addClass("friends"),$("div#sharing-menu li.private").removeClass("active");break;case"Private":$status.attr("title",$.R("~/Js/Shared/resource.share.js","Private")).removeClass("friends").addClass("private"),$("div#sharing-menu li.active").removeClass("active"),$("div#sharing-menu li.private").addClass("active")}gaTracker.Share($("input#Title").val(),n,$("input#Id").val())})})}},{text:"Cancel",click:function(){$("#sharing-dialog").data("populateUserList",!0),n=!1,$(this).dialog("close")}}]});return t.html($.R("~/Js/Shared/resource.share.js","Loading...")),$("div#page-body").busy($.get($("div#sharing-menu ul").data("href")+"?id="+$("input#Id").val()+"&rnd="+Math.random().toString(),function(n){t.html("");var i=$(n);i.find("div.collapsing li.friend").length==0&&i.find("div.collapsing").hide(),i.appendTo(t),$(document).trigger("forShareWindowSocialBarEvent",i),$("div#sharing-dialog").dialog("option","position","center")})),!1}),$("div#sharing-menu li.change-owner").click(function(){$("div#sharing-menu").hide(),$("div.sharing-div").hide();var n=$.tmpl("Tmpl-change-owner-dialog").appendTo("body").knDialog({resizable:!1,modal:!0,width:495,buttons:[{text:"OK",click:function(){var t=$(this),i=t.find("div.resource-new-owner").data("user-key");i?$(n).busy($.ajax({url:"/resource/transferownership",type:"POST",data:{id:$("input#Id").val(),userKey:i},dataType:"json",success:function(){t.dialog("close"),location.reload()},error:function(n){return n.status==400&&(t.find("div.error-message").text(n.statusText).show(),t.find("div.loading").remove(),t.find("a.back").click()),!1},suppressAjaxError:!0})):t.dialog("close")}},{text:"Cancel",click:function(){$(this).dialog("close")}}]});$("div#page-body").busy($.ajax({url:Knoema.Utils.apiUrl("/api/1.0/resource/"+$("input#Id").val()),dataType:"json",success:function(t){n.empty(),$.tmpl("Tmpl-change-resource-owner",{oldOwner:t.owner}).find("button").button().end().appendTo(n),$("div#change-owner-dialog").dialog("option","position","center").find("div.error-message").hide(),"placeholder"in document.createElement("input")||$.defaultText({context:"#change-resource-owner"})}}));n.on("keydown",function(n){if(n.keyCode==13)return $(n.currentTarget).find("input#find-new-owner").trigger("focusout"),$("div#change-owner-dialog input#find-new-owner + button").click(),!1});return!1});$(document).on({click:function(){var r=$(this),t=r.siblings("div.error-message"),i=r.siblings("#find-new-owner").val(),n;if(i){if(Knoema.Utils.strEquals($.trim(i),$.trim(r.closest("div#change-resource-owner").find("div.resource-old-owner.user-item div.user-item-email").text())))return t.text($.R("~/Js/Shared/resource.share.js","User with email above is current owner.")).show(),!1;$("div#site-holder").trigger("validateEmails",[i,function(){t.text($.R("~/Js/Shared/resource.share.js","Email address above is invalid or empty. Please correct it to continue.")).show()},"change owner"]),t.text()||(n=r.closest("div.resource-new-owner"),n.busy($.ajax({url:Knoema.Utils.apiUrl("/api/1.0/user?email="+$.trim(i)),dataType:"json",success:function(t){t&&(t.email=i,n.data("user-key",t.key),n.find("div.find-new-owner").hide(),n.find("div.container").append($.tmpl("Tmpl-change-resource-owner-user",t)),n.find("div.resource-new-owner").show())},error:function(n){return n.status==404?t.text($.R("~/Js/Shared/resource.share.js","User with such email is not found.")).show():t.text(n.statusText).show(),$("div.loading","#change-owner-dialog").remove(),!1},suppressAjaxError:!0})))}return!1}},"div#change-owner-dialog input#find-new-owner + button");$("body").on("keyup","div#share-userlist .filter-textarea input",function(n){typeof r=="number"&&(window.clearTimeout(r),delete r);var t=$(n.target||n.srcElement).val();t=Knoema.Utils.strTrim(t),r=window.setTimeout(function(){var n=$("div#share-userlist li.friend");t?n.each(function(){var n=$(this).find(".name").text();n=Knoema.Utils.strTrim(n),Knoema.Utils.strContains(n,t)?$(this).show():$(this).hide()}):n.show()},500)});$("body").delegate("div#change-owner-dialog a.back","click",function(){$(this).closest("div.resource-new-owner.user-item").hide().find("div.container").empty().end().parent().find("input#find-new-owner").val("").trigger("focusout").end().find("div.find-new-owner").show(),$("div#change-owner-dialog div.resource-new-owner").data("user-key","")}),$("body").bind("removeAccessKeyFromSharingOptionsEvent",function(n){$(n.target).closest("div.access-link-share-opts").hide().closest("#first-frame").find("div#fb-granted-people").removeClass("access-link").end().find("p.invite.corr").removeClass("access-link").end().closest("div.form").data("is-access-link-removed","true"),$("div#kn-social-bar").data("url-private-link","")});$(document).on({click:function(){return $(document).trigger("removeAccessKeyForShareWindowSocialBarEvent",this),!1}},"div.access-link-share-opts a.remove-link");$("body").delegate("div#sharing-dialog","applyUnsavedChanges",function(n,t){if($("div#share-eml div#friends").hasClass("empty")==!1&&($("div#share-eml button#add-connections").click(),$("div#share-eml div#friends span.err").length==1))return $("div#share-user-list").hide(),$("html").prop("dir")=="rtl"?$("div#sharing-dialog div#slider").animate({right:"-495"},500,"swing",function(){$("div#share-eml").slideDown("fast",function(){i="share-eml"})}):$("div#sharing-dialog div#slider").animate({left:"-495"},500,"swing",function(){$("div#share-eml").slideDown("fast",function(){i="share-eml"})}),!1;$("div#share-userlist ul li").hasClass("selected")&&$("div#share-userlist button#add-connections").click();var r=$("div.sharing-div:visible div#friends ul li input:checkbox:checked").closest("li");r.length>0&&$("div#sharing-dialog").busy({then:function(){$("div#friends ul").closest("div.sharing-div").find("button#add-connections").click()}}),t()}),$("body").delegate("div#site-holder","validateEmails",function(n,t,i,r){for(var l=r=="share",s=t.split(","),v=/^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/i,e=!0,h="",a=[],f,c,o,u=0;u"+f+"<\/span>"+c),a.push(f);return l?(o=$("div#share-eml div#friends"),e?(o.addClass("empty").text(o.attr("data-title")),$("div#share-eml div.prompt").empty(),i(a)):(o.html(h),$("div#share-eml div.prompt").text($.R("~/Js/Shared/resource.share.js","Some emails above are invalid. Please correct them to proceed.")))):e||i(),!1}),$("div#fb-granted-people ul li span").live("click",function(){if(!$(this).hasClass("active")){$(this).closest("li").find("span").removeClass("active"),$(this).addClass("active");var n=[];$("div#fb-granted-people ul li").each(function(t,i){var r=$(i);r.find("span.active").length>0&&n.push({id:r.attr("data-id"),level:r.find("span.active").attr("data-level"),provider:r.attr("data-provider"),name:r.find("b.name").text()})}),$("div#sharing-dialog form input#Shares").val(JSON.stringify(n))}});$(document).on("click","div#share-userlist ul li span",function(){var n=$(this);return(n.closest("li").addClass("selected"),n.hasClass("active"))?!1:(n.closest("li").find("span").removeClass("active"),n.addClass("active"),!1)});$("#sharing-dialog").bind("populateUserList",function(n){var t=$(this),r=Knoema.Utils.buildUrl("/resource/ShareViaUserList",{id:$("input#Id").val()}),i=t.find("#reg-users");t.data("populateUserList")&&i.busy(Knoema.Utils.loadView(r,i)),n.stopPropagation()}),$("div#sharing-dialog p a.selector").live("click",function(){var n="",t=$(this);return t.hasClass("eml")&&(n="share-eml"),t.hasClass("cm")&&(n="share-community",$.defaultText()),t.hasClass("userlist")&&(n="share-userlist",t.trigger("populateUserList")),$("div#second-frame div.sharing-div").hide(),$("html").prop("dir")=="rtl"?$("div#sharing-dialog div#slider").animate({right:"-495"},500,"swing",function(){$("div#"+n).slideDown("fast",function(){$(this).find("div button").button(),$(this).find("li[data-panel-class='tab-friends']").click(),i=n})}):$("div#sharing-dialog div#slider").animate({left:"-495"},500,"swing",function(){$("div#"+n).slideDown("fast",function(){$(this).find("div button").button(),$(this).find("li[data-panel-class='tab-friends']").click(),i=n})}),!1}),$("div#share-eml button#add-connections").live("click",function(){var n,t;return $("div#share-eml div#friends").hasClass("empty")?!1:(n={},n.name="Tmpl-share-resource-people-item",n.provider="internal",t=$("div#share-eml div#friends").text(),$("div#site-holder").trigger("validateEmails",[t,function(t){for(var r=[],f=$("div#fb-granted-people ul"),u=!1,i=0;i-1)return!0;f={Id:o,level:u.find("span.active").data("level"),provider:u.data("provider"),Name:u.find("b.name").text()},e=$.tmpl("Tmpl-share-resource-people-item",f,{provider:f.provider.toLowerCase()}),e.find("span[data-level='"+f.level+"']").addClass("active"),e.addClass("registered-user"),e.appendTo($("div#fb-granted-people ul")),t=!0}),$("#sharing-dialog").data("populateUserList",!1),t&&$("div.form div.collapsing").show(),$("div#sharing-dialog a.slide-selector").trigger("click"),e(),!1});$("div#share-eml div#friends, div.resource-new-owner input#find-new-owner").live("click",function(){var n=$(this);n.text()==n.attr("data-title")&&(n.removeClass("empty"),n.empty()),this.id=="find-new-owner"&&n.siblings("div.error-message").empty().hide()}),$("div#share-eml div#friends, div.resource-new-owner input#find-new-owner").live("focusout",function(){var n=$(this);n.text().length==0&&(n.text(n.attr("data-title")),n.addClass("empty"))});$(document).on("change","div#sharing-dialog div.notification input[type='checkbox']",function(){$(this).attr("id")=="SendEmailNotification"&&(n=!n,$("#share-userlist div.notification input[type='checkbox']").prop("checked",n),$("div#share-eml div.notification input[type='checkbox']").prop("checked",n))});if(o="div.sharing-div div.dlg-gadget-customization-tabs ul",$(o+" li").live("click",function(){if($this=$(this),$this.text()!=u){$this.closest("ul").find("li").removeClass("active"),$this.addClass("active"),u=$this.text(),h=$(this).text();var n=$(this).closest("div.sharing-div").find("div#friends");n.slideDown("fast",$.proxy(function(){n.busy($.get($(this).attr("data-href")+"&rnd="+Math.random().toString(),function(t){var r=$(t),i;n.html(""),r.appendTo(n),"placeholder"in document.createElement("input")||(i=$("div#sharing-dialog div.form div input#filter, div#security-dialog input#filter"),i.val(i.attr("placeholder")),i.addClass("default"))}))},this))}return!1}),!("placeholder"in document.createElement("input"))){$("body").on("focus","div#sharing-dialog div.form div input#filter, div#security-dialog input#filter",function(){var n=$(this);n.val()==n.attr("placeholder")&&(n.removeClass("default"),n.val(""))});$("body").on("blur","div#sharing-dialog div.form div input#filter, div#security-dialog input#filter",function(){var n=$(this);$.trim(n.val())==""&&(n.addClass("default"),n.val(n.attr("placeholder")))})}t=$(".invite-tooltip"),f=$("#invite-dialog"),t.find("#invite-btn").click(function(){f.knDialog({resizable:!1,modal:!0,width:495,buttons:{Invite:function(){var u={Id:$("#CommunityId").val(),Shares:[],SendEmailNotification:!0},r=[],n,e,i;f.find("input").each(function(){r.push($(this).val())}),n=[];for(e in r)i=r[e].trim(),i!=""&&n.push({id:i,provider:"internal",level:"Write",name:i});u.Shares=JSON.stringify(n),n.length>0&&($.post("/resource/ShareInvite",u),t.hide()),$(this).dialog("close")}}}).show()}),t.find("#close-btn").click(function(){t.hide()})})(),$("form#share-form a.sp-selector").live("click",function(){var t=$(this),n=$("div#security-dialog").dialog({resizable:!1,modal:!0,width:495});return $("div#security-dialog").css("max-height",$(window).height()-142),$("div#security-dialog").css("min-height",140),n.html($.R("~/Js/Shared/resource.share.js","Loading...")),$("form#share-form").busy($.get(t.attr("href")+"&rnd="+Math.random(),function(t){n.html(t),$("div#security-dialog div.share-eml").show()})),!1}),$("body").delegate("div#security-dialog","addPeople",function(n,t,i,r){$.tmpl(i.name,t,{provider:i.provider}).appendTo(r),$("div#security-dialog").trigger("sendInvite",[t,i.provider])}),$("div#security-dialog div#share-eml button#add-members").live("click",function(){var n,t,i;return $("div#share-eml div#friends").hasClass("empty")?!1:(n={},n.name="security-dialog-people-item",n.provider="internal",t=$("div#share-eml div#friends").text(),i=$(this),$("div#site-holder").trigger("validateEmails",[t,function(t){var f=[],e=i.closest("div").find("select#access-level-select").val(),u,r;for(levelAccess=e,u=$("div#"+e+" ul"),r=0;r0&&n.push({id:r.attr("data-id"),level:r.find("span.active").attr("data-level")})}),$("div#sharing-dialog form input#SharesCommunities").val(JSON.stringify(n))}});$("body").on("keyup cleared","div#second-frame .filter-textarea input",function(){var t=Knoema.Utils.strTrim(this.value),i=$("div#share-community li");t?i.each(function(){var n=$(this);Knoema.Utils.strContains(Knoema.Utils.strTrim(n.find(".name").text()),t)?n.show():n.hide()}):i.show()});$("body").on("mouseup","div#second-frame .filter-textarea input",function(){var t=$(this);t.val()!=""&&setTimeout(function(){var n=t.val();n==""&&t.trigger("cleared")},1)});$(function(){function n(n,t){$.get("/resource/gettags",{search:n.term.toLowerCase(),exclude:$("div#page-tags input#page-tags-state").val()},function(n){t(n.tags)})}$("a.unpinned#page-pin").live("click",function(){var n=$(this);return $("div#page-header").busy($.ajax({url:n.attr("href")+"?rnd="+Math.random(),data:{},complete:function(t){t.getResponseHeader("Content-Length")!="0"?window.location.href="/sys/login/?returnUrl="+encodeURI(window.location.pathname):n.removeClass("unpinned").addClass("pinned")}})),!1}),$("a.pinned#page-pin").live("click",function(){var n=$(this);return $("div#page-header").busy($.ajax({url:n.attr("href")+"?rnd="+Math.random(),data:{},complete:function(t){t.getResponseHeader("Content-Length")!="0"?window.location.href="/sys/login/?returnUrl="+encodeURI(window.location.pathname):n.removeClass("pinned").addClass("unpinned")}})),!1}),$("div#page-tags-links a.edit-tags").click(function(){return $("div#page-tags-editor").show(),$("div#page-tags-links").hide(),!1}),$("div#page-tags-editor a.save-tags").click(function(){var n=$(this).attr("href");return $("div#page-tags").busy($.get(n,{tags:$("div#page-tags input.page-tags-hidden").val()},function(n){var i,r,t;if(typeof n=="object"&&n instanceof Array){for($("div#page-tags-links li").remove(),i=$("div#page-tags-links ul"),r=[],t=0;t"+n[t].tag+"<\/a>, <\/li>"):i.append("
  • "+n[t].tag+"<\/a><\/li>"),r[t]=n[t].tag;$("div#page-tags input#page-tags-state").val(r.join(","))}else window.location.reload()})),$("div#page-tags-editor").hide(),$("div#page-tags-links").show(),!1}),$("div#page-tags-editor a.cancel-tags").click(function(){var t=$("div#page-tags ul.page-tags-list"),i=$("div#page-tags input#page-tags-state").val().split(","),n;for(t.tagit("removeAll"),n=0;na").each(function(){$(this).attr("href")==window.location.pathname&&$(this).addClass("active")}),$("#restore-draft").live("click",function(){var t,n;if(Modernizr.localstorage){if(t=$.parseJSON(localStorage.getItem("drafts")),t&&t.length>0)for(n in t)window.open("/page/edit/"+t[n]);for($("#restore").hide(),localStorage.removeItem("drafts"),n=0;n0&&Modernizr.localstorage&&($featureBanner=$("#feature-banner"),featureId=$featureBanner.find("input").val(),localStorage.getItem(featureId+":banner")!=="disabled"&&($featureBanner.show(),$featureBanner.find(".revert").click(function(){return $.post("/user/removefeature",{featureId:featureId},function(){location.reload(),localStorage.setItem(featureId+":banner","disabled")}),!1}),$featureBanner.find(".dismiss").click(function(){return localStorage.setItem(featureId+":banner","disabled"),$featureBanner.hide(),!1}))),function(){if(Modernizr.localstorage){var n=(new Date).valueOf();window.setTimeout(function(){var u=localStorage.getItem("browserSession"),t,i,r;if(n-u>1e4&&(t=$.parseJSON(localStorage.getItem("drafts")),i=!0,t&&t.length>0)){for(r in t)if(localStorage.getItem(t[r])!="draft"){i=!1;break}i&&$("#restore").show()}localStorage.setItem("browserSession",(new Date).valueOf()),window.setInterval(function(){localStorage.setItem("browserSession",(new Date).valueOf())},900)},3e3)}}(),$(document).ready(function(){$("a.facebook, a.twitter, a.google, a#login").bind("click",function(){$(this).trigger("LoginEvent")});var n=$("input#facebookGraph").val();n!=""&&$.get("/resource/graph/"+$("input#Id").val()+"?code="+($.deparam.querystring().code||""))}),$(function(){function u(){var n=document.location.hostname.split("."),t="";return n.length>=2&&(t=n.slice(-2).join(".")),t}var n=$("div#intro div#video"),i=$.cookie.getItem("user-interaction-count"),t=["/products","/market","/gallery","/","/sys/login","sys/login/Reset","/sys/login/signup","/network","/search"],f=!1,r;if(i==1&&!$.cookie.getItem("intro-video-discard")&&n.length>0&&$.inArray(window.location.pathname,t)==-1&&!$("input#hideWelcomeBanner").val()){for(r in t)if(window.location.pathname.indexOf(t[r])!=-1&&t[r]!="/"){f=!0;break}f||Knoema.Utils.apiGet("/api/1.0/meta/ad?rand="+Math.random(),function(n){n&&$("#intro > span").html(n),$("div#intro").show()},function(){})}i==null&&$.cookie.setItem("user-interaction-count",i+1,31536e3,"/",u(),!1),n.dialog({autoOpen:!1,width:640,height:460,resizable:!1,modal:!0,buttons:{"":function(){}},open:function(){n.append('