$(document).ready(function(){function n(n,t){var i,r;for($("#blockDiagramCTA").remove(),$("#blockErrorDivId").remove(),t=t+1,controlIdToRemove=t,r=1;r<10;r++)if($("#"+controlIdToRemove).length>0)$("#"+controlIdToRemove).closest("label").remove(),controlIdToRemove=controlIdToRemove+1;else break;if(i=$("<select id="+t+" />"),$("<option />",{text:subCategoryDefaultText}).appendTo(i),n.length>0){for(r=0;r<n.length;r++){var e=n[r],u=e.ApplicationID,f=e.ApplicationTitle;u!=null&&u!=""&&f!=null&&f!=""&&$("<option />",{value:u,text:f}).appendTo(i)}i.appendTo("#exploreFirstLevelForm");i.wrap("<label />");i.wrap('<div class="select-bg" />');$('<div class="pri-nav-typedir up"><i class="icon-chevron-thin-down"><\/i><\/div>').insertAfter(i)}}function t(n,t,r){var u;if($("#blockDropDownId").length>0&&$("#blockDropDownId").closest("label").remove(),u=$('<select id="blockDropDownId" />'),$("<option />",{text:diagramSelectDefaultText}).appendTo(u),n.length>0){for(i=0;i<n.length;i++){var f=n[i],e=f.BlockDiagramTitle,o=f.BlockDiagramCTA;$("<option />",{value:o,text:e}).appendTo(u)}u.appendTo("#exploreFirstLevelForm");u.wrap("<label />");u.wrap('<div class="select-blockdiag" style="background:#fff;" />');$('<div class="pri-nav-typedir up"><i class="icon-chevron-thin-down"><\/i><\/div>').insertAfter(u)}n.length<=0&&r.length<=0&&(u=$('<div id="blockErrorDivId">'+noBlockDiagramErrorMessage+"<\/div>"),u.appendTo("#exploreFirstLevelForm"))}$("#1 option:first-child").attr("selected",!0);$("#exploreFirstLevelForm").delegate(".select-bg","change",function(){var i=$("option:selected",this).attr("value"),r=$("select",this).attr("id"),u=$("select",this).attr("value"),f;i==undefined&&$(this.parentElement).nextAll().remove();f=$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:exploreBlockUrl,data:"{'selectedDropDownId':"+JSON.stringify(i)+"}",dataType:"json",success:function(i){var f=i.ApplicationDetails,e=i.BlockDiagramDetails;n(f,r);t(e,u,f)},error:function(){}})});$("#exploreFirstLevelForm").delegate(".select-blockdiag","change",function(){var n,t;$("#blockDiagramCTA").remove();$("#blockErrorDivId").remove();n=$("option:selected",this).attr("value");blockDiagramSelect=$('<a href="'+n+'"id="blockDiagramCTA" class="btn primary">'+diagramDefaultText+"<\/a>");t=$(this).closest("label");blockDiagramSelect.insertAfter(t);(n==""||n==undefined)&&$(this.parentElement).nextAll().remove()})})