<script src="<?php echo get_template_directory_uri(); ?>/js/scriptPortfolio.js" type="text/javascript"></script>

<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery("a#example1").fancybox();
	}); 
	
</script>
<?php

if ( have_posts() ) while ( have_posts() ) : the_post();

   	$portfolioType = get_post_meta($post->ID, 'portfolio_type_selected' , true); 
	$portfolioDate = get_post_meta($post->ID, 'portfolio_date' , true); 
	$portfolioClient = get_post_meta($post->ID, 'portfolio_client' , true); 
	$portfolioURL = get_post_meta($post->ID, 'portfolio_url' , true);
	$portfolioABSTRACT = get_post_meta($post->ID, 'portfolio_abstract' , true);
	$portfolioEMBED = get_post_meta($post->ID, 'portfolio_embed' , true);
	$portfolioTWITTER = get_post_meta($post->ID, 'portfolio_twitter' , true);

?>
<div class="item-desc fl">					
					<a href="" class="ajax-back" onclick="return backToPorfolios();"><span><?php _e('menu','pego_tr'); ?></span></a>
					
					<h2><?php  the_title(); ?></h2>
					<?php
						$terms = get_the_term_list( $post->ID,'portfolio_categories', '', ', ');
						$terms = strip_tags( $terms );
					?>
					<p><?php echo $terms; ?></p>
					<div class="dotted-line"></div>
					<p class="item-text"><?php echo get_the_content(); ?></p>
					<?php					
					if (!empty($portfolioURL))
					{
						?>
					<div class="url-stuff fl" style="margin-top: 0;margin-right:5px;">
						<a href="<?php echo $portfolioURL; ?>" target="_blank">Controverse</a>
					</div>
					<?php 
					}
					?>
					<?php					
					if (!empty($portfolioABSTRACT))
					{
						?>
					<div class="url-stuff fl" style="margin-top: 0;margin-right:5px;">
						<a href="<?php echo $portfolioABSTRACT; ?>" target="_blank">Abstract</a>
					</div>
					<?php 
					}
					?>
					<?php					
					if (!empty($portfolioClient))
					{
						?>
					<div class="url-stuff fl" style="margin-top: 0;margin-right:5px;margin-bottom:10px;">
						<a href="<?php echo $portfolioClient; ?>" target="_blank">Site de l'intervenant</a>
						
					</div>
					<?php 
					}
					?>


					<?php					
					if (!empty($portfolioTWITTER))
					{
					?>
					<div class="url-stuff fl" style="margin-top: 10px;margin-right:5px;margin-bottom:10px; width:100%;">
						<a href="https://twitter.com/<?php echo $portfolioTWITTER; ?>" target="_blank">@<?php echo $portfolioTWITTER; ?></a>
					</div>
					<?php 
					}
					?>

					<?php					
					if (!empty($portfolioEMBED))
					{
					?>
					<div class="url-stuff fl" style="margin-top: 10px;margin-right:5px;margin-bottom:10px; width:100%;">
						<?php echo $portfolioEMBED; ?>
					</div>
					<?php 
					}
					?>



				</div>
				
	  <div class="col-570 fl">
	  <?php
		
		if($portfolioType == 'Image') 			
		{
			$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
			?>
			<a id="example1" class="lightbox-image mw570"  href="<?php echo $image[0]; ?>"><img src="<?php echo $image[0]; ?>"  alt="" /></a>
			<?php					
		}
		// end if image
	    
	   //video portfolio
	   if($portfolioType == 'Video') 		
		{
	 		$video_url= get_post_meta($post->ID, 'portfolio_video_url' , true);   
	 		if(!empty($video_url)) 
	 		{
	 			echo '<figure>'.$video_url.'</figure>';
	 		}						
	 	}
	 	// end if video
	 	
	   //slideshow portfolio
	if($portfolioType == 'Slideshow') 		
		{	
				$attachments = get_children(array('post_parent' => $post->ID,
					                        'post_status' => 'inherit',
				                           'post_type' => 'attachment',
					                        'post_mime_type' => 'image',
					                        'order' => 'ASC',
					                        'orderby' => 'menu_order ID'));
											
																				
					 		
									echo '<div id="slides1">';
									echo '<div class="slides_container">';
									
									foreach($attachments as $att_id => $attachment) {
										$full_img_url = wp_get_attachment_url($attachment->ID);
										echo '<div class="slide">';
										?>
										<a href="#"><img src="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php echo get_image_path($full_img_url); ?>&h=320&w=570&zc=1" title="" alt=""></a>
										<?php
										echo '</div>';
								} //end foreach
								echo '</div>';
								echo '</div>';									
	 	}
 	?>
				</div>
				<div class="clearfix"></div>             
<?php
endwhile;
?>    

                    
