<?php

add_action('wp_enqueue_scripts', 'helium_theme_scripts_styles');
add_action('wp_enqueue_scripts', 'helium_google_fonts' );
add_action('wp_head', 'helium_primary_color');




function helium_theme_scripts_styles() {

    
    /* Add Javascript bellow - use helium_add_js() to add: $name - unique, $url - path of javascript */

    // JAVASCRIPT JS
    // helium_add_js('bootstrap', OVA_THEME_URI.'/js//bootstrap.min.js');
    helium_add_js('bootstrap', OVA_THEME_URI.'/css/bootstrap/js/bootstrap.min.js');

    helium_add_js('flexslider', OVA_THEME_URI.'/js/vendors/flexslider/flexslider.js');
    helium_add_js('slick', OVA_THEME_URI.'/js/vendors/slick/slick.min.js');
    helium_add_js('vendors_easing', OVA_THEME_URI.'/js/vendors/jquery.easing.min.js');
    helium_add_js('animateNumber', OVA_THEME_URI.'/js/vendors/jquery.animateNumber.js');
    helium_add_js('appear', OVA_THEME_URI.'/js/vendors/jquery.appear.js');
    helium_add_js('inview', OVA_THEME_URI.'/js/vendors/jquery.inview.js');
    helium_add_js('placeholder', OVA_THEME_URI.'/js/vendors/jquery.placeholder.js');
    helium_add_js('prettyphoto', OVA_THEME_URI.'/js/vendors/jquery.prettyphoto.js');
    helium_add_js('isotope', OVA_THEME_URI.'/js/vendors/isotope/isotope.pkgd.js');
    helium_add_js('stellar', OVA_THEME_URI.'/js/vendors/stellar.js');
    helium_add_js('plugin_countdown', OVA_THEME_URI.'/js/countdown/jquery.plugin.js');
    helium_add_js('countdown', OVA_THEME_URI.'/js/countdown/jquery.countdown.min.js');
    helium_add_js('main', OVA_THEME_URI.'/js/main.js');
    
    helium_add_js("googlemap", "https://maps.googleapis.com/maps/api/js?key=AIzaSyDsZ-Acy5Qz-RGmlRLVqnaPq8_2G9c-riE",array(),false,true);
    /* Add Css bellow - uyse helium_add_css to add: $name - unique, $url - path of css*/
   
    // BOOTSTRAP CSS
    // helium_add_css('bootstrap', OVA_THEME_URI.'/css/bootstrap.min.css');
    helium_add_css('bootstrap', OVA_THEME_URI.'/css/bootstrap/css/bootstrap.min.css');

    // ICONS
    helium_add_css('font-awesome', OVA_THEME_URI.'/css/icons/fontawesome/css/style.css');
    helium_add_css('icon-style', OVA_THEME_URI.'/css/icons/style.css');

    //THEME / PLUGIN CSS
    helium_add_css('default', OVA_THEME_URI.'/css/default.css');

    helium_add_css('slick', OVA_THEME_URI.'/js/vendors/slick/slick.css');
    helium_add_css('prettyphoto', OVA_THEME_URI.'/css/prettyphoto.css');

    if ( is_child_theme() ) {
      wp_enqueue_style( 'parent-stylesheet', trailingslashit( get_template_directory_uri() ) . 'style.css', false );
    }

    helium_add_css('theme', OVA_THEME_URI.'/css/theme.css');
 

    wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array(), 'helium' );

}

function helium_primary_color(){ ?>

         <style type="text/css">

            <?php
                $main_color = get_theme_mod('main_color', '#1dc6bc');
                $body_font = get_theme_mod('body_font', 'Lato');
                $heading_font = get_theme_mod('heading_font', 'Poppins');
            ?>

            /*main color*/
             a:hover {
                 color: <?php echo esc_html($main_color); ?>;
             }
             .btn.btn-primary {
                 background-color: <?php echo esc_attr($main_color); ?>;
                 border: 2px solid <?php echo esc_attr($main_color); ?>;
             }
            .btn.btn-primary.btn-border {
                 border-color: <?php echo esc_attr($main_color); ?>;
                 color: <?php echo esc_attr($main_color); ?>;
            }
             .btn.btn-black:hover {
                 background: <?php echo esc_attr($main_color); ?>;
                 border: 2px solid <?php echo esc_attr($main_color); ?>;
                 color: #fff;
             }
             .intro-form .btn.btn-primary {
                 background-color: <?php echo esc_attr($main_color); ?>;
                 border: 2px solid <?php echo esc_attr($main_color); ?>;
             } 
             .countdown.styled span.countdown-period,
             .service-box span,
             .service-box2 span,
             .service-box2 i,
             .accordion .panel-title > a i,
             .plan-price,
             .timeline .timeline-heading h4,
             .cat li::before, .widget_categories li::before,
             .blog-thumb h1 a:hover,
             .blog-thumb .blog-meta i,
             .features .feature h5,
             .nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus,
             .pagination > li > a, .pagination > li > span
             {
                color: <?php echo esc_attr($main_color); ?>;
             }
             .pagination li.active a{
                background-color: <?php echo esc_attr($main_color); ?>;
                border-color: <?php echo esc_attr($main_color); ?>;
             }

            .video-box span,
            .cta-wrap2,
            .service2
              {
                 background: <?php echo esc_attr($main_color); ?>;
              }
            .timeline > li .timeline-image {
               background-color: <?php echo esc_attr($main_color); ?>;
            }
            .portfolio-filter li a.active{
                 color: <?php echo esc_attr($main_color); ?>;
                 border-bottom: 1px solid <?php echo esc_attr($main_color); ?>;
            }
            .features .feature .icon-container .icon
             {
                 color: <?php echo esc_attr($main_color); ?>;
                 border: 1px solid <?php echo esc_attr($main_color); ?>;
             }
             .side-search button, .widget_search input[type='submit'] {
                background-color: <?php echo esc_attr($main_color); ?>;
                border: 2px solid <?php echo esc_attr($main_color); ?>;
             }
            .tags a:hover, .widget_tag_cloud .tagcloud a:hover {
                 background: <?php echo esc_attr($main_color); ?>!important;
             }
            .faq-anchor a.active {
                 border-color: <?php echo esc_attr($main_color); ?>;
                 color: <?php echo esc_attr($main_color); ?>;
             }
              @media only screen and (min-width: 250px) and (max-width: 767px) {
                .service2 {
                     background: <?php echo esc_attr($main_color); ?>;
                 }
              }
            /*Lato*/
            body,p {
                font-family: '<?php echo esc_attr($body_font); ?>', sans-serif;
            }
            .intro-style5 .intro-form h5 span,
            .counter,
            .plan-price,
            .side-widget h5, .widget h4
             {
                font-family: <?php echo esc_attr($body_font); ?>;
             }
            /*Poppins*/
            h1, h2, h3, h4, h5, h6 {
                 font-family: '<?php echo esc_attr($heading_font); ?>', sans-serif;
            }
            .btn,
            .navbar-brand,
            .navbar-default .navbar-nav > li > a,
            .author cite,
            .blog-comment input[type='submit'],
            .faq-anchor a
            {
                font-family: <?php echo esc_attr($heading_font); ?>;
            }

         </style>
    <?php
}




/* Google Font */
function helium_customize_google_fonts() {
    $fonts_url = '';

    $body_font = get_theme_mod('body_font', 'Lato');
    $heading_font = get_theme_mod('heading_font', 'Poppins');

    $body_font_c = _x( 'on', $body_font.': on or off', 'helium' );
    $heading_font_c = _x( 'on', $heading_font.': on or off', 'helium' );

 
    if ( 'off' !== $body_font_c || 'off' !== $heading_font_c ) {
        $font_families = array();
 
        if ( 'off' !== $body_font_c ) {
            $font_families[] = $body_font.':100,200,300,400,500,600,700,800,900"';
        }
 
        if ( 'off' !== $heading_font_c ) {
            $font_families[] = $heading_font.':100,200,300,400,500,600,700,800,900';
        }
        
 
        $query_args = array(
            'family' => urlencode( implode( '|', $font_families ) ),
            'subset' => urlencode( 'latin,latin-ext' ),
        );
 
        $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
    }
 
    return esc_url_raw( $fonts_url );
}






/************************************************************************************************/
/************************************************************************************************/
/************************************************************************************************/


function helium_google_fonts() {
    wp_enqueue_style( 'helium-fonts', helium_customize_google_fonts(), array(), null );
}


function helium_add_js($name, $url){
    /* enqueue javascript */
    wp_enqueue_script($name,$url,array('jquery'),false,true);
}


function helium_add_css($name, $url){
    /* enqueue css*/
    wp_enqueue_style( $name,$url);
}

function helium_hex2rgb($hex) {
   $hex = str_replace("#", "", $hex);
   if(strlen($hex) == 3) {
      $r = hexdec(substr($hex,0,1).substr($hex,0,1));
      $g = hexdec(substr($hex,1,1).substr($hex,1,1));
      $b = hexdec(substr($hex,2,1).substr($hex,2,1));
   } else {
      $r = hexdec(substr($hex,0,2));
      $g = hexdec(substr($hex,2,2));
      $b = hexdec(substr($hex,4,2));
   }
   $rgb = array($r, $g, $b);
   return $rgb; // returns an array with the rgb values
}











