<?php
 	if($pp_home_display_slide)
 	{
 		$featured_posts_arr = get_posts('numberposts='.$pp_slider_items.'&order=DESC&orderby=date&category='.$pp_featured_cat);
 	}
 
 	if(!empty($featured_posts_arr))
 	{
 ?>
 
<div id="slider_wrapper" class="fullslide"style="direction:ltr;">
 
  <div id="home_slider" class="flexslider">
		<ul class="slides">
		    <?php
		    	$slide_count = count($featured_posts_arr);
		    
		    	foreach($featured_posts_arr as $key => $featured_post)
		        {
		        	$image_url = '';
		        
		        	if(has_post_thumbnail($featured_post->ID, 'home_full_ft'))
		        	{
		        		$image_id = get_post_thumbnail_id($featured_post->ID);
		        		$image_url = wp_get_attachment_image_src($image_id, 'home_full_ft', true);
		        	}
		        					
		        	$hyperlink_url = get_permalink($featured_post->ID);
		    ?>
		    <li>
		    	<a href="<?php echo $hyperlink_url;?>">
		    		<img src="<?php echo $image_url[0]; ?>" alt="<?php echo $featured_post->post_title; ?>"/>
		    		
		    		<div id="caption<?php echo $key; ?>" class="flexslider_caption" <?php if($key == 0) { echo 'style="display:block"'; } ?>>
    					<div class="flexslider_excerpt"style="direction:rtl;">
    						<h4 style="font-family:BYekan;"><?php echo $featured_post->post_title; ?></h4>
    						<?php echo pp_substr(strip_tags(strip_shortcodes($featured_post->post_content)), 200); ?>
    					</div>
    				</div>
		    	</a>
		    </li>
		    
		    <?php
		        }
		    ?>
		</ul>
	</div>
</div>
	
<script type="text/javascript"> 
<?php
	$pp_slider_timer = get_option('pp_slider_timer');
	if(empty($pp_slider_timer))
	{
		$pp_slider_timer = 5;
	}
?>
$j(window).load(function() {
    $j('#slider_wrapper .flexslider').flexslider({
    	animation: "slide",
    	slideDirection: 'horizontal',
    	slideshowSpeed: <?php echo $pp_slider_timer*1000; ?>,
    	slideshow: true,
    	start: function(slider) {
       		var slide_control_width = 100/<?php echo $slide_count; ?>;
    		$j('#slider_wrapper .flex-control-nav li').css('width', slide_control_width+'%');
      	}
    });
});</script>
 
 <?php
 	} 
 ?>