( function( api ) {

	// Plugin Install notice section logic
	api.sectionConstructor['plugin-section'] = api.Section.extend( {
		attachEvents: function () {},
		isContextuallyActive: function () {
			return true;
		}
	} );

} )( wp.customize );

/**
 * Scroll to section in preview
 */
function paws_and_care_frontpage_sections_scroll( section_id ){
    var scroll_section_id = "";
    var $contents = jQuery('#customize-preview iframe').contents();

    switch ( section_id ) {
        case 'accordion-section-paws_and_care_slider':
            scroll_section_id = "carouselSlider";
            break;

        case 'accordion-section-paws_and_care_about':
            scroll_section_id = "about-section";
            break;

        case 'accordion-section-paws_and_care_services':
            scroll_section_id = "services-section";
            break;

        case 'accordion-section-paws_and_care_woo':
            scroll_section_id = "woocommerce-section";
            break;

        case 'accordion-section-paws_and_care_blog':
            scroll_section_id = "blog-section";
            break;
    }

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

jQuery('body').on('click', '#sub-accordion-panel-paws_and_care_front_page .control-subsection .accordion-section-title', function(event) {
    var section_id = jQuery(this).parent('.control-subsection').attr('id');
    paws_and_care_frontpage_sections_scroll( section_id );
});