/**
 * RoloPress master loop
 *
 * Currently handles most situations
 *
 * @since 1.2
 */
function rolo_loop()
{
    if (!is_single()) {
        // This class is not needed on single pages
        ?>
	<ul class="item-list">
<?php 
    }
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            ?>

		<li id="entry-<?php 
            the_ID();
            ?>
" class="<?php 
            rolopress_entry_class();
            ?>
">
		
			<?php 
            rolopress_before_entry();
            // Before entry hook
            ?>

				<div class="entry-main group">
				<?php 
            if (is_archive() || is_home()) {
                if (rolo_type_is('contact')) {
                    rolo_contact_header(get_the_ID());
                }
                if (rolo_type_is('company')) {
                    rolo_company_header(get_the_ID());
                }
                ?>
					<?php 
            } elseif (is_single()) {
                if (rolo_type_is('contact')) {
                    rolo_contact_header(get_the_ID());
                    the_content();
                    if (is_active_sidebar("contact-under-main")) {
                        ?>
											<div class="widget-area contact-under-main">
											<?php 
                        dynamic_sidebar("contact-under-main");
                        ?>
											</div> 
										<?php 
                    }
                }
                if (rolo_type_is('company')) {
                    rolo_company_header(get_the_ID());
                    the_content();
                    if (is_active_sidebar("company-under-main")) {
                        ?>
											<div class="widget-area company-under-main">
											<?php 
                        dynamic_sidebar("company-under-main");
                        ?>
											</div> 
										<?php 
                    }
                }
            } elseif (is_search()) {
                ?>
							<?php 
                if (rolo_type_is('contact')) {
                    rolo_contact_header(get_the_ID());
                } elseif (rolo_type_is('company')) {
                    rolo_company_header(get_the_ID());
                } else {
                    ?>
											<li id="entry-<?php 
                    echo basename(get_permalink());
                    ?>
" class="entry-header">
												<?php 
                    echo '<img class="entry-icon" src=' . ROLOPRESS_IMAGES . '/icons/rolo-default.jpg />';
                    ?>
												<a class="entry-title" href="<?php 
                    the_permalink();
                    ?>
" rel="bookmark"><?php 
                    the_title();
                    ?>
</a>
											</li>
								<?php 
                }
            } elseif (is_page()) {
                the_content();
                // show the page content
                if (is_page_template('widgets.php') || is_page_template('widgets-no-sidebar.php')) {
                    // is this a widget page
                    if (is_active_sidebar("widget-page")) {
                        // is the widget area active
                        ?>
										<div class="widget-area">
										<ul class="xoxo">
										<?php 
                        dynamic_sidebar("widget-page");
                        ?>
										</ul> 
										</div><!-- #widget-area -->	
										<?php 
                    } else {
                        rolo_add_some_widgets_message();
                        // if not, show a message
                    }
                }
            } else {
                ?>
								<li id="entry-<?php 
                echo basename(get_permalink());
                ?>
" class="entry-header">
									<?php 
                echo '<img class="entry-icon" src=' . ROLOPRESS_IMAGES . '/icons/rolo-default.jpg />';
                ?>
									<a class="entry-title" href="<?php 
                the_permalink();
                ?>
" rel="bookmark"><?php 
                the_title();
                ?>
</a>
								</li>
					
					<?php 
            }
            ?>
					
				</div><!-- .entry-main -->
					
				<?php 
            rolo_entry_footer();
            ?>

				<?php 
            rolopress_after_entry();
            // After entry hook
            ?>
				
		</li><!-- #entry-<?php 
            the_ID();
            ?>
 -->
<?php 
        }
        ?>

<?php 
        if (!is_single()) {
            // not needed on single pages
            ?>
	</ul><!-- item-list-->
<?php 
        }
        ?>


<?php 
    } else {
        // 404 or no search results
        ?>

		<li id="entry-0" class="<?php 
        rolopress_entry_class();
        ?>
">
			<?php 
        rolopress_before_entry();
        // Before entry hook
        ?>
				<div class="entry-main">
				
					<?php 
        // on inital setup if no contacts or companies are created then
        // the menu items produce a 404
        // This will provide instructions on how to fix
        $referring_page = $_SERVER['REQUEST_URI'];
        if ($referring_page == "/type") {
            rolo_type_tax_message();
        } else {
            rolo_404_message();
        }
        ?>
					
				</div><!-- .entry-main -->
			<?php 
        rolopress_after_entry();
        // After entry hook
        ?>
		</li><!-- #entry-0 -->

<?php 
    }
}
        ?>
" class="<?php 
        rolopress_entry_class();
        ?>
">
					
					<?php 
        rolopress_before_entry();
        // Before entry hook
        ?>
     	
					<div class="entry-main group">
					
					<?php 
        if (rolo_type_is('contact')) {
            rolo_contact_header(get_the_ID());
        }
        ?>
					
					</div><!-- .entry-main -->

					<?php 
        rolo_entry_footer();
        ?>

					<?php 
        rolopress_after_entry();
        // After entry hook
        ?>
					
					</li><!-- #entry-<?php