<?php
global $picart;  
$ImageUrl[] = esc_url(get_template_directory_uri() ."/images/slides/slider1.jpg");
$ImageUrl[] = esc_url(get_template_directory_uri() ."/images/slides/slider2.jpg");
$ImageUrl[] = esc_url(get_template_directory_uri() ."/images/slides/slider3.jpg");
$ImageUrl[] = esc_url(get_template_directory_uri() ."/images/slides/slider4.jpg");
$ImageUrl[] = esc_url(get_template_directory_uri() ."/images/slides/slider5.jpg"); 

for($i=1; $i<=10; $i++){
	if(!empty($picart['slide_image'.$i])){
		$imgArr[] = $i;
	}
}
?>
<section id="home_slider">
  <div class="slider-main">
    <?php if(!empty($imgArr)){ ?>
    <div class="slider-wrapper theme-default">
      <div id="slider" class="nivoSlider">
        <?php
			   foreach($imgArr as $val){
				?>
        <img src="<?php echo $picart['slide_image'.$val]; ?>" data-thumb="<?php echo $picart['slide_image'.$val]; ?>" alt="" title="<?php echo esc_attr('#htmlcaption'.$val) ; ?>" />
        <?php } ?>
      </div>
      <?php foreach($imgArr as $val)	{ ?>
      <div id="htmlcaption<?php echo esc_attr($val); ?>" class="nivo-html-caption">
        <?php if(!empty($picart['slide_title'.$val])){ ?>
        <div class="title"><?php echo $picart['slide_title'.$val]; ?></div>
        <?php } ?>
        <?php if(!empty($picart['slide_desc'.$val])){ ?>
        <div class="slidedesc"><?php echo $picart['slide_desc'.$val]; ?></div>
        <?php } ?>
        <?php if(!empty($picart['slide_btn'.$val])){ ?>
        <div class="slidebtn"><a class="slidelink" href="<?php echo $picart['slide_link'.$val]; ?>"><?php echo $picart['slide_btn'.$val]; ?></a></div>
        <?php } ?>        
      </div>
      <?php } ?>
    </div>
    <?php }
	else { ?>
    <div class="slider-wrapper slide-temp theme-default">
      <div id="slider" class="nivoSlider">
        <?php foreach($ImageUrl as $val) { ?>
        <img src="<?php echo $val; ?>" data-thumb="<?php echo $val; ?>" alt="" title="#htmlcaption" />
        <?php } ?>
      </div>
      <?php for($i=1; $i<=5; $i++)	{ ?>
      <div id="htmlcaption" class="nivo-html-caption">
        <div class="title"><?php echo 'AWESOME PHOTOGRAPHY THEME'; ?></div>
        <div class="slidedesc"><?php echo 'Praesent elementum nisl ac augue pretium, et feugiat neque malesuada. 
Mauris luctus tellus a nisi consectetur molestie.'; ?></div>
        <div class="slidebtn"><a href="#"><?php echo 'Read More';?></a></div>
      </div>
      <?php } ?>
    </div>
    <?php } ?>
  </div>
</section>
