<?php /* Global Post file. */ ?>
            

<?php

$img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'listing');
$img = $img[0];
if($img) {
$cart_image = $img;
} else {
$cart_image = get_template_directory_uri() . "/images/no-image.jpg";
}
?>
<div id="product">

<div class="post-content">
				
<div class="images">
<div class="big-thumb">
<span>
<?php
$imgb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'big-thumb');
$imgb = $imgb[0];
if($imgb) {
echo "<img src=\"" . $imgb . "\">";
} else {
echo "<img src=\"" . get_template_directory_uri() . "/images/no-image-big.jpg\">";
}
?>
<?php //the_post_thumbnail('big-thumb'); ?>
</span>
</div>
</div>

<div class="post-title">
	<h1><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e('Permanent Link to', 'cp'); ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
</div>

<div class="single-details">
<?php if( get_post_meta( get_the_ID(), 'product_details_1', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_1'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_1', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_2', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_2'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_2', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_3', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_3'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_3', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_4', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_4'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_4', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_5', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_5'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_5', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_6', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_6'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_6', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_7', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_7'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_7', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_8', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_8'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_8', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_9', true )) { ?>
<p><strong><?php echo get_option('cp_product_detail_9'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_9', true ); ?></p>
<?php } ?>
<?php if( get_post_meta( get_the_ID(), 'product_details_10', true )) { ?>
<p class="last"><strong><?php echo get_option('cp_product_detail_10'); ?>:</strong> <?php echo get_post_meta( get_the_ID(), 'product_details_10', true ); ?></p>
<?php } ?>

</div>
<br class="clear">
			<div class="post-entry">
			<h2 class="description">Opis</h2>
				<?php the_content(); ?>
			</div>

<div id="product-videos">

<?php if(get_post_meta( get_the_ID(), 'product_video_youtube', true )) {
$url = get_post_meta( get_the_ID(), 'product_video_youtube', true );
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
//$my_array_of_vars['v']; 
?>
<iframe class="youtube-player" type="text/html" width="450" height="271" src="http://www.youtube.com/embed/<?php echo $my_array_of_vars['v']; ?>" allowfullscreen frameborder="0"></iframe>
<?php } ?>

<?php if(get_post_meta( get_the_ID(), 'product_video_dailymotion', true )) {
$dailymotion_id = explode("/", get_post_meta( get_the_ID(), 'product_video_dailymotion', true ));
$dailymotion_id = explode("_", end($dailymotion_id));
?>
<iframe frameborder="0" width="450" height="271" src="http://www.dailymotion.com/embed/video/<?php echo $dailymotion_id[0]; ?>" allowfullscreen></iframe>
<?php } ?>



</div>

			
    <div id="share-it"><div id="share-it-icons"></div></div>
	
			<div class="clear"></div>



		</div><!--#END post-content -->

<?php wp_reset_query(); ?>
<div id="related-products">
<h1>Povezani proizvodi</h1>
<?php
query_posts('post_type=products&posts_per_page=12');
if ( have_posts() ) : while ( have_posts() ) : the_post();
$img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'product-listing');
$img = $img[0];
if($img) {
$cart_image = $img;
} else {
$cart_image = get_template_directory_uri() . "/images/no-image.jpg";
}
?>
        <div class="product">
            <div class="product-cover">
				<?php
				$img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'product-listing');
				$img = $img[0];
				if($img) {
				?>
				<a href="<?php echo get_permalink(); ?>"><img src="<?php echo $img; ?>" /></a>
				<?php } else { ?>
				<a href="<?php echo get_permalink(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/no-image.jpg"></a>
				<?php } ?>
            </div>
            <div class="product-content">
                <h1><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></h1>
            </div>
        </div>
	<?php
	endwhile;
	endif;
	?>
</div>
<?php wp_reset_query(); ?>
	</div><!-- #END post -->