<?php
$layout=theme_get_option('blog','search_layout');
if($layout == 'default'){
	$layout = theme_get_option('general','layout');
}
?>
<?php get_header(); ?>
<?php theme_generator('introduce');?>
<div id="content-area">
	<div class="wrap-center <?php if($layout=='right'):?>right_sidebar<?php endif;?><?php if($layout=='left'):?>left_sidebar<?php endif;?><?php if($layout=='full'):?>full_width<?php endif;?>">
		<div id="content" class="main">
			<?php 
				if(!have_posts()){
					$search_nothing_found = wpml_t(THEME_NAME, 'Search Nothing Found Text',theme_get_option('blog','search_nothing_found'));
					$search_nothing_found = empty($search_nothing_found) ? __("\(╯-╰)/ Sorry SIR. we were unable to find what you were looking for. Perhaps mapping will help", THEME_FRONT_DOMAIN) : $search_nothing_found;
					echo  '<h3>'.$search_nothing_found.'</h3>';
				
			?>
			<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>
			<?php
				}else{
					echo theme_generator('breadcrumbs');
					get_template_part( 'loop','search');
			?>
				<div class="clear"></div>
			<?php theme_generator('blog_page_navgation');?>
			<?php } ?>
		</div>
		<?php  get_sidebar(); ?>
		<div class="clear"></div>
	</div>
</div>
<?php get_footer(); ?>
