
dwn_index = 0;
jQuery( '.elex-multi-vendor-for-woocommerce-add-download-file-row-btn' ).click( function() {
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).prepend( jQuery( '#template-for-add-product-file-download' ).html() );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex_mv_name_file_download' ).attr( 'id', 'elex_mv_name_file_download_id-' + dwn_index );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex_mv_hash_file_download' ).attr( 'id', 'elex_mv_hash_file_download_id-' + dwn_index );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex_mv_url_file_download' ).attr( 'id', 'elex_mv_url_file_download_id-' + dwn_index );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex-multi-vendor-for-woocommerce-edit-upload-download-file-btn' ).attr( 'id', 'elex-multi-vendor-for-woocommerce-edit-upload-download-file-btn-id-' + dwn_index );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex-multi-vendor-for-woocommerce-file-download' ).attr( 'id', 'elex-multi-vendor-for-woocommerce-file-download-id-' + dwn_index );
	jQuery( '#elex_mv_add_table_download_file' ).find( 'tbody' ).children( 'tr:first' ).find( '.elex-multi-vendor-for-woocommerce-remove-dowload-tr-simple-product' ).attr( 'id', 'elex-multi-vendor-for-woocommerce-remove-dowload-tr-simple-product-id-' + dwn_index );

	dwn_index++;
} );

jQuery( document.body ).on( 'click', '.elex-multi-vendor-for-woocommerce-remove-dowload-tr-simple-product', function( event ) {

	var variat_index = this.id.split( '-' ).pop();
	jQuery( '#elex-multi-vendor-for-woocommerce-remove-dowload-tr-simple-product-id-' + variat_index ).parent().parent().remove();

} );

jQuery( '#elex_multivendor_new_product_type' ).change( function() {
	if ( this.value == 'simple' ) {
		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-variations-tab' ).closest( 'li' ).addClass( 'd-none' );
		jQuery( '.elex-multi-vendor-for-woocommerce-regular-price-sale-price-div' ).removeClass( 'd-none' );

		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-variations' ).addClass( 'd-none' );
		jQuery( '#elex-multi-vendor-for-woocommerce-add-virtual-product-switch-div' ).removeClass( 'd-none' );
		jQuery( '#elex-multi-vendor-for-woocommerce-add-dwn-product-switch-div' ).removeClass( 'd-none' );

		parent = jQuery( '.elex_mv_add_attribute_parent' ).children().first().find( '.elex-multi-vendor-for-woocommerce-use-for-variations' ).parent();
		parent.addClass( 'd-none' );

	} else {
		jQuery( '.elex-multi-vendor-for-woocommerce-regular-price-sale-price-div' ).addClass( 'd-none' );

		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-variations-tab' ).closest( 'li' ).removeClass( 'd-none' );
		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-variations' ).removeClass( 'd-none' );
		jQuery( '#elex-multi-vendor-for-woocommerce-add-virtual-product-switch-div' ).addClass( 'd-none' );
		jQuery( '#elex-multi-vendor-for-woocommerce-add-dwn-product-switch-div' ).addClass( 'd-none' );

		parent = jQuery( '.elex_mv_add_attribute_parent' ).children().first().find( '.elex-multi-vendor-for-woocommerce-use-for-variations' ).parent();
		parent.removeClass( 'd-none' );
	}
} );

jQuery( '#elex-multi-vendor-for-woocommerce-add-dwn-product-switch' ).change( function() {

	if ( jQuery( this ).is( ':checked' ) ) {
		jQuery( '.elex-multi-vendor-for-woocommerce-edit-download-file-div' ).removeClass( 'd-none' );
		jQuery( '.elex-multi-vendor-for-woocommerce-dwm-limit-expiry-div' ).removeClass( 'd-none' );

	} else {
		jQuery( '.elex-multi-vendor-for-woocommerce-edit-download-file-div' ).addClass( 'd-none' );
		jQuery( '.elex-multi-vendor-for-woocommerce-dwm-limit-expiry-div' ).addClass( 'd-none' );
	}

} );

jQuery( '#elex-multi-vendor-for-woocommerce-add-virtual-product-switch' ).change( function() {

	if ( jQuery( this ).is( ':checked' ) ) {

		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-shipping-tab' ).closest( 'li' ).addClass( 'd-none' );
		// jQuery('#elex-multi-vendor-for-woocommerce-add-ac-shipping-tab').attr('disabled','disabled');

		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-shipping' ).addClass( 'd-none' );
	} else {
		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-shipping-tab' ).closest( 'li' ).removeClass( 'd-none' );
		// jQuery('#elex-multi-vendor-for-woocommerce-add-ac-shipping-tab').attr('disabled','disabled');

		jQuery( '#elex-multi-vendor-for-woocommerce-add-ac-shipping' ).removeClass( 'd-none' );
	}

} );


jQuery( '.elex_mv_product_schedule_btn' ).click( function() {
	jQuery( '.elex_mv_product_schedule_sec' ).removeClass( 'd-none' );
	jQuery( this ).addClass( 'd-none' );
	jQuery( '.elex_mv_product_schedule_cancel_btn' ).removeClass( 'd-none' );
} );
jQuery( '.elex_mv_product_schedule_cancel_btn' ).click( function() {
	jQuery( '.elex_mv_product_schedule_sec' ).addClass( 'd-none' );
	jQuery( '.elex_mv_product_schedule_btn' ).addClass( 'd-none' );
	jQuery( this ).addClass( 'd-none' );
	jQuery( '.elex_mv_product_schedule_btn' ).removeClass( 'd-none' );
} );
