/*
 * Customizer.js to reload changes on Theme Customizer Preview asynchronously.
 *
 */
(function($) {
    $(document).ready(function() {

	/* Default WordPress Customizer settings */
	wp.customize( 'blogname', function( value ) {
		value.bind( function( to ) {
			$( '#logo .site-title' ).text( to );
		} );
	} );
	wp.customize( 'blogdescription', function( value ) {
		value.bind( function( to ) {
			$( '#logo .site-description' ).text( to );
		} );
	} );
    if (wp.customize( 'pmthemes_theme_options[header_gradient_enable]' )() == 1) {
	/* Header Background Color */
	var header_backgr = wp.customize( 'pmthemes_theme_options[header_backgr]' )();
	var header_grad_ient = wp.customize( 'pmthemes_theme_options[header_grad_ient]' )();
	var header_gr_dir = wp.customize( 'pmthemes_theme_options[header_gr_dir]' )();
	wp.customize( 'pmthemes_theme_options[header_backgr]', function( value ) {
		value.bind( function( to ) {
			header_backgr = to;
			$( '#header-wrap, .natty #header-wrap' ).css( {
				'background': 'linear-gradient( '
					.concat( header_gr_dir ).concat(' , ' )
					.concat( header_backgr ).concat( ' , ' )
					.concat( header_grad_ient ).concat( ' )' )
			} );
		} );
	} );
	/* Header Background Gradient Effect */
	wp.customize( 'pmthemes_theme_options[header_grad_ient]', function( value ) {
		value.bind( function( to ) {
			header_grad_ient = to;
			$( '#header-wrap, .natty #header-wrap' ).css(
				{'background': 'linear-gradient( '
					.concat( header_gr_dir ).concat(' , ' )
					.concat( header_backgr ).concat( ' , ' )
					.concat( header_grad_ient ).concat( ' )' )
				}
			);
		} );
	} );
    } else {
	/* Plain Header Background Color */
	wp.customize( 'pmthemes_theme_options[header_backgr]', function( value ) {
		value.bind( function( newval ) {
			$('#header-wrap, .natty #header-wrap')
				.css('background', newval );
		} );
	} );
    }
    var header_topbo_height = wp.customize( 'pmthemes_theme_options[header_topbo_height]' )();
    var header_topbo = wp.customize( 'pmthemes_theme_options[header_topbo]' )();
	/* Header Top Border Height */
	wp.customize( 'pmthemes_theme_options[header_topbo_height]', function( value ) {
		value.bind( function( to ) {
			header_topbo_height = to;
			$( '#header-wrap, .natty #header-wrap' ).css( {
				'border-top': ' '
					.concat( header_topbo_height ).concat( 'px solid' )
					.concat( header_topbo ).concat( ' ' )
			} );
		} );
	} );
	/* Header Top Border Color */
	wp.customize( 'pmthemes_theme_options[header_topbo]', function( value ) {
		value.bind( function( to ) {
			header_topbo = to;
			$( '#header-wrap, .natty #header-wrap' ).css(
				{'border-top': ' '
					.concat( header_topbo_height ).concat( 'px solid' )
					.concat( header_topbo ).concat( ' ' )
				}
			);
		} );
	} );
    var header_bottom_bor_height = wp.customize( 'pmthemes_theme_options[header_bottom_bor_height]' )();
    var header_bottom_border = wp.customize( 'pmthemes_theme_options[header_bottom_border]' )();
	/* Header Bottom Border Height */
	wp.customize( 'pmthemes_theme_options[header_bottom_bor_height]', function( value ) {
		value.bind( function( to ) {
			header_bottom_bor_height = to;
			$( '#header-wrap, .natty #header-wrap' ).css( {
				'border-bottom': ' '
					.concat( header_bottom_bor_height ).concat( 'px solid' )
					.concat( header_bottom_border ).concat( ' ' )
			} );
		} );
	} );
	/* Header Bottom Border Color */
	wp.customize( 'pmthemes_theme_options[header_bottom_border]', function( value ) {
		value.bind( function( to ) {
			header_bottom_border = to;
			$( '#header-wrap, .natty #header-wrap' ).css(
				{'border-bottom': ' '
					.concat( header_bottom_bor_height ).concat( 'px solid' )
					.concat( header_bottom_border ).concat( ' ' )
				}
			);
		} );
	} );
	var headline_top_bor_height = wp.customize( 'pmthemes_theme_options[headline_top_bor_height]' )();
	var headline_top_border = wp.customize( 'pmthemes_theme_options[headline_top_border]' )();
	/* Header Line Top Border Height */
	wp.customize( 'pmthemes_theme_options[headline_top_bor_height]', function( value ) {
		value.bind( function( to ) {
            headline_top_bor_height = to;
			$( '.header-line' ).css( {
				'border-top': ' '
					.concat( headline_top_bor_height ).concat( 'px solid' )
					.concat( headline_top_border ).concat( ' ' )
			} );
		} );
	} );
	/* Header Line Top Border Color */
	wp.customize( 'pmthemes_theme_options[headline_top_border]', function( value ) {
		value.bind( function( to ) {
            headline_top_border = to;
			$( '.header-line' ).css(
				{'border-top': ' '
					.concat( headline_top_bor_height ).concat( 'px solid' )
					.concat( headline_top_border ).concat( ' ' )
				}
			);
		} );
	} );
	/* Header Line Bottom Border Color */
	wp.customize( 'pmthemes_theme_options[headline_bottom_border]', function( value ) {
		value.bind( function( newval ) {
			$('.header-line')
				.css('border-bottom', '1px solid ' + newval )
		} );
	} );
	/* Font Title Size */
	wp.customize ( "pmthemes_theme_options[title_font_size]", function( value ) {
		value.bind( function( newval ) {
			var $child = $( ".pmthemes_control_title_font_size" );
			if ( newval ) {
				/** @type {string} */
				var newstyle = '<style class="pmthemes_control_title_font_size">@media only screen and (min-width:30em) {#logo .site-title{font-size: ' + newval + "px;}}</style>";
				if ( $child.length ) {
					$child.replaceWith( newstyle );
				} else {
					$( "head" ).append( newstyle );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	/* Title Font Size if Mobile */
	wp.customize ( "pmthemes_theme_options[title_font_size_mobile]", function( value ) {
		value.bind( function( newval ) {
			var $child = $( ".pmthemes_control_title_font_size_mobile" );
			if ( newval ) {
				/** @type {string} */
				var newstyle = '<style class="pmthemes_control_title_font_size_mobile">@media only screen and (max-width:30em) {#logo .site-title{font-size: ' + newval + "px;}}</style>";
				if ( $child.length ) {
					$child.replaceWith( newstyle );
				} else {
					$( "head" ).append( newstyle );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	/* Tagline Size */
	wp.customize( 'pmthemes_theme_options[title_describe_size]', function( value ) {
		value.bind( function( newval ) {
			$('#logo .site-description')
				.css('font-size', newval + 'px');
		} );
	} );
	/* Font Title Spacing */
	wp.customize( 'pmthemes_theme_options[title_font_space]', function( value ) {
		value.bind( function( newval ) {
			$('#logo .site-title')
				.css('letter-spacing', newval + 'px');
		} );
	} );
	/* Logo Title Width */
	wp.customize ( "pmthemes_theme_options[logo_title_width]", function( value ) {
		value.bind( function( newval ) {
			var $child = $( ".pmthemes_control_logo_title_width" );
			if ( newval ) {
				/** @type {string} */
				var newstyle = '<style class="pmthemes_control_logo_title_width">@media only screen and (min-width: 60em){#logo {max-width: ' + newval + '%;}#header-banner, #header #navi-wrap {max-width: calc(100% - ' + newval + "%);}}</style>";

				if ( $child.length ) {
					$child.replaceWith( newstyle );
				} else {
					$( "head" ).append( newstyle );
				}
			} else {
				$child.remove();
			}
		} );
	} );
    /* Top Menu Header Padding */
    wp.customize( 'pmthemes_theme_options[topmenu_bar_padding]', function( value ) {
        value.bind( function( newval ) {
            $('#topnav-menu a, .topinner .social-icons-menu li a')
                .css('padding', newval + 'em');
        } );
    } );
    /* Top Menu Font Size */
    wp.customize( 'pmthemes_theme_options[topmenu_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('#topnav-menu a, .topinner .social-icons-menu li a')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Main Menu Font Size*/
    wp.customize( 'pmthemes_theme_options[mainmenu_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('.nav-menu li a')
                .css('font-size', newval + 'em');
        } );
    } );
	/* Main Menu Header Padding */
	wp.customize( 'pmthemes_theme_options[mainmenu_bar_padding]', function( value ) {
		value.bind( function( newval ) {
			$('.nav-menu li a')
				.css('padding', newval + 'em');
		} );
	} );
    /* Product Title Font Size */
    wp.customize( 'pmthemes_theme_options[product_title_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('.woocommerce div.product .product_title')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Page and Title Font Size */
    wp.customize( 'pmthemes_theme_options[posts_title_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('.page-title:not(#frontpage-magazine-widgets), .post-title:not(#frontpage-magazine-widgets)')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Entry Font Size */
    wp.customize( 'pmthemes_theme_options[entry_font_sizes]', function( value ) {
        value.bind( function( newval ) {
            $('.entry p, .entry li, .entry tr td, code, pre, dd,.comment p,.comment li')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Front Page Small Posts Title Font Size */
    wp.customize( 'pmthemes_theme_options[front_page_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('.widget-category-posts .small-post .post-title')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Front Page Big Posts Title Font Size */
    wp.customize( 'pmthemes_theme_options[front_page_fonts_size]', function( value ) {
        value.bind( function( newval ) {
            $('.widget-category-posts .big-post .post-title')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Single Posts Title Font Size */
    wp.customize( 'pmthemes_theme_options[front_posts_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('#widget-category-posts-single .single-post .post-title')
                .css('font-size', newval + 'em');
        } );
    } );
	/* Top Bar Background Color */
	wp.customize( 'pmthemes_theme_options[top_bar_bg]', function( value ) {
		value.bind( function( newval ) {
			$('#topnavbar')
				.css('background', newval )
		} );
	} );
	/* Top Bar Top Border Color */
	wp.customize( 'pmthemes_theme_options[top_bar_top_border]', function( value ) {
		value.bind( function( newval ) {
			$('#topnavbar')
				.css('border-top', '1px solid ' + newval )
		} );
	} );
	/* Top Bar Bottom Border Color */
	wp.customize( 'pmthemes_theme_options[top_bar_bottom_border]', function( value ) {
		value.bind( function( newval ) {
			$('#topnavbar')
				.css('border-bottom', '1px solid ' + newval )
		} );
	} );
	// Top Bar Font Color
	wp.customize( 'pmthemes_theme_options[top_bar_font_color]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-top_bar_font_color' );
			if ( to ) {
				var style = '<style class="customizer-top_bar_font_color">#topnavbar p, #topnavbar #header-social-icons .social-icons-menu li a:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	
    /* Frontpage Header Font Padding */
	wp.customize( 'pmthemes_theme_options[fpbar_font_pad_top]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-magazine-widgets .widget .widgettitle')
				.css('padding-top', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[fpbar_font_pad_right]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-magazine-widgets .widget .widgettitle')
				.css('padding-right', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[fpbar_font_pad_bottom]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-magazine-widgets .widget .widgettitle')
				.css('padding-bottom', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[fpbar_font_pad_left]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-magazine-widgets .widget .widgettitle')
				.css('padding-left', newval + 'px');
		} );
	} );
    
    /* Frontpage Bar Font Size*/
    wp.customize( 'pmthemes_theme_options[frontbar_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('#frontpage-magazine-widgets .widget .widgettitle')
                .css('font-size', newval + 'em');
        } );
    } );
	/* Sidebar Header Font Padding */
	wp.customize( 'pmthemes_theme_options[sidebar_font_pad_top]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget .widgettitle')
				.css('padding-top', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[sidebar_font_pad_right]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget .widgettitle')
				.css('padding-right', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[sidebar_font_pad_bottom]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget .widgettitle')
				.css('padding-bottom', newval + 'px');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[sidebar_font_pad_left]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget .widgettitle')
				.css('padding-left', newval + 'px');
		} );
	} );
    /* Sidebar Widget Bar Font Size*/
    wp.customize( 'pmthemes_theme_options[wgtbar_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar .widget .widgettitle')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Tabbed Widget Header Padding */
    wp.customize( 'pmthemes_theme_options[side_tabbed_padding]', function( value ) {
        value.bind( function( newval ) {
            $('.widget-tabnav li a')
                .css('padding', newval + 'em');
        } );
    } );
    /* Tabbed Widget Header Size*/
    wp.customize( 'pmthemes_theme_options[tabbed_font_size]', function( value ) {
        value.bind( function( newval ) {
            $('.widget-tabnavi')
                .css('font-size', newval + 'em');
        } );
    } );
    /* Sidebar Width */
    wp.customize( 'pmthemes_theme_options[sidecon_width]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('width', newval + '%');
            $('#sidebar')
        		.css('margin-left', 100 - newval + '%');
            $('#content')
                .css('width', 100 - newval + '%');
            $('.rlayout #sidebar')
                .css('margin-left', 0);
            $('.rlayout #sidebar')
                .css('margin-right', 100 - newval + '%');
        } );
    } );
    /* Sidebar Padding */
    wp.customize( 'pmthemes_theme_options[sidebar_padding_adjust]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('padding', '14px ' + newval + 'px');
        } );
    } );
    /* Sidebar Padding */
    wp.customize( 'pmthemes_theme_options[sidebar_padding_top]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('padding-top', newval + 'em');
        } );
    } );
    wp.customize( 'pmthemes_theme_options[sidebar_padding_right]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('padding-right', newval + 'em');
        } );
    } );
    wp.customize( 'pmthemes_theme_options[sidebar_padding_bottom]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('padding-bottom', newval + 'em');
        } );
    } );
    wp.customize( 'pmthemes_theme_options[sidebar_padding_left]', function( value ) {
        value.bind( function( newval ) {
            $('#sidebar')
                .css('padding-left', newval + 'em');
        } );
    } );
	/* Header Padding */
	wp.customize( 'pmthemes_theme_options[header_padding_top]', function( value ) {
		value.bind( function( newval ) {
			$('#header')
				.css('padding-top', newval + 'em');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[header_padding_right]', function( value ) {
		value.bind( function( newval ) {
			$('#header')
				.css('padding-right', newval + 'em');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[header_padding_bottom]', function( value ) {
		value.bind( function( newval ) {
			$('#header')
				.css('padding-bottom', newval + 'em');
		} );
	} );
	wp.customize( 'pmthemes_theme_options[header_padding_left]', function( value ) {
		value.bind( function( newval ) {
			$('#header')
				.css('padding-left', newval + 'em');
		} );
	} );
    /* Wide Header Border Color */
    wp.customize( 'pmthemes_theme_options[body_borders_color]', function( value ) {
        value.bind( function( newval ) {
            $('.wide-header #content-wrap')
                .css('border', '1px solid ' + newval )
        } );
    } );
	/* Theme Colors */
	wp.customize( 'pmthemes_theme_options[topnav_color]', function( value ) {
		value.bind( function( newval ) {
			$('#topnav, #topnav-icon, #topheader')
				.css('background', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[topnav_current]', function( value ) {
		value.bind( function( newval ) {
			$('#topnav-menu .current_page_item, #topnav-menu .current-menu-item')
				.css('background', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[topnav_hover]', function( value ) {
		value.bind( function( newval ) {
			$('#topnav-menu a:hover, #topnav-menu li a:hover')
				.css('background', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[topnav_dropdown]', function( value ) {
		value.bind( function( newval ) {
			$('#topnav-menu .sub-menu, #topnav-menu .children')
				.css('background-color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[topnav_drophov]', function( value ) {
		value.bind( function( newval ) {
			$('ul#topnav-menu ul a:hover, #topnav-menu ul ul a:hover, ul#topnav-menu ul a:focus, #topnav-menu ul ul a:focus')
				.css('background-color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[topnav_dropbor]', function( value ) {
		value.bind( function( newval ) {
			$('ul#topnav-menu ul a, #topnav-menu ul ul a')
				.css('border-top', '1px solid ' + newval )
			$('#topnav-menu .sub-menu, #topnav-menu .children')
				.css('border-color', newval );
		} );
	} );
	// Top Navigation Color
	wp.customize( 'pmthemes_theme_options[topnav_text_color]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-topnav_text_color' );
			if ( to ) {
				var style = '<style class="customizer-topnav_text_color">#topnav-menu a:link, #topnav-menu a:visited, #header-social-icons .social-icons-menu li a:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Main Navigation Color
	wp.customize( 'pmthemes_theme_options[navi_text_color]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-navi_text_color' );
			if ( to ) {
				var style = '<style class="customizer-navi_text_color">.nav-menu li a, .nav-menu .current_page_ancestor > a, .nav-menu .current-menu-ancestor > a, .search-form:before, .nav-menu li.menu-item-has-children > a:after, .nav-menu .submenu li.menu-item-has-children > a:after, #header #navi-wrap .nav-menu li a, #header .search-form:before, #header #navi-wrap .nav-menu li.menu-item-has-children > a:after, #header #navi-wrap .nav-menu .submenu li.menu-item-has-children > a:after{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Main Menu Background Color
	wp.customize( 'pmthemes_theme_options[navi_color]', function( value ) {
		value.bind( function( newval ) {
			$('#navi-wrap, .natty #navi-wrap, .stickynav')
				.css('background', newval );
		} );
	} );
	// Main Menu TOP Border Color and Height
	var navi_top_bd_hei = wp.customize( 'pmthemes_theme_options[navi_top_bd_hei]' )();
	var navi_top_bd_clr = wp.customize( 'pmthemes_theme_options[navi_top_bd_clr]' )();
	wp.customize( 'pmthemes_theme_options[navi_top_bd_hei]', function( value ) {
		value.bind( function( to ) {
			navi_top_bd_hei = to;
			$( '#navi-wrap, .natty #navi-wrap, .stickynav' ).css( {
				'border-top': ' '
					.concat( navi_top_bd_hei ).concat( 'px solid' )
					.concat( navi_top_bd_clr ).concat( ' ' )
			} );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_top_bd_clr]', function( value ) {
		value.bind( function( to ) {
			navi_top_bd_clr = to;
			$( '#navi-wrap, .natty #navi-wrap, .stickynav' ).css(
				{'border-top': ' '
						.concat( navi_top_bd_hei ).concat( 'px solid' )
						.concat( navi_top_bd_clr ).concat( ' ' )
				}
			);
		} );
	} );
	// Main Menu Bottom Border Color and Height
	var navi_bot_bd_hei = wp.customize( 'pmthemes_theme_options[navi_bot_bd_hei]' )();
	var navi_bot_bd_clr = wp.customize( 'pmthemes_theme_options[navi_bot_bd_clr]' )();
	wp.customize( 'pmthemes_theme_options[navi_bot_bd_hei]', function( value ) {
		value.bind( function( to ) {
			navi_bot_bd_hei = to;
			$( '#navi-wrap, .natty #navi-wrap, .stickynav' ).css( {
				'border-bottom': ' '
					.concat( navi_bot_bd_hei ).concat( 'px solid' )
					.concat( navi_bot_bd_clr ).concat( ' ' )
			} );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_bot_bd_clr]', function( value ) {
		value.bind( function( to ) {
			navi_bot_bd_clr = to;
			$( '#navi-wrap, .natty #navi-wrap, .stickynav' ).css(
				{'border-bottom': ' '
						.concat( navi_bot_bd_hei ).concat( 'px solid' )
						.concat( navi_bot_bd_clr ).concat( ' ' )
				}
			);
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_border]', function( value ) {
		value.bind( function( newval ) {
			$('.nav-menu li')
				.css('border-left', '1px solid ' +  newval );
			$('.nav-menu li')
				.css('border-right', 'none');
			$('.nav-menu li:first-child')
				.css('border-left', 'none');
			$('.nav-menu li:last-child, .wide-header .nav-menu li:last-child')
				.css('border-right', '1px solid ' +  newval );
			$('.wide-header .nav-menu li:first-child')
				.css('border-left', '1px solid ' +  newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_hover]', function( value ) {
		value.bind( function( newval ) {
			$('.nav-menu li:hover > a, .nav-menu li a:hover, .nav-menu li:focus > a, .nav-menu li a:focus')
				.css('background', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_dropdown]', function( value ) {
		value.bind( function( newval ) {
			$('.nav-menu .sub-menu, .nav-menu .children')
				.css('background', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_drophov]', function( value ) {
		value.bind( function( newval ) {
			$('ul.nav-menu ul a:hover, .nav-menu ul ul a:hover, ul.nav-menu ul a:focus, .nav-menu ul ul a:focus')
				.css('background-color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_dropdown_border]', function( value ) {
		value.bind( function( newval ) {
			$('.nav-menu .sub-menu, .nav-menu .children')
				.css('border', '2px solid ' +  newval );
			$('.nav-menu .sub-menu ul, .nav-menu .children ul')
				.css('border-left', '1px solid ' +  newval );
			$('ul.nav-menu ul a, .nav-menu ul ul a')
				.css('border-top', '1px solid ' +  newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[default_text_color]', function( value ) {
		value.bind( function( newval ) {
			$('body, input, textarea')
				.css('color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[site_title_color]', function( value ) {
		value.bind( function( newval ) {
			$('#logo .site-title, #logo a:hover .site-title')
				.css('color', newval );
		} );
	} );
    wp.customize( 'pmthemes_theme_options[site_title_shadow]', function( value ) {
        value.bind( function( newval ) {
            $('#logo .site-title')
                .css('text-shadow', '1px 1px 0 ' + newval );
        } );
    } );
	wp.customize( 'pmthemes_theme_options[site_tagline_color]', function( value ) {
		value.bind( function( newval ) {
			$('#logo .site-description')
				.css('color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[title_color]', function( value ) {
		value.bind( function( newval ) {
			$('.page-title, .post-title, .post-title a:link, .post-title a:visited, .archive-title span')
				.css('color', newval );
			$('.post-title a:hover, .post-title a:active')
				.css('color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[link_color]', function( value ) {
		value.bind( function( newval ) {
			$('.entry a, .entry a:link, .entry a:visited, .postinfo a, .comment a:link, .comment a:visited, .post-pagination a:link, .post-pagination a:visited, #image-nav .nav-previous a, #image-nav .nav-next a')
				.css('color', newval );
			$('.post-pagination .current')
				.css('background', newval );
		} );
	} );
	// Scroll to Top Background Color
	wp.customize( 'pmthemes_theme_options[sctop_bg_color]', function( value ) {
		value.bind( function( newval ) {
			$('.scrollToTop')
				.css('background', newval );
			$('.scrollToTop')
				.css('opacity', '0.85' );
		} );
	} );
	// Scroll to Top Arrow Color
	wp.customize( 'pmthemes_theme_options[sctop_arrow_color]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-sctop_arrow_color' );
			if ( to ) {
				var style = '<style class="customizer-sctop_arrow_color">.scrollToTop:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Scroll to Top Border Color
	wp.customize( 'pmthemes_theme_options[sctop_brdr_color]', function( value ) {
		value.bind( function( newval ) {
			$('.scrollToTop')
				.css('border', '3px solid ' + newval );
			$('.scrollToTop')
				.css('opacity', '0.9' );
		} );
	} );
	// Comment Button Background Color
	wp.customize( 'pmthemes_theme_options[cmbtn_bg_color]', function( value ) {
		value.bind( function( newval ) {
			$('#commentform #submit')
				.css('background', newval );
		} );
	} );
	// Comment Button Text Color
	wp.customize( 'pmthemes_theme_options[cmbtn_text_color]', function( value ) {
		value.bind( function( newval ) {
			$('#commentform #submit')
				.css('color', newval );
		} );
	} );
	// Frontpage
	// Slider Caption Title Color
	wp.customize( 'pmthemes_theme_options[sldr_title_clr]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-sldr_title_clr' );
			if ( to ) {
				var style = '<style class="customizer-sldr_title_clr">#frontpage-slider .pmsslide .slide-entry .slide-title a:link, #frontpage-slider .pmsslide .slide-entry .slide-title a:visited{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Slider Caption Text Color
	wp.customize( 'pmthemes_theme_options[sldr_text_clr]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-sldr_text_clr' );
			if ( to ) {
				var style = '<style class="customizer-sldr_text_clr">#frontpage-slider .pmsslide .slide-entry, #frontpage-slider .pmsslide .slide-entry .slide-more-link, #frontpage-slider .pmsslide .slide-entry .slide-more-link:link{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Slider Caption Background Color
	wp.customize( 'pmthemes_theme_options[sldr_bg_clr]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-slider .pmsslide .slide-entry')
				.css('background', newval );
			$('#frontpage-slider .pmsslide .slide-entry')
				.css('opacity', '0.75' );
		} );
	} );
	// Slider Arrow Colors
	wp.customize( 'pmthemes_theme_options[sldr_arrow_clr]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-sldr_arrow_clr' );
			if ( to ) {
				var style = '<style class="customizer-sldr_arrow_clr">.frontpage-slider-controls .pmsflex-direction-nav a:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Slider Arrow Background Color
	wp.customize( 'pmthemes_theme_options[sldr_arrow_bg_clr]', function( value ) {
		value.bind( function( newval ) {
			$('.frontpage-slider-controls .pmsflex-direction-nav a')
				.css('background', newval );
			$('.frontpage-slider-controls .pmsflex-direction-nav a')
				.css('opacity', '0.75' );
		} );
	} );
	// Slider Border Color
	wp.customize( 'pmthemes_theme_options[sldr_border_clr]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-slider')
				.css('border', '1px solid ' +  newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[frontbar_font_clr]', function( value ) {
		value.bind( function( newval ) {
			$('#frontpage-magazine-widgets .widget .widgettitle')
				.css('color', newval );
		} );
	} );
	if (wp.customize( 'pmthemes_theme_options[frontpage_header_style]' )() == 1) {
		wp.customize( 'pmthemes_theme_options[frontbar_bg_color]', function( value ) {
			value.bind( function( newval ) {
				$('#frontpage-magazine-widgets .widget .widgettitle')
					.css('background', newval )
					.css('display', 'inline-block' )
					.css('margin', '0')
			} );
		} );
		wp.customize( 'pmthemes_theme_options[front_header_bg_color]', function( value ) {
			value.bind( function( newval ) {
				$('#frontpage-magazine-widgets .widget .widget-header')
					.css('background', newval )
					.css('margin', '-0.5em -0.5em 1em')
			} );
		} );
		wp.customize( 'pmthemes_theme_options[front_header_top_border]', function( value ) {
			value.bind( function( newval ) {
				$('#frontpage-magazine-widgets .widget .widget-header')
					.css('border-top', '1px solid ' +  newval );
			} );
		} );
		wp.customize( 'pmthemes_theme_options[front_header_bot_border]', function( value ) {
			value.bind( function( newval ) {
				$('#frontpage-magazine-widgets .widget .widget-header')
					.css('border-bottom', '2px solid ' +  newval );
			} );
		} );
	} else {
		wp.customize( 'pmthemes_theme_options[frontbar_bg_color]', function( value ) {
			value.bind( function( newval ) {
				$('#frontpage-magazine-widgets .widget .widgettitle')
					.css('background', newval )
			} );
		} );
	}
	// Sidebar
	wp.customize( 'pmthemes_theme_options[widget_title_color]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widgettitle')
				.css('color', newval );
		} );
	} );
	if (wp.customize( 'pmthemes_theme_options[widget_header_styling]' )() == 1) {
		wp.customize( 'pmthemes_theme_options[widget_header_color]', function( value ) {
			value.bind( function( newval ) {
				$('#sidebar .widgettitle')
					.css('background', newval )
					.css('display', 'inline-block' )
					.css('margin', '0')
			} );
		} );
		wp.customize( 'pmthemes_theme_options[widget_header_bg_color]', function( value ) {
			value.bind( function( newval ) {
				$('#sidebar .widget-header')
					.css('background', newval )
					.css('margin', '-0.5em -0.5em 1em')
			} );
		} );
		wp.customize( 'pmthemes_theme_options[widget_header_top_border]', function( value ) {
			value.bind( function( newval ) {
				$('#sidebar .widget-header')
					.css('border-top', '1px solid ' +  newval );
			} );
		} );
		wp.customize( 'pmthemes_theme_options[widget_header_bot_border]', function( value ) {
			value.bind( function( newval ) {
				$('#sidebar .widget-header')
					.css('border-bottom', '2px solid ' +  newval );
			} );
		} );
	} else {
		wp.customize( 'pmthemes_theme_options[widget_header_color]', function( value ) {
			value.bind( function( newval ) {
				$('#sidebar .widgettitle')
					.css('background', newval )
			} );
		} );
	}
	// Sidebar Widget Link Color
	wp.customize( 'pmthemes_theme_options[widget_link_color]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-widget_link_color' );
			if ( to ) {
				var style = '<style class="customizer-widget_link_color">#sidebar .widget .rp-title a:link, #sidebar .widget .rp-title a:visited, .product_list_widget .product-title{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Widget Text Color
	wp.customize( 'pmthemes_theme_options[widget_text_color]', function( value ) {
		value.bind( function( newval ) {
			$('.widget ul, #sidebar .widget .textwidget')
				.css('color', newval );
		} );
	} );
	// Widget Post Meta Color
	wp.customize( 'pmthemes_theme_options[widget_post_meta_clr]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-widget_post_meta_clr' );
			if ( to ) {
				var style = '<style class="customizer-widget_post_meta_clr">.widget-posts-entries .widget-postmeta, .widget-posts-entries .widget-postmeta a:link, .widget-posts-entries .widget-postmeta span:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Widget Background Color
	wp.customize( 'pmthemes_theme_options[widget_backgr_color]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget:not(.pmthemes_tabbed_content)')
				.css('background', newval );
		} );
	} );
	/* Sidebar Background Color w/ Gradient */
	if (wp.customize( 'pmthemes_theme_options[sidebar_gradient_enable]' )() == 1) {
		var sidebar_backgr = wp.customize( 'pmthemes_theme_options[sidebar_background]' )();
		var sidebar_grad_ient = wp.customize( 'pmthemes_theme_options[sidebar_grad_ient]' )();
		var sidebar_gr_dir = wp.customize( 'pmthemes_theme_options[sidebar_gr_dir]' )();
		wp.customize( 'pmthemes_theme_options[sidebar_background]', function( value ) {
			value.bind( function( to ) {
                sidebar_backgr = to;
				$( '#sidebar, .rlayout #sidebar' ).css( {
					'background': 'linear-gradient( '
						.concat( sidebar_gr_dir ).concat(' , ' )
						.concat( sidebar_backgr ).concat( ' , ' )
						.concat( sidebar_grad_ient ).concat( ' )' )
				} );
			} );
		} );
		/* Sidebar Background Gradient */
		wp.customize( 'pmthemes_theme_options[sidebar_grad_ient]', function( value ) {
			value.bind( function( to ) {
                sidebar_grad_ient = to;
				$( '#sidebar, .rlayout #sidebar' ).css(
					{'background': 'linear-gradient( '
						.concat( sidebar_gr_dir ).concat(' , ' )
						.concat( sidebar_backgr ).concat( ' , ' )
						.concat( sidebar_grad_ient ).concat( ' )' )
					}
				);
			} );
		} );
	} else {
		/* Plain Sidebar Background Color */
        wp.customize( 'pmthemes_theme_options[sidebar_background]', function( value ) {
            value.bind( function( newval ) {
                $('#sidebar, .rlayout #sidebar')
                    .css('background', newval );
            } );
        } );
    }
	// Sidebar Borders
	var sidebar_brth = wp.customize( 'pmthemes_theme_options[sidebar_border_thick]' )();
	var sidebar_brcl = wp.customize( 'pmthemes_theme_options[sidebar_border_color]' )();
	/* Sidebar Border Thickness */
	wp.customize( 'pmthemes_theme_options[sidebar_border_thick]', function( value ) {
		value.bind( function( to ) {
            sidebar_brth = to;
			$( '#sidebar .widget' ).css( {
				'border': ' '
					.concat( sidebar_brth ).concat( 'px solid' )
					.concat( sidebar_brcl ).concat( ' ' )
			} );
		} );
	} );
	/* Sidebar Border Color */
	wp.customize( 'pmthemes_theme_options[sidebar_border_color]', function( value ) {
		value.bind( function( to ) {
            sidebar_brcl = to;
			$( '#sidebar .widget' ).css(
				{'border': ' '
					.concat( sidebar_brth ).concat( 'px solid' )
					.concat( sidebar_brcl ).concat( ' ' )
				}
			);
		} );
	} );
	// Tabbed Background Color
	wp.customize( 'pmthemes_theme_options[tabbed_bg_color]', function( value ) {
		value.bind( function( newval ) {
			$('.pmthemes_tabbed_content')
				.css('background', newval );
		} );
	} );
	// Tabbed Header Color
	wp.customize( 'pmthemes_theme_options[tabbed_header_color]', function( value ) {
		value.bind( function( newval ) {
			$('.widget-tabnavi, .widget-tabnav')
				.css('background', newval );
		} );
	} );
	// Tabbed Header Title Color
	wp.customize( 'pmthemes_theme_options[tabbed_hdtl_color]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget.pmthemes_tabbed_content .widget-tabnav a:link')
				.css('color', newval );
		} );
	} );
	// Tabbed Link Color
	wp.customize( 'pmthemes_theme_options[tabbed_linked_color]', function( value ) {
		value.bind( function( newval ) {
			$('#sidebar .widget.pmthemes_tabbed_content .tabdiv a:link')
				.css('color', newval );
		} );
	} );
	// Tabbed Post Meta Color
	wp.customize( 'pmthemes_theme_options[tabbed_post_meta_clr]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-tabbed_post_meta_clr' );
			if ( to ) {
				var style = '<style class="customizer-tabbed_post_meta_clr">.widget-tabbed .tabdiv ul li .widget-postmeta, .widget-tabbed .tabdiv ul li .widget-postmeta:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	// Footer Widgets
	wp.customize( 'pmthemes_theme_options[footer_widgets_texts]', function( value ) {
		value.bind( function( newval ) {
			$('#footer-widgets .widget a:link, #footer-widgets .widget a:visited, #footer-widgets .product-title')
				.css('color', newval );
		} );
	} );
	// Footer Widgets Plain Text
	wp.customize( 'pmthemes_theme_options[footer_widgets_pltxt]', function( value ) {
		value.bind( function( newval ) {
			$('#footer-widgets .widget div, #footer-widgets .widget ul')
				.css('color', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[footer_texts_borders]', function( value ) {
		value.bind( function( newval ) {
			$('#footer-widgets .widget ul li')
			.css('border-bottom', '1px solid ' +  newval );
		} );
	} );
	/* Footer Widgets Background Color */
	if (wp.customize( 'pmthemes_theme_options[fwidget_gradient_enable]' )() == 1) {
		var fwidget_backgr = wp.customize( 'pmthemes_theme_options[footer_widgets_color]' )();
		var fwidget_grad_ient = wp.customize( 'pmthemes_theme_options[fwidget_grad_ient]' )();
		var fwidget_grad_dir = wp.customize( 'pmthemes_theme_options[fwidget_gr_dir]' )();
		wp.customize( 'pmthemes_theme_options[footer_widgets_color]', function( value ) {
			value.bind( function( to ) {
                fwidget_backgr = to;
				$( '#footer-widgets-bg' ).css( {
					'background': 'linear-gradient( '
						.concat( fwidget_grad_dir ).concat(' , ' )
						.concat( fwidget_backgr ).concat(' , ' )
						.concat( fwidget_grad_ient ).concat( ' )' )
				} );
			} );
		} );
		/* Header Background Gradient Effect */
		wp.customize( 'pmthemes_theme_options[fwidget_grad_ient]', function( value ) {
			value.bind( function( to ) {
                fwidget_grad_ient = to;
				$( '#footer-widgets-bg' ).css(
					{'background': 'linear-gradient( '
						.concat( fwidget_grad_dir ).concat(' , ' )
						.concat( fwidget_backgr ).concat( ' , ' )
						.concat( fwidget_grad_ient ).concat( ' )' )
					}
				);
			} );
		} );
	} else {
		/* Plain Footer Widget Background Color */
        wp.customize( 'pmthemes_theme_options[footer_widgets_color]', function( value ) {
            value.bind( function( newval ) {
                $('#footer-widgets-bg')
                    .css('background', newval );
            } );
        } );
	}
    wp.customize( 'pmthemes_theme_options[footer_each_widget]', function( value ) {
        value.bind( function( newval ) {
            $('#footer-widgets .widget')
                .css('background', newval );
        } );
    } );
    wp.customize( 'pmthemes_theme_options[footer_widgets_header_title]', function( value ) {
        value.bind( function( newval ) {
            $('#footer-widgets .widgettitle')
                .css('color', newval );
        } );
    } );
    wp.customize( 'pmthemes_theme_options[footer_widgets_header_bg]', function( value ) {
        value.bind( function( newval ) {
            $('#footer-widgets .widgettitle')
                .css('background', newval );
        } );
    } );
	wp.customize( 'pmthemes_theme_options[footer_texts_colol]', function( value ) {
		value.bind( function( to ) {
			var $child = $( '.customizer-footer_texts_colol' );
			if ( to ) {
				var style = '<style class="customizer-footer_texts_colol">#footer-text, #footer-text a:link, #footer-text a:visited, #footernav-menu a:link, #footernav-menu a:visited, #footernav-menu li:before{ color: ' + to + '; }</style>';
				if ( $child.length ) {
					$child.replaceWith( style );
				} else {
					$( 'head' ).append( style );
				}
			} else {
				$child.remove();
			}
		} );
	} );
	wp.customize( 'pmthemes_theme_options[footer_color]', function( value ) {
		value.bind( function( newval ) {
			$('#footer')
				.css('background', newval );
		} );
	} );



	wp.customize( 'pmthemes_theme_options[footer_top_brdr]', function( value ) {
		value.bind( function( newval ) {
			$('#footer')
			.css('border-top', '1px solid ' +  newval );
		} );
	} );
    wp.customize( 'pmthemes_theme_options[footer_bottom_brdr]', function( value ) {
        value.bind( function( newval ) {
            $('#footer')
                .css('border-bottom', '1px solid ' +  newval );
        } );
    } );
    // Footer Top Border Color & Height
	var footer_top_brdr_hei = wp.customize( 'pmthemes_theme_options[footer_top_brdr_hei]' )();
	var footer_top_brdr = wp.customize( 'pmthemes_theme_options[footer_top_brdr]' )();
	wp.customize( 'pmthemes_theme_options[footer_top_brdr_hei]', function( value ) {
		value.bind( function( to ) {
			footer_top_brdr_hei = to;
			$( '#footer' ).css( {
				'border-top': ' '
					.concat( footer_top_brdr_hei ).concat( 'px solid' )
					.concat( footer_top_brdr ).concat( ' ' )
			} );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[footer_top_brdr]', function( value ) {
		value.bind( function( to ) {
			footer_top_brdr = to;
			$( '#footer' ).css(
				{'border-top': ' '
					.concat( footer_top_brdr_hei ).concat( 'px solid' )
					.concat( footer_top_brdr ).concat( ' ' )
				}
			);
		} );
	} );
	// Footer Bottom Border Color & Height
	var footer_bot_brdr_hei = wp.customize( 'pmthemes_theme_options[footer_bot_brdr_hei]' )();
	var footer_bottom_brdr = wp.customize( 'pmthemes_theme_options[footer_bottom_brdr]' )();
	wp.customize( 'pmthemes_theme_options[footer_bot_brdr_hei]', function( value ) {
		value.bind( function( to ) {
			footer_bot_brdr_hei = to;
			$( '#footer' ).css( {
				'border-bottom': ' '
					.concat( footer_bot_brdr_hei ).concat( 'px solid' )
					.concat( footer_bottom_brdr ).concat( ' ' )
			} );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[footer_bottom_brdr]', function( value ) {
		value.bind( function( to ) {
			footer_bottom_brdr = to;
			$( '#footer' ).css(
				{'border-bottom': ' '
						.concat( footer_bot_brdr_hei ).concat( 'px solid' )
						.concat( footer_bottom_brdr ).concat( ' ' )
				}
			);
		} );
	} );
	// Layout Style
	wp.customize( 'pmthemes_theme_options[theme_style]', function( value ) {
		value.bind( function( newval ) {
			if ( 'boxed-one' == newval ) {
				$( 'body' ).removeClass( 'wide-header' ).removeClass( 'wide-header' );
			}
			if ( 'wide-head' == newval ) {
				$( 'body' ).addClass( 'wide-header' ).addClass( 'wide-header' );
			}
		} );
	} );
	// Sidebar Location
	wp.customize( 'pmthemes_theme_options[layout]', function( value ) {
		value.bind( function( newval ) {
			if ( 'right-sidebar' == newval ) {
				$( 'body' ).removeClass( 'rlayout' ).removeClass( 'rlayout' );
			}
			if ( 'left-sidebar' == newval ) {
				$( 'body' ).addClass( 'rlayout' ).addClass( 'rlayout' );
			}
		} );
	} );
	/* Theme Styles */
	wp.customize( 'pmthemes_theme_options[theme_styles]', function( value ) {
		value.bind( function( newval ) {
			// Embed Style
			var style_dir_uri = pmth_js_uri.themeUrl;
			var preDefinedStyle = newval.split(" ").join("+");
			var styleDir = ""+style_dir_uri+"/css/styles/"+preDefinedStyle+".css";
			var theNewStyle = "<link id='pmthemes-custom-css' href='"+styleDir+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-css").length;
			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-css").remove();
			}
			$("head").append(theNewStyle);
		} );
	} );
	// Theme Width
	var themewd = ['wd1', 'wd2', 'wd3','wd4', 'wd5', 'wd6','wd7', 'wd8', 'wd9','wd10'];
	wp.customize( 'pmthemes_theme_options[theme_width]', function( value ) {
		value.bind( function( newval ) {
			var theme_width = $( 'body' );
			if ( theme_width.length ) {
				$.each( themewd, function( i, v ) {
					theme_width.removeClass( v );
				});
				theme_width.addClass( newval );
			}
		});
	});
	// Grid Item Width
	var gridwd = ['one-column', 'one-hundred', 'one-fifty','two-hundred', 'two-fifty', 'three-hundred','three-fifty', 'four-hundred', 'four-fifty','five-hundred'];
	wp.customize( 'pmthemes_theme_options[pmth_grid_width]', function( value ) {
		value.bind( function( newval ) {
			var grid_width = $( '.pmth-grid' );
			if ( grid_width.length ) {
				$.each( gridwd, function( i, v ) {
					grid_width.removeClass( v );
				});
				grid_width.addClass( newval );
			}
		});
	});
	// Grid Column Nos.
	var gridcol = ['one-col', 'two-col', 'three-col','four-col', 'five-col', 'six-col','seven-col', 'eight-col', 'nine-col','ten-col','eleven-col','twelve-col'];
	wp.customize( 'pmthemes_theme_options[pmth_grid_column]', function( value ) {
		value.bind( function( newval ) {
			var grid_colmn = $( '.pmth-grid' );
			if ( grid_colmn.length ) {
				$.each( gridcol, function( i, v ) {
					grid_colmn.removeClass( v );
				});
				grid_colmn.addClass( newval );
			}
		});
	});
	// Archive Image Alignment
	var imgalg = ['alignleft', 'alignright', 'aligncenter','alignnone'];
	wp.customize( 'pmthemes_theme_options[pmth_arc_align_img]', function( value ) {
		value.bind( function( newval ) {
			var img_align = $( '.wp-post-image' );
			if ( img_align.length ) {
				$.each( imgalg, function( i, v ) {
					img_align.removeClass( v );
				});
				img_align.addClass( newval );
			}
		});
	});

	// Align Archive Title
	var titlealg = ['pmthleft', 'pmthrigth', 'pmthcenter','pmthjustify', 'pmthnone'];
	wp.customize( 'pmthemes_theme_options[pmth_arc_align_header]', function( value ) {
		value.bind( function( newval ) {
			var talign = $( '.archive-title' );
			if ( talign.length ) {
				$.each( titlealg, function( i, v ) {
					talign.removeClass( v );
				});
				talign.addClass( newval );
			}
		});
	});

	// Read More Label
	wp.customize( 'pmthemes_theme_options[excerpt_text]', function( value ) {
		value.bind( function( to ) {
			$( '.more-link' ).text( to );
		} );
	} );
	// Related Header Title
	wp.customize( 'pmthemes_theme_options[related_header_title]', function( value ) {
		value.bind( function( to ) {
			$( '.reltitle' ).text( to );
		} );
	} );

	// Footer Text
	wp.customize( 'pmthemes_theme_options[footer_text]', function( value ) {
		value.bind( function( to ) {
			$( '#footer-text' ).text( to );
		} );
	} );

	/* Theme Fonts */
	wp.customize( 'pmthemes_theme_options[text_font]', function( value ) {
		value.bind( function( newval ) {
			// Embed Font
			var fontFamilyUrl = newval.split(" ").join("+");
			var googleFontPath = "https://fonts.googleapis.com/css?family="+fontFamilyUrl;
			var googleFontSource = "<link id='pmthemes-custom-text-font' href='"+googleFontPath+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-text-font").length;

			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-text-font").remove();
			}
			$("head").append(googleFontSource);
			// Set CSS
			$('body, input, textarea')
				.css('font-family', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[site_title_font]', function( value ) {
		value.bind( function( newval ) {
			// Embed Font
			var fontFamilyUrl = newval.split(" ").join("+");
			var googleFontPath = "https://fonts.googleapis.com/css?family="+fontFamilyUrl;
			var googleFontSource = "<link id='pmthemes-custom-site-title-font' href='"+googleFontPath+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-site-title-font").length;

			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-site-title-font").remove();
			}
			$("head").append(googleFontSource);
			// Set CSS
			$('#logo .site-title')
				.css('font-family', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[title_font]', function( value ) {
		value.bind( function( newval ) {
			// Embed Font
			var fontFamilyUrl = newval.split(" ").join("+");
			var googleFontPath = "https://fonts.googleapis.com/css?family="+fontFamilyUrl;
			var googleFontSource = "<link id='pmthemes-custom-title-font' href='"+googleFontPath+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-title-font").length;
			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-title-font").remove();
			}
			$("head").append(googleFontSource);
			// Set CSS
			$('.page-title, .post-title, #frontpage-slider .pmsslide .slide-entry .slide-title, #comments .comments-title, #respond #reply-title')
				.css('font-family', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[navi_font]', function( value ) {
		value.bind( function( newval ) {
			// Embed Font
			var fontFamilyUrl = newval.split(" ").join("+");
			var googleFontPath = "https://fonts.googleapis.com/css?family="+fontFamilyUrl;
			var googleFontSource = "<link id='pmthemes-custom-navi-font' href='"+googleFontPath+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-navi-font").length;
			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-navi-font").remove();
			}
			$("head").append(googleFontSource);
			// Set CSS
			$('.nav-menu li a, #topnav-menu a')
				.css('font-family', newval );
		} );
	} );
	wp.customize( 'pmthemes_theme_options[widget_title_font]', function( value ) {
		value.bind( function( newval ) {
			// Embed Font
			var fontFamilyUrl = newval.split(" ").join("+");
			var googleFontPath = "https://fonts.googleapis.com/css?family="+fontFamilyUrl;
			var googleFontSource = "<link id='pmthemes-custom-widget-title-font' href='"+googleFontPath+"' rel='stylesheet' type='text/css'>";
			var checkLink = $("head").find("#pmthemes-custom-widget-title-font").length;
			if (checkLink > 0) {
				$("head").find("#pmthemes-custom-widget-title-font").remove();
			}
			$("head").append(googleFontSource);
			// Set CSS
			$('.widgettitle, #frontpage-magazine-widgets .widget .widgettitle')
				.css('font-family', newval );
		} );
	} );
    });
})(jQuery);