<!-- <?=filenamecomment(__FILE__)?> -->
<div id="loop" class=" <?=$section?>  <?php echo (is_tax())? 'istax':'';?> clearfix" >
<?php 
	global $query_string,$posts; // required
//$termchildren = get_term_children( $normalid, 'pcat' );//get children for normal, basically everything but specials //d($termchildren);
//$allnormalcats = array_merge(ia($termchildren),array($normalid));// add the parent normal to that.
//d($allnormalcats);										

if($f = apply_filters('loopoverride', false, $post) AND (!is_search() or count($posts) < 2) ){ //  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx watch out for the_content and other 'in the loop ' funcs.  they dont work on these two filters, cuz it's not in the loop
		include pathtocustom. 'themefiles/'.$f;
		if(apply_filters('loopoverrideComments', false, $post) AND (is_single() || is_page()) AND $showcomments   )
			 wrappedComments();
}elseif($f = apply_filters('loopoverrideWithPath', false, $post) AND (!is_search() or count($posts) < 2)){
		include $f;
		if(apply_filters('loopoverrideComments', false, $post) AND (is_single() || is_page()) AND $showcomments  )
			 wrappedComments();
}elseif ($post->post_name == getThemeOption('contactpageslug') ){
			include  getNormalOrCustomPath($f = '400-contact.php').$f;
}elseif ($wp_query->query_vars['name'] == 'terms' AND is_404() ){//if you dont already have a terms page, it will be 404 and query_vars['name'] == 'terms'
		$f = get_include_contents(pathtotheme.'999-terms.php');
		echo '<!-- '.filenamecomment(pathtotheme.'999-terms.php').' -->';
		echo wpautop($f);
}elseif ($wp_query->query_vars['name'] == 'privacy' AND is_404()  ){
		$f = get_include_contents(pathtotheme.'999-privacy.php');
		echo '<!-- '.filenamecomment(pathtotheme.'999-privacy.php').' -->';
		echo wpautop($f);
}elseif ($post->post_name == getThemeOption('testimonialFormPageSlug') or $post->post_name == getThemeOption('testimonialDisplayPageSlug')) {
		include getNormalOrCustomPath($f = '304-testimonials.php').$f;
}elseif ($post->post_type == 'testimonial') {
		include getNormalOrCustomPath($f = '301-loop-single-testi.php').$f;
}elseif (is_404()) {
		include getNormalOrCustomPath($f = '001-404.php').$f;
}else{

	$posts = apply_filters('loopQuery', $posts);

	$loopnum = 1;
	$nullpost = $filteredLoopTpl = $loopmulti = $loopattachment = $loopsingle = false;
	if(is_null($post))
		$nullpost = true;
	elseif($whileF = apply_filters('loopTpl', false, $post)){
		$filteredLoopTpl = true;
		$whileclass = 'filteredLoopTpl';
	}elseif(count($posts) > 1 OR $paged or is_search()){ // you could move this or issearch into there to make single result searches show in the multi loop instead of loop single...
		$loopmulti = true;
		$whileclass = 'loopmulti';
		$whileF = getNormalOrCustomPath($whileF = '302-loop-multi.php').$whileF;
	}elseif(is_attachment()){
		$loopattachment = true;
		$whileclass = 'loopattachment';
		$whileF = getNormalOrCustomPath($whileF = '301-single-attachment.php').$whileF;
	}else{
		$loopsingle = true;
		$whileclass = 'loopsingle';
		$whileF = getNormalOrCustomPath($whileF = '301-loop-single.php').$whileF;
	}
	
	echo div('class="while_'.$whileclass.'"');
		
		if( $home ){
		    //echo wdiv(getPostContent(2), 'class="post clearfix topofloop"');
			include pathtothemefiles.'301 top of home multi.php';
		}
			
		while (  have_posts() ) : the_post(); // why do i have to have this????   dp($post);
			if($nullpost){
				comment('null post');
			}else
			 	include $whileF;
			$loopnum++;
		endwhile;
	echo div(0);
	// if ( !have_posts() )
	//	 echo 'Nothing found.  This page must be under construction or maybe nothing was found for your search.';

	if($home AND $showcomments){
		wrappedComments(array('location'=>'home'));
	}
 }//else loop decider
?>

</div><!-- id="loop" -->

