/* v1 */ var onceLoaded=0; var newTitle=''; var hrefRunned=0; var lastHREF; var firstTimePrices=1; var hideConfigOnLoad=1; var leftAnimate; var cat = ''; var playVideo; var photoswEl; if(productHrefDenyUpdate==undefined){ var productHrefDenyUpdate=false; } function resizeEnlargedGallery(){ $(".galleryFullsized .container").css({'height':($(window).height()-100)}); $(".galleryFullsized .imgContainer img").css({'max-height':($(window).height()-100)}); } function openEnlargedGallery(href){ if(href==undefined){ }else{ $(".galleryFullsized img#zoomedPhoto").attr('src',href); } $(".galleryFullsized").addClass('active'); resizeEnlargedGallery(); $("body").css({'overflow':'hidden'}); } $(document).ready(function(){ if($("body").hasClass("section_product")){ var i = 0; var last = $(".bread a").length; $(".bread a").each(function(i,el){ if($(el).hasClass("root")==false){ cat = cat + $(el).html(); if(i+1
"); $(document).on('click',".mainPictureLink",function(e){ e.preventDefault(); gtag('event', 'product_pictures_enlarge'); openEnlargedGallery($(this).attr('href')); return false; }); $(window).resize(resizeEnlargedGallery); $(document).on('click',".galleryFullsized .prev",function(){ openPic('prev','.JSONcontainer','mainGallery'); }); $(document).on('click',".galleryFullsized .next",function(){ openPic('next','.JSONcontainer','mainGallery'); gtag('event', 'product_pictures_navigation'); }); $(document).on('click',".galleryFullsized .close",function(e){ $(".galleryFullsized").removeClass('active'); $("body").css({'overflow':'auto'}); }); } $(document).on("submit",".product_form",function(e){ e.preventDefault(); that = e; addToCart(that); return false; }); // $(document).on("click",".addToCart",addToCart); $("form#productForm label").click(function(){return false;}); $(document).on("click",".ytPlaceholder",function(){ playVideo = this; load("https://www.youtube.com/iframe_api","js"); }); }); function onYouTubeIframeAPIReady() { console.log($(playVideo).html()); player = new YT.Player('video_'+$(playVideo).attr('data-videoID'), { height: '450', width: '100%', videoId: $(playVideo).attr('data-videoID'), events: { 'onReady': onPlayerReady, /* 'onStateChange': onPlayerStateChange */ } }); } function onPlayerReady(event) { event.target.playVideo(); } var done = false; function onPlayerStateChange(event) { if(event.data == YT.PlayerState.PLAYING && !done){ setTimeout(stopVideo, 6000); done = true; } } function stopVideo(){ player.stopVideo(); } function cheapBoxPosition(parentElClass){ if($(parentElClass+" .canBeCheaper").html()!=undefined){ var that = $(parentElClass+" .JSONcontainer .product .priceContainer"); vStart = $(that).offset().top; vEnd = vStart + $(parentElClass+" .cheapBox").height(); if(vEnd>$(window).height()){ vStart = vStart - (vEnd-$(window).height()); } $(parentElClass+" .cheapBox").css({'left':$(that).find(".canBeCheaper").offset().left-25,'top':vStart}); } } function productOnPageLoad(parentElClass){ on_mousestop(function(){ $(parentElClass+" .canBeCheaper").mousestop(function(){ gtag('event', 'product_canBeCheaper_opened'); cheapBoxPosition(parentElClass); $(parentElClass+" .cheapBox").show(); }); }); $(document).on("click",parentElClass+" .canBeCheaper",function(){ gtag('event', 'product_canBeCheaper_opened'); cheapBoxPosition(parentElClass); $(parentElClass+" .cheapBox").show(); return false; }); $(parentElClass+" .cheapBox .x").click(function(){ $(parentElClass+" .cheapBox").hide(); }); $(parentElClass+" .letsMakeItCheap").click(function(){ $(parentElClass+" .cheapBox").animate({ height:'450px', marginTop:'-100px', },1000); $(parentElClass+" .cheapBox b.htitle").animate({ opacity:'0' },400,function(){ $(parentElClass+" .cheapBox b.htitle").html('Почти готово.').animate({ opacity:'1' },400); }); $(parentElClass+" .cheapBox .step1").animate({ marginTop:'50px', opacity:'0' },400,function(){ $(parentElClass+" .cheapBox .step1").addClass('hidden'); $(parentElClass+" .cheapBox .step2").removeClass('hidden'); $(parentElClass+" .cheapBox .step2").animate({ opacity:'1' },400); }); return false; }); $(document).on("submit",parentElClass+" form#giveMeCodeForm",function(e){ gtag('event', 'product_canBeCheaper_form_submit'); e.preventDefault(); $.ajax({ type: 'POST', data: $(this).serialize(), url: '/build/json/bestPrice.php', success: function(data){ if(data[0]==true){ $(parentElClass+" .cheapBox").animate({ height:'500px', marginTop:'-150px', },1000); $(parentElClass+" .cheapBox b.htitle").animate({ opacity:'0' },400,function(){ $(parentElClass+" .cheapBox b.htitle").html('Все получилось!').animate({ opacity:'1' },400); }); if(data[6]){ burnDiscount(data[6]); var x = setInterval(function(){ burnDiscount(data[6]); }, 1000); } $(parentElClass+" .cheapBox .step2").animate({ marginTop:'50px', opacity:'0' },400,function(){ $(parentElClass+" .cheapBox .step2").addClass('hidden'); $(parentElClass+" .cheapBox .step3").removeClass('hidden'); $(parentElClass+" .cheapBox .oldPrice").html(data[4]); $(parentElClass+" .cheapBox .newPrice").html(data[5]); $(parentElClass+" .cheapBox .promocode").html(data[3]); $(parentElClass+" .cheapBox span.text").html(data[1]); $(parentElClass+" .cheapBox .step3").animate({ opacity:'1' },400); }); } }, async: true, dataType: "json" }); return false; }); onceOnLoad(); $(window).resize(onResize); $(window).scroll(onScroll); $(document).on('click',parentElClass+" .giveFeedback a",function(){ state = $(this).attr('data-state'); that = this; data = "section="+$(this).attr('data-section')+"&id="+$(this).attr('data-id')+"¶m="+$(this).attr('data-param')+"&state="+$(this).attr('data-state'); $.ajax({ type: 'POST', data: data, url: '/build/json/feedback.php', success: function(data){ if(data==true){ if(state=='positive'){ $(that).parent().html("Спасибо за ваше мнение, мы рады что этот раздел вам понравился :)"); } if(state=='negative'){ $(that).parent().html("Спасибо, мы постараемся улучшить эту секцию в ближайшее время."); } } }, async: true, dataType: "json" }); return false; }); if(mobile==1){ // $(document).on('click',".mainPic",function(){ $(".swiper-wrapper img[str='"+$(this).attr('src')+"']").parent().parent().trigger('click'); }); }else{ $(document).on('click',parentElClass+" .floatingBuybox h1",function(){ scrollToElem($("body")); }); /* $(parentElClass+" #aviaslider").aviaSlider({ blockSize: {height: 250, width:978}, betweenBlockDelay:60, animationSpeed:900, autorotationSpeed:5, display: 'all', autorotation: true, transition: 'fade' }); */ $(document).on('mouseover',parentElClass+" .controls span",function(){ $(parentElClass+" .gallery .controls span, .gallery .controls a").addClass('zeroOpacity'); $(this).removeClass('zeroOpacity'); }); $(document).on('mouseout',parentElClass+" .controls span",function(){ $(parentElClass+" .gallery .controls span, .gallery .controls a").removeClass('zeroOpacity'); }); $(document).on('click',parentElClass+" .thumbs .pic",function(e){ that = this; thumbClick(that,parentElClass+' .galleryIDContainer[data-gallery='+$(that).attr('data-gallery')+']'); e.preventDefault(); return false; }); $(document).on('click',parentElClass+" .controls .next",function(){ openPic('next',parentElClass,$(this).attr('data-gallery')); }); $(document).on('click',parentElClass+" .controls .prev",function(){ openPic('prev',parentElClass,$(this).attr('data-gallery')); }); } on_history(function(){ var History = window.History, State = History.getState(), $log = $("#log"); History.Adapter.bind(window,'statechange',function(){ State = History.getState(); if(productHrefDenyUpdate==undefined || productHrefDenyUpdate==false){ History.log('statechange:', State.data, State.title, State.url); } loadHref(State.url,parentElClass); }); }); $(document).on('click',parentElClass+" .cardInfo a.vop",function(){ if($(this).hasClass('disabled')){ return false; }else{ var thatHref = $(this).attr('href'); loadHref(thatHref,parentElClass); } return false; }); $(document).on("submit","#reviewFORM",function(e){ str = $(this).serialize(); arr = $(this).serializeArray(); stop=0; jQuery.each(arr,function(i,field ){ if(field.name=='g-recaptcha-response' && field.value==''){ bubble('Отметьте капчу'); stop=1; }else if(field.value==''){ bubble('Все поля обязательны для заполнения'); stop=1; } }); if(stop==0){ $.ajax({ type: 'POST', data: str, url: "/build/json/postReview.php", success: function(data){ if(data[0]==1){ $("#reviewFORM .alaForm").hide(); $("#reviewFORM .thanx").removeClass('hidden'); }else{ alert(data[1]); } }, dataType: "json" }); } e.preventDefault(); }); $(document).on('click',parentElClass+" .qu",function(){ if($(parentElClass+" .answer."+$(this).attr('data-id')).hasClass('visible')){ $(parentElClass+" .answer."+$(this).attr('data-id')).slideUp().removeClass('visible'); }else{ $(parentElClass+" .answer."+$(this).attr('data-id')).slideDown().addClass('visible'); } return false; }); $(document).on('click',".tabsHeader li.navigate a",function(){ $(".tabsHeader li").removeClass('selected'); $(".tabsHeader li."+$(this).attr('data-li')).addClass('selected'); if($(this).attr('data-href')=='reviewsTab'){ gtag('event', 'open_product_reviews'); }else if($(this).attr('data-href')=='specsTab'){ gtag('event', 'open_product_specification'); }else if($(this).attr('data-href')=='galleryTab'){ gtag('event', 'open_product_gallery'); }else if($(this).attr('data-href')=='accessoriesTab'){ gtag('event', 'open_product_accessories'); } if($("#"+$(this).attr('data-href')).hasClass('loaded')==false && typeof $("#"+$(this).attr('data-href')).attr('data-href')!=='undefined'){ that = this; $.ajax({ type: 'GET', url: $("#"+$(that).attr('data-href')).attr('data-href'), success: function(data){ $("#"+$(that).attr('data-href')).append(data); // $("#"+$(this).attr('data-href')).addClass('loaded'); $(".tabsContent .tab").removeClass('opened').addClass('closed'); $("#"+$(that).attr('data-href')).removeClass('closed').addClass('opened loaded'); }, async: true, dataType: "json" }); }else{ $(".tabsContent .tab").removeClass('opened').addClass('closed'); $("#"+$(this).attr('data-href')).removeClass('closed').addClass('opened'); } curHash = $(this).attr('href'); fElem = $(".floatingPanelPlaceHolder"); fScroll = isScrolledIntoView(fElem); if(fScroll == 'top' || fScroll == 'bottom'){ scrollToElem(fElem,topFloatingHeight-1); } window.location.replace(curHash); return false; }); $(document).on("click",".scrollToEl",function(){ scrollToElem($($(this).attr('data-el')),0); return false; }); } $(window).on('load',function(){ productOnPageLoad("body"); }); function bubble(message,elem,position,style){ alert(message); } function loadHref(href,parentElClass){ $(parentElClass+" .cheapBox").hide(); if(hrefRunned==0){ if(lastHREF!='' && lastHREF==href){ return false; } lastHREF = href; hrefRunned=1; $(parentElClass+" .cardInfo a.vop").addClass('disabled'); $(parentElClass+" .JSONcontainer .product").addClass('disabled'); e = href.substr(1).split('?'); if(e[0]!=undefined && e[0].length>0){ determ='&'; }else{ determ='?'; } url = href+determ+"jsonLoad=1"; $.ajax({ type: 'GET', url: url, success: function(data){ if(productHrefDenyUpdate==undefined || productHrefDenyUpdate==false){ on_history(function(){ History.pushState("","", href); }); } // window.history.pushState("","", href); $(parentElClass+" .JSONcontainer").replaceWith(data); setTimeout(onceOnLoad,100); hrefRunned=0; }, async: true, dataType: "json" }); } } function onResize(onLoad){ if(onLoad == undefined){onLoad = false;} /* on_sly(function(){ $(".cat_submenu").sly('reload'); }); */ if(mobile!=1){ floatingBuybox(onLoad); floatingProductInfo(onLoad); } floatingMenu(); cheapBoxPosition(); } function onScroll(){ if(mobile!=1){ floatingBuybox(); floatingProductInfo(); } floatingMenu(); } function hashWorks(){ if(window.location.hash) { hash = window.location.hash.substr(1); if(hash=='description'){ $(".tabDescription a").trigger("click"); }else if(hash=='specs'){ $(".tabSpecs a").trigger("click"); }else if(hash=='reviews'){ $(".tabReviews a").trigger("click"); }else if(hash=='accessories'){ $(".tabAccessories a").trigger("click"); } } } function onceOnLoad(parentElClass){ if(parentElClass==undefined){parentElClass='';} $(".optionsList .vop.selected").each(function(i,el){ compensate = $(el).offset().left-22; $(el).parent().scrollLeft(compensate); }); $(".variantsScroll .variantVariant.active").each(function(i,el){ compensate = $(el).offset().left-30; $(el).parent().scrollLeft(compensate); }); if($(parentElClass+" .thumbs .pic").length>0 && !$(parentElClass+" .thumbs .pic").hasClass('active')){$(parentElClass+" .thumbs .pic").eq(0).addClass('active');} if(mobile==1){ loadLater("/cache/js/mobile/js/photoswipe.min.js","js",2000,function(){ load("/cache/js/mobile/css/photoswipe.css","css"); load("/cache/js/mobile/js/photoswipe-ui-default.min.js","js",function(){ load("/cache/js/mobile/js/photoswiper.js","js",function(){ initPhotoSwipeFromDOM(".mainPic"); initPhotoSwipeFromDOM(".swiper-wrapper"); }); }); }); /* if(typeof photosw === 'undefined'){ photoswEl = parentElClass; }else{ initPhotoSwipeFromDOM(parentElClass+" .mainPic"); initPhotoSwipeFromDOM(parentElClass+" .swiper-wrapper"); } */ } if(typeof dataLayer != 'undefined' ){ dataLayer.push({ "ecommerce": { "detail": { "products": [ { "brand": $("meta[itemprop=brand]").attr('content'), "category": $("span[itemprop=category]").html(), "id": $("#productID").val(), "name": $(".dataLayerTitle").html(), "price": $("#productForm").attr('data-price'), "quantity": $("#qty").val(), "variant" : $("#nomID").attr('data-variation') } ] } } }); } if(newTitle!=''){ $("title").html(newTitle); newTitle=''; } if($("title").html()!=document.title){ document.title = $("title").html(); } onResize(true); hashWorks(); if(onceLoaded==1){ if(typeof getUserData !== 'undefined'){ getUserData(userInfo); } } if($(window).width()<1165){ $(".specs").addClass('minWidth'); $(".product").removeClass('paddings'); $(".product").addClass('paddings'); } if($(window).width()<1165){ $(".specs").addClass('minWidth'); $(".product").removeClass('paddings'); $(".product").addClass('paddings'); } if(onceLoaded==0){ onceLoaded=1; if($(".reviews .review_block").length>0){ $(".tabsHeader .tabReviews span").after(""+$(".reviews .review_block").length+""); $(".product .scroll-link.reviews").after(" ("+$(".reviews .review_block").length+")"); }else{ $(".scroll-link.reviews").html("Добавить отзыв"); } if($("#accessories").val()==0){ $(".tabsHeader .tabAccessories").hide(); $(".cardInfo .fa.fa-diamond.fa-fw").hide(); $(".product .scroll-link.accessories").hide(); } if($("#accessoriesTab .miniProd").length>0){ $(".tabsHeader .tabAccessories span").after("("+$("#accessoriesTab .miniProd").length+")"); $(".scroll-link.accessories").after(" ("+$("#accessoriesTab .miniProd").length+")"); } } if($(parentElClass+" .variantVariant.active").html()==undefined){ $(parentElClass+" div.variants .variantVariants").each(function(i,el){ $(el).find(".variantVariant").eq(0).addClass('active'); }); } } function buildConfiguration(){ if(hideConfigOnLoad==0){ if(selectBoxes.length>0) { var str=''; jQuery.each($("#productForm label.realOpt"), function( i, field ) { ttl = $(field).children('b').html(); pic = $(field).children('select').children('option:selected').attr('data-pic'); desc = $(field).children('select').children('option:selected').attr('data-desc'); price = $(field).children('select').children('option:selected').attr('data-price'); optionTTL = $(field).children('select').children('option:selected').html(); if(desc==undefined){desc='';} if(desc==''){desc='';}else{desc='
'+desc+'
';} if(price==undefined){price=0;} if(price==0){price='';}else{price=''+parseFloat(price).format()+' р.';} if(pic==undefined){pic='';} if(pic==''){pic='';}else{pic='';} str=str+'
'+pic+'
'+ttl+':
'+optionTTL+desc+price+'
'; }); if(str.length>0){ $(".cnfOptionsContainer").html(str); if(mobile==0){ $(".configurator").slideDown(); } }else{ $(".cnfOptionsContainer").html(''); } }else{ $(".cnfOptionsContainer").html(''); } }else{hideConfigOnLoad=0;} } function writeOptionPrices(box){ nullPrice = $("select.product_options[name="+box+"] option:selected").attr('data-price'); jQuery.each( $("select.product_options[name="+box+"] option"), function( i, field ) { dataPrice = parseFloat($(field).attr('data-price')); /* diff = dataPrice-nullPrice; if(diff>0){msg = ' (плюс '+diff.format()+' р.)';}else if(diff<0){msg = ' (дешевле на '+(diff*(-1)).format()+' р.)';}else{ msg='(бесплатная опция)'; } */ if(dataPrice>0){ msg = '('+dataPrice.format()+' р.)'; }else{ msg = ''; } $(field).html($(field).attr('data-title')+' '+msg); if(firstTimePrices==0){ // $("form#productForm select").selectmenu("refresh"); }else{firstTimePrices=1;} // console.log(nullPrice); }); } var addressFormatting = function(text, opt){ var newText = text; //array of find replaces var findreps = [ {find:/^([^\-]+) \- /g, rep: '$1'}, {find:/([^\|><]+) \| /g, rep: '$1'}, {find:/([^\|><\(\)]+) (\()/g, rep: '$1$2'}, {find:/([^\|><\(\)]+)$/g, rep: '$1'}, {find:/(\([^\|><]+\))$/g, rep: '$1'} ]; for(var i in findreps){ newText = newText.replace(findreps[i].find, findreps[i].rep); } return newText; } function thumbClick(that,parentElClass){ $(".thumbs .imgPlaceholder").each(function(i,el){ $(el).attr('src',$(el).attr('data-src')).addClass('loaded'); }); if($(parentElClass).attr('data-gallery')=='mainGallery'){ hgt = $(parentElClass+" .thumbs .pic").height()+7; if($(that).index()>3){ compensate = $(that).index()-3; $(parentElClass+" .thumbs").addClass('swipedDown'); if($(parentElClass+" .thumbs .pic").length>$(that).index()+4){ $(parentElClass+" .thumbs .th_inner").animate({'margin-top':'-'+(compensate*hgt)+'px'}); }else{ $(parentElClass+" .thumbs .th_inner").animate({'margin-top':'-'+(($(parentElClass+" .thumbs .pic").length-8)*hgt)+'px'}); } }else{ $(parentElClass+" .thumbs").removeClass('swipedDown'); $(parentElClass+" .thumbs .th_inner").animate({'margin-top':'0px'}); } if($(that).hasClass('active') && $(that).hasClass('zoom')){ openEnlargedGallery(); } } $(parentElClass+" .thumbs .pic").removeClass('active'); $(that).addClass('active'); screen2 = $(that).children('a').attr('data-screen'); link2 = $(that).children('a').attr('href'); alt = $(that).children('a').attr('alt'); changeMainPic(screen2,link2,alt,parentElClass); } function openPic(direction,parentElClass,galleryID){ var ours = 0; if(direction=='next'){ $(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").each(function(i,elem){ if($(elem).hasClass('active') && i==$(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").length-1){ ours=0; }else if($(elem).hasClass('active')){ ours=i+1; } }); thumbClick($(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").eq(ours),parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"]"); } if(direction=='prev'){ $(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").each(function(i,elem){ if($(elem).hasClass('active') && i==0){ ours=$(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").length-1; }else if($(elem).hasClass('active')){ ours=i-1; } }); thumbClick($(parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"] .thumbs .pic").eq(ours),parentElClass+" .galleryIDContainer[data-gallery="+galleryID+"]"); } } function changeMainPic(screen2,link2,caption,parentElClass) { if($(parentElClass+" .thumbs .pic").length>0){ // $(parentElClass+" .mainPic img").animate({opacity:0.4},100); } $('').on('load',function() { // $(parentElClass+" .mainPic img").attr({'src':screen2}).css({'width': w1, 'height': h1}); $(parentElClass+" .mainPictureLink").attr({'href':link2}); $(parentElClass+" .mainPic img").attr({'src':screen2}); $(".galleryFullsized img#zoomedPhoto").attr('src',link2); if(caption){ $(parentElClass+" .mainPic .caption").html(alt).removeClass('hidden'); $(".galleryFullsized .caption").html(alt); }else{ $(parentElClass+" .mainPic .caption").html('').addClass('hidden'); $(".galleryFullsized .caption").html(''); } // $(parentElClass+" .mainPic img").animate({opacity:1},100); }); } function addToCart(that){ el = $(that.target); if($(".addToCart").hasClass('forwardToCart')){ $.ajax({ type: 'POST', data: $(el).serialize(), url: "/build/json/cart.php?action=update&output=json", success: function(data){ // refreshCart(data); if((accsShown!=0 || presentBlock!=0) && $(".cartFader").html()!=undefined){ return cartfader(); }else{ return window.location.assign('/cart.html'); } }, dataType: "json" }); }else{ $.ajax({ type: 'POST', data: $(el).serialize(), url: "/build/json/cart.php?action=set&output=json", success: function(data){ // if($(".addToCart").hasClass('metric')){ dataLayer.push({ "ecommerce": { "add": { "products": [ { "id": $("#productID").val(), "name": $(".dataLayerTitle").html(), "price": $("form.product_form").attr('data-price'), "brand": $("meta[itemprop=brand]").attr('content'), "category": cat, "quantity": $("select[name=qty] option:selected").val(), "variant" : $("#nomID").attr('data-variation') } ] } } }); // yaCounter12080917.reachGoal('addedToCart',function(){},data); gtag('event', 'add_to_cart', { "items": [ { "id": $("#productID").val(), "name": $(".dataLayerTitle").html(), "price": $("form.product_form").attr('data-price'), "brand": $("meta[itemprop=brand]").attr('content'), "category": cat, "quantity": $("select[name=qty] option:selected").val(), "variant" : $("#nomID").attr('data-variation') } ] }); var fbrows = []; fbrows.push({ item_price: $("form.product_form").attr('data-price'), quantity: $("select[name=qty] option:selected").val(), id: $("#productID").val(), }); /* FB fbq('track', 'AddToCart', { contents: fbrows, content_type: 'product', currency: 'RUB' }); */ // refreshCartContent(this); if($(".cartFader").html()!=undefined){ cartfader(); }else{ window.location.assign('/cart.html'); } return false; /* }else{ refreshCartContent(this); if($(".cartFader").html()!=undefined){ cartfader(); }else{ window.location.assign('/cart.html'); } } */ }, dataType: "json" }); } } function rebuildSelect(selectID){ // htm = $("ul#"+selectID+"-menu li").html(); // $("ul#"+selectID+"-menu li").html(htm+' еще'); } function postReview(form){ productID = $("input[name=productID]").val(); title = $("#reviewTitle").val(); author = $("#reviewName").val(); text = $("#reviewText").val(); cap = $("#cap").val(); if(title && author && text){ $.ajax({ type: 'POST', data: "cap="+cap+"&productID="+productID+"&title="+title+"&author="+author+"&text="+text, url: "/build/json/postReview.php", success: function(data){ if(data['status']==1){ $(".reviewForm .alaForm").hide(); $(".reviewForm .thanx").show(); data = '
'+data['title']+'
'+data['author']+' / '+data['date']+'
'+data['text']+'
'; $(data).insertAfter(".reviews .freeContainer"); $(".reviews .freeContainer").addClass('hidden'); }else{ if(data['status']==2){ $(".reviewError").html('Вы не ввели правильный ответ на вопрос. Ответ это сумма, написанная буквами, например: один').slideDown(); $("#cap").addClass('highlight'); }else if(data['status']==3){ $(".reviewError").html('Все поля обязательны для заполнения').slideDown(); }else if(data['status']==0){ $(".reviewError").html('Что-то пошло не так').slideDown();} // setTimeout(function(){$(".reviewError").html('').slideUp(); },3000); } }, dataType: "json" }); }else{ $(".reviewError").html('Все поля обязательны для заполнения').slideDown(); // setTimeout(function(){ $(".reviewError").html('').slideUp(); },3000); } return false; } function isScrolledIntoView(elem,marginTop,marginBottom){ if(marginTop==undefined){marginTop=0;} if(marginBottom==undefined){marginBottom=0;} if($(elem).html()==undefined){ return undefined; } var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top-marginTop; var elemBottom = elemTop + $(elem).outerHeight()+marginTop; ret = false; if(elemBottom<=docViewBottom && elemTop >= docViewTop){ ret = true; }else if(elemTop < docViewTop){ ret = 'top'; }else if(elemBottom > docViewBottom){ ret = 'bottom'; } return ret; } var topFloatingHeight=0; function floatingMenu(){ if(denyProductPlacements==false){ fPosition = isScrolledIntoView($(".floatingPanelPlaceHolder"),topFloatingHeight); $(".floatingPanel").css('top','auto'); if(fPosition==true){ $(".floatingPanel").removeClass('fixed-panel-top').removeClass('fixed-panel-bottom'); $(".floatingBuybox").removeClass('merge'); }else if(fPosition!=undefined){ $(".floatingPanel").addClass('fixed-panel-'+fPosition); if(fPosition=='top'){ $(".floatingPanel").css('top',topFloatingHeight); $(".floatingBuybox").addClass('merge'); }else{ $(".floatingBuybox").removeClass('merge'); } } setTimeout(function(){$(".floatingPanel").removeClass('justLoad');},1000); } } var floatingProductTop=0; var floatingBuyboxTop=0; function floatingBuybox(onLoad){ if(onLoad == undefined){onLoad = false;} if(onLoad==true){ $(".buybox").animate({opacity:1}); } fPosition = isScrolledIntoView($(".cardInfo .pricebox"),20) if(denyProductPlacements==false){ if(fPosition==true){ $(".floatingBuybox").removeClass('fixed-panel-top'); topFloatingHeight=0; }else if(fPosition!=undefined){ $(".floatingBuybox").addClass('fixed-panel-top'); $(".floatingBuybox .autowidth .div1").html($(".cardInfo .floatingBuyboxFrom").clone()); topFloatingHeight = $(".floatingBuybox").height(); fPosition = isScrolledIntoView($(".buyboxContainer .addToCart"),topFloatingHeight/1.5); if(fPosition==true){ $(".floatingBuybox .autowidth .div2").html(''); }else{ $(".floatingBuybox .autowidth .div2").html($(".buyboxContainer .addToCart").clone()); } } }else{ $(".floatingBuybox").removeClass('fixed-panel-top'); topFloatingHeight=0; } } function floatingProductInfo(onLoad){ if(onLoad == undefined){onLoad = false;} if(onLoad==true){ $(".gallery").animate({opacity:1}); } topOffset = topFloatingHeight+10; minOffset = $(".galleryContainer").offset().top; gMaxOffset = minOffset; bMaxOffset = minOffset; cHeight = $(".cardInfo").height(); gHeight = $(".gallery").height(); bHeight = $(".buybox").height(); docView = $(window).scrollTop(); curPosition = docView-minOffset; if(docView220){ if(cHeight>gHeight){ gMaxOffset = cHeight-gHeight+minOffset-topOffset; $(".galleryContainer").height(cHeight); } // if(cHeight>gHeight){ gMaxOffset = cHeight-gHeight+minOffset-topOffset; $(".mainPicContainer").height(cHeight); } if(docView>minOffset){ $(".gallery").width($(".galleryContainer").width()).css('margin-top',topOffset+'px'); // $(".mainPic").width($(".mainPicContainer").width()).css('margin-top',topOffset+'px'); // $(".gallery .thumbs .th_inner").width($(".gallery .thumbs").width()).css('margin-top',topOffset+'px'); if(docView220){ if(cHeight>bHeight){ bMaxOffset = cHeight-bHeight+minOffset-topOffset; $(".buyboxContainer").height(cHeight); } if(docView>minOffset){ $(".buybox").width($(".buyboxContainer").width()).css('margin-top',topOffset+'px'); if(docView