/* var catalog = new fConnector('catalog'); var ishop = new fConnector('ishop'); catalog.execute({count_comparse:{}}); var ccount = (catalog.result.count) ? catalog.result.count : 0; */ (function ($) { $.nano = function (template, data) { return template.replace(/\{([\w\.]*)\}/g, function (str, key) { var keys = key.split("."), value = data[keys.shift()]; $.each(keys, function () { value = value[this]; }); return (value === null || value === undefined) ? "" : value; }); }; })(jQuery); var number_format = function(number, decimals, dec_point, thousands_sep){ number = (number+'').replace(',', '').replace(' ', ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function(n, prec){ var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if(s[0].length > 3){s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);} if ((s[1] || '').length < prec) {s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0');} return s.join(dec); } var price_format = function(price, curr){ if(typeof price == 'string'){ price = price.split(' '); nlast = price.pop(); if(price.length){ str = '' + price.join(',') + ' ' + nlast + ' ' + curr + ''; } else { str = '' + nlast + ' ' + curr + ''; } return str; } } var startmnav=''; var startmsub=''; var back_to_current=false; var menu_go = true; var banners = new fConnector('banners'); $(function(){ if ($('.cat-cart').size()) { $('.cat-search').remove(); } $(".visual-news2").tabs( { event: "mouseover", tabTemplate: '
  • #{label}
  • ', select: function(event, ui) { var tab = ui.panel; var img = $('.xpic img',tab).eq(0).attr('src'); $('.first-picture img').attr('src',img); //debugger; } } ); $('.visual-news2 li a').click(function(){ var tab_id = $(this).attr('href'); var ahref = $('.visual-news2 #'+tab_id+' a.go-link').eq(0).attr('href'); if (ahref) { //document.location.href=ahref; } }); $('.cpopup .apopup').click(function(){ t = $(this).parent(); var d = t.find('.dpopup'); if (!d.size()) { t = t.parent(); d = t.find('.dpopup'); } if (d.hasClass('hidden')) { d.removeClass('hidden'); d.addClass('shown'); } else { d.removeClass('shown'); d.addClass('hidden'); } }); $('.banner-rotation div').jCarouselLite({visible:3,btnNext:'#next2',btnPrev:'#prev2'}); $('.people-carusel div').jCarouselLite({visible:4,btnNext:'#next3',btnPrev:'#prev3'}); $('.top').hover( function(){}, function(){ if (back_to_current){ $('.mnav.selected').removeClass('selected'); $('.msub.selected').removeClass('selected'); if (startmnav){ $('#'+startmnav).addClass('selected'); } if (startmsub){ $('#'+startmsub).addClass('selected'); } } } ); if ( $('.cl-list').size() && ($('.pages').size() < 2) ) { $('.cl-list li:last').addClass('last'); } if ( $('.a-cat.blog').size() && ($('.pages').size() < 1) ) { $('.a-cat.blog li:last').addClass('last'); } $('.people .tabs a').click(function(){ document.location.href = $(this).attr('rel'); }); $('a.banner, a.banner2, a.banner-in-list').click(function(){ var banner_id = $(this).attr('rel'); var url = document.location.pathname; banners.execute({add_click:{ "banner_id" : banner_id, "url" :url }}); }); var xfusers=new fConnector('fusers'); var curid; $('a.private').click(function(e) { e.preventDefault(); xfusers.execute({auth:true}); if(xfusers.result.ok) { $.fn.toggleWin({empty:1}); curid=$(this).attr('id'); }else{ alert('Вы неавторизованы!'); } }); refresh_chat=function(id) { xfusers.execute({get_users_messages:{id:id}}); if(xfusers.result) { html=''; for (r in xfusers.result.results) { html+=$.nano('
  • {updated}

    {message}

  • ', xfusers.result.results[r]); } } return html=''; } $('.open-messages').toggle(function(e) { e.preventDefault(); id=$(this).attr('rel'); html=refresh_chat(id); $(this).addClass('minus'); $(this).parent().nextAll('.mlist').html(html).fadeIn(); }, function(e){ e.preventDefault(); $(this).removeClass('minus'); $(this).parent().nextAll('.mlist').fadeOut(); }); $('input.sendit').click(function() { form=xoad.html.exportForm('message'); if(form.message!='') { xfusers.execute({send_message:{message:form.message,to:curid}}); if(xfusers.result.ok) { $('textarea[name=message]').val(''); $('#message_sent').fadeIn(1000).fadeOut(2000); if($('#'+curid).length>0) { html=refresh_chat(curid); $('#'+curid).parent().nextAll('.mlist').html(html); } $.fn.toggleWin(); }else{ alert('Ошибка отправки'); } } }); $.fn.alignCenter = function () { //get margin left var marginLeft = -$(this).width() / 2 + 'px'; //get margin top var marginTop = -$(this).height() / 2 + 'px'; //return updated element return $(this).css( { 'margin-left': marginLeft, 'margin-top': marginTop }); }; $.fn.toggleWin = function (options) { var defaults = {empty:false, content: ($(this).selector) ? $(this).html() : '' } var options = $.extend(defaults, options); //detect whether popup is visible or not if ($('#sfpopup').hasClass('hidden')) { if ($.browser.msie) { $('#opaco').height($(document).height()).toggleClass('hidden').click(function () { $(this).toggleWin(); }); } else //in all the rest browsers - fade slowly { $('#opaco').height($(document).height()).toggleClass('hidden').fadeTo(300, 0.2).click(function () { $(this).toggleWin(); }); } $('#sfpopup').alignCenter().toggleClass('hidden'); $('#sfpopup').find('.close').click(function (e) { e.preventDefault(); e.stopPropagation(); $(this).toggleWin(); }); if(!options.empty) { $('#sfpopup').find('.inner').html(options.content); } } else { //visible - then hide $('#opaco').fadeTo(300, 0, function () { $('#sfpopup').addClass('hidden'); $('#opaco').addClass('hidden'); }).unbind('click'); } }; if (document.location.pathname == '/') { $('.menu li:first').addClass('selected'); } $('.news > ul > li:last-child').addClass('last'); });