<?php
/* Load and prepare slides  */

$query_string = 'post_type=jawslides&order=ASC&orderby=menu_order&&nopaging=true';
if ($gantry->get('slider-jawslides') != 'jawall')
    $query_string .= "&slideshows=" . $gantry->get('slider-jawslides') . "";

$query_string2 = $query_string."&limit=1";

$query2 = new WP_Query($query_string2);


if ($query2->have_posts()) { ?>

    
    <script>
        jQuery(document).ready(function($){
            $("a[rel^='prettyPhoto']").prettyPhoto();
        });
    </script>

    <div id="featured_home" class="clearfix"> 
        <div class="slider_shadow">

            <?php 
           
            global $gantry;

            
            ///// nwe
            
            
            $slides = 0;
            $pttyPhoto='';
            while($query2->have_posts()) {
                    $query2->the_post();
                   
                    if (get_post_meta( get_the_id(), 'jaw_slide_linktype', true) == 1) {
                        $pttyPhoto = 'rel="PrettyPhoto[Gallery]"';
                    }
                        
                    $image = wp_get_attachment_image_src ( get_post_thumbnail_id ( get_the_id()), 'single-post-thumbnail' );
                    
                        
                        if (get_post_meta( get_the_id(), 'jaw_slide_type', true) == 1) {
                            $pttyPhoto = 'rel="PrettyPhoto[Gallery]"';
                        }?>
                            <div class="post_info_holder clearfix">
                                <?php
                                $tmpAlt = explode('<br>', $query2->post->post_content);
                                $alt = '';
                                $countAlt = count($tmpAlt);
                                $index = 1;
                                foreach ($tmpAlt as $value) {
                                    if ($countAlt > $index) {
                                        $alt .= '<span class="category_alt">' . $value . '</span><br>';
                                    } else {
                                        $alt .= '<span class="category_alt">' .$value . '</span>';
                                    }
                                    $index++;
                                }
                                ?>
                                <div class="post_category" id="slider_post_cat"><a href="<?php echo get_post_meta( get_the_id(), 'jaw_slide_link', true); ?>" title="View all posts in Web Design" <?php echo $pttyPhoto; ?>><?php echo $alt; ?></a></div>
                            </div><!--  END "post_info_holder"  //--> 
                          
            <div id="slider_freshcubes" style="background-image: url('<?php echo get_template_directory_uri().'/scripts/timthumb.php?src=' . $image[0] . '&amp;w=594&amp;h=350&amp;zc=1'; ?>')">
                <?php
                $c_w = 149;
                $c_h = 118;
                for ($w = 0; $w < 4; $w++) {
                    for ($h = 0; $h < 3; $h++) {
                        echo '<div class="fresh_cube" id="fresh_cube_' . $w . '_' . $h . '" style="left:' . ($w * 149) . 'px; top:' . ($h * 118) . 'px; background-position:' . ($w * -149) . 'px ' . ($h * -118) . 'px; background-image: url("'.get_template_directory_uri().'/scripts/timthumb.php?src=' . $image[0] . '&amp;w=594&amp;h=350&amp;zc=1");"></div>';
                    }
                }?>
                
                <?php break;} // while ?> 
               
                <ul id="fresh_cube_data">
                    <?php
                    $query = new WP_Query($query_string);
                    $id_object = 0;
                    $counter = 0;
                    while ($query->have_posts()) {
                        $query->the_post();
                        $tmpAlt = explode('<br>', $query->post->post_content);
                        $image = wp_get_attachment_image_src ( get_post_thumbnail_id ( $query->post->ID ), 'single-post-thumbnail' );
                        $altRow = '';
                        $countAlt = count($tmpAlt);
                        $index = 1;

                        foreach ($tmpAlt as $value) {
			  if (strlen($value)>0)
                            if ($countAlt > $index) {
                                $altRow .= '<span class="category_alt">' . $value . '</span><br>';
                            } else {
                                $altRow .= '<span class="category_alt">' . $value . '</span>';
                            }
                            $index++;
                        }
                        echo '<li class="fresh_cube_image_' . $id_object . '" >';
                        echo '<img src="'.get_template_directory_uri().'/scripts/timthumb.php?src=' . $image[0] . '&amp;w=594&amp;h=350&amp;zc=1" />'; //echo '<span class="img_src">'.$row['image_url'].'</span>';                            
                        echo '<span class="transition" title="' . get_post_meta($query->post->ID, 'jaw_slide_transition', true) . '">

                    <div class="post_category" id="slider_post_cat"><a href="' . get_post_meta($query->post->ID, 'jaw_slide_url', true) . '" title="View all posts in Web Design" rel="category">' . $altRow . '</a></div>

              </span>';
                        if (get_post_meta($query->post->ID, 'jaw_slide_linktype', true) == 1) {
                            echo '<span class="ligthbox" title="' . get_post_meta($query->post->ID, 'jaw_slide_linktype', true) . '">' . $image[0] . '</span>';
                        } else {
                            echo '<span class="ligthbox" title="' . get_post_meta($query->post->ID, 'jaw_slide_linktype', true) . '">' . get_post_meta($query->post->ID, 'jaw_slide_link', true) . '</span>';
                        }
                        ?>
                        <div class="slider_tit" style="display:none"><?php echo $query->post->post_title; ?></div>
                        <a class="slider_img" title="<?php echo get_post_meta($query->post->ID, 'jaw_slide_linktype', true); ?>"  style="display:none" href="<?php echo get_template_directory_uri(); ?>/scripts/timthumb.php?src=<?php echo $image[0] . $fixed_height; ?>&amp;w=594&amp;zc=1"></a>
                        <a class="slider_desc" title="<?php echo $counter; ?>" style="display:none" href="<?php echo get_post_meta($query->ID, 'jaw_slide_link', true); ?>"><?php echo $query->post->post_content; ?></a><?php
                echo '</li>';
                $counter++;
                $id_object++;
            
                } ?>
                </ul>
                <div class="slide_left"></div>
                <div class="slide_right"></div>
                <div class="slide_info">
                    <!--     <div class="slide_desc">
                               <h4 class="slide_title"><?php echo $alt; ?></h4>
                           <p><?php echo $query->post_content; ?></p>
                         </div>           -->
                </div>
            </div><!-- END "div.slider_fresh" -->
        </div>
    </div>
    <?php 
    
    $slides ++; ?> 
    
   
<?php } else {  // No slieds  ?>
    <div id="featured_home" class="clearfix"> 
        <div class="slider_shadow">
            <div class="warning">
    <?php echo __("You don't have any slides to display. Please, goto the administration and add slide and setup slideshow category in the template administration.", "kaula"); ?>
            </div>
        </div>
    </div>
<?php } 

 ?>