var tools = {
    
    escape: function(htmlStr) {
   return htmlStr.replace(/&/g, "&amp;")
         .replace(/</g, "&lt;")
         .replace(/>/g, "&gt;")
         .replace(/"/g, "&quot;")
         .replace(/'/g, "&#39;");        

},
    
    scroll_to : function(class_div) {
        var hash = "."+class_div;
        $('html, body').animate({
        scrollTop: $(hash).offset().top
      }, 600, function(){
      });
    },
    
    mouse_pos_pop_ups_close_it : function() {
        
        $('.the_force_pop_up_holderr').remove();
        $('#no_escape').remove();
        
    },
    
    mouse_con_us_but : function(ele) {
        
        var full_name = $(ele).parent().find('.full_name').val();
        var m_phone = $(ele).parent().find('.m_phone').val();
        var email = $(ele).parent().find('.your_email').val();
        
        var cur_site_id = $('#cur_site_id').val();
        var trafic_id = $('#trafic_id').val();
        
        var the_txt = "השארי פרטים ללפני נטישה - נא לחזור אליו במיידי";
        
        if (full_name.length > 0) {
            if (m_phone.length > 0) {
                if (email.length > 0) {
                    if (valid.email(email)) {
                        if (valid.mobile(m_phone)) {
                        
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"con_us_send",
                                    cur_site_id : cur_site_id,
                                    full_name : full_name,
                                    email : email,
                                    m_phone : m_phone,
                                    the_txt : the_txt,
                                    trafic_id : trafic_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re == 1) {
                                    Swal.fire(thejson.re_err);
                                    setTimeout(function(){ 
                                    location.reload();
                                    }, 1000);
                                } else {
                                    Swal.fire(thejson.re_err);
                                }
                            },
                            error:function(){}
                            });                
                            
                        } else {Swal.fire("נא למלא טלפון נייד");}
                    } else {Swal.fire("נא למלא אימייל תקין");}
                } else {Swal.fire("נא למלא אימייל תקין");}
            } else {Swal.fire("נא למלא טלפון נייד תקין 10 ספרות בלבד");}
        } else {Swal.fire("נא למלא שם מלא");}
        
    },
    
    sales_db : "",
    mouse_get_sales : function() {
        
        var cur_site_id = $('#cur_site_id').val();
        $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"mouse_get_sales",
                                    cur_site_id : cur_site_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re == 1) {
                                    
                                if (thejson.re_data) {
                                    
                                    var the_html = "<div class='the_sales_products_holder_pop_up'>";
                                    the_html += "<div class='the_sales_products_holder_pop_up_in'>";
                                    the_html += "<div class='the_owl owl-carousel'>";
                                    $(thejson.re_data).each(function(kk,vv) {
                                        
                                        the_html += "<a href='"+vv.url+"' title='"+vv.title+"'>";
                                        the_html += "<div class='sale_prod_box'>";
                                        the_html += "<div class='sale_prod_box_img'><img src='"+vv.main_img+"' /></div>";
                                        the_html += "<div class='sale_title'>"+vv.title+"</div>";
                                        the_html += "<div class='sale_price'>₪"+vv.price_sale+" | <span style='text-decoration:line-through; font-size:18px;'>₪"+vv.price+"</span> </div>";
                                        var calc_saving =  100 - ( ( vv.price_sale / vv.price ) * 100);
                                        the_html += "<div class='sale_price2'>"+calc_saving.toFixed(0)+"% הנחה</div>";
                                        the_html += "<div class='sale_but'>הוסף לעגלה</div>";
                                        the_html += "</div>"; //sale_prod_box
                                        the_html += "</a>";
                                        
                                    });
                                    the_html += "</div>";
                                    
                                    the_html += "</div>"; //the_sales_products_holder_pop_up_in
                                    the_html += "</div>"; //the_sales_products_holder_pop_up
                                    
                                    $('.sale_txt_zone').html(the_html);
                                    
                                    var owl_mobile = $('.the_owl').owlCarousel({
                                        items : 10,
                                        rtl: true,
                                        autoWidth:true,
                                        margin:5,
                                        responsive:{
                                            0:{
                                                items:1,
                                            },
                                            600:{
                                                items:3,
                                            },
                                            1000:{
                                                items:4,
                                            }
                                        }
                                        });
                                }
                                
                                }
                            },
                            error:function(){
                            }
                            });
        
    },
    
    mouse_pos_pop_ups : function(type) {
        
        console.log("the_info_txt->"+the_info_txt);
        var get_txt = $.parseJSON(the_info_txt);
        
        
        var escape_flag = $('#escape_flag').val();
        if (escape_flag == 0) {        
        var iframe_flag = $('#iframe_flag').val();
        if (iframe_flag == 0) {
        var cur_width = $(window).width();
        
        if (cur_width >= 1050) {
        
        var cur_site_id = $('#cur_site_id').val();
        if (cur_site_id > 0) {
        
        if (type == 1) {
            // נטישה
            if ($('.ser_page_renna').length) {
                // SER IS OPEN
            } else {
            if ($('#no_escape').length) {
                //ALL READY ON SCREEN
            } else {
            
            var the_css = "";
            the_css += ".the_force_pop_up_holderr{";
            the_css += "position: fixed;";
            the_css += "top:0;";
            the_css += "left:0;";
            the_css += "width:100%;";
            the_css += "height:100vh;";
            the_css += "z-index:1500;";
            the_css += "background: rgba(0,0,0,0.6);";
            the_css += "display: flex;";
            the_css += "justify-content: center;";
            the_css += "align-items: center;";
            the_css += "}";
                    //.the_force_pop_up{}
            the_css += ".the_force_pop_up_in{";
            the_css += "    width: 500px;";
            the_css += "}";
            the_css += ".the_force_pop_up_in {";
            the_css += "width: 500px;";
            the_css += "font-size: 22px;";
            the_css += "color: white;";
            the_css += "text-align: center;";
            the_css += "}";
            the_css += ".the_all_form1{";
            the_css += "font-size:50px;";
            the_css += "color:orange;";
            the_css += "text-shadow:2px 1px 1px black;";
            the_css += "margin-bottom: 15px;";
            the_css += "}";
            the_css += ".the_all_form3 input,.the_all_form4 input,.the_all_form5 input{";
            the_css += "width: 100%;";
            the_css += "padding: 10px;";
            the_css += "font-size: 18px;";
            the_css += "margin-top: 10px;";
            the_css += "}";
            the_css += ".the_all_form6{";
            the_css += " width:100%; ";
            the_css += " padding:10px; margin-top:10px; ";
            the_css += " font-weight:bold; color:white; background:black; border-radius:3px; cursor:pointer;  transition: all 300ms;";
            the_css += "}";
            the_css += ".the_all_form6:hover{";
            the_css += "color:black; background:white;";
            the_css += "}";
            the_css += ".the_force_pop_up_in_close{";
            the_css += "text-align:center; color:white; font-weight:bold; cursor:pointer; font-size:30px; text-decoration:underline;";
            the_css += "}";
            
            //sale_but
            the_css += ".sale_but{ position: absolute; top: calc(50% - 35px); right: calc(50% - 40px); font-weight: bold;  padding: 10px;   border: 1px solid white; text-decoration: none; color: white;  font-family: 'Assistant_bold'; background: mediumseagreen; border-radius: 3px; box-shadow: 1px 1px 5px white; transition: all 300ms; }";
            
            the_css += ".sale_but:hover{ box-shadow: 1px 1px 5px black; }";
            
            the_css += ".the_force_pop_up{ height: calc(100vh - 360px); }";
            
            the_css += ".the_sales_products_holder_pop_up_in{ padding-top:10px; padding-bottom:10px; }";
            the_css += ".sale_prod_box{ width:330px; height:330px; overflow:hidden; position: relative; }";
            the_css += ".sale_prod_box img{ width:300px; height:300px; object-fit:contain; overflow:hidden; background:white;}";
            the_css += ".sale_title { position: absolute; bottom: 60px; right:0px; width:100%; z-index: 150; color: black; font-size: 18px; font-family: 'Assistant_ExtraBold';  text-align: center; background: white; }";
            the_css += ".the_owl{width:100%; }";
            
            the_css += ".sale_price{ position: absolute; top: 0px; left:0px; z-index: 150; color: black; font-size: 22px; font-family: 'Assistant_ExtraBold';  text-align: center; padding:5px; box-sizing:box-border; background:white;  }";
            the_css += ".sale_price2{ position: absolute; top: 0px; right:0px; z-index: 150; color: black; font-size: 22px; font-family: 'Assistant_ExtraBold';  text-align: center; padding:5px; box-sizing:box-border; background:white;  }";
            
            the_css += " .sale_txt{ position: absolute; bottom: 375px; font-size: 30px; color: white; font-family: 'Assistant_light'; text-decoration: none; padding-right: 10px;     padding-left: 10px;     border-bottom: 1px solid white; padding-bottom: 5px;     padding-top: 5px; } ";
            
            //sale_txt
            
            //sale_price
            //the_sales_products_holder_pop_up
            
            the_css += ".the_sales_products_holder_pop_up{";
            the_css += " position:fixed; bottom:0px; height:360px; width:100%; background:black; left:0px; z-index:150;";
            the_css += "";
            
            the_css += "";
            the_css += "}";
            
            $('.the_force_pop_up_holderr').remove();
            var the_html = "";
            
            the_html += "<style id='no_escape'>"+the_css+"</style>";
            
            the_html += "<div class='the_force_pop_up_holderr'>";
            
            the_html += "<div class='the_force_pop_up'>";
            the_html += "<div class='the_force_pop_up_in'>";
            
            the_html += "<div class='the_force_pop_up_in_close' onclick=\" tools.mouse_pos_pop_ups_close_it(); \">סגירה</div>";
            
            the_html += "<div class='the_all_form'>";
            the_html += "<div class='the_all_form1'>"+get_txt.escape_title+"</div>";
            the_html += "<div class='the_all_form2'>"+get_txt.escape_txt+"</div>";
            the_html += "<div class='the_all_form3 the_full_name'><input type='text' placeholder='שם מלא' class='full_name' /></div>";
            the_html += "<div class='the_all_form4 the_m_phone'><input type='number' placeholder='0500000000' class='m_phone' /></div>";
            the_html += "<div class='the_all_form5 the_email'><input type='email' placeholder='email@email.co.il' class='your_email' /></div>";
            the_html += "<div class='the_all_form6 the_but' onclick=\" tools.mouse_con_us_but(this); \" >שלח</div>";
            the_html += "</div>"; //the_all_form
            
            the_html += "</div>"; //the_force_pop_up_in
            
            the_html += "</div>"; //the_force_pop_up
            
            if (get_txt.escape_title_d.length > 0) {
            the_html += "<div class='sale_txt'>"+get_txt.escape_title_d+"</div>";
            the_html += "<div class='sale_txt_zone'>";
            the_html += "</div>"; //sale_txt_zone
            }
            
            the_html += "</div>"; //the_force_pop_up_holderr
            
            $('body').prepend(the_html);
            if (get_txt.escape_title_d.length > 0) {
            tools.mouse_get_sales();
            }
        
        /*
        $.getScript( "https://unpkg.com/swiper@8/swiper-bundle.min.js", function( data, textStatus, jqxhr ) {
            
            
            
            var the_html = "";
            the_html += "<div class='idan_pop_ups_swiper swiper mySwiper'>";
            the_html += "<div class='idan_pop_ups_swiper_in swiper-wrapper'>";
            the_html += "<div class='idan_pop_ups_swiper_row swiper-slide'><img src='https://swiperjs.com/demos/images/nature-1.jpg' /></div>";
            the_html += "<div class='idan_pop_ups_swiper_row swiper-slide'><img src='https://swiperjs.com/demos/images/nature-1.jpg' /></div>";
            the_html += "<div class='idan_pop_ups_swiper_row swiper-slide'><img src='https://swiperjs.com/demos/images/nature-1.jpg' /></div>";
            the_html += "<div class='idan_pop_ups_swiper_row swiper-slide'><img src='https://swiperjs.com/demos/images/nature-1.jpg' /></div>";
            the_html += "</div>"; //swiper-wrapper
            the_html += "</div>"; //swiper
            
            the_html += "<div class='swiper-pagination'></div>";
            
            $('.sale_txt_zone').html(the_html);
            
            var swiper = new Swiper(".mySwiper", {
              effect: "coverflow",
              grabCursor: true,
              centeredSlides: true,
              slidesPerView: "auto",
              coverflowEffect: {
                rotate: 50,
                stretch: 0,
                depth: 100,
                modifier: 1,
                slideShadows: true,
              },
              pagination: {
                el: ".swiper-pagination",
              },
            });
    
            
        });
        */
        
                }
            }
            
        }
        
        }
        
        }
        
        }
        
        }
        
    },
    
    mouse_pos : function() {
        
        var the_hot_zones = [];
        var the_width = $(window).width();
        
        var the_10_pre = the_width * (5/100);
        var the_90_pre = the_width * (90/100);
        var the_20_pre = the_width * (20/100);
        var the_80_pre = the_width * (80/100);
        
                    
        var language = window.navigator.userLanguage || window.navigator.language;
        var pointerX = -1;
        var pointerY = -1;
        document.onmousemove = function(event) {
                pointerX = event.pageX;
                pointerY = event.pageY;
                
                //console.log("pointerX->"+pointerX+" -> pointerY -> "+pointerY+" -> language "+language);
                //console.log("the_20_pre->"+the_20_pre+" -> the_80_pre -> "+the_80_pre);
                
                    /*
                    if (pointerX > the_20_pre && pointerX < the_80_pre) {
                        if (pointerY >= 0 && pointerY <= 25) {
                            console.log("EXIT ON CENTER");
                            tools.mouse_pos_pop_ups(1);
                        }
                    }
                    */
                
                if ( language.includes("he") ) {
                    // שמאל
                    if (pointerX > 0 && pointerX < the_10_pre) {
                        if (pointerY >= 0 && pointerY <= 50) {
                            console.log("EXIT IN HEB");
                            tools.mouse_pos_pop_ups(1);
                        }
                    }
                    
                    
                } else {
                    // en
                    // ימין
                    if (pointerX >= the_90_pre && pointerX <= the_width) {
                        if (pointerY >= 0 && pointerY <= 50) {
                            console.log("EXIT IN EN");
                            tools.mouse_pos_pop_ups(1);
                        }
                    }
                }
        }
        
    },
}
var valid = {
    is_int: function(value) {
    var x = parseFloat(value);
    return !isNaN(value) && (x | 0) === x;    
    },
     isInt: function(value) {
    var x = parseFloat(value);
    return !isNaN(value) && (x | 0) === x;
    },
    do_copy : function(ele) {
        var txt = $(ele).parent().find('.re_type_val_in_doc');
        txt.select();
        document.execCommand("copy");
        Swal.fire("הועתק - "+txt.val());
    },
    do_copy_recss : function(ele) {
        var txt = $(ele).parent().parent().find('.re_type_val_in_doc');
        txt.select();
        document.execCommand("copy");
        Swal.fire("הועתק - "+txt.val());
    },
    mobile : function(mobile) {
        if (/^\d{10}$/.test(mobile)) {
            return true;
        } else {
            return false;
        }
    },
    email : function(email) {
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        if (re.test(email)) {
            return true;
        } else {
            return false;
        }
    }
}
var the_mobile_menu = {
    sub_open : function(ele) {
        var sub_div = $(ele).attr("sub_div");
        $('.'+sub_div).slideToggle('fast');
    },
    open : function(ele) {
        var cur_site_id = $('#cur_site_id').val();
        var cur_store_id = $('#cur_store_id').val();
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"the_mobile_menu_open",
                                    cur_site_id : cur_site_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re_data) {
                                    
        $('.the_menu_black_pop_up').remove();
        
        var the_html = "<div class='the_menu_black_pop_up'>";
        the_html += "<div class='the_menu_black_pop_up_in'>";
        the_html += "<a onclick=\" $('.the_menu_black_pop_up').remove(); \"><div class='the_menu_black_pop_up_in_title_close'>X (סגור)</div></a>";
        the_html += "<div>";
        var the_i = 1;
        $(thejson.re_data).each(function(kk,vv){
            if (vv.type == 1) {
        the_html += "<div class='links_area_main the_overflow'>";
        the_html += "<a href='"+vv.url+"'><div class='links_area_main1_r float_right'>"+vv.title+"</div></a>";
        the_html += "<a onclick=\" the_mobile_menu.sub_open(this); \" sub_div='llaa_zone_"+the_i+"' ><div class='links_area_main2_l float_left'>"+gog_keyboard_arrow_down+"</div></a>";
        the_html += "</div>";
        the_html += "<div class='the_sub_cats_zone llaa_zone_"+the_i+"'>";
        $(thejson.re_data).each(function(kkk,vvv){
            if (vvv.type == 2 && vvv.owner_id == vv.id) {
            the_html += "<div class='links_area_main_sub the_overflow'>";
            the_html += "<a href='"+vvv.url+"'>";
            the_html += "<div class='links_area_main_sub_in the_overflow'>";
            the_html += vvv.title;
            the_html += "</div>";
            the_html += "</a>";
            the_html += "</div>";    
            }
        });
        the_html += "</div>";        
            }
            the_i++;
        });
        the_html += "";
        the_html += "";
        the_html += "</div>";
        the_html += "<div class='the_down_text1 the_overflow'>";
        the_html += "<a>צרו עימנו קשר</a>";
        the_html += "</div>";
        the_html += "<div class='the_overflow the_sociel_icons'>";
        the_html += "<div class='the_inline'><img src='/Css/Imgs/icon_fb.png' /></div>";
        the_html += "<div class='the_inline the_socie_mid'><img src='/Css/Imgs/icon_istegram.png' /></div>";
        the_html += "<div class='the_inline'><img src='/Css/Imgs/google_icon.png' /></div>";
        the_html += "</div>";
        the_html += "</div>"; //the_menu_black_pop_up_in
        the_html += "</div>"; //the_menu_black_pop_up
        $('body').append(the_html);        
                                }
                            },
                            error:function(){
                            }
                            });
    },
}
var the_wish_list = {
    site_login : function(ele) {
        var email = $(ele).parent().parent().parent().find('.email').val();
        var pass = $(ele).parent().parent().parent().find('.pass').val();
        var cur_site_id = $('#cur_site_id').val();
        if (valid.email(email)) {
            if (pass.length > 0) {
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"site_login_users_sites",
                                    cur_site_id : cur_site_id,
                                    email : email,
                                    pass : pass
                                    },
                            dataType: "html",
                            beforeSend:function(){},
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re == 1) {
                                      location.reload();
                                } else {
                                     Swal.fire(thejson.re_err);
                                }
                            },
                            error:function(){
                            }
                            });
            } else {Swal.fire("נא למלא סיסמא");}
        } else {Swal.fire("נא למלא אימייל תקין");}
    },
    site_login_pass_restore : function(ele) {},
    site_register : function(ele) {
        var cur_site_id = $('#cur_site_id').val();
        var full_name = $(ele).parent().parent().parent().find('.full_name').val();
        var email = $(ele).parent().parent().parent().find('.email').val();
        var m_phone = $(ele).parent().parent().parent().find('.m_phone').val();
        //var sociel_id = $(ele).parent().parent().parent().find('.sociel_id').val();
        var prod_id = $(ele).parent().parent().parent().parent().find('.prod_id').val();
        if (prod_id > 0) {
        if (full_name.length > 0) {
            if (email.length > 0) {
                if (m_phone.length > 0) {
                    if (sociel_id.length > 0) {
                        if (valid.email(email)) {
                            if (valid.mobile(m_phone)) {
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"the_wish_list_site_register",
                                    cur_site_id : cur_site_id,
                                    full_name : full_name,
                                    email : email,
                                    m_phone : m_phone,
                                    prod_id : prod_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re == 1) {
                                      Swal.fire("תודה רבה, הפריט סומן לאזור הWISHLIST שלך");
                                      location.reload();
                                } else {
                                    Swal.fire(thejson.re_err);
                                }
                            },
                            error:function(){
                            }
                            });
                            } else {Swal.fire("נא למלא מספר נייד תקין");}
                        } else {Swal.fire("נא למלא אימייל תקין");}
                    } else {Swal.fire("נא למלא תעודת זהות כולל ספרת ביקורת");}
                } else {Swal.fire("נא למלא טלפון נייד");}
            } else {Swal.fire("נא למלא אימייל");}
        } else {Swal.fire("נא למלא שם מלא");}
        } else {Swal.fire("תקלה, נא לרפרש");}
    },
    switch_l_r : function(type,ele) {
        $('.aassaaz').removeClass('stat_active_log');
        $('.all_s_s_s').css('display','none');
        $(ele).parent().addClass('stat_active_log');
        if (type == 1) {
            $('.the_login_screeen').css('display','block');
        }
        if (type == 2) {
            $('.the_register_screeen').css('display','block');
        }
    },
    remove : function(prod_id,ele) {
            var cur_site_id = $('#cur_site_id').val();
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"the_wish_list_remove",
                                    cur_site_id : cur_site_id,
                                    prod_id : prod_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                $(ele).parent().remove();
                            },
                            error:function(){}
                            });    
    },
    add : function(prod_id,ele) {
        var cur_dodmain_url = $('#cur_dodmain').val();
        var p_url = "https://"+cur_dodmain_url+"/me";
                            var cur_site_id = $('#cur_site_id').val();
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"the_wish_list_cheak_login",
                                    cur_site_id : cur_site_id,
                                    prod_id : prod_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re == 1) {
                                    $(ele).find('.products_show_all_in6_1_icon').html(gog_favorite);
    var the_html = "<div class='the_wish_box'>";
    the_html += "<div class='the_wish_box_in'>";
    the_html += "";
    the_html += "";
        the_html += "<div class='the_cart_zone_details_wish'>";
        the_html += "<div class='the_cart_zone_details_wish_in'>";
        the_html += "<div class='the_button_summin_in_buts_aaa'>";
        the_html += "<div class='wl_title'>";
        the_html += "<div class='wl_title1'>My Wishlist</div>";
        //the_html += "<div class='wl_title2'>My Wishlist</div>";
        the_html += "</div>";
        the_html += "</div>";
        the_html += "<div class='all_w_l_products'>";
        if (thejson.re_data) {
            $(thejson.re_data).each(function(kk,vv){
                the_html += "<div class='the_wish_list_li_box the_rel'>";
                the_html += "<a onclick=\" the_wish_list.remove('"+vv.id+"',this); \"><div class='the_w_l_del'><span class='the_w_l_del_icon'>"+gog_delete_outline+"</span></div></a>";
                the_html += "<a href='"+vv.url+"'><div class='the_wish_list_li_box1'>"+vv.title+"</div></a>";
                the_html += "<div class='the_wish_list_li_box2'><img src='"+vv.main_img+"' /></div>";
                the_html += "</div>";
            });
        }
        the_html += "</div>";
        the_html += "<div class='the_button_summin_in_buts_aaa' style='margin-top:20px;'>";
        the_html += "<div class='the_button_summin_in_buts1_login'><input type='button' value='חזרה לחנות' onclick=\" $('.the_wish_box').remove(); \"/></div>";
        the_html += "</div>";
        the_html += "<div class='the_button_summin_in_buts_aaa' style='margin-top:20px;'>";
        the_html += "<div class='the_button_summin_in_buts1_login'><input type='button' value='אזור אישי' onclick=\" window.location.href = '"+p_url+"'; \"/></div>";
        the_html += "</div>";
        the_html += "</div>"; //the_cart_zone_details_wish_in
        the_html += "</div>"; //the_cart_zone_details_wish
        $('body').append(the_html);
                                } else {
    var the_html = "<div class='the_wish_box'>";
    the_html += "<div class='the_wish_box_in'>";
    the_html += "";
    the_html += "";
        the_html += "<div class='the_cart_zone_details_wish'>";
        the_html += "<div class='the_cart_zone_details_wish_in'>";
        the_html += "<div class='the_button_summin_in_buts_aaa'>";
        the_html += "<div class='aassaaz the_button_summin_in_buts1'><input type='button' value='התחברות' onclick=\" the_wish_list.switch_l_r(1,this); \" /></div>";
        the_html += "<div class='aassaaz the_button_summin_in_buts114 stat_active_log'><input type='button' value='הצטרפות' onclick=\" the_wish_list.switch_l_r(2,this); \" /></div>";
        the_html += "</div>";
        the_html += "<input type='hidden' value='"+prod_id+"' class='prod_id' />";
        the_html += "<div class='the_login_screeen all_s_s_s'>";
        the_html += "<div class='the_tab2_t1' >כיף שחזרתם , התחברו</div>";
        the_html += "<div class='the_tab2_t1_row'>";
        the_html += "<div class='the_tab2_t1_row1'>אימייל</div>";
        the_html += "<div class='the_tab2_t1_row2'><input type='email' placeholder='email@email.co.il' class='email' /></div>";
        the_html += "</div>";
        the_html += "<div class='the_tab2_t1_row'>";
        the_html += "<div class='the_tab2_t1_row1'>סיסמא</div>";
        the_html += "<div class='the_tab2_t1_row2'><input type='password' placeholder='XXXXXX' class='pass' /></div>";
        the_html += "</div>";
        the_html += "<div class='the_button_summin_in_buts_aaa' style='margin-top:20px;'>";
        the_html += "<div class='the_button_summin_in_buts1_login'><input type='button' value='הכנסו' onclick=\" the_wish_list.site_login(this); \"/></div>";
        the_html += "<a onclick=\" the_wish_list.site_login_pass_restore(this); \"><div class='the_tab2_t22' >שיחזור סיסמא</div></a>";
        the_html += "</div>";
        the_html += "</div>";
        the_html += "<div class='the_register_screeen all_s_s_s'>";
        the_html += "<div class='the_tab2_t1' >איזה כיף, קצת פרטים ומצטרפים</div>";
        the_html += "<div class='the_tab2_t1_row'>";
        the_html += "<div class='the_tab2_t1_row1'>שם מלא</div>";
        the_html += "<div class='the_tab2_t1_row2'><input type='text' placeholder='שם מלא' class='full_name' /></div>";
        the_html += "</div>";
        the_html += "<div class='the_tab2_t1_row'>";
        the_html += "<div class='the_tab2_t1_row1'>אימייל</div>";
        the_html += "<div class='the_tab2_t1_row2'><input type='email' placeholder='email@email.co.il' class='email' /></div>";
        the_html += "</div>";
        the_html += "<div class='the_tab2_t1_row'>";
        the_html += "<div class='the_tab2_t1_row1'>טלפון נייד</div>";
        the_html += "<div class='the_tab2_t1_row2'><input type='number' placeholder='0525209340' class='m_phone' /></div>";
        the_html += "</div>";
        //the_html += "<div class='the_tab2_t1_row'>";
        //the_html += "<div class='the_tab2_t1_row1'>תעודת זהות</div>";
        //the_html += "<div class='the_tab2_t1_row2'><input type='number' placeholder='039909864' class='sociel_id' /></div>";
        //the_html += "</div>";
        the_html += "<div class='the_button_summin_in_buts'>";
        the_html += "<div class='the_button_summin_in_buts1'><input type='button' value='לא כרגע' onclick=\" $('.the_wish_box').remove(); \"/></div>";
        the_html += "<div class='the_button_summin_in_buts2'><input type='button' value='הצטרפו' onclick=\" the_wish_list.site_register(this); \" /></div>";
        the_html += "</div>";
        the_html += "</div>"; //the_register_screeen
    the_html += "</div>"; //the_wish_box_in
    the_html += "</div>"; //the_wish_box
    $('body').append(the_html);                                
                                }
                            },
                            error:function(){}
                            });
    },
}
var the_cart_theam = {
    
    cart_tax : 17,
    cart_tax_flag : 1,
    
    u_f_name : "",
    u_email : "",
    u_mobile : "",
    u_sociel_id : "",
    
    cur_sum : 0,
    cur_sum_del : 0,
    cur_flag_del : 0,
    
    cart_delivery_data : "",
    
    cart_delivery_data_more : "",
    
    all_citys_db : "",
    
    paypal : "",
    paypal_stat : 0,
    
    privacy_url : "/privacy",
    regulation_url : "/regulations",
    
    cur_unix_time : "",
    
    init_open : 0,
    
    order_by_phone : 0,
    biz_info : "",
    
    init : function() {
        
     var cur_site_id = $('#cur_site_id').val();
        
                            $.ajax({
                            type: 'POST',
                            url: "/Ajax/sites_ajax.php",
                            data: { 
                                    action:"get_delivery_data",
                                    cur_site_id : cur_site_id
                                    },
                            dataType: "html",
                            beforeSend:function(){
                            },
                            success:function(responseaa){
                                var thejson =  $.parseJSON(responseaa);
                                if (thejson.re_data) {
                                    
                                    the_cart_theam.cart_delivery_data = thejson.re_data;
                                    the_cart_theam.cart_delivery_data_more = thejson.delivery_more;
                                    the_cart_theam.all_citys_db = thejson.all_citys;
                                    
                                    the_cart_theam.privacy_url = thejson.privacy_url;
                                    the_cart_theam.regulation_url = thejson.regulations_url;
                                    the_cart_theam.paypal = thejson.paypal_data;
                                    
                                    the_cart_theam.cur_unix_time = thejson.cur_time;
                                    the_cart_theam.biz_info = thejson.biz_info;
                                    
                                    the_cart_theam.init_open = 1;
                                    
                                    if (thejson.biz_info) {
                                        if (thejson.biz_info.order_by_phone == 1) {
                                            the_cart_theam.order_by_phone = 1;
                                        }
                                    }
                                    
                                }
                                
                            },
                            error:function(){
                              
                              
                              
                            }
                            });   
        
    },
    
    cart_data : "",
    
    last_postions : "",
    
    the_map : "",
    
    update_bag_number : function() {
        
        //bag_number
        var bag_data = "";
        var local_data = localStorage.getItem('cart_data');
            if (local_data) {
            bag_data = $.parseJSON(local_data);
            }
            
            var items = 0;
            $(bag_data).each(function(kk,vv){
                items++;
            });
            
            $('.txt_bag_not_uniq,.bag_number_mmm').html(items);
            $('#txt_bag').html(items);
            $('#txt_bag_m').html(items);
        
    },
    
    
    
}
var adika_js_agter_load_chaekr = false;
the_cart_theam.show = function(aa_prod_id) {
        var cur_site_id = $('#cur_site_id').val();
        if (adika_js_agter_load_chaekr) { the_cart_theam.show_the_older(aa_prod_id); } else {
        $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
            if (cur_site_id == 38 || cur_site_id == 27 || cur_site_id == 22) {
                $.getScript('https://www.sitisell.com/temps/comjet/Js/comjet_cart.js').then(function () {
                    adika_js_agter_load_chaekr = true;
                    the_cart_theam.show_the_older(aa_prod_id);
                });
            } else {
                adika_js_agter_load_chaekr = true;
                the_cart_theam.show_the_older(aa_prod_id);
                }
        });
        }
    }
the_cart_theam.add_to_cart = function(prod_id,ele) {
        var cur_site_id = $('#cur_site_id').val();
    if (adika_js_agter_load_chaekr) { the_cart_theam.add_to_cart_after_load(prod_id,ele); } else {
        $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
            if (cur_site_id == 38 || cur_site_id == 27 || cur_site_id == 22) {
                
                $.getScript('https://www.sitisell.com/temps/comjet/Js/comjet_cart.js').then(function () {
                    adika_js_agter_load_chaekr = true;
                    the_cart_theam.add_to_cart_after_load(prod_id,ele);
                });
                
            } else {
            adika_js_agter_load_chaekr = true;
            the_cart_theam.add_to_cart_after_load(prod_id,ele);
            }
        });
    }
}    
var the_menu = {
    the_cats_info : "",
    the_cats_subs_info : "",
    top_menu : function(catid) {
        $('.menu_zone').css('display','none');
        var nav_bar = $('.attch_sub_menu').position();
        var nav_bar_height = $('.attch_sub_menu').outerHeight();
        var calc = nav_bar.top + nav_bar_height;
        $('#menu_zone_'+catid).css('display','block');
    },
    onhover : function() {
    $('.main_triger').mouseover(function() {
    var cur_site_id = $('#cur_site_id').val();    
    var catid = $(this).attr('catid');
    the_menu.top_menu(catid);
    });
    $('.the_cart_box').mouseover(function() {
        the_cart_theam.show(0);
    });
    },
}
var visual_show = {
    make_liner : function() {
        var the_html = "<div class='the_toper_liner'><div>";
        $('body').prepend(the_html);
        setTimeout(function(){ 
        $('.the_toper_liner').addClass('the_toper_liner_color');
        }, 100);
    },
}
var the_nav_top = {
    set_des : function() {
        
        the_screeen_width = $(window).width();
        
        if (the_screeen_width < 1450) {
            var the_calc = "calc((100% - "+the_screeen_width+"px)/2)";
            $('.the_main_link_story_in').css('right',the_calc);
            $('.the_main_link_story_in').css('width','98%');
            $('.the_main_link_story_in').css('margin-right','1%');
            $('.the_main_link_story_in').css('margin-left','1%');
            console.log(the_calc);
        }
    },
}
var the_gall = {
        cur_img_big : "",
        the_imgs : "",
        the_imgs_total : 0,
        get_imgs : function() {
            the_gall.the_imgs_total = 0;
            var get_all_imgs = [];
            $('.products_show_all_in2_all_1').find('.small_gal_img').each(function(){
                var imgid = $(this).find('img').attr("imgid");
                var img_src = $(this).find('img').attr("big_size_src");
                var img_height = $(this).find('img').height() + parseInt(10);
                var the_Rec = {
                    'imgid':imgid
                    ,'img_src':img_src
                    ,'img_height':img_height
                };
                get_all_imgs.push(the_Rec);
                the_gall.the_imgs_total++;
            });
            the_gall.the_imgs = get_all_imgs;
        },
        
        pick_img : function(ele) {
            $('.small_gal_img').each(function() {
                $(this).find('img').css('border','1px solid transparent');
            });
            var img_src = $(ele).find('img').attr("src");
            var img_src_big = $(ele).find('img').attr("big_size_src");
            var img_imgid = $(ele).find('img').attr("imgid");
            $(ele).find('img').css('border','1px solid black');
            $('.the_img_main_2 img').attr('src',img_src_big);
                the_gall.cur_img_big = img_imgid;
                $('#cur_img_big').val(the_gall.cur_img_big);
                the_gall.right_slider(img_imgid);
        },
        right_slider : function(img_id) {
            $('.small_gal_img').each(function() {
                $(this).find('img').css('border','1px solid transparent');
            });
            if (img_id == 0) {
                $('.small_gal').css('margin-top','0px');
            } else {
                if (img_id > 0) {
                    $('.small_gal_img').each(function() {
                        var imgid = $(this).find('img').attr("imgid");
                        if (imgid == img_id) {
                            $(this).find('img').css('border','1px solid black');
                        }
                    });
                    var calc_margin = 0;
                    $(the_gall.the_imgs).each(function(kk,vv){
                        calc_margin = parseFloat(calc_margin) + parseFloat(vv.img_height);
                        if (vv.imgid == img_id) {
                            calc_margin = calc_margin - vv.img_height;
                            return false; 
                        }
                    });
                    //$('.small_gal').css('margin-top',"-"+calc_margin+'px');
                    $('.small_gal').animate({ marginTop: '-'+calc_margin+'px' }, 500);
                    $('.the_img_main_2').addClass('item_blur_out');
                }
            }
        },
        arrow_right : function() {
            console.log("arrow_right");
            var cur_img_big = $('#cur_img_big').val();
            if (cur_img_big > 0) {
                cur_img_big = parseInt(cur_img_big) - parseInt(1);
                the_gall.cur_img_big = cur_img_big;
                $('#cur_img_big').val(the_gall.cur_img_big);
                the_gall.right_slider(cur_img_big);
                the_gall.show_img();
            }
        },
        arrow_left : function() {
            console.log("arrow_left");
            var cur_img_big = $('#cur_img_big').val();
            if (cur_img_big >= 0) {
                cur_img_big = parseInt(cur_img_big) + parseInt(1);
                if ( (the_gall.the_imgs_total - 1) >= cur_img_big) {} else {
                    cur_img_big = 0;
                }
                the_gall.cur_img_big = cur_img_big;
                $('#cur_img_big').val(the_gall.cur_img_big);
                the_gall.right_slider(cur_img_big);
                the_gall.show_img();
            }
        },
        
        show_img : function() {
            $(the_gall.the_imgs).each(function(kk,vv){
                if (vv.imgid == the_gall.cur_img_big) {
                    $('.the_img_main_2 img').attr("src",vv.img_src);
                }
            });
        },
    }
var the_ser_vegi = {
    
    ser_page : function() {
        if (adika_js_agter_load_chaekr) {
            the_ser_vegi_after.ser_page();
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                the_ser_vegi_after.ser_page();

            });
        }
    },
    ser : function(ele) {
        if (adika_js_agter_load_chaekr) {
            the_ser_vegi_after.ser(ele);
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                the_ser_vegi_after.ser(ele);

            });
        }
    },
}
var clicks = {
    phone_click : function() {
        if (adika_js_agter_load_chaekr) {
            clicks_after.phone_click();
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                clicks_after.phone_click();

            });
        }
    },
    whatsapp_click : function() {
        if (adika_js_agter_load_chaekr) {
            clicks_after.whatsapp_click();
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                clicks_after.whatsapp_click();

            });
        }
    },
}
var con_us = {
    send : function(ele) {
        if (adika_js_agter_load_chaekr) {
            con_us_after.send(ele);
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                con_us_after.send(ele);

            });
        }
    },
    send_duble : function(ele) {
        if (adika_js_agter_load_chaekr) {
            con_us_after.send_duble(ele);
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                con_us_after.send_duble(ele);

            });
        }
    },
}
var news_latter = {
    cheak_it2 : function(ele) {
        var stat = $(ele).attr("stat");
        if (stat == 0) {
            $(ele).attr("stat",1);
            $('#approve_new_latter').val(1);
            $(ele).find('.the_footer_all_in1_in_cheak_box_icon2').html(gog_check_box);
        }
        if (stat == 1) {
            $(ele).attr("stat",0);
            $('#approve_new_latter').val(0);
            $(ele).find('.the_footer_all_in1_in_cheak_box_icon2').html(gog_check_box_outline_blank);
        }
    },
    cheak_it : function(ele) {
        var stat = $(ele).attr("stat");
        if (stat == 0) {
            $(ele).attr("stat",1);
            $('#approve_new_latter').val(1);
            $(ele).find('.the_footer_all_in1_in_cheak_box_icon').html(gog_check_box);
        }
        if (stat == 1) {
            $(ele).attr("stat",0);
            $('#approve_new_latter').val(0);
            $(ele).find('.the_footer_all_in1_in_cheak_box_icon').html(gog_check_box_outline_blank);
        }
    },
    add : function(ele) {
        if (adika_js_agter_load_chaekr) {
            news_latter.add_after(ele);
        } else {
            $.getScript('https://www.sitisell.com/temps/adika_js_after_load.js').then(function () {
                adika_js_agter_load_chaekr = true;
                news_latter.add_after(ele);

            });
        }
    },
}

var recomends_pop_up = {
    
    show : function() {
        
        $('.recomends_pop_up_box').remove();
        
        var the_html = "";
            the_html += "<div class='recomends_pop_up_box'>";
            the_html += "<style>";
            the_html += ".recomends_pop_up_box { z-index: 1111111111; transition: all 1000ms; position:fixed; bottom:25px; left:-350px; width:300px; padding:5px; border-radius:3px; background-color:rgba(245,245,245,1); }";
            the_html += ".recomends_pop_up_box_r img{ width:100px; }";
            the_html += ".recomends_pop_up_box_l { width: calc(100% - 110px); margin-right: 5px; line-height: 20px; font-family: 'Assistant_light'; height:100px; display: flex; align-items: center; justify-content: right; }";
            the_html += ".recomends_pop_up_box_r { width: 100px; height: 100px; border-radius: 50%; overflow: hidden; }";
            the_html += ".recomends_pop_up_box_show { left:25px; border: 1px solid lightgray; border-radius: 3px; box-shadow: 5px 5px 10px rgba(0,0,0,0.2);}";
            the_html += "</style>";
            the_html += "<div class='recomends_pop_up_box_in the_overflow'>";
            the_html += "<div class='recomends_pop_up_box_r float_right'><img src='/temps/kesem/imgs/the_person.jpg' /></div>";
            the_html += "<div class='recomends_pop_up_box_l float_right'>";
            the_html += "עידן חוגג 40 ועושה מסיבה גדולה , החליט להזמין את כולם בצורה יחודית ועשה הזמנה דיגטלית";
            the_html += "</div>"; //recomends_pop_up_box_l
            the_html += "</div>"; //recomends_pop_up_box_in
            the_html += "</div>"; //recomends_pop_up_box
            
            $('body').prepend(the_html);
            
            setTimeout(function(){
                $('.recomends_pop_up_box').addClass('recomends_pop_up_box_show');
            }, 1000);
    },
    
}

var the_screeen_width = "";
function onTouchStart() {};
document.addEventListener('touchstart', onTouchStart, {passive: true});

$(function() {
    
    var the_site_id = $('#cur_site_id').val();
    var iframe_flag = $('#iframe_flag').val();
    
    tools.mouse_pos();
    
    setTimeout(function(){ 
    
    the_screeen_width = $(window).width();
    var cur_site_id = $('#cur_site_id').val();
    var cur_temp_id = $('#cur_temp_id').val();
    if (cur_temp_id == 1 || cur_temp_id == 13) {
        the_cart_theam.init();
    $(window).scroll(function () {
        if ($('.the_cart_all_box_fly_holder')) {
        var the_cart_all_box_fly = $('.the_cart_all_box_fly_holder').offset();
        if (the_cart_all_box_fly) {
        if (the_cart_all_box_fly.top <= 220) {
             $('.the_cart_all_box_fly_holder').removeClass('the_cart_all_box_fly_animted');
             $('.the_cart_all_box_fly_holder').addClass('the_cart_all_box_fly');
        } else {
            $('.the_cart_all_box_fly_holder').removeClass('the_cart_all_box_fly');
            $('.the_cart_all_box_fly_holder').addClass('the_cart_all_box_fly_animted');
        }
        }
        }
    });
    }
    
    the_cart_theam.update_bag_number();
    
    if ($('.the_products_zone').length) { 
    setTimeout(function(){ 
    $('.the_products_zone').find('.the_products_box1').each(function(){
        $(this).find('img').each(function(){
            if ( $(this).attr('idanlazy') == 1) {
                var lazysrc = $(this).attr('lazysrc');
                $(this).attr('src',lazysrc);
                $(this).attr('idanlazy',0);
            } 
        });
    });
    }, 4000);
    }
    setTimeout(function(){
    $('body').find('.is_lazy_idan').each(function(){
        var idanlazy = $(this).find('img').attr('idanlazy');
        if (idanlazy == 1) {
            var lazysrc = $(this).find('img').attr('lazysrc');
            $(this).find('img').attr('src',lazysrc);
            $(this).find('img').attr('idanlazy',0);
        }
    });
    }, 4000);
    
    if ($('.the_brand_all_prod_in')) {
    setTimeout(function(){ 
    $('.the_products_zone').find('.the_products_box_smaler').each(function(){
        var idanlazy = $(this).find('img').attr('idanlazy');
        if (idanlazy == 1) {
            var lazysrc = $(this).find('img').attr('lazysrc');
            $(this).find('img').attr('src',lazysrc);
            $(this).find('img').attr('idanlazy',0);
        }
    });
    }, 5000);    
    }
    
    }, 500);
    
    if (the_site_id == 15) {
        if (iframe_flag == 1) {
            recomends_pop_up.show();
        }
    }
    
});
