/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the top of the page (after the nav bar). If no widgets added AND
 * preivewing the theme, then display some widgets as samples. Once the theme is actually
 * in use, it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
global $xsbf_theme_options;
/* If page top "sidebar" has widgets, then display them */
$sidebar_pagetop = get_dynamic_sidebar('Page Top');
if ($sidebar_pagetop) {
    ?>
	<div id="sidebar-pagetop" class="sidebar-pagetop">
		<?php 
    echo apply_filters('xsbf_pagetop', $sidebar_pagetop);
    ?>
	</div><!-- .sidebar-pagetop -->

<?php 
    /* Otherwise, show an example if we are on the front page and its set to display the blog */
    /*elseif ( $xsbf_theme_options['sample_widgets'] != false AND is_front_page() AND is_home() ) :
    
    ?>
    	<div id="sidebar-pagetop" class="sidebar-pagetop">
    
<?php

if (is_active_sidebar('body_bottom')) {
    ?>
<div id="body-bottom">
	<div class="container">
    	<div class="container-pad">
            <div class="row-fluid">
                <?php 
    echo get_dynamic_sidebar('body_bottom');
    ?>
            </div>
        </div>
	</div>
</div>
<?php 
}
<?php

/**
 * The sidebar containing the search widget area.
 */
global $sidebar_width;
?>
<div id="sidebar" class="<?php 
echo $sidebar_width ? 'col-md-3' : 'col-md-4';
?>
">
<?php 
if (is_active_sidebar('search_page_sidebar')) {
    ?>
	<?php 
    dynamic_sidebar('search_page_sidebar');
} else {
    echo get_dynamic_sidebar('main_sidebar');
}
?>
</div><!--#sidebar-->
function ppb_contact_sidebar_func($atts, $content)
{
    //extract short code attr
    extract(shortcode_atts(array('title' => '', 'slug' => '', 'subtitle' => '', 'sidebar' => '', 'padding' => '', 'custom_css' => ''), $atts));
    $sec_id = '';
    if (!empty($slug)) {
        $sec_id = 'id="' . esc_attr($slug) . '"';
    }
    $return_html = '';
    $return_html .= '<div class="standard_wrapper">';
    $return_html .= '<div ' . $sec_id . ' class="one withsmallpadding" ';
    $custom_css .= 'padding:' . esc_attr($padding) . 'px 0 ' . esc_attr($padding) . 'px 0;';
    if (!empty($custom_css)) {
        $return_html .= 'style="' . urldecode($custom_css) . '" ';
    }
    $return_html .= '>';
    $return_html .= '<div class="page_content_wrapper"><div class="inner"><div class="inner_wrapper"><div class="sidebar_content full_width nopadding">';
    $return_html .= '<div class="sidebar_content page_content">';
    //Display Title
    if (!empty($title)) {
        $return_html .= '<h2 class="ppb_title">' . urldecode(tg_get_first_title_word($title)) . '</h2>';
    }
    //Display Content
    if (!empty($subtitle)) {
        $return_html .= '<div class="ppb_subtitle">' . urldecode($subtitle) . '</div>';
    }
    if (!empty($title) or !empty($subtitle)) {
        $return_html .= '<div class="page_header_sep left"></div>';
    }
    //Display Content
    if (!empty($content)) {
        $return_html .= '<div class="ppb_content">' . urldecode($content) . '</div>';
    }
    //Display contact form
    //Get contact form random ID
    $custom_id = time() . rand();
    $pp_contact_form = unserialize(get_option('pp_contact_form_sort_data'));
    wp_enqueue_script("jquery.validate", get_template_directory_uri() . "/js/jquery.validate.js", false, THEMEVERSION, true);
    wp_register_script("script-contact-form", get_template_directory_uri() . "/templates/script-contact-form.php?form=" . $custom_id, false, THEMEVERSION, true);
    $params = array('ajaxurl' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('tgajax-post-contact-nonce'));
    wp_localize_script('script-contact-form', 'tgAjax', $params);
    wp_enqueue_script("script-contact-form", get_template_directory_uri() . "/templates/script-contact-form.php?form=" . $custom_id, false, THEMEVERSION, true);
    $return_html .= '<div id="reponse_msg_' . $custom_id . '" class="contact_form_response"><ul></ul></div>';
    $return_html .= '<form id="contact_form_' . $custom_id . '" class="contact_form_wrapper" method="post" action="/wp-admin/admin-ajax.php">';
    $return_html .= '<input type="hidden" id="action" name="action" value="pp_contact_mailer"/>';
    if (is_array($pp_contact_form) && !empty($pp_contact_form)) {
        foreach ($pp_contact_form as $form_input) {
            switch ($form_input) {
                case 1:
                    $return_html .= '<label for="your_name">' . __('Name *', PLUGINDOMAIN) . '</label>
    				<input id="your_name" name="your_name" type="text" class="required_field" placeholder="' . __('Name *', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 2:
                    $return_html .= '<label for="email">' . __('Email *', PLUGINDOMAIN) . '</label>
    				<input id="email" name="email" type="text" class="required_field email" placeholder="' . __('Email *', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 3:
                    $return_html .= '<label for="message">' . __('Message *', PLUGINDOMAIN) . '</label>
    				<textarea id="message" name="message" rows="7" cols="10" class="required_field" style="width:95.5%;" placeholder="' . __('Message *', PLUGINDOMAIN) . '"></textarea>
    				';
                    break;
                case 4:
                    $return_html .= '<label for="address">' . __('Address', PLUGINDOMAIN) . '</label>
    				<input id="address" name="address" type="text" placeholder="' . __('Address', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 5:
                    $return_html .= '<label for="phone">' . __('Phone', PLUGINDOMAIN) . '</label>
    				<input id="phone" name="phone" type="text" placeholder="' . __('Phone', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 6:
                    $return_html .= '<label for="mobile">' . __('Mobile', PLUGINDOMAIN) . '</label>
    				<input id="mobile" name="mobile" type="text" placeholder="' . __('Mobile', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 7:
                    $return_html .= '<label for="company">' . __('Company Name', PLUGINDOMAIN) . '</label>
    				<input id="company" name="company" type="text" placeholder="' . __('Company Name', PLUGINDOMAIN) . '"/>
    				';
                    break;
                case 8:
                    $return_html .= '<label for="country">' . __('Country', PLUGINDOMAIN) . '</label>				
    				<input id="country" name="country" type="text" placeholder="' . __('Country', PLUGINDOMAIN) . '"/>
    				';
                    break;
            }
        }
    }
    $pp_contact_enable_captcha = get_option('pp_contact_enable_captcha');
    if (!empty($pp_contact_enable_captcha)) {
        $return_html .= '<div id="captcha-wrap">
    		<div class="captcha-box">
    			<img src="' . get_template_directory_uri() . '/get_captcha.php" alt="" id="captcha" />
    		</div>
    		<div class="text-box">
    			<label>Type the two words:</label>
    			<input name="captcha-code" type="text" id="captcha-code">
    		</div>
    		<div class="captcha-action">
    			<img src="' . get_template_directory_uri() . '/images/refresh.jpg"  alt="" id="captcha-refresh" />
    		</div>
    	</div>
    	<br class="clear"/><br/>';
    }
    $return_html .= '<br/><br/><div class="contact_submit_wrapper">
    	<input id="contact_submit_btn' . $custom_id . '" name="contact_submit_btn' . $custom_id . '" type="submit" class="solidbg" value="' . __('Send', PLUGINDOMAIN) . '"/>
    </div>';
    $return_html .= '</form>';
    $return_html .= '</div>';
    //Display Sidebar
    $return_html .= '<div class="sidebar_wrapper"><div class="sidebar"><div class="content"><ul class="sidebar_widget">';
    $return_html .= get_dynamic_sidebar(urldecode($sidebar));
    $return_html .= '</ul></div></div></div>';
    $return_html .= '</div></div></div></div>';
    $return_html .= '</div>';
    $return_html .= '</div>';
    return $return_html;
}
function vacancies_in_top()
{
    $text_to_site = '';
    $args = array('showposts' => -1, 'category_name' => 'vacancies', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC');
    $wp_query = new WP_Query($args);
    $cat = get_category_by_slug('vacancies');
    $text_to_site .= '<h1 align="center">' . $cat->cat_name . '</h1>';
    if ($wp_query->have_posts()) {
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            $text_to_site .= '<div class="row">
                         <div class="vacancies col-md-12 col-lg-12 col-sm-12 col-xs-12">
                          <span class="day">';
            $text_to_site .= get_the_time('d.m.y');
            $text_to_site .= '</span>
                          <h3 class="title"><a href="';
            $text_to_site .= get_the_permalink();
            $text_to_site .= '">';
            $text_to_site .= get_the_title();
            $text_to_site .= '</a></h3>';
            $text_to_site .= content(15);
            $text_to_site .= '<div class="clearfix"></div>';
            $text_to_site .= get_dynamic_sidebar('share-sidebar');
            $text_to_site .= '<div class="more"><a href="';
            $text_to_site .= get_the_permalink();
            $text_to_site .= '"><i class="sprite-arrow-right"></i>  <span id="ua">Детальніше</span><span id="en">More</span></a></div>
                          <div class="clearfix"></div>
                          <hr />    
                          </div>
                      </div>';
        }
    }
    wp_reset_postdata();
    return $text_to_site;
}
/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the bottom of the page (before the widgetized footer area). If no 
 * widgets added AND preivewing the theme, then display some widgets as samples. Once the
 * theme is actually in use, it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
global $xsbf_theme_options;
/* If page bottom "sidebar" has widgets, then display them */
$sidebar_pagebottom = get_dynamic_sidebar('Page Bottom');
if ($sidebar_pagebottom) {
    ?>
	<div id="sidebar-pagebottom" class="sidebar-pagebottom">
		<?php 
    echo apply_filters('xsbf_pagebottom', $sidebar_pagebottom);
    ?>
	</div><!-- .sidebar-pagebottom -->

<?php 
    /* Otherwise, if user is previewing this theme, then show an example */
} elseif ($xsbf_theme_options['sample_widgets']) {
    ?>
	<div id="sidebar-pagebottom" class="sidebar-pagebottom">

		<aside id="sample-text" class="widget widget_text section bg-lightgreen centered clearfix">
<?php

if (is_active_sidebar('main_bottom')) {
    ?>
<div id="main-bottom">
	<div class="container">
    	<div class="container-pad">
            <div class="row-fluid">
                <?php 
    echo get_dynamic_sidebar('main_bottom');
    ?>
            </div>
        </div>
	</div>
</div>
<?php 
}
<?php

/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the widgetized footer area. If no widgets added AND just preivewing
 * the theme, then display some widgets as samples. Once the theme is actually in use,
 * it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
/* If footer "sidebar" has widgets, then display them */
$sidebar_footer = get_dynamic_sidebar('Footer');
if ($sidebar_footer) {
    ?>
	<div class="sidebar-footer clearfix">
	<div class="container">
		<div class="row">
		<?php 
    echo apply_filters('xsbf_footer', $sidebar_footer);
    ?>
		</div><!-- .row -->
	</div><!-- .container -->
	</div><!-- .sidebar-footer -->

<?php 
    /* Otherwise, if user is previewing this theme, then show some examples */
    /*
/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the bottom of the page (before the widgetized footer area). If no 
 * widgets added AND preivewing the theme, then display some widgets as samples. Once the
 * theme is actually in use, it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
global $xsbf_theme_options;
/* If page bottom "sidebar" has widgets, then display them */
$sidebar_pagebottom = get_dynamic_sidebar('sidebar-4');
if ($sidebar_pagebottom) {
    ?>
	<div id="sidebar-pagebottom" class="sidebar-pagebottom">
		<?php 
    echo apply_filters('xsbf_pagebottom', $sidebar_pagebottom);
    ?>
	</div><!-- .sidebar-pagebottom -->

<?php 
    /* Otherwise, if user is previewing this theme, then show an example */
} elseif ($xsbf_theme_options['sample_widgets']) {
    ?>
	<div id="sidebar-pagebottom" class="sidebar-pagebottom">

		<aside id="sample-text" class="widget widget_text section bg-lightgreen centered clearfix">
/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the top of the page (after the nav bar). If no widgets added AND
 * preivewing the theme, then display some widgets as samples. Once the theme is actually
 * in use, it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
global $xsbf_theme_options;
/* If page top "sidebar" has widgets, then display them */
$sidebar_pagetop = get_dynamic_sidebar('sidebar-3');
if ($sidebar_pagetop) {
    ?>
	<div id="sidebar-pagetop" class="sidebar-pagetop">
		<?php 
    echo apply_filters('xsbf_pagetop', $sidebar_pagetop);
    ?>
	</div><!-- .sidebar-pagetop -->

<?php 
    /* Otherwise, show an example if we are on the front page and its set to display the blog */
    /*elseif ( $xsbf_theme_options['sample_widgets'] != false AND is_front_page() AND is_home() ) :
    
    ?>
    	<div id="sidebar-pagetop" class="sidebar-pagetop">
    
 function az_footer_widget($postid)
 {
     global $options_alice, $post;
     $footer_widget_color_area = !empty($options_alice['footer_widget_area_color_type']) ? $options_alice['footer_widget_area_color_type'] : 'dark-type';
     $footer_widget_cols = !empty($options_alice['footer_widget_columns']) ? $options_alice['footer_widget_columns'] : '3';
     $footer_data_cols = ' data-cols="' . $footer_widget_cols . '"';
     $output_footer_widgets = '';
     if (!function_exists('get_dynamic_sidebar')) {
         function get_dynamic_sidebar($index = 1)
         {
             $sidebar_contents = "";
             ob_start();
             dynamic_sidebar($index);
             $sidebar_contents = ob_get_clean();
             return $sidebar_contents;
         }
     }
     $output_footer_widgets .= '
     <div class="footer-widget-area ' . $footer_widget_color_area . '"' . $footer_data_cols . '>';
     $output_footer_widgets .= '
     <div class="item-footer-widget-area">' . get_dynamic_sidebar('footer-area-one') . '</div>
     <div class="item-footer-widget-area">' . get_dynamic_sidebar('footer-area-two') . '</div>';
     if ($footer_widget_cols == '3' || $footer_widget_cols == '4') {
         $output_footer_widgets .= '
         <div class="item-footer-widget-area">' . get_dynamic_sidebar('footer-area-three') . '</div>';
     }
     if ($footer_widget_cols == '4') {
         $output_footer_widgets .= '
         <div class="item-footer-widget-area">' . get_dynamic_sidebar('footer-area-four') . '</div>';
     }
     $output_footer_widgets .= '
     </div>';
     // If Search
     if (is_search()) {
         $check_search_footer_widgets_settings = $options_alice['search_footer_widget_visibility'];
         if ($check_search_footer_widgets_settings == 'show') {
             echo !empty($output_footer_widgets) ? $output_footer_widgets : '';
         }
     } else {
         if (is_archive()) {
             $check_archive_footer_widgets_settings = $options_alice['archive_footer_widget_visibility'];
             if ($check_archive_footer_widgets_settings == 'show') {
                 echo !empty($output_footer_widgets) ? $output_footer_widgets : '';
             }
         } else {
             $options_az = redux_post_meta('alice', $postid);
             $check_footer_widgets_settings = $options_az['az_footer_widget_display'];
             if ($check_footer_widgets_settings == 'show') {
                 echo !empty($output_footer_widgets) ? $output_footer_widgets : '';
             }
         }
     }
 }
/**
 * Theme: Tauch Terminal Bootstrap
 *
 * The "sidebar" for the bottom of the page (before the widgetized footer area). If no
 * widgets added AND preivewing the theme, then display some widgets as samples. Once the
 * theme is actually in use, it will be empty until the user adds some actual widgets.
 *
 * @package tauchterminal
 */
?>

<?php 
global $xsbf_theme_options;
/* If page bottom "sidebar" has widgets, then display them */
$sidebar_pagebottom = get_dynamic_sidebar('Page Bottom');
$sidebar_pagebottom_banner = get_dynamic_sidebar('Page Bottom Banner');
if ($sidebar_pagebottom) {
    ?>
    <div id="sidebar-pagebottom" class="sidebar-pagebottom bg-orange">
        <div class="container">
            <div class="col-lg-3"><?php 
    echo apply_filters('xsbf_pagebottom', $sidebar_pagebottom);
    ?>
</div>
            <?php 
    if ($sidebar_pagebottom_banner) {
        ?>
                <div class="col-lg-9"><?php 
        echo apply_filters('xsbf_pagebottom_banner', $sidebar_pagebottom_banner);
        ?>
</div>
/**
 * Theme: Flat Bootstrap
 * 
 * The "sidebar" for the widgetized footer area. If no widgets added AND just preivewing
 * the theme, then display some widgets as samples. Once the theme is actually in use,
 * it will be empty until the user adds some actual widgets.
 *
 * @package flat-bootstrap
 */
?>

<?php 
/* If footer "sidebar" has widgets, then display them. The filter is very important as
   it handles adjusting the bootstrap grid based on the number of widgets in the footer
 */
$sidebar_footer = get_dynamic_sidebar('sidebar-2');
if ($sidebar_footer) {
    ?>
	<div class="sidebar-footer clearfix">
	<div class="container">
		<div class="row">
		<?php 
    echo apply_filters('xsbf_footer', $sidebar_footer);
    ?>
		</div><!-- .row -->
	</div><!-- .container -->
	</div><!-- .sidebar-footer -->

<?php 
    /* Otherwise, if user is previewing this theme, then show some examples */
    /*