function render_events($events, $atts, $content, $do_shortcode = true, $uid, $render_images_ids)
 {
     if (isset($atts['separator']) && 'eap' == $atts['separator']) {
         $atts['showimage'] = "1";
     }
     extract(shortcode_atts(array('date_format' => 'MMM d, yyyy', 'time_format' => 'h:mmtt', 'showimage' => '0', 'microdata' => '1', 'gmt_offset' => get_option('gmt_offset'), 'parse_postmeta' => '', 'parse_taxonomy' => '1', 'template' => 'widget_upcoming_events.php', 'separator' => '', 'words' => '', 'last_event_info' => '1'), $atts));
     $render_images_ids = explode(',', $render_images_ids);
     $gmt_offset = empty($gmt_offset) ? '' : $gmt_offset;
     $tz_suffix = $this->convert_hours_to_hours_and_minutes($gmt_offset);
     $microdata = '1' == $microdata ? true : false;
     $parse_taxonomy = '1' == $parse_taxonomy ? true : false;
     $tools = new calendar_ajax();
     $out = '';
     if (is_array($events) && count($events) > 0) {
         $done_dates = array();
         $start_tss = array();
         $end_tss = array();
         foreach ($events as $event_index => $e) {
             $replacements = array();
             //---
             $start = strtotime($e->event_start);
             $end = strtotime($e->event_end);
             $start_tss[] = $start;
             $end_tss[] = $end;
             /*
             echo "LINE:".__LINE__."<br>";
             echo "<pre>";
             print_r( $e );
             echo "</pre>";
             */
             $dom = new DomDocument();
             //--
             $tpl = apply_filters('supe_get_template_content', $this->get_template_content($template, $content, $e, $do_shortcode), $uid, $template, $content, $e, $do_shortcode, $atts);
             if (empty($tpl) || false === $tpl) {
                 continue;
             }
             //$dom->loadHTML( htmlentities( $tpl ) );
             @$dom->loadHTML($tpl);
             //--
             if ($microdata) {
                 $this->dom_class_set_attribute($dom, 'rhc-widget-upcoming-item', 'itemscope', '');
                 $this->dom_class_set_attribute($dom, 'rhc-widget-upcoming-item', 'itemtype', 'http://schema.org/Event');
                 //--
                 $microdata_date_format = intval($e->allday) ? 'Y-m-d' : 'Y-m-d\\TH:i:s';
                 $this->dom_node_append_microdata_itemprop($dom, 'rhc-widget-upcoming-item', 'startDate', date($microdata_date_format, $start) . $tz_suffix, $microdata);
                 $this->dom_node_append_microdata_itemprop($dom, 'rhc-widget-upcoming-item', 'endDate', date($microdata_date_format, $end) . $tz_suffix, $microdata);
             }
             //ID			//------------------
             $this->dom_class_set_attribute($dom, 'rhc-widget-upcoming-item', 'data-post_id', $e->ID);
             //TITLE			//------------------
             $replacements[] = (object) array('replace' => '[RHCTITLE]', 'with' => $e->post_title);
             $this->dom_title($dom, '[RHCTITLE]', $atts, $microdata);
             //DESC			//------------------
             $this->dom_description($dom, $e, $atts, $microdata);
             //URL			//------------------
             $url = $this->get_event_url($e);
             if ($e->number > 0 && !empty($url)) {
                 $url = $this->addURLParameter($url, 'event_rdate', date('YmdHis', $start) . ',' . date('YmdHis', $end));
             }
             //$this->dom_class_set_attribute( $dom, 'rhc-title-link', 'href', $url );
             if (property_exists($e, 'meta') && isset($e->meta['fc_click_link']) && 'none' == $e->meta['fc_click_link']) {
                 $this->dom_url($dom, '', $microdata);
             } else {
                 $this->dom_url($dom, $url, $microdata);
             }
             //--
             //IMAGE
             if ('1' == $showimage) {
                 $attachment_id = get_post_meta($e->ID, 'rhc_tooltip_image', true);
                 $size = $tools->get_image_size();
                 $image = $tools->get_tooltip_image($e->ID, $attachment_id, $size);
                 if (is_array($image) && isset($image[0])) {
                     $this->dom_class_set_image($dom, 'rhc-widget-upcoming-featured-image', $image[0], $url);
                     $this->dom_class_add_class($dom, 'rhc-widget-upcoming-item', 'featured-1');
                     //--
                     $this->dom_class_set_image_no_link($dom, 'fc-event-featured-image', $image[0]);
                 } else {
                     //$this->dom_class_remove( $dom, 'rhc-widget-upcoming-featured-image' );
                     $this->dom_class_add_class($dom, 'rhc-widget-upcoming-item', 'featured-1');
                 }
             } else {
                 $this->dom_class_remove($dom, 'rhc-widget-upcoming-featured-image');
                 $this->dom_class_add_class($dom, 'rhc-widget-upcoming-item', 'featured-0');
             }
             //OTHER IMAGES
             $this->handle_event_images($dom, $e, $url, $tools, $render_images_ids);
             //-- dates below the title
             //this take into consideration the passed formats
             $this->dom_class_set_date($dom, 'rhc-widget-date', $start, $date_format);
             $this->dom_class_add_class($dom, 'rhc-widget-date', 'fc-date-format');
             $this->dom_class_set_date($dom, 'rhc-widget-time', $start, $time_format);
             $this->dom_class_add_class($dom, 'rhc-widget-time', 'fc-date-format');
             $this->dom_class_set_date($dom, 'rhc-widget-end-date', $end, $date_format);
             $this->dom_class_add_class($dom, 'rhc-widget-end-date', 'fc-date-format');
             $this->dom_class_set_date($dom, 'rhc-widget-end-time', $end, $time_format);
             $this->dom_class_add_class($dom, 'rhc-widget-end-time', 'fc-date-format');
             //--- fc_color or other styles saved in post_meta as strings
             $this->dom_post_meta_styles($dom, $e);
             //--- convert some post_meta into element attr for javascript processing.
             $this->dom_post_meta_to_attr($dom, $e);
             //--- different date: flag elements that only show on different dates / or remove them ( .if-different-date .if-different-date-r
             if (date('Ymd', $start) == date('Ymd', $end)) {
                 $this->dom_class_add_class($dom, 'if-different-date', 'is-same-date');
                 $this->dom_class_remove($dom, 'if-different-date-r');
             }
             //--- different month:
             if (date('Ym', $start) == date('Ym', $end)) {
                 $this->dom_class_add_class($dom, 'if-different-month', 'is-same-month');
                 $this->dom_class_remove($dom, 'if-different-month-r');
             }
             //--- different year:
             if (date('Y', $start) == date('Y', $end)) {
                 $this->dom_class_add_class($dom, 'if-different-year', 'is-same-year');
                 $this->dom_class_remove($dom, 'if-different-year-r');
             }
             //--- date range
             $diff = floor(($end - $start) / 86400);
             if ($diff > 0) {
                 $this->dom_class_set_date_range($dom, 'rhc-widget-date-range', $start, $end, $date_format);
                 $this->dom_class_remove($dom, 'rhc-day_diff0');
             } else {
                 $this->dom_class_set_date($dom, 'rhc-widget-date-range', $start, $date_format);
                 $this->dom_class_add_class($dom, 'rhc-widget-date-range', 'fc-date-format');
                 $this->dom_class_remove($dom, 'rhc-day_diff1');
             }
             //-- dates in post info detail boxes
             $this->dom_class_set_post_info_dates($dom, 'rhc_date', $start, $end);
             $this->dom_class_add_class($dom, 'rhc_date', 'fc-date-format');
             //-- dates in the left boxes
             $this->dom_class_set_date_with_format($dom, 'rhc-date-start', $start);
             $this->dom_class_add_class($dom, 'rhc-date-start', 'fc-date-format');
             //--
             $current_date = date('Ymd', $start);
             if (in_array($current_date, $done_dates)) {
                 $this->dom_class_add_class($dom, 'hide-repeat-date', 'repeated-date');
             } else {
                 $done_dates[] = $current_date;
             }
             //--
             if (intval($e->allday)) {
                 $this->dom_class_add_class($dom, 'rhc-allday-hidden', 'fc-is-allday');
                 $this->dom_class_add_class($dom, 'rhc-widget-upcoming-item', 'fc-is-allday');
                 $this->dom_class_remove($dom, 'rhc-widget-time');
                 $this->dom_class_remove($dom, 'rhc-widget-end-time');
                 //$this->dom_class_remove( $dom, 'rhc-widget-date-time' );
             }
             //handle render post meta
             $this->dom_post_meta($dom, $e);
             $this->handle_render_taxonomy($dom, $e, $parse_taxonomy, $atts, $replacements);
             //rnoe: remove node on empty
             $this->handle_rnoe($dom);
             //cleanup
             $this->handle_cleanup($dom);
             # remove <!DOCTYPE
             $dom->removeChild($dom->doctype);
             # remove <html><body></body></html>
             $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild);
             $tmp = $dom->saveHTML();
             foreach ($replacements as $r) {
                 $tmp = str_replace($r->replace, $r->with, $tmp);
             }
             $next_index = $event_index + 1;
             if (isset($events[$next_index])) {
                 if ('eap' == $separator && defined('EAP_DIVIDER')) {
                     $separator = EAP_DIVIDER;
                 }
                 $tmp .= apply_filters('rhc_supe_render_separator', $separator, $atts);
             }
             /*
             $bodyNode = $dom->getElementsByTagName('body')->item(0);
             foreach ($bodyNode->childNodes as $childNode) {
               $tmp .= $dom->saveHTML($childNode);
             }
             */
             if (isset($_REQUEST['rhc_debug'])) {
                 $out .= "<!-- MARK START -->\n" . $tmp . "\n<!-- MARK END -->\n";
             } else {
                 $out .= $tmp . "\n";
             }
         }
         //-- last event $e
         if ('1' == $last_event_info) {
             $max_start_ts = array_keys($start_tss, max($start_tss));
             if (isset($max_start_ts[0])) {
                 $j = $max_start_ts[0];
                 $out .= sprintf("<script class=\"rhc-supe-last\" data-last_date_start=\"%s\" data-last_date_end=\"%s\"></script>", date('Y-m-d\\TH:i:s', $start_tss[$j]), date('Y-m-d\\TH:i:s', $end_tss[$j]));
             }
         }
         //$out.="<div><pre>".print_r($start_tss,true)."</pre> ".."</div>";
         //
     }
     return $out;
 }
 public static function handle_get_images($events, $atts)
 {
     if (empty($events)) {
         return $events;
     }
     $tools = new calendar_ajax();
     $images = apply_filters('rhc_images', array('rhc_top_image', 'rhc_dbox_image', 'rhc_tooltip_image', 'rhc_month_image'));
     foreach ($events as $i => $e) {
         if (!property_exists($e, 'images')) {
             $events[$i]->images = array();
         }
         foreach ($images as $meta_key) {
             $attachment_id = get_post_meta($e->ID, $meta_key, true);
             $size = 'full';
             $image = $tools->get_tooltip_image($e->ID, $attachment_id, $size);
             if (is_array($image) && isset($image[0])) {
                 $events[$i]->images[$meta_key] = $image[0];
             }
         }
     }
     return $events;
 }