( 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 nexcraft_frontpagesectionsscroll( section_id ){
    var scroll_section_id = "slider-section";

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

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

        case 'accordion-section-service_setting':
        scroll_section_id = "service-section";
        break;

        case 'accordion-section-features_setting':
        scroll_section_id = "features-section";
        break;
		
        case 'accordion-section-project_setting':
        scroll_section_id = "portfolio-section";
        break;
		
		case 'accordion-section-cta_setting':
        scroll_section_id = "cta-section";
        break;
		
		case 'accordion-section-pricing_setting':
		scroll_section_id = "pricing-section";
		break;
		
		case 'accordion-section-client_setting':
        scroll_section_id = "client-section";
        break;
		
		case 'accordion-section-team_setting':
        scroll_section_id = "team-section";
        break;
		
		case 'accordion-section-funfact_setting':
        scroll_section_id = "funfact-section";
        break;
		
		case 'accordion-section-blog_setting':
        scroll_section_id = "post-section";
        break;
		
		case 'accordion-section-testimonial_setting':
        scroll_section_id = "testimonial-section";
        break;
		
		case 'accordion-section-custom_setting':
        scroll_section_id = "custom-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-nexcraft_frontpage_sections .control-subsection .accordion-section-title', function(event) {
        var section_id = jQuery(this).parent('.control-subsection').attr('id');
        nexcraft_frontpagesectionsscroll( 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');
        nexcraft_frontpagesectionsscroll( footer_id );
});

(function($) {
	$(document).ready(function($) {
		if($("select").hasClass("contact-icon-picker")){
			$('.contact-icon-picker.iconPicker').fontIconPicker();
		}
	});
	
	jQuery(document).ready(function($) {
	 jQuery("#sub-accordion-section-nexcraft_sidebar select:not(#_customize-input-nexcraft_default_pg_sidebar), #sub-accordion-section-nexcraft_typography select, #sub-accordion-section-nexcraft_headings_typography select").prop('disabled', true);
});
	
})(jQuery);