<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);
?>

<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link href="<?php echo G5_PLUGIN_URL?>/Diagonal-Slider-jQuery-Cross-Slider/theme.css" rel="stylesheet" type="text/css" media="screen">
<link href="<?php echo G5_PLUGIN_URL?>/Diagonal-Slider-jQuery-Cross-Slider/cross-slider.css" rel="stylesheet" type="text/css" media="screen">


<div id="slides-collection">
    <?php
    $max_width = $max_height = 0;
    for ($i=0; $row=sql_fetch_array($result); $i++)
    {
        if($i%2==0) {
            echo '<div class="slide">'.PHP_EOL;
        }
        //print_r2($row);
        // 테두리 있는지
        $bn_border  = ($row['bn_border']) ? ' class="sbn_border"' : '';;
        // 새창 띄우기인지
        $bn_new_win = ($row['bn_new_win']) ? ' target="_blank"' : '';

        $bimg = G5_DATA_PATH.'/banner/'.$row['bn_id'];
        if (file_exists($bimg))
        {
            $banner = '';
            $size = getimagesize($bimg);

            if($size[2] < 1 || $size[2] > 16)
                continue;

            if($max_width < $size[0])
                $max_width = $size[0];

            if($max_height < $size[1])
                $max_height = $size[1];

            if ($row['bn_url'][0] == '#')
                $banner .= '<a href="'.$row['bn_url'].'">';
            else if ($row['bn_url'] && $row['bn_url'] != 'http://') {
                $banner .= '<a href="'.G5_SHOP_URL.'/bannerhit.php?bn_id='.$row['bn_id'].'&amp;url='.urlencode($row['bn_url']).'"'.$bn_new_win.'>';
            }
            echo $banner;
            $background_image = G5_DATA_URL.'/banner/'.$row['bn_id'];
            if($i%2==1) {
                $class = 'right-half';
            } else {
                $class = 'left-half';
            }
            ?>
                <div class="<?php echo $class?>" style="background-image:url(<?php echo $background_image?>);">
                    <div class="slide-content">
                        <h2><?php echo $row['bn_alt']?></h2>
                        <!-- <p>Aladdin, an urchin, falls in love with Princess Jasmine. He cannot marry her as she can only marry a prince.</p> -->
                    </div>
                </div>
            <?php
            if($banner)
                echo '</a>'.PHP_EOL;
        }
        if($i%2==1) {
            echo '</div>'.PHP_EOL;
        }
    }
    ?>

    <div id="nav">
        <a href="#" class="next-slide">Next Slide</a>
        <a href="#" class="prev-slide">Prev Slide</a>
    </div>

</div>


<!-- <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> -->
<script src="<?php echo G5_PLUGIN_URL?>/Diagonal-Slider-jQuery-Cross-Slider/cross-slider.js"></script>
<script>
$(document).ready(function() {
$("#slides-collection").crossslider({
    containerWidth: 1170
});
});
</script>