<?php
/**
 * @version	$Id$
 * @package	IT_Theme_Framework
 * @author	 InnoThemes Team <support@innothemes.com>
 * @copyright  Copyright (C) 2012 InnoThemes.com. All Rights Reserved.
 * @license	GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.innothemes.com
 */
get_header();
?>
<div id="it-body">
	<div id="it-content-top">
		<?php IT_Theme_Render::promo(); ?>
	</div><!--End div#it-content-top-->
	<div id="it-content">
		<?php
		$loop = new WP_query(
			array(
				'post_type'      => 'portfolio',
				'posts_per_page' => -1,
				'orderby'        => 'ASC'
			)
		);

		$arr_content = array();
		while( $loop->have_posts() ) :
			$loop->the_post();

		$url 	= get_post_meta($post->ID, "url", true);
		$urlimg	= get_post_meta($post->ID, 'urlimg', true);
		$src 	= wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), true, '' );
		$str 	= '';

		if( $url != '' ) {
			$str .= '<li class="it-project"><div class="it-project-thumb"><a class="fancybox" href="' . $urlimg . '"><img src="' . $url . '" />';
			$str .= '<span class="mark"></span>';
			$str .= '</a><span class="portfolio-cat">';
			$str .= get_the_title();
			$str .= '</span></div></li>';
		} else {
			$str .= '<li class="it-project"><div class="it-project-thumb"><a class="fancybox" href="' . $src[0] . '">';
			$str .= get_the_post_thumbnail( $page->ID, 'portthumb' );
			$str .= '<span class="mark"></span>';
			$str .= '</a><span class="portfolio-cat">';
			$str .= get_the_title();
			$str .= '</span></div></li>';
		}
		$arr_content[] = $str;

		endwhile;  wp_reset_query();
		?>
		<ul id="it-recent-project">
			<link href="<?php echo IT_THEME_URI . '/assets/3rd-party/fancybox/jquery.fancybox.css' ?>" rel="stylesheet">
			<script src="<?php echo IT_THEME_URI . '/assets/3rd-party/fancybox/jquery-1.10.1.min.js' ?>"></script>
			<script src="<?php echo IT_THEME_URI . '/assets/3rd-party/fancybox/jquery.fancybox.js' ?>"></script>
			<script type="text/javascript">
				$(document).ready(function() {
					$("a.fancybox").fancybox();
				});
			</script>

			<h3 class="it-title-project">
				<?php _e( 'All Projects', IT_THMFW_TEXTDOMAIN ); ?>
				<span class="it-title-sub"><?php _e( 'This is just an example for a photographer portfolio website, you can use this portfolio for other purposes to showcase your work.', IT_THMFW_TEXTDOMAIN ); ?></span>
			</h3>
			<div class="it-separate"></div>

			<?php echo implode( "", $arr_content ); ?>

		</ul><!--End ul#it-recent-project-->
	</div><!--End div#it-content-->
	<div id="it-content-bottom">
		<?php get_sidebar( 'bottom' ); ?>
	</div><!--End div#it-content-bottom-->
</div><!--End div#it-body-->
<?php get_footer(); ?>
