var Home=function(){return{Common:{createViewModel:function(n){n.SearchTerm.SearchText.subscribe(function(){n.HasSearchPerformed(!1);n.SearchStatus.HasDocumentsSearchPerformed(!1);n.SearchStatus.HasDriveCadSearchPerformed(!1);n.SearchStatus.HasProductdataSearchPerformed(!1);n.SearchStatus.HasDownloadsSearchPerformed(!1)});n.SelectedLanguages.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedDocumentTypes.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.PdfEncryption.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedCADSystemAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedCADSystemViewAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedTwoDimensionalExportFormatAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedTwoDimensionalExportViewsAsStrings.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedThreeDimensionalExportFormatsAsStrings.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedThreeDimensionalExportFormatVersionSatAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedThreeDimensionalExportFormatVersionStepAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedThreeDimensionalExportFormatVersionDxfAsString.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedAssemblyType.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SelectedProductDataDocumentFormats.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)});n.SuppressPrices.subscribe(function(){DuD.App.Home.updateSessionSettingsCookie(n)})},setSynchronisation:function(n){n.SelectedLanguages.syncWith(DuD.App.Const.KO.LANGUAGES,!0);n.SelectedDocumentTypes.syncWith(DuD.App.Const.KO.DOCUMENT_TYPES,!0);n.SelectedProductDataDocumentFormats.syncWith("SelectedProductDataDocumentFormats",!0);n.SelectedProductDataLanguage.syncWith("ProductdataSelectedLanguageSetting",!0);n.SuppressPrices.syncWith("SuppressPricesVal",!0);n.ShowPrices.syncWith("ShowPricesVal",!0);n.NetPrice.syncWith("NetPrice",!0);n.SelectedProduct.syncWith(DuD.App.Const.KO.PRODUCT,!0);n.SelectedItems.syncWith("SelectedItems",!0);n.SelectedSoftwareCategory.syncWith(DuD.App.Const.KO.SOFTWARE_CATEGORY,!0);n.SelectedSoftwareId.syncWith("SelectedSoftwareId",!0);n.PdfEncryption.syncWith(DuD.App.Const.KO.PDF_PROTECTION_SETTING,!0);n.SelectedCADSystemAsString.syncWith("SelectedCADSystem",!0);n.SelectedCADSystemViewAsString.syncWith("SelectedCADSystemView",!0);n.SelectedTwoDimensionalExportFormatAsString.syncWith("SelectedTwoDimensionalExportFormat",!0);n.SelectedTwoDimensionalExportViewsAsStrings.syncWith("SelectedTwoDimensionalExportViews",!0);n.SelectedThreeDimensionalExportFormatsAsStrings.syncWith("SelectedThreeDimensionalExportFormats",!0);n.SelectedThreeDimensionalExportFormatVersionSatAsString.syncWith("SelectedThreeDimensionalExportFormatVersionSat",!0);n.SelectedThreeDimensionalExportFormatVersionStepAsString.syncWith("SelectedThreeDimensionalExportFormatVersionStep",!0);n.SelectedThreeDimensionalExportFormatVersionDxfAsString.syncWith("SelectedThreeDimensionalExportFormatVersionDxf",!0);n.SelectedAssemblyType.syncWith("SelectedAssemblyType",!0);DuD.App.Common.setOptionSettingSynchronisation(n);DuD.App.Common.setDefaultOptionSettingSynchronisation(n);n.ProductMetaData.syncWith("productMetaData",!0);n.IsConfigurationOriginator.syncWith("IsConfigurationOriginator",!0)},updateSessionSettingsCookie:function(n){var t={SelectedLanguages:ko.toJS(n.SelectedLanguages()),SelectedDocumentTypes:ko.toJS(n.SelectedDocumentTypes()),PdfEncryption:ko.toJS(n.PdfEncryption()),SelectedCADSystemAsString:ko.toJS(n.SelectedCADSystemAsString()),SelectedCADSystemViewAsString:ko.toJS(n.SelectedCADSystemViewAsString()),SelectedTwoDimensionalExportFormatAsString:ko.toJS(n.SelectedTwoDimensionalExportFormatAsString()),SelectedTwoDimensionalExportViewsAsStrings:ko.toJS(n.SelectedTwoDimensionalExportViewsAsStrings()),SelectedThreeDimensionalExportFormatsAsStrings:ko.toJS(n.SelectedThreeDimensionalExportFormatsAsStrings()),SelectedThreeDimensionalExportFormatVersionSatAsString:ko.toJS(n.SelectedThreeDimensionalExportFormatVersionSatAsString()),SelectedThreeDimensionalExportFormatVersionStepAsString:ko.toJS(n.SelectedThreeDimensionalExportFormatVersionStepAsString()),SelectedThreeDimensionalExportFormatVersionDxfAsString:ko.toJS(n.SelectedThreeDimensionalExportFormatVersionDxfAsString()),SelectedAssemblyType:ko.toJS(n.SelectedAssemblyType())};Utils.ajax({async:!0,type:DuD.App.Const.Events.POST,url:DuD.App.Const.Mvc.API_SESSION_SETTINGS_SERVICE,contentType:DuD.App.Const.General.CONTENT_TYPE_JSON,data:JSON.stringify(t),dataType:"json",success:function(){}},!1)},clickButton:function(n){var t=jQuery(DuD.App.Const.FormElements.SEARCH_BUTTON+n);t.length>0&&t.click()},checkForNewTransactionPositionAndSetNewSearch:function(n){var t=n.SearchTextTrimmed(),i;return hashTableTransactionPosition.hasItem(t)&&(i=hashTableTransactionPosition.getItem(t),n.SearchTerm.Transactions()!=null&&n.SearchTerm.Transactions()[0].PosNumber!==i)?(hashTableTransactionPosition.setItem(t,n.SearchTerm.Transactions()[0].PosNumber),!0):!1},initDialogFunctions:function(n){jQuery(DuD.App.Const.General.DIALOG_CONTENT).on(DuD.App.Const.Events.DIALOG_BEFORE_CLOSE,function(){DuD.App.Common.removeLoader()});jQuery(DuD.App.Const.General.DIALOG_CONTENT).on(DuD.App.Const.Events.DIALOG_CLOSE,function(){jQuery(DuD.App.Const.IDs.SEARCH_TABS).tabs(DuD.App.Const.Events.DESTROY)});if(n.IsDialog()&&n.OpenDocumentsPackageDialog()){var t=jQuery(DuD.App.Const.IDs.SEARCH_TABS);t.load(DuD.App.Const.Mvc.DOCUMENTS_PACKAGE_LOADING,null,null)}}}}}(jQuery);(function(){var n={viewModel:{},init:function(){var n=this,t;n.initViewModel();n.initTabFunctions();n.initHideInfoBox();t=jQuery(DuD.App.Const.IDs.SEARCH_TABS);t.on(DuD.App.Const.Events.TABS_ACTIVATE,function(t,i){var u,r;if(DuD.App.Common.initPopOverClose(),u=i.newPanel.attr("aria-labelledby"),i.newTab.data(DuD.App.Const.Events.LOADED)&&n.viewModel.HasSearchPerformed()){r="";switch(u){case DuD.App.Const.TabNames.DRIVECAD_TAB_LINK:n.viewModel.SearchStatus.HasDriveCadSearchPerformed()||(r=DuD.App.Const.TabNames.DRIVECAD);break;case DuD.App.Const.TabNames.DOCUMENTS_TAB_LINK:n.viewModel.SearchStatus.HasDocumentsSearchPerformed()||(r=DuD.App.Const.TabNames.DOCUMENTS);break;case DuD.App.Const.TabNames.PRODUCTDATA_TAB_LINK:n.viewModel.SearchStatus.HasProductdataSearchPerformed()||(r=DuD.App.Const.TabNames.PRODUCTDATA);break;case DuD.App.Const.TabNames.SOFTWARE_TAB_LINK:n.viewModel.SearchStatus.HasDownloadsSearchPerformed()||(r=DuD.App.Const.TabNames.DOWNLOADS)}Home.Common.clickButton(r)}});n.viewModel.IsConfigurationOriginator()&&(jQuery("#"+DuD.App.Const.TabNames.DRIVECAD+"-tab-link").hide(),jQuery("#"+DuD.App.Const.TabNames.DOCUMENTS+"-tab-link").hide(),jQuery("#"+DuD.App.Const.TabNames.DOWNLOADS+"-tab-link").hide(),jQuery("#"+DuD.App.Const.TabNames.DRIVECAD+"-tab-listitem").hide(),jQuery("#"+DuD.App.Const.TabNames.DOCUMENTS+"-tab-listitem").hide(),jQuery("#"+DuD.App.Const.TabNames.DOWNLOADS+"-tab-listitem").hide());Home.Common.initDialogFunctions(n.viewModel)},checkForNewTransactionPositionAndSetNewSearch:function(){return Home.Common.checkForNewTransactionPositionAndSetNewSearch(this.viewModel)},initViewModel:function(){var n=this,t=jQuery(DuD.App.Const.KO.ViewModel.SEARCH_INDEX_JSON).val();n.viewModel=n.createHomeViewModel(t);n.viewModel.HasSearchPerformed()&&hashTableSearchTerm.setItem(n.viewModel.SearchTerm.SearchText(),n.viewModel.SearchTerm.Type());ko.applyBindings(n.viewModel)},initTabFunctions:function(){jQuery(DuD.App.Const.IDs.SEARCH_TABS).on(DuD.App.Const.Events.TABS_BEFORE_LOADED,function(n,t){if(t.tab.data(DuD.App.Const.Events.LOADED)){n.preventDefault();return}t.jqXHR.success(function(){t.tab.data(DuD.App.Const.Events.LOADED,!0)})})},initHideInfoBox:function(){var t=this,n=jQuery("#info-box-close-button");n.unbind(DuD.App.Const.Events.CLICK);n.on(DuD.App.Const.Events.CLICK,function(n){n.preventDefault();t.viewModel.ShowInfoBox(!1)})},createHomeViewModel:function(n){var t=this;return DuD.App.Common.createGenericViewModel(n,function(n){DuD.App.Common.setGenericSynchronization(n,function(n){t.setSynchronisation(n)});n.InitialTab=ko.computed(function(){var t;switch(n.SelectedTab()){case DuD.App.Const.TabNames.DOCUMENTS:t=1;break;case DuD.App.Const.TabNames.PRODUCTDATA:t=2;break;case DuD.App.Const.TabNames.DOWNLOADS:t=3;break;default:t=0}return t});Home.Common.createViewModel(n);n.ShowInfoBox=ko.observable(!0)})},setSynchronisation:function(n){Home.Common.setSynchronisation(n)},openDocumentsPackageDialog:function(n){var t;Utils.ajax({type:DuD.App.Const.Events.GET,url:DuD.App.Const.Mvc.DOCUMENTS_PACKAGE_INDEX+"?width=fullsize&"+n,contentType:"html",success:function(n){var i=jQuery(n);t=i},complete:function(){Utils.Dialog.open(t,{});DuD.App.Common.initPopOverClose()}},!0)},updateSessionSettingsCookie:function(){Home.Common.updateSessionSettingsCookie(this.viewModel)}};n.init()})(jQuery),function(){jQuery(document).ready(function(){var t=jQuery(DuD.App.Const.KO.ViewModel.SEARCH_INDEX_JSON).val(),n=ko.mapping.fromJSON(t);n.OpenDocumentsPackageDialog()&&DuD.App.DocumentsPackage.openDialog(n.DocumentsPackageQueryString())})}(jQuery)