var youtube_url = null var leftover = randomInteger(10, 30) var totalover = randomInteger(1000, 2500) var order_interval = randomInteger(7000, 25000) var ordersCitys = ['г. Москва', 'г. Иркутск', 'г. Киев', 'г. Харьков', 'г. Минск', 'г. Калининград'] var ordersNames = ['Максим', 'Надежда', 'Ludmila', 'Сергей', 'Константин', 'Marina', 'Irina'] var currentOrderCity = ordersCitys[randomInteger(0, ordersCitys.length-1)] var currentOrderName = ordersNames[randomInteger(0, ordersNames.length-1)] var fixedHandPriceActive = false function randomInteger(min, max) { var rand = min + Math.random() * (max - min) rand = Math.round(rand); return rand; } $(document).ready(function () { if($('#video').attr('src')){ var youtube=$('#video').attr('src').match(/youtube.com\/embed\/([^?]+)/im); if(youtube){ $('.bg').css('background-image','url("http://img.youtube.com/vi/'+youtube[1]+'/0.jpg")') youtube_url = 'http://img.youtube.com/vi/'+youtube[1]; setInterval(function () { $('.bg').css('background-image','url("'+youtube_url+'/'+randomInteger(1, 3)+'.jpg")') }, 2000); } var vimeo=$('#video').attr('src').match(/vimeo.com\/video\/([0-9]+)/im); if(vimeo){ $.ajax({ type:'GET', url: 'http://vimeo.com/api/v2/video/' + vimeo[1] + '.json', jsonp: 'callback', dataType: 'jsonp', success: function(data){ var thumbnail_src = data[0].thumbnail_large; $('.bg').css('background-image','url('+thumbnail_src+')') } }); } } //заплатка для количества заказов и количества оставщегося товара $('.totalover').html(totalover) $('.leftover').html(leftover) $('.currentOrderCity').html(currentOrderCity) setInterval(function () { if(leftover"+ currentOrderCity+"") currentOrderCity = ordersCitys[randomInteger(0, ordersCitys.length-1)] currentOrderName = ordersNames[randomInteger(0, ordersNames.length-1)] $('.currentOrderCity').html(currentOrderCity) $('.totalover').html(totalover) $('.leftover').html(leftover) if(!fixedHandPriceActive){ setTimeout(function () { $(".fixed-hand.fixed-hand-order").addClass('active'); }, 1000); setTimeout(function () { $(".fixed-hand.fixed-hand-price").removeClass('active'); }, randomInteger(500,3000)); fixedHandPriceActive = true } }, order_interval); $(".fixed-hand.fixed-hand-order .close").bind('click', function() { $(".fixed-hand.fixed-hand-order").removeClass('active'); }); setTimeout(function () { $(".fixed-hand.fixed-hand-price").toggleClass('active'); }, 5000); $(".fixed-hand.fixed-hand-price .close").bind('click', function() { $(".fixed-hand.fixed-hand-price").toggleClass('active'); }); $("input.focus-input").bind('click', function() { $(".hidden-inputs").addClass('active'); $(".form .title").removeClass('active'); }) // function fixedHand() { // // timeoutID = window.setTimeout(slowAlert, 2000); // // setTimeout($(".fixed-hand").toggleClass('active'), 5000); // // $(".fixed-hand .close").bind('click', function() { // $(".fixed-hand").toggleClass('active'); // }); // // } // fixedHand(); function inputDescr() { } inputDescr(); $('.form input').focus(function() { $('.input-descr').removeClass('active'); $('.input-descr.' + $(this).attr('data-target')).addClass('active'); $(this).parents('.form').addClass('active'); }); }) function apishopsActionDate(type) { var currentTimestamp=new Date().getTime() if(typeof apishopsActionGetCookie('apishopsActionDate') == 'undefined' || currentTimestamp > parseInt(apishopsActionGetCookie('apishopsActionDate'))){ endTimestamp=currentTimestamp + (1 * 24 * 60 * 60 * 1000); apishopsActionSetCookie('apishopsActionDate', endTimestamp); }else{ endTimestamp=parseInt(apishopsActionGetCookie('apishopsActionDate')) } if(type=='timestamp') return endTimestamp; else if(type=='circularEnd'){ date=new Date(endTimestamp); y=date.getFullYear(); d=date.getDate(); m=date.getMonth()+1; h=date.getHours()+1; mn=date.getMinutes(); return y+","+m+","+d+","+h+","+mn+",0"; //'2016,-6,-4,16,19,10', //year,month,day,hour,minute,second } else if(type=='circularBegin'){ date=new Date(); y=date.getFullYear(); d=date.getDate(); m=date.getMonth()+1; h=date.getHours()+1; mn=date.getMinutes(); return y+","+m+","+d+","+h+","+mn+",0"; //'2016,-6,-4,16,19,10', //year,month,day,hour,minute,second } else return new Date(endTimestamp); } function apishopsActionGetCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\/\+^])/g, '\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } function apishopsActionSetCookie(name, value, options) { options = options || {}; var expires = options.expires; if (typeof expires == "number" && expires) { var d = new Date(); d.setTime(d.getTime() + expires*1000); expires = options.expires = d; } if (expires && expires.toUTCString) { options.expires = expires.toUTCString(); } value = encodeURIComponent(value); var updatedCookie = name + "=" + value; for(var propName in options) { updatedCookie += "; " + propName; var propValue = options[propName]; if (propValue !== true) { updatedCookie += "=" + propValue; } } document.cookie = updatedCookie; return value; }