/* ( function( api ) {

	// Extends our custom "example-1" section.
	api.sectionConstructor['plugin-section'] = api.Section.extend( {

		// No events for this type of section.
		attachEvents: function () {},

		// Always make the section active.
		isContextuallyActive: function () {
			return true;
		}
	} );

} )( wp.customize ); */


function pet_bazaarfrontpagesectionsscroll( section_id ){
    var scroll_section_id = "slider-section";

    var $contents = jQuery('#customize-preview iframe').contents();

    switch ( section_id ) {
        case 'accordion-section-category_product_setting':
		case 'accordion-section-category2_product_setting':
		case 'accordion-section-category3_product_setting':
		case 'accordion-section-category4_product_setting':
		case 'accordion-section-category5_product_setting':
        scroll_section_id = "product-category-section";
        break;

        case 'accordion-section-banner2_setting':
        case 'accordion-section-banner22_setting':
        case 'accordion-section-banner32_setting':
        case 'accordion-section-banner2_setting':
        case 'accordion-section-banner2_setting':
        scroll_section_id = "banner2-section";
        break;

        case 'accordion-section-feature_product_setting':
        case 'accordion-section-feature_product2_setting':
        case 'accordion-section-feature_product3_setting':
        case 'accordion-section-feature_product4_setting':
        case 'accordion-section-feature_product5_setting':
        scroll_section_id = "feature-product-section";
        break;
		
        case 'accordion-section-deal_product_setting':
        case 'accordion-section-deal_product2_setting':
        case 'accordion-section-deal_product3_setting':
        case 'accordion-section-deal_product4_setting':
        case 'accordion-section-deal_product_setting':
        scroll_section_id = "product-deal-section";
        break;
		
		case 'accordion-section-banner_setting':
		case 'accordion-section-banner21_setting':
		case 'accordion-section-banner_setting':
		case 'accordion-section-banner_setting':
		case 'accordion-section-banner_setting':
        scroll_section_id = "banner-section";
        break;
		
		case 'accordion-section-trending_product_setting':
		case 'accordion-section-trending_product2_setting':
		case 'accordion-section-trending_product3_setting':
		case 'accordion-section-trending_product4_setting':
		case 'accordion-section-trending_product5_setting':
		scroll_section_id = "trending-product-section";
		break;
		
		case 'accordion-section-cta_setting':
		case 'accordion-section-cta2_setting':
		case 'accordion-section-cta3_setting':
		case 'accordion-section-cta4_setting':
		case 'accordion-section-cta5_setting':
        scroll_section_id = "cta-section";
        break;
		
		case 'accordion-section-funfact_setting':
		case 'accordion-section-funfact2_setting':
		case 'accordion-section-funfact3_setting':
		case 'accordion-section-funfact4_setting':
		case 'accordion-section-funfact5_setting':
        scroll_section_id = "funfact-section";
        break;
		
		case 'accordion-section-week_deal_setting':
		case 'accordion-section-week_deal2_setting':
		case 'accordion-section-week_deal3_setting':
		case 'accordion-section-week_deal4_setting':
		case 'accordion-section-week_deal5_setting':
        scroll_section_id = "deal-section";
        break;
		
		case 'accordion-section-work_process_setting':
		case 'accordion-section-work_process2_setting':
		case 'accordion-section-work_process3_setting':
		case 'accordion-section-work_process4_setting':
		case 'accordion-section-work_process5_setting':
        scroll_section_id = "progress-section";
        break;
		
		case 'accordion-section-banner4_setting':
		case 'accordion-section-banner42_setting':
		case 'accordion-section-banner43_setting':
		case 'accordion-section-banner44_setting':
		case 'accordion-section-banner45_setting':
        scroll_section_id = "banner4-section";
        break;
		
		case 'accordion-section-testimonial_setting':
		case 'accordion-section-testimonial2_setting':
		case 'accordion-section-testimonial3_setting':
		case 'accordion-section-testimonial4_setting':
		case 'accordion-section-testimonial5_setting':
        scroll_section_id = "testimonial-section";
        break;
		
		case 'accordion-section-blog_setting':
		case 'accordion-section-blog2_setting':
		case 'accordion-section-blog3_setting':
		case 'accordion-section-blog4_setting':
		case 'accordion-section-blog5_setting':
        scroll_section_id = "post-section";
        break;
		
		case 'accordion-section-gallery_setting':
		case 'accordion-section-gallery2_setting':
		case 'accordion-section-gallery3_setting':
		case 'accordion-section-gallery4_setting':
		case 'accordion-section-gallery5_setting':
        scroll_section_id = "gallery-section";
        break;
		
		case 'accordion-section-recent_news_setting':
		case 'accordion-section-recent_news2_setting':
		case 'accordion-section-recent_news3_setting':
		case 'accordion-section-recent_news4_setting':
		case 'accordion-section-recent_news5_setting':
        scroll_section_id = "recent-news-section";
        break;
		
		case 'accordion-section-sponsor_setting':
		case 'accordion-section-sponsor2_setting':
		case 'accordion-section-sponsor3_setting':
		case 'accordion-section-sponsor4_setting':
		case 'accordion-section-sponsor5_setting':
        scroll_section_id = "sponsor-section";
        break;
		
		case 'accordion-section-service_setting':
		case 'accordion-section-service2_setting':
		case 'accordion-section-service3_setting':
		case 'accordion-section-service4_setting':
		case 'accordion-section-service5_setting':
        scroll_section_id = "service-section";
        break;
		
		case 'accordion-section-team_setting':
		case 'accordion-section-team2_setting':
		case 'accordion-section-team3_setting':
		case 'accordion-section-team4_setting':
		case 'accordion-section-team5_setting':
        scroll_section_id = "team-section";
        break;
		
		case 'accordion-panel-footer_section':
        scroll_section_id = "footer-section";
        break;
    }

    if( $contents.find('#'+scroll_section_id).length > 0 ){
        $contents.find("html, body").animate({
        scrollTop: $contents.find( "#" + scroll_section_id ).offset().top
        }, 1000);
    }
}

 jQuery('body').on('click', '#sub-accordion-panel-pet_bazaar_frontpage_sections .control-subsection .accordion-section-title', function(event) {
        let section_id = jQuery(this).parent('.control-subsection').attr('id');
        pet_bazaarfrontpagesectionsscroll( section_id );
});
 jQuery('body').on('click', '#sub-accordion-panel-pet_bazaar_frontpage2_sections .control-subsection .accordion-section-title', function(event) {
        let section_id = jQuery(this).parent('.control-subsection').attr('id');
        pet_bazaarfrontpagesectionsscroll( section_id );
});
 jQuery('body').on('click', '#sub-accordion-panel-pet_bazaar_frontpage3_sections .control-subsection .accordion-section-title', function(event) {
        let section_id = jQuery(this).parent('.control-subsection').attr('id');
        pet_bazaarfrontpagesectionsscroll( section_id );
});
 jQuery('body').on('click', '#sub-accordion-panel-pet_bazaar_frontpage4_sections .control-subsection .accordion-section-title', function(event) {
        let section_id = jQuery(this).parent('.control-subsection').attr('id');
        pet_bazaarfrontpagesectionsscroll( section_id );
});
 jQuery('body').on('click', '#sub-accordion-panel-pet_bazaar_frontpage5_sections .control-subsection .accordion-section-title', function(event) {
        let section_id = jQuery(this).parent('.control-subsection').attr('id');
        pet_bazaarfrontpagesectionsscroll( section_id );
});

jQuery('body').on('click', '#accordion-panel-footer_section .accordion-section-title', function(event) {
        var footer_id = jQuery(this).parent('.control-panel').attr('id');
        pet_bazaarfrontpagesectionsscroll( footer_id );
});

/* Option Disable */
jQuery(function($) {
	jQuery("#sub-accordion-section-footer_background input, #customize-control-site_ttl_size input, #customize-control-site_desc_size input, #sub-accordion-section-footer_background button.wp-color-result, #customize-control-sticky_header_logo button, #customize-control-pet_bazaar_site_cntnr_width input, #sub-accordion-section-pet_bazaar_sidebar select:not(#_customize-input-pet_bazaar_default_pg_sidebar), #customize-control-scroller_icon select, #_customize-input-breadcrumb_title_enable, #_customize-input-breadcrumb_path_enable, #customize-control-breadcrumb_overlay_color button, #sub-accordion-section-pet_bazaar_typography select, #sub-accordion-section-pet_bazaar_headings_typography select, #sub-accordion-section-pet_bazaar_menu_typography select").prop('disabled', true);
});