<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="Custom Uniforms offered in a variety colors to match your team. Browse through our baseball, fastpitch, softball, lacrosse, football, volleyball and basketball gear.">
    <meta name="keywords" content="custom uniforms, footwear, athletic equipment, sporting goods">
    <meta name="author" content="Kidneo">
    <meta name="csrf_token" content="{{ csrf_token() }}" />
    <meta name="company_url" content="{{ $store_array[0]->StoreUrl }}" />

    <meta property="og:url" content="https://merchbay.com" />
    <meta property="og:type" content="article" />
    <meta property="og:title" content="CREW Apparel" />
    <meta property="og:description" content="Custom Uniforms offered in a variety colors to match your team. Browse through our baseball, fastpitch, softball, lacrosse, football, volleyball and basketball gear." />
    <meta property="og:image" content="{{asset('public/images/logo.png')}}" />

    <!-- favicons
        <link rel="apple-touch-icon" sizes="180x180" href="{{asset('public/favicons/apple-touch-icon.png')}}">
        <link rel="icon" type="image/png" href="{{asset('public/favicons/favicon-32x32.png')}}" sizes="32x32">
        <link rel="icon" type="image/png" href="{{asset('public/favicons/favicon-16x16.png')}}" sizes="16x16">
        <link rel="manifest" href="{{asset('public/favicons/manifest.json')}}">
        <link rel="mask-icon" href="{{asset('public/favicons/safari-pinned-tab.svg')}}" color="#5bbad5">
        <meta name="theme-color" content="#ffffff">-->
    <!-- end favicons -->
    <title>{{ $store_array[0]->StoreName }} Store</title>

    <!-- Bootstrap core CSS -->
    {{-- <link href="{{asset('public/assets/css/bootstrap.min.css')}}" rel="stylesheet"> --}}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="{{asset('public/assets/css/ie10-viewport-bug-workaround.css')}}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="{{asset('public/assets/css/style.css')}}" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="{{asset('public/assets/js/ie-emulation-modes-warning.js')}}"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

        <![endif]-->
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

    <!-- Social Media Share button 
        <script type="text/javascript" src="//platform-api.sharethis.com/js/sharethis.js#property=599bc5cf6d61950012975405&product=sticky-share-buttons"></script>-->

    <link href="{{asset('/public/designer/css/build.css')}}" rel="stylesheet">
    <style>

    </style>

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-136108155-1"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }
        gtag('js', new Date());

        gtag('config', 'UA-136108155-1');
    </script>
</head>

<body>
    @include('layout.navbar')
    <!-- Example row of columns -->
    @yield('content')


    <!-- Bootstrap core JavaScript  ================================================= !-->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
    <!-- <script>window.jQuery || document.write('<script src="{{asset('public/assets/js/vendor/jquery.min.js')}}"><\/script>')</script> -->
    <!-- <script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> -->
    <script src="{{asset('public/assets/js/jquery.validate.js')}}"></script>
    <!-- <script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script> -->
    <!-- <script src="{{asset('public/assets/js/crew-designer.js')}}"></script> -->
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
    <!-- jquery.bcSwipe -->
    <script src="{{asset('public/assets/js/jquery.bcSwipe.min.js')}}"></script>
    <script src="{{asset('public/assets/js/jquery.zoom.js')}}"></script>


    <script>
        $(document).ready(function() {
            // $('.img-zoom').zoom();
            $('.inputName').keyup(function() {
                this.value = this.value.toLocaleUpperCase();
            });

            $('.carousel').bcSwipe({
                threshold: 50
            });

            $('.btn-number').click(function(e) {
                e.preventDefault();

                fieldName = $(this).attr('data-field');
                type = $(this).attr('data-type');
                var input = $("input[name='" + fieldName + "']");
                var currentVal = parseInt(input.val());
                if (!isNaN(currentVal)) {
                    if (type == 'minus') {

                        if (currentVal > input.attr('min')) {
                            input.val(currentVal - 1).change();
                        }
                        if (parseInt(input.val()) == input.attr('min')) {
                            $(this).attr('disabled', true);
                        }

                    } else if (type == 'plus') {

                        if (currentVal < input.attr('max')) {
                            input.val(currentVal + 1).change();
                        }
                        if (parseInt(input.val()) == input.attr('max')) {
                            $(this).attr('disabled', true);
                        }

                    }
                } else {
                    input.val(0);
                }
            });

            $('#myCarousel').on('slid.bs.carousel', function(e) {
                var id = $('.item.active').data('slide-number');
                // $('#carousel-text').html($('#slide-content-'+id).html());
                // console.log(id)
                $('.a_thumbnail').removeClass('active');
                $('#carousel-selector-' + id).addClass('active');
            });

            $('.input-number').focusin(function() {
                $(this).data('oldValue', $(this).val());
            });

            $('.input-number').change(function() {

                minValue = parseInt($(this).attr('min'));
                maxValue = parseInt($(this).attr('max'));
                valueCurrent = parseInt($(this).val());

                name = $(this).attr('name');
                if (valueCurrent >= minValue) {
                    $(".btn-number[data-type='minus'][data-field='" + name + "']").removeAttr('disabled')
                } else {
                    alert('Sorry, the minimum value was reached');
                    $(this).val($(this).data('oldValue'));
                }
                if (valueCurrent <= maxValue) {
                    $(".btn-number[data-type='plus'][data-field='" + name + "']").removeAttr('disabled')
                } else {
                    alert('Sorry, the maximum value was reached');
                    $(this).val($(this).data('oldValue'));
                }


            });

            $(".input-number").keydown(function(e) {
                // Allow: backspace, delete, tab, escape, enter and .
                if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
                    // Allow: Ctrl+A
                    (e.keyCode == 65 && e.ctrlKey === true) ||
                    // Allow: home, end, left, right
                    (e.keyCode >= 35 && e.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                // Ensure that it is a number and stop the keypress
                if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
                    e.preventDefault();
                }
            });

            $('.multi-item-carousel .item').each(function() {
                var next = $(this).next();
                if (!next.length) {
                    next = $(this).siblings(':first');
                }

                next.children(':first-child').clone().appendTo($(this));


                for (var i = 0; i < 2; i++) {

                    next = next.next();

                    if (!next.length) {
                        next = $(this).siblings(':first');
                    }
                    next.children(':first-child').clone().appendTo($(this));
                }

            });

            $('#jersey_chk').click(function() {

                var product_price = $('#product_price').val();
                var getPriceHold = $('#price_holder').val();
                var getHalf = getPriceHold / 2;

                if ($(this).is(':checked')) {
                    $('.td-hide').css('display', '');
                    $('.th-hide').css('display', '');

                    $('#product_price').val(Number(product_price) + Number(getHalf));
                    $('#display-product-price').html('$ ' + $('#product_price').val());
                    // console.log($('#product_price').val() - getHalf);
                } else {
                    $('.cls-uniformName').val('');
                    $('.td-hide').css('display', 'none');
                    $('.th-hide').css('display', 'none');

                    $('#product_price').val(Number(product_price) - Number(getHalf));
                    $('#display-product-price').html('$ ' + $('#product_price').val());
                    // console.log($('#product_price').val() + getHalf);
                }
                // console.log($(this).is(':checked'));
            });

            $('#shorts_chk').click(function() {

                var product_price = $('#product_price').val();
                var getPriceHold = $('#price_holder').val();
                var getHalf = getPriceHold / 2;

                if ($(this).is(':checked')) {
                    $('#product_price').val(Number(product_price) + Number(getHalf));
                    $('#display-product-price').html('$ ' + $('#product_price').val());
                } else {

                    $('#product_price').val(Number(product_price) - Number(getHalf));
                    $('#display-product-price').html('$ ' + $('#product_price').val());
                }
            });

            $(document).on('input keyup', '.capitalizeText', function() {
                $(this).val($(this).val().toUpperCase());
            });

            $('[id^=carousel-selector-]').click(function() {
                var id = this.id.substr(this.id.lastIndexOf("-") + 1);
                var id = parseInt(id);
                $('#myCarousel').carousel(id);
                $('.a_thumbnail').removeClass('active');
                $(this).addClass('active');
            });

            $("#frm-order-list").validate({

                rules: {

                    'order_jersey_size[]': {
                        required: true
                    },
                    'order_shorts_size[]': {
                        required: true
                    },
                    'order_number[]': {
                        required: true
                    }
                },

                messages: {},
                errorPlacement: function(error, element) {
                    var placement = $(element).data('error');
                    if (placement) {
                        $(placement).html(error);
                    }
                },

                success: function(error, element) {
                    var placement = $(element).data('error');
                    if (placement) {
                        $(placement).html('');
                    }
                },
                submitHandler: submitOrderListForm
            });

            function submitOrderListForm() {
                var data = $("#frm-order-list").serializeArray();

                $.ajax({
                    type: 'POST',
                    url: "{{ url('teamstore/q/add-to-cart') }}",
                    data: data,
                    dataType: 'json',
                    beforeSend: function(xhr) {
                        var token = $('meta[name="csrf_token"]').attr('content');

                        if (token) {
                            return xhr.setRequestHeader('X-CSRF-TOKEN', token);
                        }
                        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
                    },
                    success: function(response) {

                        if (response.success) {
                            window.location = "{{ url('cart') }}";
                        } else {
                            alert(response.message);
                            location.reload();
                        }
                    }
                });
                return false;

            }

            // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ adding of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

            $(document).on('button click', '#addNewRow', function() {
                var p_id = $('#p_id').val();
                $.ajax({ //create an ajax request to load_page.php
                    type: "POST",
                    url: "{{ url('/teamstore/q/add-new-row') }}",
                    data: {
                        p_id: p_id
                    },

                    dataType: "html", //expect html to be returned
                    beforeSend: function(xhr) {
                        var token = $('meta[name="csrf_token"]').attr('content');

                        if (token) {
                            return xhr.setRequestHeader('X-CSRF-TOKEN', token);
                        }
                        xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
                    },

                    success: function(response) {

                        var d = new Date();
                        var n = d.getTime();

                        var parser = new DOMParser();
                        var doc = parser.parseFromString(response, "text/html");
                        var elem = doc.getElementById("orderTableBody");
                        var currentClassName = elem.getElementsByTagName('tr')[0].className;
                        elem.getElementsByClassName(currentClassName)[0].classList.remove(currentClassName); // remove current Classname 
                        elem.getElementsByTagName('tr')[0].classList.add("table-tr-" + Math.ceil(Math.random() * 999999) + n); // add random classname
                        $('#tableRow tbody').append(elem.innerHTML);
                        $('#addnew-btn-tbl-row').html('')
                        $('#addnew-btn-tbl-row').append('<button type="button" id="addNewRow" class="btn btn-success btn-sm pull-left" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button>');
                        $('.tr-remove-btn').html('<button type="button" class="btn btn-danger btn-sm removeRow btn-roster-action" data-toggle="tooltip" title="Remove"><i class="fa fa-remove" aria-hidden="true"></i></button>');
                        $('#orderListPanel').scrollTop($('#orderListPanel')[0].scrollHeight);
                        $('.inputName').keyup(function() {
                            this.value = this.value.toLocaleUpperCase();
                        });
                    }
                });

            });
            // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ end adding of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

            // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ removing  of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
            $(document).on('button click', '.removeRow', function() {
                var str = $(this).closest('tr').attr('class');
                var trCount = $('#tableRow tbody').children('tr').length;
                if (trCount <= 2) {
                    $('#addnew-btn-tbl-row').html('');
                    $('.tr-remove-btn').html('<button type="button" id="addNewRow" class="btn btn-success btn-sm btn-roster-action" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i></button>');
                }
                $('.' + str).remove();
            });
            // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ end removing  of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


           
        }); //end document ready
    </script>
</body>

</html>