$(document).ready(function () {
    // ============ swiper
    function myswiper(slidername, win_width) {
        var win_w = win_width
        if (win_w > 0) {
            if (slidername == ".swiper2") {
                slidesnum = 1
            }
            if (slidername == ".swiper1") {
                slidesnum = 2
            }
            spacebetween = 10
        }
        if (win_w > 992) {
            if (slidername == ".swiper2") {
                slidesnum = 1
            }
            if (slidername == ".swiper1") {
                slidesnum = 4
            }
            spacebetween = 20
        }
        if (win_w > 1300) {
            spacebetween = 30
            slidesnum = $(slidername).attr("data-slidesnum")
        }
        // ====
        swiper = new Swiper(slidername, {
            speed: 800,
            slidesPerView: slidesnum,
            spaceBetween: spacebetween,
            effect: "slide", /* slide | fade */
            loop: false,
            freeMode: {
                enabled: true,
            },
            autoplay: {
                delay: 5000,
                disableOnInteraction: false,
                stopOnLastSlide: false,
            },
            pagination: {
                el: ".swiper-pagination",
                type: "bullets",
                clickable: true,
            },
        })
    }
    // resize
    $(window).on("resize", function () {
        for (i = 1; i <= 3; i++) {
            slidername = ".swiper" + i
            if (slidername !== undefined) {
                var win_w = $(window).width()
                myswiper(slidername, win_w)
            }
        }
    });
    // === load
    for (i = 1; i <= 3; i++) {
        slidername = ".swiper" + i
        if (slidername !== undefined) {
            var win_w = $(window).width()
            myswiper(slidername, win_w)
        }
    }
    // *************path*********************	
    if (window.location.hostname == "t") {
        t_url = "http://" + window.location.hostname + "/landing_em_print_co_il/"
    } else {
        t_url = "http://" + window.location.hostname;
    }
    myhash = window.location.hash
    /* ======== calendar ======== */
    function rotating_calendar() {
        mycalendar = $(".calendar").height()
        mycalendar_top = (mycalendar / 2) * -1
        $(".spin").css("top", mycalendar_top + "px")
    }
    rotating_calendar()
    $(window).on("resize", function () {
        rotating_calendar()
    })
    // ***********************MAIN*********************************	
    $('body').on('click', '.submit', function (e) {
        e.preventDefault();
        page = $(this).attr("file");
        type = $(this).attr("data-type");
        // ======= ==============================
        var url_current = window.location.hostname
        url = t_url + "/ajax/index.php?type=" + type + "&t=" + page;
        // ==== data type ==
        if (page == "search" || page == "search_results_simple" || page == "filter" || page == "filter_price" || page == "item_select" || page == "item_select1" || page == "item_select2" || page == "item_select3" || page == "item_select4") {
            d = "html";
        } else {
            d = "json";
        };
        // ====
        switch (page) {
            case "cart_update":
                wait("show")
                break;
            default:
                wait("show")
        }
        //wait("show");
        var data = $(this).closest("form").serializeArray();
        $.ajax({
            url: url,
            data: data,
            dataType: d,
            context: this,
            type: "post"
        })
            .done(function (returned_content1) {
                json_str = JSON.stringify(returned_content1);
                json_obj = JSON.parse(json_str);
                // === set_cookie
                if (page == "set_cookie") {
                    window.location.reload()
                }
                // === order_add
                if (page == "order_add") {
                    $(this).addClass("color-red")
                    $(this).find(".icofont-cart-alt").addClass("icofont-pulsate")
                    $(".cart-pre").animate({ right: "0" })
                    $(".cart-pre-content").html(json_obj.cart_pre)
                    $(".quantity-holder").slideUp()
                    $(".quantity").val(1)
                    $(".quantity-holder").slideDown()
                }
                // === order_delete
                if (page == "order_delete") {
                    $(".cart-pre-content").hide()
                    $(".cart-pre-content").html(json_obj.cart_pre)
                    $(".cart-pre-content").slideDown()
                    if (json_obj.reload == "true") {
                        window.location.reload()
                    }
                }
                // === order_update
                if (page == "order_update") {
                    $(".cart-pre-content").html(json_obj.cart_pre)
                    window.location.reload()
                };
                // ========= bday ===
                if (page == "bday") {
                    wait("hide")
                    if (json_obj.bday == "1") {
                        $(".add_cart_button_holder").slideDown()
                        $(".kin-holder").slideDown()
                        $(".kin").html(json_obj.kin)
                        $(".button-teaser-holder").slideDown()
                        $(".id-kin").val(json_obj.kin)
                        $(".info_button_holder").hide()
                    }
                    clk()
                }
                // === item_select
                if (page == "item_select") {
                    $(".display-teaser-win").html(returned_content1)
                    $(".fixed-back").show()
                }
                // === item_select1
                if (page == "item_select1") {
                    $(".display-teaser-win").html(returned_content1)
                    $(".fixed-back").show()
                }
                // === item_select2
                if (page == "item_select2") {
                    $(".display-teaser-win").html(returned_content1)
                    $(".fixed-back").show()
                }
                // === item_select3
                if (page == "item_select3") {
                    $(".display-teaser-win").html(returned_content1)
                    $(".fixed-back").show()
                }
                // === item_select4
                if (page == "item_select4") {
                    $(".display-teaser-win").html(returned_content1)
                    $(".fixed-back").show()
                }
                // === pay_simulate ===
                if (page == "pay_simulate") {
                    if (json_obj.response == "000") {
                        window.location.href = "?t=success"
                    }
                }
                // === login
                if (page == "login") {
                    window.location.reload()
                }
                // === logoff
                if (page == "logoff") {
                    window.location.reload()
                }
                // ==
                if (page == "contact_session_clear") {
                    if (json_obj.session_user_contact == "0") {
                        window.location.reload();
                    };
                };
                // ==========search======
                if (page == "search") {
                    $(".search-result").html(returned_content1)
                    $(".search-result").fadeIn();
                    $(".orderby-buttons").slideDown()
                    $(".orderby-buttons .orderby").css("font-weight", "normal")
                    $(this).css("font-weight", "bold")
                }
                // ==========search_results_simple======
                if (page == "search_results_simple") {
                    $(".search-results-simple").html(returned_content1)
                    $(".search-results-simple-holder").fadeIn()
                    $(".content").hide()
                }
                // === user_add
                if (page == "user_add" || page == "user_update") {
                    if (json_obj.msg !== undefined) {
                        alert(json_obj.msg)
                        wait("hide")
                        return false
                    } else {

                        $("#tranzila .first-name").val(json_obj.first_name)
                        $("#tranzila .last-name").val(json_obj.last_name)
                        $("#tranzila .phone").val(json_obj.phone)
                        $("#tranzila .email").val(json_obj.email)
                        $("#tranzila .address").val(json_obj.address)
                        $("#tranzila .city").val(json_obj.city)
                        $("#tranzila .grand-total").val(json_obj.grand_total)
                    }
                    $(".form-holder").html("<div class='w1 align-center font-size2'>פנייתך נשלחה</div>")
                    wait("hide")
                };//end if page
                // =============== filter ===================
                if (page == "filter") {
                    if (returned_content1 != "") {
                        $(".gallery-wrap").html(returned_content1);
                        $("html, body").animate({ scrollTop: 0 }, "slow");
                    }
                    if (returned_content1 == "") {
                        alert("לא נבחרו נושאי סינון")
                    }
                };
                // =============== calculate ===================
                if (page == "calculate") {
                    if (json_obj.bday != "") {
                        $(".add-cart-holder").slideDown()
                    } else {
                        alert("לא נבחר תאריך לידה לצורך ביצוע החישוב \n לחצ/י על התא מעל ללחצן הצהוב להגדרת תאריך לידה.")
                    }
                };
                // =============== filter price - temp ===================
                if (page == "filter_price") {
                    if (returned_content1 != "") {
                        $(".gallery-wrap").html(returned_content1);
                        $("html, body").animate({ scrollTop: 0 }, "slow");
                    }
                };
                // === clear_sessions ==========
                if (page == "clear_sessions") {
                    window.location.reload();
                };
                // ~~~
                wait("hide");
            })
            .fail(function (jqXHR, status, err) {
                alert(jqXHR.responseText);
                //alert("error")
                wait("hide");
            })
    });
    // ============ get $_GET value
    var $_GET = {};
    document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
        function decode(s) {
            return decodeURIComponent(s.split("+").join(" "));
        }
        $_GET[decode(arguments[1])] = decode(arguments[2]);
    });
    // ========= tree products control =========
    $(".tree-control li .open-tree").click(function (e) {
        e.stopPropagation()
        thechildren = $(this).parent().children().not("span, i, div")
        if ((thechildren).is(":hidden")) {
            thechildren.slideDown()
            thechildren.parent().find("i").first().addClass("icofont-simple-up color-red")
            thechildren.parent().find("i").first().removeClass("icofont-simple-down color-black")
            return false
        }
        if ((thechildren).is(":visible")) {
            thechildren.slideUp()
            thechildren.parent().find("i").first().removeClass("icofont-simple-up color-red")
            thechildren.parent().find("i").first().addClass("icofont-simple-down color-black")
            return false
        }
        $(".ic").show()
    })
    // ===
    $(".open-all").click(function () {
        $(".tree-control ul li ul").slideDown()
        $(".tree-control .ic").addClass("icofont-simple-up color-red")
        $(".tree-control .ic").removeClass("icofont-simple-down")
    })
    $(".close-all").click(function () {
        $(".tree-control ul li ul").slideUp()
        $(".tree-control .ic").removeClass("icofont-simple-up color-red")
        $(".tree-control .ic").addClass("icofont-simple-down")
    })
    // ********************************************************	
    $('body').on('click', '.uncheck', function (e) {
        $(".filter").prop('checked', false)
    })
    // ===== masked checkbox function for colors selection
    $('body').on('change', '.attr-color', function () {
        $(".circle").removeClass("brdr-black")
        $(".circle").addClass("brdr-black20")
        $(".colorname").removeClass("bold")
        mystate = ($(this).is(":checked"))
        if (mystate == true) {
            $(this).parent().find(".circle").addClass("brdr-black")
            $(this).parent().find(".circle").removeClass("brdr-black20")
            $(this).parent().find(".colorname").addClass("bold")
        }
    })
    // ===== masked checkbox function for sizes selection
    $('body').on('change', '.attr-size', function () {
        $(".attr-size").parent().parent().removeClass("color-bg-blue-dark color-white bold")
        $(".attr-size").parent().parent().addClass("color-blue-dark")
        mystate = ($(this).is(":checked"))
        //alert(mystate)
        if (mystate == true) {
            $(this).parent().parent().addClass("color-bg-blue-dark color-white bold")
            $(this).parent().parent().removeClass("color-blue-dark")
        }
    })
    // ===== masked checkbox function for color selection
    $('body').on('change', '.attr-color', function () {
        var myimage = $(this).attr("data-img");
        if (myimage != "") {
            $(".lv-image").hide()
            $(".lv-image").attr("src", myimage);
            $(".lv-image").fadeIn()
        }
    })
    // ****************** color_size_test *************************
    $('body').on('click', '.attr-checkbox', function () {
        var page = $(this).attr("file");
        var type = $(this).attr("data-type");
        var data = $(this).closest("form").serializeArray();
        url = t_url + "/ajax/index.php?t=" + page + "&type=" + type;
        $.ajax({
            url: url,
            data: data,
            dataType: "html",
            context: this,
            type: "post"
        })
            .done(function (returned_content1) {
                if (type == "color") {
                    mystate = ($(this).is(":checked"))
                    if (mystate == false) {
                        $(".size-holder").html(returned_content1)
                    }
                }
                if (type == "size") {
                    mystate = ($(this).is(":checked"))
                    $(".color-holder").hide()
                    $(".color-holder").html(returned_content1)
                    $(".color-holder").fadeIn("slow")
                }
            })
    })
    // ======= filter checkbox masks =====
    $('body').on('change', '.checkbox-mask', function () {
        mystate = ($(this).is(":checked"))
        if (mystate == true) {
            $(this).parent().parent().parent().parent().addClass("brdr-blue-dark shadow-low")
            $(this).parent().parent().parent().parent().removeClass("brdr-black05")
        }
        if (mystate == "") {
            $(this).parent().parent().parent().parent().addClass("brdr-black05 ")
            $(this).parent().parent().parent().parent().removeClass("brdr-blue-dark shadow-low")
        }
    })
    // ===== hide add to cart message delayed ====
    function hide_cart_message() {
        $(".add-cart-msg").fadeOut()
    }
    // ======== lv images =======
    $(".lv-icon").click(function () {
        $(".lv-icon").removeClass("shadow-low")
        $(this).addClass("shadow-low")
        $(".lv-image").hide()
        new_img = $(this).attr("src")
        $(".lv-image").attr("src", new_img);
        $(".lv-image").fadeIn("slow")
        $(".lv-image").parent().attr("href", new_img)
    })
    // ======== lv images no thumb
    $(".lv-icon-nothumb").click(function () {
        $(".lv-icon-nothumb").removeClass("bold")
        $(this).addClass("bold")
        $(".lv-image").hide()
        new_img = $(this).attr("data-img8")
        $(".lv-image").attr("src", new_img);
        $(".lv-image").fadeIn("slow")
        $(".lv-image").parent().attr("href", new_img)
    })
    // ==========fancybox==============
    $('.fancybox').fancybox({
        "padding": 0,
        "scrolling": 0,
        "openEffect": "elastic",
        "closeEffect": "elastic"
    });
    // =========
    $("body").mousemove(function (e) {
        var clientCoords = "X: " + e.clientX + " | Y:" + e.clientY;
        $(".loc").text(clientCoords);
    });

    // ======= screen width and proportional win
    $(window).on("load resize", function () {
        screen_width = $(window).width() + 15; // temp
        if (screen_width < 576) {
            screen_width = screen_width + " | <strong>xs</strong>";
        }
        if (screen_width < 768) {
            screen_width = screen_width + " | <strong>sm</strong>";
        }
        if (screen_width < 992) {
            screen_width = screen_width + " | <strong>md</strong>";
        }
        if (screen_width < 1200) {
            screen_width = screen_width + " | <strong>lg</strong>";
        }
        if (screen_width >= 1200) {
            screen_width = screen_width + " | <strong>xl</strong>";
        }
        $(".screen_width").html("<span class='color4'>" + screen_width + "</span>")
    });
    // ==========
    $(".test").click(function () {
        wait("show")
    });
    // ======== link to su if cart is full
    $('body').on('click', '.su-button-cart-full', function (e) {
        myurl = $(this).attr("myurl");
        confirm_del_cart("מעבר לאזור האישי יסיר את המוצרים הקיימים בסל הקניות\nהאם להמשיך?", myurl);
    });
    // ====== opener ==========
    $(".opener").click(function (e) {
        e.stopPropagation()
        receiver = "." + ($(this).attr("receiver"));
        t0 = $(this).attr("t0");
        t1 = $(this).attr("t1");
        if ($(receiver).is(":visible")) {
            $(this).find("span").html(t0);
            $(receiver).slideUp()
        };
        if ($(receiver).is(":hidden")) {
            $(this).find("span").html(t1);
            $(receiver).slideDown()
        }
    });
    // =============
    $(".search").keyup(function (e) {
        searchval = $(this).val()
        $(".search-results-simple-holder .orderby-buttons .search").val(searchval)
    })
    // ====== opener_hover ==========
    $(".opener_hover").mouseover(function (e) {
        receiver = "." + ($(this).attr("receiver"));
        $(receiver).fadeIn()
    });
    $(".opener_hover").mouseout(function (e) {
        receiver = "." + ($(this).attr("receiver"));
        $(receiver).hide()
    });
    // ====== close parent
    $(".close-parent").click(function () {
        $(this).parent().fadeOut();
    })
    // ====== opener_vnav ==========
    $(".opener_vnav").click(function (e) {
        e.stopPropagation();
        receiver = $(this).children("ul");
        if ($(receiver).is(":visible")) {
            $(this).find("i:first").addClass("icofont-rounded-left");
            $(this).find("i:first").removeClass("icofont-rounded-down");
            $(receiver).slideUp()
        };
        if ($(receiver).is(":hidden")) {
            $(this).find("i:first").removeClass("icofont-rounded-left");
            $(this).find("i:first").addClass("icofont-rounded-down");
            $(receiver).slideDown()
        }
    });
    // ====== opener_drop_down ==========
    $(".opener-hover").mouseover(function (e) {
        receiver = "." + $(this).attr("receiver");
        $(receiver).stop().fadeIn("fast")
    });
    $(".opener-hover").mouseout(function () {
        receiver = "." + $(this).attr("receiver");
        $(receiver).stop().fadeOut()
    });
    // ============== hide abs
    $(document).mouseup(function (e) {
        var container = $(".hoc");
        if (!container.is(e.target) // if the target of the click isn't the container...
            && container.has(e.target).length === 0) // ... nor a descendant of the container
        {
            container.fadeOut();
            // ==== changes arrow direction in header only
            $("header span i").removeClass("icofont-simple-up")
            $("header span i").addClass("icofont-simple-down")
        }
    });
    // ======== hide cart popup ===
    $(".hideme").click(function () {
        var target_width = $(".cart-pre").outerWidth() * -1
        $(".cart-pre").animate({ right: target_width })
    })
    $(".hideme-phone").click(function () {
        var target_width = $(".cart-pre").outerWidth() * -2
        $(".cart-pre").animate({ right: target_width })
    })
    // ======== show cart popup ===
    $(".show-cart-popup").click(function (event) {
        $(".cart-overlay").addClass("flex-centered")
        $(".cart-overlay").removeClass("d-none")
        $(".cart-overlay").fadeIn()
    })
    // ============= back button =============
    $(".back-button").click(function (e) {
        e.preventDefault();
        history.go(-1);
    });
    // =============
    // ========== hide abs on click anywhere
    $(document).mouseup(function (e) {
        var container = $(".access_wrapper");
        if (!container.is(e.target) // if the target of the click isn't the container...
            && container.has(e.target).length === 0) // ... nor a descendant of the container
        {
            container.animate({ right: "-20%" });;
        }
    });
    // ======= reload button ===
    $(".reloadme").click(function () {
        window.location.reload()
    })
    // ======== save effect =========
    function wait(state) {
        if (state == "show") {
            $(".wait").fadeIn();
        }
        if (state == "hide") {
            $(".wait").fadeOut();
        }
    };
    // ========== jq gallery =============
    //$(window).on("load", function() { 
    var arr2 = [];
    $(".jq").each(function () { arr2.push($(this)); });
    $.each(arr2, function (key, val) {
        jq_id = $(this).attr("jq_id");
        //~~~~~~
        $.ajax({
            type: "post",
            url: "ajax/jq.php?jq_id=" + jq_id
        })
            .done(function (data_out) {
                val.html(data_out)
            })
            .fail(function (jqXHR, status, err) {
                alert(err);
            }); // fail
        //~~~~~
    });
    //});
    $(".act").click(function (e) {
        $(".h .lv_win").slideUp()
        receiver = $(this).attr("receiver");
        $("." + receiver).slideDown()
    });
    $("<div class='w1 abs align_center font_size14 color8 normal' style='top:-12px;right:0;'>^</div>").insertAfter(".grid .r_up");
    $("<div class='w1 abs align_center font_size14 color8 normal' style='top:17px;right:0;transform: rotate(180deg);'>^</div>").insertAfter(".grid .r_down");
    // ==== for avg only
    $("<div class='w1 abs align_center font_size14 color8 normal' style='top:-14px;right:0;'>^</div>").insertAfter(".grid .r_up_avg");
    $("<div class='w1 abs align_center font_size14 color8 normal' style='top:13px;right:0;transform: rotate(180deg);'>^</div>").insertAfter(".grid .r_down_avg");
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // === submit search_numeric ==
    $(".filter_numeric").submit(function (e) {
        wait("show");
        myprice_min = $(".myprice_min").val()
        myprice_max = $(".myprice_max").val()
        if ((myprice_min == "") || (myprice_max == "")) {
            alert("לחיפוש לפי טווח מחיר יש לרשום מחיר מינימלי ומחיר מקסימלי");
            wait("hide");
            return false;
        };
    });
    // === submit search_groups ==
    $(".filter_volume").submit(function () {
        wait("show");
        volume = $(".volume").val()
        if (volume == "") {
            alert("לסינון יש לבחור קבוצה");
            wait("hide");
            return false;
        };
    });
    // === login ===================
    /*
    $("#submit_person_login").click(function (e) {
        wait("show");
        e.preventDefault();
        var data = $("#form_person_login").serialize();
        $.ajax({
            type: "post",
            url: "ajax/ajax_person_login.php",
            data: data
        })
        .done(function (response) {//a parameter inserted here
            if (response != "") {
                $(".login").html(response);
                $(".form_holder").slideUp();
                $(".refresh").slideDown();
                setTimeout(reload_win, 2000);
            };
            if (response == "") {
                $(".login_title").html("<span class='font_size10 color3'>כניסתך לא אושרה</span>");
                wait("hide");
            };
        })
        .fail(function (jqXHR, status, err) {
            alert(jqXHR.responseText);
            wait("hide");
        }); // fail
    });
    */
    // ===== popup
    $(".fixed-back").click(function (e) {
        $(this).fadeOut();
    })
    $(".hide-fixed-back").click(function (e) {
        $(".fixed-back").fadeOut();
    })
    $(".tbox-msg-holder").click(function (e) {
        e.stopPropagation()
    })
    // ======= delete person cookie =========
    // =======
    $(".delete_person_cookie").click(function () {
        wait("show");
        l1 = $(this).attr("data-l1");
        $.ajax({
            type: "post",
            url: "ajax/ajax_delete_person_cookie.php?l1=" + l1
        })
            .done(function (response) {//a parameter inserted here
                $(".login_holder").slideUp();
                setTimeout(reload_win, 500);
                wait("hide");
            });
    });
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // ======== add recommend ======
    $(".submit_recommend").click(function () {
        if (($("#full_name").val() == "") || ($("#requests").val() == "")) {
            fb_open("יש למלא שם ולרשום חוות דעת");
            return false;
        }
        var data = $("#form_recommend").serializeArray();
        $.ajax({
            type: "post",
            url: "ajax/ajax_recommend.php",
            data: data
        })
            .done(function () {
                $(".form_recommend").slideUp();
                $(".recommend_open").html("<div style='text-align:center;font-size:1.3em'>חוות הדעת נשלחה</div>");
            });
    });
    // ======= select color ===
    $(".attr_color_button").click(function (event) {
        $(this).parent().find(".abs").toggle();
    });
    // =========== search ==============
    $(".search_button button").click(function (event) {
        if ($(".search").val() == "") {
            alert("Please enter a search term")
            return false;
        };
    });
    $(".search").keyup(function () {
        // ======= set a slash at the start of path depending on t folder
        myurl = t_url + "/ajax/index.php?t=search_popup";
        // ============================
        var data = $("#form_search").serializeArray();
        $.ajax({
            type: "post",
            url: myurl,
            data: data
        })
            .done(function (data_out) {
                $(".search_result").html(data_out);
                if (data_out != "") {
                    $(".search_menu").slideDown()
                    $(".search_button").removeClass("color-bg-green");
                    $(".search_button").addClass("color-bg-red");
                }
                if (data_out == "") {
                    $(".search_menu").slideUp()
                    $(".search_button").addClass("color-bg-green");
                    $(".search_button").removeClass("color-bg-red");
                }
                wait("hide")
            })
            .fail(function (jqXHR, status, err) {
                alert(jqXHR.responseText);
            }); // fail
    });
    // =========== cities ==============
    $(".city").keyup(function () {
        var data_in = $("form").serializeArray();
        //alert(data_in)
        $.ajax({
            url: "ajax/ajax_cities.php",
            data: data_in,
            type: "post"
        })
            .done(function (data_out) {
                $(".cities_result").html(data_out)
                if (data_out != "") {
                    $(".cities_menu").show()
                } else {
                    $(".cities_menu").hide()
                }
            })
            .fail(function (jqXHR, status, err) {
                alert(err);
            }); // fail
    });
    // =====
    /*
    $(function () {
        $(".datepicker").datepicker({
            changeYear: true,
            yearRange: "1910:c",
            buttonImage: "/images/assets/calendar.gif",
            dateFormat: 'dd-mm-yy'
        })
    });
    $(".datepicker").change(function () {
        mybday = $(".datepicker").val()
        $(".datepicker_add_cart").val(mybday)
    })
    */
    // =====
    $('body').on('click', '.city_found', function (e) {
        e.preventDefault();
        $(".city").val($(this).text());
        $(".cities_menu").fadeOut()
    });
    // =========== lang
    $(".lang").click(function () {
        $(this).parent().find(".abs").toggle();
    });
    // hide abs on click anywhere
    $(document).mouseup(function (e) {
        var container = $(".hide_on_click");
        if (!container.is(e.target) // if the target of the click isn't the container...
            && container.has(e.target).length === 0) // ... nor a descendant of the container
        {
            container.fadeOut();
        }
    });
    // ========= video ===========
    $(".video_play").click(function (e) {
        e.preventDefault();
        var my_video = $(this).attr("data-video");
        var parent_width = $(this).parent().width();
        var parent_height = $(this).parent().height();
        parent_height = parent_height;
        //$(this).parent().parent().hide();
        var my_iframe = '<iframe width="' + parent_width + '" height="' + parent_height + '" src="https://www.youtube.com/embed/' + my_video + '?autoplay=1&amp;rel=0&amp;modestbranding=1&mute=1&loop=1" frameborder="0" allowfullscreen></iframe>'
        $(this).parent().parent().parent().find(".youtube").html(my_iframe);
    });
    function play_v(aa) {
        var my_video = $(aa).attr("data-video");
        var parent_width = $(aa).parent().width();
        var parent_height = $(aa).parent().height();
        parent_height = parent_height;
        var my_iframe = '<iframe width="' + parent_width + '" height="' + parent_height + '" src="https://www.youtube.com/embed/' + my_video + '?autoplay=1&rel=0&modestbranding=1&mute=1&loop=1" frameborder="0" allowfullscreen></iframe>'
        $(aa).parent().parent().parent().find(".youtube").html(my_iframe);
    }
    myt = setTimeout(play_v, 2500, ".video_play_special")
    // fix size on resize
    // check
    // ======== vticker
    $(function () {
        // get home gallery height
        cell_height = $(".g1").height();
        if ($_GET["t"] == undefined) {
            cell_height = $(".g1").height();
        }
        if (cell_height < 100) {
            cell_height = 450;
        }
        // ====
        tname = $('.ticker').attr("tname");
        tspeed = $('.ticker').attr("tspeed");
        tpause = $('.ticker').attr("tpause");
        theight = cell_height;
        $("." + tname).vTicker({
            speed: 1000,
            pause: tpause,
            animation: 'fade',
            mousePause: true,
            showItems: 0,
            height: theight
        });
    });
    // =========================
    $(".hide_delayed").delay(20000).slideUp(1500);
    // ===== quantity buttons ===
    $(".qty-plus").click(function () {
        current_val = $(this).parent().find(".quantity").val()
        current_val = parseInt(current_val) + 1
        $(this).parent().find(".quantity").val(current_val)
    });
    $(".qty-minus").click(function () {
        current_val = $(this).parent().find(".quantity").val()
        if (current_val > 1) {
            current_val = parseInt(current_val) - 1
            $(this).parent().find(".quantity").val(current_val)
        }
    });
    $(".quantity").blur(function () {
        current_val = $(this).parent().find(".quantity").val()
        if (current_val < 1) {
            $(this).parent().find(".quantity").val(1)
        }
    })
    // =========================
    tc = 1;
    $(".temp").delay(20000).slideUp(1500);
    function tafnit_control() {
        tc = tc * -1
        $(".tafnit_control").animate({ left: "-160px" });
        $(".show_control .grid .box").html("&raquo;")
    }
    myt = setTimeout(tafnit_control, 6000)
    $(".show_control").click(function () {
        tc = tc * -1
        if (tc == 1) {
            $(".tafnit_control").animate({ left: "-20px" });
            $(".show_control .grid .box").html("&laquo;")
        };
        if (tc == -1) {
            $(".tafnit_control").animate({ left: "-160px" });
            $(".show_control .grid .box").html("&raquo;")
        };
    })
    // ===== on screen
    function change_nav() {
        var myScroll = $(window).scrollTop()
        sticky_h = $(".myheader").height()
        $(".scrollpos").text(myScroll)
        if (myScroll > sticky_h) {
            $(".myheader").addClass("shadow-low")
            $(".myheader").addClass("brdrb-black15")
            $(".myblock").removeClass("h110-lg")
            $(".myblock").removeClass("header_effect1")
            $(".myblock").addClass("header_effect2")
            $(".breadcrumbs").removeClass("font-size13")
            return false
        }
        if (myScroll <= sticky_h) {
            $(".myheader").removeClass("shadow-low")
            $(".myblock").removeClass("header_effect2")
            $(".myblock").addClass("header_effect1")
            $(".breadcrumbs").addClass("font-size13")
            $(".myheader").removeClass("brdrb-black15")


        }
    }
    $(window).scroll(function () {
        change_nav()
    })
    change_nav()
    // ============= show pass ============
    $('body').on('click', '.show-pass', function () {
        if ($(".password").attr("type") == "password") {
            $(".password").attr("type", "text");
            $(".show-pass").removeClass("icofont-eye")
            $(".show-pass").addClass("icofont-eye-blocked")
            return false
        };
        if ($(".password").attr("type") == "text") {
            $(".password").attr("type", "password");
            $(".show-pass").addClass("icofont-eye")
            $(".show-pass").removeClass("icofont-eye-blocked")
        };
    })
    // ============  opener-more for lv ==========
    $(".opener-more").click(function () {
        more_block = "." + $(this).attr("data-receiver");
        $(".more-holder " + more_block).slideUp("slow")
        $(".more-holder .more").slideUp()
        $(".opener-more").removeClass("bold")
        $(".opener-more").removeClass("brdrb2-blue-dark")
        $(this).addClass("bold")
        $(this).addClass("brdrb2-blue-dark")
        more_block = "." + $(this).attr("data-receiver");
        $(".more-holder " + more_block).slideDown("slow")
    })
    // ========== marquee =============
    sp = ($(".t").height()) / 30 + "s"
    $(".t").css("animation", "marquee " + sp + " linear infinite")
    // ==========ready end==============
});
// ====
function delConfirm() {
    return confirm("האם להסיר?");
}
// ==== check if cookies are disabled
if (navigator.cookieEnabled != true) {
    alert("הדפדפן שלך אינו מאפשר שמירת נתונים \n נא אפשר/י שמירת נתונים בדפדפן זה להמשך.");
};