/**
 * Scripts within the customizer controls window.
 *
 * Contextually shows the navbar type setting and informs the preview
 * when users open or close the front page sections section.
 */
 



 ( function () {
	wp.customize.bind( 'ready', function () {		
		wp.customize( 'wrockmetro_newsticker_style', function ( setting ) {			
			//style one
		  function setupControl(controlName) {
                wp.customize.control(controlName, function (control) {
                    const visibility = function () {
                        if ('styleone' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }

            // List of controls to be handled
            const controls = [
                'wrockmetro_tickerbg',
                'wrockmetro_tickerlabelfont',
                'wrockmetro_tickerpostbg',
                'wrockmetro_tickerpostlink'
            ];

            // Setup each control
            controls.forEach(function (controlName) {
                setupControl(controlName);
            });
			
			
			
			 function setupControlTwo(controlNameTwo) {
                wp.customize.control(controlNameTwo, function (control) {
                    const visibility = function () {
                        if ('styletwo' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }
			 // List of controls to be handled
            const controlstwo = [
                'wrockmetro_tickerbg_two',
                'wrockmetro_tickerlabelfont_two',
                'wrockmetro_tickerpostbg_two',
                'wrockmetro_tickerpostlink_two'
            ];

            // Setup each control
            controlstwo.forEach(function (controlNameTwo) {
                setupControlTwo(controlNameTwo);
            });
			//style two
			
			 function setupControlThree(controlNameThree) {
                wp.customize.control(controlNameThree, function (control) {
                    const visibility = function () {
                        if ('stylethree' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }
			 // List of controls to be handled
            const controlsthree = [
                'wrockmetro_tickerbg_three',
                'wrockmetro_tickerlabelfont_three',
                'wrockmetro_tickerpostbg_three',
                'wrockmetro_tickerspeed_three',
                'wrockmetro_tickerpostlink_three'
            ];

            // Setup each control
            controlsthree.forEach(function (controlNameThree) {
                setupControlThree(controlNameThree);
            });
			//style three
		
					
		});			
		wp.customize('wrockmetro_posts_layout', function (setting) {
    function setupControlWrockMetro(controlNameWrockMetro) {
        wp.customize.control(controlNameWrockMetro, function (control) {
            const visibility = function () {
                if ('wrock-metro' === setting.get()) {
                    control.container.slideDown(180);
                } else {
                    control.container.slideUp(180);
                }
            };
            visibility();
            setting.bind(visibility);
        });
    }

    const controlswrockmetro = [
        'wrockmetro_wrockmetro_heading',
        'topcateid_hide',
        'topcateid',
        'cat_contlr_top',
        'cat_contlr_left',
        'cat_contlr_right',
        'leftcateid_hide',
        'leftcateid',
        'rightcateid_hide',
        'rightcateid',
    ];

    controlswrockmetro.forEach(function (controlNameWrockMetro) {
        setupControlWrockMetro(controlNameWrockMetro);
    });
});

		wp.customize( 'wrockmetro_header_style', function ( setting ) {			
			//style one
		  function setupControl(controlName) {
                wp.customize.control(controlName, function (control) {
                    const visibility = function () {
                        if ('styleone' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }

            // List of controls to be handled
            const controls = [
                'wrockmetro_topnavbgcolor',
                'wrockmetro_topnavhover',
                'wrockmetro_topnavtext',
                'wrockmetro_primarymenubg',
                'wrockmetro_primarymenubgs',
                'wrockmetro_primarymenutext',
                'wrockmetro_primarymenuhover',
                'wrockmetro_primarymenuhovertext'
            ];

            // Setup each control
            controls.forEach(function (controlName) {
                setupControl(controlName);
            });
			
			
			
			
			//style two
			  function setupControlTwo(controlNameTwo) {
                wp.customize.control(controlNameTwo, function (control) {
                    const visibility = function () {
                        if ('styletwo' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }
			 // List of controls to be handled
            const controlstwo = [
                'wrockmetro_heroarea_links',
                'wrockmetro_heroarea_links_hover',
                'wrockmetro_heroarea',
                'wrockmetro_stickymenu',
            ];

            // Setup each control
            controlstwo.forEach(function (controlNameTwo) {
                setupControlTwo(controlNameTwo);
            });
			
			//style Three
			  function setupControlThree(controlNameThree) {
                wp.customize.control(controlNameThree, function (control) {
                    const visibility = function () {
                        if ('stylethree' === setting.get()) {
                            control.container.slideDown(180);
                        } else {
                            control.container.slideUp(180);
                        }
                    };
                    visibility();
                    setting.bind(visibility);
                });
            }
			 // List of controls to be handled
            const controlsthree = [
                'wrockmetro_primarymenutext_three',
                'wrockmetro_topnavi_leftthree',
                'wrockmetro_topnavi_rightthree',
                'wrockmetro_primarymenutexthover_three',
                'wrockmetro_topnavibg_three',
                'wrockmetro_topnavi_enablethree',
                'wrockmetro_primarymenubg_three',
                'wrockmetro_topnavitext_three',
            ];

            // Setup each control
            controlsthree.forEach(function (controlNameThree) {
                setupControlThree(controlNameThree);
            });		
					
		});			
	} );

    wp.customize("wrockmetro_scroll_top_position", function(value) {
        value.bind(function(newVal) {
            if ( newVal === "left" ) {
                jQuery( "a.scrollup" ).css( { "right": "auto", "left": "0" } );
            } else if ( newVal === "right" ) {
                jQuery( "a.scrollup" ).css( { "left": "auto", "right": "0" } );
            }
        });
    });
    wp.customize( 'wrockmetro_footerbg', function( value ) {
		value.bind( function( footerWigbg ) {
			jQuery('#wrapper-footer-full').css('background-color', footerWigbg );
			jQuery('#wrapper-static-hero').css('background-color', footerWigbg );
		} );
	} );
    wp.customize( 'wrockmetro_footer_copy', function( value ) {
		value.bind( function( footerCopybg ) {
			jQuery('#wrapper-footer').css('background', footerCopybg );
		} );
	} );
    wp.customize( 'wrockmetro_pagenavi_current', function( value ) {
		value.bind( function( pagenavic ) {
			jQuery('span.page-link.current').css('background-color', pagenavic );
		} );
	} );  
	wp.customize( 'wrockmetro_pagenavi_bg', function( value ) {
		value.bind( function( pagenavibg ) {
			jQuery('a.page-link').css('background-color', pagenavibg );
		} );
	} );    
	wp.customize( 'wrockmetro_pagenavia_textcurrent', function( value ) {
		value.bind( function( pagenavitextc) {
			jQuery('span.page-link.current').css('color', pagenavitextc );
		} );
	} );    
	wp.customize( 'wrockmetro_pagenavia_text', function( value ) {
		value.bind( function( pagenavitext) {
			jQuery('a.page-link').css('color', pagenavitext );
		} );
	} );  
	wp.customize( 'wrockmetro_pagenavia_hover', function( value ) {
    value.bind( function( pagenavihover ) {
        jQuery('a.page-link').hover(function(){
            jQuery(this).css('background-color', pagenavihover);
        }, function(){
            var pagenavibg = wp.customize.value('wrockmetro_pagenav_bg')();
            jQuery(this).css('background-color', pagenavibg);
			});
		} );
	} );
    wp.customize( 'wrockmetro_scrolltop_radius ', function( value ) {
		value.bind( function( borderRadius ) {
			jQuery('a.scrollup.backtoup').css('border-radius', borderRadius + 'px');
		} );
	} );
    

} )( jQuery );