<?php get_header(); 
global $wp_query, $post;
$current_term = $wp_query->get_queried_object();
if($_REQUEST['etype']=='')
{
	$_REQUEST['etype'] = 'upcoming';   
}
?>
<div id="wrapper" class="clearfix">
 <div id="content" class="clearfix" >
    <?php if ( get_option( 'ptthemes_breadcrumbs' )) {  ?>
    <div class="breadcrumb clearfix">
        <div class="breadcrumb_in"><?php yoast_breadcrumb('','');  ?></div>
    </div>
<?php } ?>
  <h1><?php echo $current_term->name; ?></h1>   
<div class="tabber">
<ul class="tab">

		<?php $category_link =  get_term_link( $term, $taxonomy );?>
         <li class="<?php if($_REQUEST['etype']=='upcoming'){ echo 'active';}?>"> <a href="<?php if(strstr($category_link,'?')){ echo $cat_url = $category_link."&amp;etype=upcoming";}else{ echo $cat_url = 				$category_link."?etype=upcoming";}?>">  <?php _e('Upcoming Events');?> </a></li>
          <li class="<?php if($_REQUEST['etype']=='past'){ echo 'active';}?>"> <a href="<?php if(strstr($category_link,'?')){ echo $cat_url = $category_link."&amp;etype=past";}else{ echo $cat_url = $category_link."?etype=past";}?>">  <?php _e('Past Events');?> </a></li>
</ul>
              <form method="get" name="sort_by_result_frm" id="sort_by_result_frm" action="" >
              <?php	if($_REQUEST[CUSTOM_CATEGORY_TYPE1]){?>
				<input type="hidden" name="<?php echo CUSTOM_CATEGORY_TYPE1;?>" value="<?php echo $_REQUEST[CUSTOM_CATEGORY_TYPE1];?>" />
				<?php }	?>
                <?php if($_REQUEST['etype']){?>
                <input type="hidden" name="etype" value="<?php echo $_REQUEST['etype']; ?>" />
                <?php }?>
              <select name="sortby" id="sortby_id" class="category" onchange="sort_as_set()">
                <option value=""> <?php _e('Select Sorting');?></option>
                <option value="title_asc" <?php if($_REQUEST['sortby']=='title_asc'){ echo 'selected="selected"';}?>> <?php _e('Title Ascending');?></option>
                <option value="title_desc" <?php if($_REQUEST['sortby']=='title_desc'){ echo 'selected="selected"';}?>> <?php _e('Title Descending');?></option>
                <option value="stdate_low_high" <?php if($_REQUEST['sortby']=='stdate_low_high'){ echo 'selected="selected"';}?>> <?php _e('Start Date low to high');?></option>
                <option value="stdate_high_low" <?php if($_REQUEST['sortby']=='stdate_high_low'){ echo 'selected="selected"';}?>> <?php _e('Start Date high to low');?></option>
                <option value="address_high_low" <?php if($_REQUEST['sortby']=='address_high_low'){ echo 'selected="selected"';}?>> <?php _e('Address (A-Z)');?></option>
                <option value="address_low_high" <?php if($_REQUEST['sortby']=='address_low_high'){ echo 'selected="selected"';}?>> <?php _e('Address (Z-A)');?></option>
              </select>
              </form>
              <script type="text/javascript">
				function sort_as_set()
				{
					if(document.getElementById('sortby_id').value)
					{
						document.sort_by_result_frm.submit();	
					}
				}
				</script>
   </div> 
         <?php if(have_posts()) : $pcount=0; ?>
      <?php while(have_posts()) : the_post()  ?>
         <?php get_the_post_content('listing_li')?>
        <?php endwhile; ?>
      <div class="pagination">       
       <span class="i_previous" > <?php previous_posts_link(__('Previous')) ?> </span>
       <span class="i_next" ><?php next_posts_link(__('Next')) ?> </span>
        <?php if (function_exists('wp_pagenavi')) { ?>
        <?php wp_pagenavi(); ?>
      </div>
      <?php } ?>
        <?php else: ?>
     <b><?php echo CUSTOM_POST_NOT_FOUND;?></b>
      <?php endif; ?>
      
</div> <!-- content #end -->
    <?php get_sidebar(); ?>
</div> <!-- wrapper #end -->
<div id="bottom"></div>    
<?php get_footer(); ?>