<?php
$skip_sets=true;
  include ("includes/header.php");


?>
<?php
        $item_num=$_GET['_i'];
        set_str('item_num',$item_num);
        do_perform('WSLBC0;read_wsitem');
        do_perform('WSLBS0;lookup_price');
        do_perform("WSLBS0;get_cust_info");
        $item_desc = get_str('item_desc1');
        $mainImg = get_str('raw_item_pic');
?>
    <div class="row productsdetail">

        <div id="mainItemDetail" class="col-md-9">
            <div class="rhs-breadcrumb tbpad">HOME &gt;
            </div>

            <style>
                .controlouter {
                    border: 1px solid black;
                    background-color: #E6E7E8;
                    padding: 10px;
                    padding-top: 5px;
                    padding-bottom: 5px;
                    margin-bottom: 20px;
                    margin-top: 20px;
                }
                .controlhead {
                    background-color: black;
                    color: white;
                    text-align: center;
                    min-height: 20px;
                    padding: 5px;
                    margin-bottom: 10px;
                    margin-top: 10px;
                    font-weight: bold;
                    background-image: url(/images/expandedCH.png);
                    background-position: 4px center;
                    background-repeat: no-repeat;
                    cursor: pointer;
                }
                .controlhead.collapsed {
                    background-image: url(/images/collapsedControlHead.png);
                    background-position: 4px center;
                    background-repeat: no-repeat;
                    cursor: pointer;
                }
                .controlhead.nocollapse {
                    background-image: none;
                    cursor: default;
                }
                .controlbody {
                    background-color: white;
                    color: black;
                    border: 1px solid black;
                    margin-bottom: 10px;
                    cursor: pointer;
                }
                .controlexpanded {
                    background-image: url(/images/expandedControlHead.png);
                    background-position: 4px center;
                    background-repeat: no-repeat;
                    height: 20px;
                    width: 20px;
                    float: left;
                    margin-right: 5px;
                    cursor: pointer;
                }
                .controlexpanded.collapsed {
                    background-image: url(/images/collapsedCH.png);
                }
                .controlbody.collapsed {
                    display: none;
                }
                .controlcheck {
                    padding-left: 7px;
                    padding-top: 5px;
                }
                .controlcheck.collapsed {
                    display: none;
                }
                .controlcheck label {
                    display: block;
                }
            </style>


    <style>
        .productsview, .productsdetail {
            font-size: 12px;
        }
        .rhs-search input {
            border: 1px solid red;
            width: 50%;
        }
        .tbpad {
            padding-top: 10px;

        }
        .producttable {
            margin-top: 30px;
        }
        .table-striped tbody tr:nth-of-type(even) {
            background-color: rgba(0,0,0,.05);
        }
        .table-striped tbody tr:nth-of-type(odd) {
            background-color: transparent;
        }
        .table th {
            padding-top: 0px;
            padding-bottom: 0px;
        }

    </style>

            <style>
                .producttable tbody > tr > td:nth-of-type(1) img {
                    border: 1px solid grey;
                }
                .producttable tbody > tr > td:nth-of-type(2) {
                    position: relative;
                }
                .producttable tbody > tr > td:nth-of-type(2) > div:nth-of-type(1) {
                    font-size: 18px;
                }
                .producttable tbody > tr > td:nth-of-type(2) > div:nth-of-type(3) {
                    position: absolute; bottom: 0; width: 100%;
                }

                .producttable tbody > tr > td:nth-of-type(3) {
                    text-align: center;
                }
                .producttable tbody > tr > td:nth-of-type(4) img {
                    margin: auto;
                    display: block;
                }
                .producttable tbody > tr > td:nth-of-type(5) {
                    text-align: center;
                }
                .producttable tbody > tr > td:nth-of-type(6) {
                    text-align: center;
                }

                .red {
                    color: red;
                }
                .atcwidget {
                    position: relative;
                }
                .atcwidget div {
                    position: absolute;
                    text-align: center;
                }
                .atcwidget div:nth-of-type(1) {
                    left: 0;
                    top: 0;
                    height: 20px;
                    width: 30%;
                    border: 1px solid grey;
                    cursor: pointer;

                }
                .atcwidget div:nth-of-type(2) {
                    left: 30%;
                    top: 0;
                    height: 20px;
                    width: 40%;
                    border: 1px solid grey;
                }
                .atcwidget input {
                    width: 100%;
                    height: 100%;
                    text-align: center;

                }
                .atcwidget div:nth-of-type(3) {
                    left: 70%;
                    top: 0;
                    height: 20px;
                    width: 30%;
                    border: 1px solid grey;
                    cursor: pointer;
                }
                .atcwidget img {
                    width: 100%;
                    height: auto;
                }

                .blueprice {
                    color: #00AEEF;
                }

                .productsdetail .mainimage img {
                    border: 1px solid black;
                    width: 100%;
                    height: auto;
                    min-height: 50px;
                }
                .productsdetail .imgthumb img {
                    border: 1px solid black;
                    width:100%;
                    height: auto;
                    cursor: pointer;
                }

                .productsdetail .detailinput, .productsdetail .detailselect {
                    width: 100%;
                }
                .spacing2 {
                    padding-top: 10px;
                    padding-bottom: 10px;
                }
                .spaceleft {
                    margin-left: 10px;
                }
                .continueShoppingButton {
                    display: block;
                    border: 1px solid black;
                    width:  206px;
                    color: black;
                    text-align: center;
                    font-size: 16px;
                    float: right;
                }
                .continueShoppingButton:hover {
                    color: black;
                    text-decoration: none;
                }

                .controlhead.bodystyle {
                    margin-bottom: 0;
                    text-align: left;
                    padding-left: 28px;
                }
                .controlbody.bodystyle {
                    padding: 10px;
                    background-color: #ebebeb;
                }


            </style>

            <table class="table table-striped producttable">
                <thead>
                    <tr style="background-color: #D1D3D4;">
                        <th scope="col">&nbsp;</th>
                        <th scope="col">DESCRIPTION</th>
                        <th scope="col" style="text-align: center;">IN STOCK</th>
                        <th scope="col" style="text-align: center;">LIST PRICE</th>
<?php
                        if ($auth) {
                          print '<th scope="col" style="text-align: center;">YOUR PRICE</th>
                          <th scope="col" style="text-align: center;">QUANTITY</th>';
                        }
?>
                    </tr>
                </thead>
                <tbody>
                <tr>

<?php
                do_perform('WSLBC0;read_wsitem');
                do_exec('imagelist$=cvs(cvs(cvs(wsitem.image1$,3)+";"+cvs(wsitem.image2$,3)+";"+cvs(wsitem.image3$,3)+";",32:";"),3)');
                do_exec('numimages=pos(";"=imagelist$,1,0)');
                $numimages = get_num('numimages');
                $imagelist = get_str('imagelist');
                if ($numimages>=1) {
                  $pos = strpos($imagelist,';');
                  $image1 = substr($imagelist,0,$pos);
                  $imagelist = substr($imagelist,$pos+1);
                }
                if ($numimages>=2) {
                  $pos = strpos($imagelist,';');
                  $image2 = substr($imagelist,0,$pos);
                  $imagelist = substr($imagelist,$pos+1);
                }
                if ($numimages>=3) {
                  $pos = strpos($imagelist,';');
                  $image3 = substr($imagelist,0,$pos);
                  $imagelist = substr($imagelist,$pos+1);
                }

                do_perform('WSLBS0;lookup_price');
                $mainImg=get_str('item_pic');
                $item_num=get_str('item_num');
                $desc=get_str('item_desc1');
                $desc_url=url_clean($desc);
                do_exec('whse_list$=gbl_whse_list$');
                do_exec('ws.loop=0');
                $loop_flag=0;
                $loop='WSLBC0;item_whse_loop';
                $available="0";
                while (do_loop($loop_flag,$loop)) {
                  $available+=get_str('whse_available_qty');
                }
                do_exec('tot_available_qty$=str(max(num(tot_available_qty$),0))');
                if (!$auth) {
                  if ($available>0) {
                    $available='YES';
                  } else {
                    $available='NO';
                  }
                }
                $desc_class = "itemDesc";
                $desc_len = strlen($desc);
                if ($desc_len >= 20 ) {
                  $desc_class = "itemDescSmall";
                }

                    if (strlen($mainImg)===0) {
                      $mainImg = $item_num.".jpg";
                    }
                    print '<td><img src="/showimg.php?sz=gd&image='.$mainImg.'" alt=""></td>'; 
?>
                    <td style="position: relative;">
                        <div>
                            <?php echo $item_num; ?>
                        </div>
                        <div>
                            <span class="<?php echo $desc_class; ?>"><?php echo $desc;?></span>
                        </div>
                    </td>
                    <td>
                        <div><?php echo $available; ?></div>
                    </td>
<?php
                      do_exec('default_price$="$"+default_price$');
                      do_exec('list_price$="$"+list_price$');
                    if ($auth) {
?>
                    <td>
                        <div style="text-align:center;"><?php echo get_str('list_price'); ?></div>
                    </td>
                    <td>
                        <div><span class="blueprice"><?php echo get_str('default_price'); ?></span></div>
                    </td>
<?php
                    } else {
?>
                    <td style="text-align:center;">
                        <?php echo get_str('list_price'); ?>
                    </td>
<?php
                    }
                    if ($auth) {
?>
                    <td>
                        <div class="atcwidget">
                          <select id="<?php echo $item_num; ?>-qty" name="add_qty">
<?php
                          for ($x = 1; $x<=50; $x++) {
                            print '<option value="'.$x.'">'.$x.'</option>';
                          }
?>
                         </select>&nbsp;&nbsp;<?php echo get_str('price_uom'); ?>
                            <br><br>
                            <a href="#" class="addToCartLink" id="<?php echo $item_num;?>-add" onclick="addToCart(this.id);">ADD TO
CART</a>
                        </div>
                    </td>
<?php
                    }
?>
                </tr>
                </tbody>
            </table>



            <div class="row">
                <div class="col-sm-5">
                    <div class="mainimage">
<?php
                      print '<a href="'.$req_home.'/showimg.php?sz=fl&image='.$mainImg.'" target="_blank"><img id="mainimage" src="/showimg.php?sz=id&image='.$mainImg.'" alt=""></a>';
?>
                    </div>
                    <div class="row" style="padding-top: 20px;">
<?php
                      if (!empty($image1)) { 
                      print '
                        <div class="col-sm-3 itemThumbs">
                            <div class="imgthumb">
                                <img src="/showimg.php?sz=si&image='.$mainImg.'" alt="">
                            </div>
                        </div>';
                      print '
                        <div class="col-sm-3 itemThumbs">
                            <div class="imgthumb">
                                <img src="/showimg.php?sz=si&image='.$image1.'" alt="">
                            </div>
                        </div>';
                      }
?>
<?php
                      if (!empty($image2)) { 
                      print '
                        <div class="col-sm-3 itemThumbs">
                            <div class="imgthumb">
                                <img src="/showimg.php?sz=si&image='.$image2.'" alt="">
                            </div>
                        </div>';
                      }
?>
<?php
                      if (!empty($image3)) { 
                      print '
                        <div class="col-sm-3 itemThumbs">
                            <div class="imgthumb">
                                <img src="/showimg.php?sz=si&image='.$image3.'" alt="">
                            </div>
                        </div>';
                      }
?>

                    </div>
<?php
?>
                </div>
                <div class="col-sm-4">
<?php
  /*
?>
                    <div style="background-color: #E7E7E8">
                        <div class="row spacing2">
                            <div class="col-sm-6 spaceleft">
                                Shipping To:
                            </div>
                            <div class="col-sm-4">
                                <input type="text" class="detailinput" />
                            </div>
                        </div>
                        <div class="row spacing2">
                            <div class="col-sm-6 spaceleft">
                                Shipping Options:
                            </div>
                            <div class="col-sm-4">
                                <select name="" id="" class="detailselect">
                                    <option value="">Ground</option>
                                    <option value="">1-Day</option>
                                    <option value="">2-Day</option>
                                    <option value="">3-Day</option>
                                    <option value="">International</option>
                                </select>
                            </div>
                        </div>
                        <div class="row spacing2">
                            <div class="col-sm-8 spaceleft">
                                Get it by Thurs, May 3 with Ground Shipping.
                            </div>
                        </div>

                    </div>
<?php
 */
?>
<?php
 /*
?>

                    <div style="background-color: #F3F3F4; margin-top: 20px;">
                        <div class="row spacing2">
                            <div class="col-sm-12" style="text-align: right;">
                                <a href="#"><img src="/images/0001632941.png"></a>
                            </div>
                        </div>
                    </div>
<?php
 */
?>

                    <div style="margin-top: 20px;">
                        <div class="row spacing2">
                            <div class="col-sm-12">
<?php
$cs = isset($_COOKIE["_cs"]) ? $_COOKIE["_cs"] : '/';
?>
                                <a href="<?php echo $cs; ?>" class="continueShoppingButton">CONTINUE SHOPPING</a>
                            </div>
                        </div>
                    </div>


                </div>
                <div class="col-sm-3">&nbsp;</div>
            </div>
            <script>
                $(document).ready(function(){
                    $(".imgthumb img").click(function(){
                        var imgsrc = '';
                        var oldsrc = '';
                        imgsrc = $(this).attr('src');
                        imgsrc = imgsrc.replace('sz=si','sz=id');
                        $("#mainimage").attr("src", imgsrc);
                      
                    });



        $(".controlhead").click(function(){
            if ($(this).hasClass("nocollapse")) return;
            if ($(this).hasClass("collapsed")) {
                $(this).removeClass("collapsed");
                $(this).next().removeClass("collapsed");
            } else {
                $(this).addClass("collapsed");
                $(this).next().addClass("collapsed");
            }
        });
        $(".controlexpanded").click(function(){
            if ($(this).hasClass("collapsed")) {
                $(this).removeClass("collapsed");
                $(this).parent().find(".controlcheck").removeClass("collapsed");
            } else {
                $(this).addClass("collapsed");
                $(this).parent().find(".controlcheck").addClass("collapsed");
            }
        });

                });
  function addToCart (id) {
      var item_num = id.substr(0,id.length-4);
      var add_qty = $('#'+item_num+'-qty').val();
      var url = "/subpage/addtocart.php";
      $.ajax({
        type: "POST",
        url: url,
        dataType: "html",
        data: {add_qty: add_qty,item_num : item_num},
        success: function(data)
        {
          $('#cartlines').html($(data).filter('#cartLines').html());
          $('#cartupdate').html($(data).filter('#itemadded').html());
          $('#cartupdate').css('display','block');
        }
      });
  }
            </script>
        </div>
    </div>

<div class="pre-footer"></div>

<?php
  include ('includes/footer.php');
?>



