<?php 
$error_page = theme_get_option('advanced','error_page');
if($error_page){
	wp_redirect( get_permalink($error_page)); 
	exit; 
}
?>
<?php  get_header(); ?>
<?php theme_generator('introduce');?>
<div id="content-area">
	<div class="wrap-center right_sidebar">
	
	<div id="content" class="main">
		<div id="post-0" class="post error404">
<?php echo '<h2 class="post-title">'.__("Hmm, didn't find this page, sorry!",THEME_FRONT_DOMAIN).'</h2>';?>
			<div class="post-content">
<?php echo '<p>'.__("Apologies, but we were unable to find what you were looking for. Perhaps  searching & mapping will help.",THEME_FRONT_DOMAIN).'</p>';?>
			</div>
		</div><!-- .post -->
		<h2><?php _e('Pages',THEME_FRONT_DOMAIN);?></h2>
		<?php if (theme_get_option('general','enable_nav_menu') && has_nav_menu( 'primary-menu' ) ) {
			wp_nav_menu( array( 
				'theme_location' => 'primary-menu',
				'container_class' => '',
				'container' => '',
	 	 	 	'sort_column' => 'menu_order'
			));
		}else{
			$excluded_pages_with_childs = theme_get_excluded_pages();
			
			$output = '<ul>';
			$output .= wp_list_pages("sort_column=menu_order&exclude=$excluded_pages_with_childs&title_li=&echo=0");
			$output .= '</ul>';
			
			echo $output;
		}
?>
				<div class="divider top"><a href="#"><?php _e('Top',THEME_FRONT_DOMAIN);?></a></div> 
<?php 
	$exclude_cats = theme_get_option('blog','exclude_categorys');
?>
				<h2><?php _e( 'Category Archives',THEME_FRONT_DOMAIN); ?></h2>
				<ul>
					<?php wp_list_categories( array( 'exclude'=> implode(",",$exclude_cats), 'feed' => __( 'RSS', THEME_FRONT_DOMAIN ), 'show_count' => true, 'use_desc_for_title' => false, 'title_li' => false ) ); ?>
				</ul>
				<div class="divider top"><a href="#"><?php _e('Top',THEME_FRONT_DOMAIN);?></a></div> 

<?php 
	$archive_query = new WP_Query( array('showposts' => 1000,'category__not_in' => $exclude_cats ));
?>
				<h2><?php _e( 'Blog Posts',THEME_FRONT_DOMAIN ); ?></h2>
				<ul>
<?php while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
					<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( __("Permanent Link to %s", THEME_FRONT_DOMAIN), get_the_title() ); ?>"><?php the_title(); ?></a> (<?php comments_number('0', '1', '%'); ?>)</li>
<?php endwhile; ?>
				</ul>

				<div class="divider top"><a href="#"><?php _e('Top',THEME_FRONT_DOMAIN);?></a></div>
				<div class="clear"></div>
	</div>

	<aside id="sidebar">
			<div class="sidebar-top">
				<div class="sidebar-bottom">
				<?php get_search_form(); ?>
				</div>
			</div>
	</aside>
	<div class="clear"></div>

	</div>
</div>

<?php get_footer(); ?>
