<?php

$headline_cat = 104;
$front_cat_list = "4,103,104,412,102,6";

get_header() ?>

<div id="wrapper">
<div id="content">

<div id="headline">
<div id="headline-content" class="glidecontentwrapper">
<?php $headline = new WP_Query('cat='.$headline_cat.'&showposts=3'); while($headline->have_posts()) : $headline->the_post(); ?>
<div class="clearfix glidecontent">

<?php
$headline_preview = get_post_custom_values("preview-big");
if ( is_array($headline_preview) ) { ?>
<img class="teaser-image" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, 'preview-big',true) ?>&amp;w=390&amp;h=252&amp;zc=1" alt="<?php the_title(); ?>" />
<?php } else { ?>
<img class="teaser-image" src="<?php bloginfo('template_directory'); ?>/images/image-blank-headline.jpg" alt="<?php the_title(); ?>" />
<?php } ?>

<div class="teaser-main">
<div class="teaser-wrap">
<div class="overlay"></div>
<h3 class="teaser-title"><a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Read %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>"><?php the_title(); ?></a></h3>
<div class="teaser-text"><?php the_content_limit(100, ''); ?></div>
</div>
</div>

</div>
<?php endwhile; ?>
</div><!-- .glidecontentwrapper -->

<div id="teaser" class="glidecontenttoggler">
<?php $teaser_small = new WP_Query('cat='.$headline_cat.'&showposts=3'); while($teaser_small->have_posts()) : $teaser_small->the_post(); ?>
<a href="#" class="toc">
<span class="togglerwrap">
<span class="togglercontent clearfix">
<?php
$teaser_preview = get_post_custom_values("preview-big");
if ( is_array($teaser_preview) ) { ?>
<img class="teaser-image-small" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, 'preview-big',true) ?>&amp;w=60&amp;h=60&amp;zc=1" alt="<?php the_title(); ?>" />
<?php } else { ?>
<img class="teaser-image-small" src="<?php bloginfo('template_directory'); ?>/images/image-blank-small.jpg" alt="<?php the_title(); ?>" />
<?php } ?>

<span class="togglertitle"><?php the_title(); ?></span>
</span>
</span>
</a>
<?php endwhile; ?>
</div><!-- .glidecontenttoggler -->
</div><!-- #headline -->

<?php if ( function_exists('get_flickrRSS') ) : ?>
<div id="flickrbox">
<h3 class="section-title"><?php _e('FOTOGRAFLAR !'); ?></h3>
<div id="flickrwrap">
<?php get_flickrRSS(); ?>
</div>
</div>
<?php endif; ?>

<div id="list-categories">
<h2 class="section-title"><?php _e( 'SON YAZILAR', 'wpbx' ) ?></h2>
<?php
// Flag to indicate alternating columns
$catLeftCol = true;
$intCount = 0;

// Determine how many posts to show per category
$intPostCount = 5;

// Retrieve a list of selected categories
$categories = get_categories("orderby=ID&order=asc&hide_empty=1& hierarchial=0&include=$front_cat_list");

// Iterate over each category
foreach ($categories as $category)
{
// Retrieve a handful of posts for this category
query_posts("cat=" . $category->cat_ID . "&showposts=$intPostCount&orderby=date&order=DESC" );

// Increment the debug counter
$intCount++;

?>
<!-- Loop: <?php echo $intCount; ?> -->
<?php
// Initialise the thumb display flag
$catFirstPost = true;

// Do we have any categories to display?
while (have_posts())
{

// Advance the post queue
the_post(); $do_not_duplicate = $post->ID;

// Is this the first post in the category?
if ($catFirstPost)
{
?>
<?php
// Check whether we need to create the "row wrapper"
if ($catLeftCol)
{
?>
<div class="entry-row clearfix">
<?php
}
?>

<div id="<?php echo $category->slug; ?>-list" class="entry-list">
<h3 class="entry-list-cat-title">
<a href="<?php echo get_category_link($category->cat_ID); ?>" title="<?php echo $category->name; ?>"><?php echo $category->name; ?>&raquo;</a>
</h3>

<h4 class="entry-list-title"><a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Oku %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>"><?php the_title(); ?></a></h4>
<div class="entry-list-meta">
<span class="entry-list-date"><?php unset($previousday); printf( __( '%1$s', 'wpbx' ), the_date( 'D, M j Y', '', '', false ) ) ?></span>
<span class="entry-meta-sep">|</span>
<span class="entry-list-comm"><?php comments_popup_link( __( 'Yorum yok', 'wpbx' ), __( '1 Yorum', 'wpbx' ), __( '% Yorum', 'wpbx' ) ) ?></span>
</div>

<div class="entry-list-thumb">
<a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Oku %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>">
<?php
$entry_preview = get_post_custom_values("resim");
if ( is_array($entry_preview) ) { ?>
<img class="resim" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, 'resim',true) ?>&amp;w=258&amp;h=110&amp;zc=1" alt="<?php the_title(); ?>" />
<?php } else { ?>
<img class="resim" src="<?php bloginfo('template_directory'); ?>/images/image-blank-big.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</a>
</div>

<div class="entry-list-content">
<?php the_content_limit(150, ''); ?>
</div>

<p class="more-link">Kategorideki diger yazilar</p>
<ul>
<?php
// First post display is complete
$catFirstPost = false;
the_post() == $do_not_duplicate;

} // if ($catFirstPost)
?>

<li class="clearfix">
<span class="entry-star"><img src="<?php bloginfo('template_directory'); ?>/images/bullet-star.png" alt="#" /></span>
<h4><a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Oku %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>"><?php the_title(); ?></a></h4>
<div class="entry-meta">
<span class="entry-date"><?php unset($previousday); printf( __( '%1$s', 'wpbx' ), the_date( 'D, M j Y', '', '', false ) ) ?></span>
<span class="entry-meta-sep">|</span>
<span class="entry-comm"><?php comments_popup_link( __( 'Yorum yok', 'wpbx' ), __( '1 Yorum', 'wpbx' ), __( '% Yorum', 'wpbx' ) ) ?></span>
</div>
</li>

<?php
} // while (have_posts())
?>
</ul>
</div>

<?php
/*
If we've run out of posts to display, we need to close the "row"
*/
if (!$catLeftCol)
{
?>
</div><!-- .entry-row -->

<?php
}

// Toggle the alternator
$catLeftCol = !$catLeftCol;

} // end foreach category

// Account for odd number of posts
if (!$catLeftCol)
{
?>
</div><!-- .entry-row -->

<?php
}
?>

</div><!-- #list-categories -->

</div><!-- #content -->
</div><!-- #wrapper -->

<?php get_sidebar() ?>
<?php get_footer() ?>