<?php

require_once 'departures/departure-display.php';
$bar = 1;
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $hash = get_post_meta($post->ID, 'departure_blogtrip_hashtag', true);
        $dest = get_post_meta($post->ID, 'departure_destination', true);
        $dep = get_post_meta($post->ID, 'departure_date_start', true);
        $rtn = get_post_meta($post->ID, 'departure_date_end', true);
        // get data for display
        $taxonomies = get_blogtrip_taxonomies(get_the_ID(), array(), 'name');
        $crew = $organizer = '';
        foreach ($taxonomies['crew'] as $slug => $crew_name) {
            $crew .= !empty($crew) ? ', ' : '';
            $crew .= '<a href="' . get_term_link($slug, 'crew') . '">' . $crew_name . '</a>';
        }
        foreach ($taxonomies['organizer'] as $slug => $organizer_name) {
            $organizer .= !empty($organizer) ? ', ' : '';
            $organizer .= '<a href="' . get_term_link($slug, 'organizer') . '">' . $organizer_name . '</a>';
        }
        ?>
			<?php 
        if ($dep < current_time('timestamp') && $rtn < current_time('timestamp') && isset($bar)) {
            unset($bar);
            ?>
			<div class="sep-item">
				Past Trips
			</div>
			<?php 
$dep = get_post_meta($post->ID, 'departure_date_start', true);
$rtn = get_post_meta($post->ID, 'departure_date_end', true);
foreach ($taxonomies['crew'] as $slug => $crew_name) {
    $crew .= !empty($crew) ? ', ' : '';
    $crew .= '<a href="' . get_term_link($slug, 'crew') . '">' . $crew_name . '</a>';
}
foreach ($taxonomies['organizer'] as $slug => $organizer_name) {
    $organizer .= !empty($organizer) ? ', ' : '';
    $organizer .= '<a href="' . get_term_link($slug, 'organizer') . '">' . $organizer_name . '</a>';
}
$people = array();
foreach ($taxonomy_objects['crew'] as $slug => $crew_term) {
    $people[] = get_avatar($crew_term->description, '102', '', $crew_term->name);
}
$images = get_children('post_parent=' . $post->ID . '&post_type=attachment&post_mime_type=image');
$taxes = get_blogtrip_taxonomies(array('post' => $post->ID));
$term_id = get_term_by('slug', $custom_meta['departure_blogtrip_hashtag'][0], 'post_tag');
$blog_object_ids2 = get_posts_by_tag($custom_meta['departure_blogtrip_hashtag'][0], 'DESC', 4);
// setup photo style - style from *.pds
$image_sizes = array('large' => array('width' => 396, 'height' => 252), 'medium' => array('width' => 244, 'height' => 252), 'thumb' => array('width' => 153, 'height' => 153));
$photo_styles = array(array('class' => 'prime', 'width' => $image_sizes['large']['width'], 'height' => $image_sizes['large']['height'], 'type' => 'large'), array('class' => 'sub-prime', 'width' => $image_sizes['medium']['width'], 'height' => $image_sizes['medium']['height'], 'type' => 'medium'), array('class' => 'sub', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-2', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-4', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-6', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'));
// setup photo style - 12 thumbs
$photo_styles = array(array('class' => 'sub', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-2', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-4', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-6', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-2', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-4', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-6', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-2', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-4', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'), array('class' => 'sub push-6', 'width' => $image_sizes['thumb']['width'], 'height' => $image_sizes['thumb']['height'], 'type' => 'thumb'));
$count_photo = count($photo_styles);
// include twitter script
$tweet_params = array('hashcode' => $custom_meta['departure_blogtrip_hashtag'][0], 'since_id' => $custom_meta['_departure_tweet_since_id'][0], 'until' => date('Y-m-d', $custom_meta['departure_date_end'][0]), 'since' => date('Y-m-d', $custom_meta['departure_date_start'][0]), 'live' => time() < $custom_meta['departure_date_end'][0] ? true : false, 'page_tweets' => $page_tweets, 'photo_count' => $count_photo);
$photo_cached = array();
$i = 0;
foreach ($images as $post_image) {
    $image_custom_fields = get_post_custom($post_image->ID);
    $large = $medium = $thumb = '';