<?php 
global $wp_query;

// Background image

$postid = kk_postid();

$bg_type_selector = get_post_meta($postid, '_custom_bg_type_value', true); 
$bg_image = get_post_meta($postid, '_bg_image_value', true); 

if (function_exists('rwmb_meta')) {
	$bg_title = rwmb_meta( 'kk_title_bg', 'type=image_advanced', $postid );
} else {
	$bg_title = false;
}

if( $bg_title !== false ) {
	$title_image = array_shift($bg_title);
}

if( empty($bg_image ) ) { 
	$bg_image = get_option( 'toppic_theme_default_background_image');
	$bg_repeat = get_option( 'toppic_theme_default_background_repeat');
	$bg_pos = get_option( 'toppic_theme_default_background_position');
	$bg_size = get_option( 'toppic_theme_default_background_size');
} else {	
	$bg_repeat = get_post_meta($postid, '_custom_bg_repeat_value', true); 
	$bg_pos = get_post_meta($postid, '_custom_bg_position_value', true); 
	$bg_size = get_post_meta($postid, '_custom_bg_size_value', true);
}

?>
<style type='text/css' id='kk-custom-style'>
<?php 
	if( $bg_image ) { ?>
	body {
		background-attachment: fixed;
		background-clip: border-box;
		background-image: url("<?php echo esc_url($bg_image) ?>");
		background-origin: padding-box;
		background-position: <?php echo esc_html($bg_pos) ?>;
		background-repeat: <?php echo esc_html($bg_repeat) ?>;
		<?php if($bg_size == 'full' || $bg_size == 'Full') { ?>
		background-size: cover;
		<?php } ?>
	}
<?php }

	if (isset($title_image)) { ?>

	.kk-parallax-wrapper .kk-parallax-bg {
		background-image: url('<?php echo esc_url ( $title_image['full_url'] ) ?>');
	}
	
	<?php } ?>	
		
	.main-nav .sub-menu li a:hover,	
	.kk_menu_default .main-nav .current-menu-parent .current-menu-item  > a, 
	.kk_menu_default .main-nav .menu-item-has-children .current-menu-parent > a, 
	.kk_menu_default_hidden .main-nav .current-menu-parent .current-menu-item  > a, 
	.kk_menu_default_hidden .main-nav .menu-item-has-children .current-menu-parent > a, 
	.kk_menu_left_boxed .main-nav .current-menu-parent .current-menu-item  > a, 
	.kk_menu_left_boxed .main-nav .menu-item-has-children .current-menu-parent > a, 
	ul#thumb-list li:hover, 
	ul#thumb-list li.current-thumb, 
	.pagination .current, 
	input[type="reset"]:hover, 
	.blog-entry .moretag:hover, 
	.bg-slider-ctrl span:hover, 
	.woocommerce .container table.shop_table th, 
	.woocommerce-page .container table.shop_table th { 
		background-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
		color: <?php echo get_option( 'toppic_theme_color_scheme_links' )?>;
	}
	
	.woocommerce #content input.button:hover, 
	.woocommerce #respond input#submit:hover, 
	.woocommerce a.button:hover, 
	.woocommerce button .button:hover, 
	.woocommerce input.button:hover, 
	.woocommerce-page #content input.button:hover, 
	.woocommerce-page #respond input#submit:hover, 
	.woocommerce-page a.button:hover, 
	.woocommerce-page button.button:hover, 
	.woocommerce-page input.button:hover, 
	.woocommerce ul.products li.product a.added_to_cart:hover, 
	.woocommerce-page ul.products li.product a.added_to_cart:hover, 
	.woocommerce #respond input#submit.alt:hover, 
	.woocommerce a.button.alt:hover, 
	.woocommerce button.button.alt:hover, 
	.woocommerce input.button.alt:hover,	
	.pagination .current,
	.pagination a:hover,
	.blog-entry .more-link:hover,
	.single .post-tags a:hover,
	.moretag:hover,
	.main-nav ul li a:hover,
	.main-nav .current-menu-parent > a,
	blockquote,
	.linkto:hover .gallery-title, 
	.linkto:hover .portfolio-title,
	input.submit:hover, 
	input[type="submit"]:hover,
	.kk_vc .wpb_accordion .wpb_accordion_wrapper .wpb_accordion_header.ui-state-active a,
	.kk_vc .vc_tta.vc_general .vc_tta-panel.vc_active a,
	.more-link:hover	{
		border-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
	}
	
	.blog-title a:hover,
	.blog-meta a:hover, 
	.format-standard 
	.blog-thumb a:hover, 
	.format-image 
	.blog-thumb a:hover, 
	.flickr_badge_image a:hover, 
	.portfolio-thumb a:hover,
	.widget-img a:hover, 
	.sub-footer a:hover, a:hover, 
	.current-menu-item,
	.blog-entry a, 
	.post-entry a, 
	.home-teaser a,
	.social li a:hover,
	.kk-content-fullwidth .kk-parallax-wrapper .blog-meta a:hover {
		color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
	}
	
	.single .post-tags a:hover,
	.tipsy-inner,
	.kk-loader,
	#filter-trigger,
	#filter ul	{
		background-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
	}
	
	.kk-preloader:before,
	.kk-content-fullwidth.kk-parallax-title.kk-parallax-title-fullheight .kk-parallax-wrapper .is-loading.kk-down:after	{
		border-top-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
		border-left-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
	}
	
	.over-more, 
	.over-more-title {
		background: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
		color: <?php echo get_option( 'toppic_theme_color_scheme_links' )?>;
	}
		
	::selection {
		background-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
		color: <?php echo get_option( 'toppic_theme_color_scheme_links' )?>;
	}
	::-moz-selection {
		background-color: <?php echo get_option( 'toppic_theme_color_scheme' )?>;
		color: <?php echo get_option( 'toppic_theme_color_scheme_links' )?>;
	}
	
	.menu-wrapper,
	.main-nav .sub-menu,
	.kk_menu_classic .menu-wrapper,
	.kk_menu_classic .main-nav .sub-menu,
	.dark-skin.kk_menu_classic .menu-wrapper,
	.dark-skin.kk_menu_classic .main-nav .sub-menu,
	.kk_menu_default_hidden .menu-helper,
	.kk_menu_left_boxed .menu-wrapper,
	.kk_menu_left_boxed .main-nav .sub-menu,
	.kk_menu_left_boxed.kk-grid-active .menu-wrapper,
	.kk_menu_left_boxed.kk-grid-active .main-nav .sub-menu	{
		background-color: <?php echo kk_menuColor() ?>;
	}	
	
	.main-nav li a,
	.kk_menu_default_hidden .kk-search i,
	.kk_menu_default_hidden.kk-fs-g .kk-info-trigger, 
	.kk_menu_default_hidden.kk-template-fullscreen .kk-thumbs-trigger,
	.kk_menu_classic .menu-wrapper,
	.dark-skin.kk_menu_classic .menu-wrapper	{
		color: <?php echo get_option( 'toppic_theme_menu_links_color' )?>;
	}
	
	.kk_menu_left_boxed .kk-mobile-trigger span, 
	.kk_menu_left_boxed .kk-mobile-trigger span:before, 
	.kk_menu_left_boxed .kk-mobile-trigger span:after,
	.kk_menu_default .kk-mobile-trigger span, 
	.kk_menu_default .kk-mobile-trigger span:before, 
	.kk_menu_default .kk-mobile-trigger span:after,
	.kk_menu_default_hidden .kk-mobile-trigger span, 
	.kk_menu_default_hidden .kk-mobile-trigger span:before, 
	.kk_menu_default_hidden .kk-mobile-trigger span:after,
	.kk_menu_default_hidden .kk-menu-trigger span, 
	.kk_menu_default_hidden .kk-menu-trigger span:before, 
	.kk_menu_default_hidden .kk-menu-trigger span:after,
	.kk-menu-open .kk-menu-trigger span:before, 
	.kk-menu-open .kk-menu-trigger span:after,
	.kk_menu_fullscreen.kk-menu-open .kk-menu-trigger span:before, 
	.kk_menu_fullscreen.kk-menu-open .kk-menu-trigger span:after	{
		background-color: <?php echo get_option( 'toppic_theme_menu_links_color' )?>;
	}

   /* custom css */
  <?php echo stripslashes(get_option("toppic_theme_custom_css"))?>
  
</style>