<?php header("content-type: application/x-javascript"); ?> 

<?php
define('WP_DEBUG', false);
@ini_set('log_errors','On'); 
@ini_set('display_errors','Off'); 
require_once( '../../../../wp-load.php' );
?>

<?php
//Display portfolio items
$pp_portfolio_items = get_option('pp_portfolio_items');
if(empty($pp_portfolio_items))
{
    $pp_portfolio_items = 12;
}

$paged = 1;
if(isset($_GET['paged']))
{
	$paged = $_GET['paged'];
}

$temp = $wp_query; 
$wp_query = null; 
$wp_query = new WP_Query(); 
$wp_query->query('showposts='.$pp_portfolio_items.'&post_type=portfolios&orderby=menu_order&order=ASC'.'&paged='.$paged);

//Check featured content display setting
$pp_portfolio_enable_feat = get_option('pp_portfolio_enable_feat');

//Get AJAX portfolio items
$ajax_portfolios_arr = array();

while ($wp_query->have_posts()) : $wp_query->the_post(); 

	$portfolio_type = get_post_meta(get_the_ID(), 'portfolio_type', true);

	if($portfolio_type == 'AJAX Portfolio Content')
	{
		$portfolio_ID = get_the_ID();
    	$portfolio_title = get_the_title();
    	$portfolio_content = get_the_content();
	
		$ajax_portfolios_arr[] = array(
			'ID' => $portfolio_ID,
			'title' => $portfolio_title,
			'content' => $portfolio_content,
		);
	}

endwhile;

$count_ajax_items = count($ajax_portfolios_arr);

foreach($ajax_portfolios_arr as $key => $portfolio_item)
{
	//Get portfolio gallery ID
    $portfolio_gallery_id = get_post_meta($portfolio_item['ID'], 'portfolio_gallery_id', true);
    
    if(!empty($pp_portfolio_enable_feat))
    {
		if(!empty($portfolio_gallery_id))    
		{
			//Get portfolio slider settings
    		$pp_portfolio_slider_timer = get_option('pp_portfolio_slider_timer');
    		if(empty($pp_portfolio_slider_timer))
    		{
    		    $pp_portfolio_slider_timer = 5;
    		}
    		
    		$pp_portfolio_slider_autoplay = get_option('pp_portfolio_slider_autoplay');
?>
$j(document).ready(function(){
    $j('#portfolio_slider_<?php echo $portfolio_item['ID']; ?>').flexslider({
    	animation: "fade",
    	<?php
    	if(empty($pp_portfolio_slider_autoplay))
    	{
    	?>
    	slideshow: false,
    	<?php
    	}
    	?>
    	controlNav: true,
    	slideshowSpeed: <?php echo $pp_portfolio_slider_timer*1000; ?>
    });
});
<?php
		}
	}
}
?>