<?php
/*
Template Name: Image Gallery
*/
?>

<?php get_header(); ?>
       
    <div id="content" class="page col-full">
		<div id="main" class="col-right">
                                                                            
		<?php if ( $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) { ?>
			<div id="breadcrumbs">
				<?php woo_breadcrumbs(); ?>
			</div><!--/#breadcrumbs -->
		<?php } ?>  

            <div <?php post_class(); ?>>

			    <h1 class="title"><?php the_title(); ?></h1>
                
				

		        <?php										
	            	if ( have_posts() ) { 
						the_post();
	            		the_content();
	            	}
	            ?>
				
                <?php 	
					$custom_fields = get_post_custom($post_id);
					if (array_key_exists('id_category', $custom_fields)) {
						$categories = get_categories(array('child_of' => $custom_fields['id_category'][0]));
					} else {
						$categories = get_categories();
					}
					
					foreach ($categories as $category) {?>
                                                <div class="entry">
						<h2><?php echo $category->cat_name; ?></h2>
                                                <?php
						$query = 'showposts=60&orderby=title&order=ASC';
						$query .= '&cat=' . $category->cat_ID;
					
						query_posts( $query ); 					
						
						if ( have_posts() ) { 					
							while ( have_posts() ) { 
								the_post();						
								$wp_query->is_home = false;
								woo_image( 'single=true&class=thumbnail alignleft' );                                                                
							} // End WHILE Loop
                                        ?>      
                                                </div><!-- /.entry -->
                                                <div class="fix"></div>
                                        
                                        <?php
						} // End IF Statement
					} // End FOREACH Loop
                ?>	
                </div>

                                                            
		</div><!-- /#main -->
		
        <?php get_sidebar(); ?>

    </div><!-- /#content -->
		
<?php get_footer(); ?>