/* /js/authFunctions.js begin */
var modal_window = null;
var modal_window_close_interval = null;
var authTriggerElement = null;
if (!needToReloadDocument) var needToReloadDocument = false;
$(function () {
//auth events
//этап 1 - форма
$(document).on('auth.init', function () {
loadAuthOverlay(function () {
$("#login_modal_popup").show();
$('#login_step2').hide();
$('#login_step1').show();
$('#initAuth_livejournal_uname').focus();
});
});
//этап 1 - успешно
$(document).on('auth.social.success', function (event, params) {
window.clearInterval(modal_window_close_interval);
if (_gaq) _gaq.push(['_trackEvent', 'authorization', 'buttonClick', params.provider]);
for (var k in params.JSVARS) {
JSVARS[k] = params.JSVARS[k];
}
if (JSVARS.user === 'confirmed') {
$.event.trigger('auth.complete', [authTriggerElement]);
} else {
$.event.trigger('auth.confirmation');
}
});
//этап 2 - облом
$(document).on('auth.social.fail', function () {
window.clearInterval(modal_window_close_interval);
JSVARS.user = 'none';
$('#msgAuthError').fadeIn(700);
setTimeout(function () {
$('#msgAuthError').fadeOut(700);
}, 2000);
});
//этап 2 - форма
$(document).on('auth.confirmation', function () {
loadAuthOverlay(function () {
$("#login_modal_popup").show();
$('#login_step1').hide();
$('#registrAgree, #subscribeAgree').prop('checked', 'checked');
$('#registrBtn').removeClass('disable').removeAttr('disabled');
$('#login_step2_name').html(JSVARS.user_name);
JSVARS.user_has_email ? $('#login_step2_subscribe').show() : $('#login_step2_subscribe').hide();
$('#login_step2').show();
});
});
//этап 2 - успешно
$(document).on('auth.complete', function () {
JSVARS.user = 'confirmed';
if (needToReloadDocument || JSVARS.reloadOnLogin) {
//top.location.search += (top.location.search ? '&' : '') + Math.floor(Math.random() * 1000000);
var loc = new String(top.window.document.location.href);
var uri = loc;
if (loc.indexOf('#') > 0) {
var anchorName = new String(top.window.document.location.hash);
uri = new String(loc.substr(0, loc.indexOf('#')));
if (uri.indexOf('?') > 0) {
uri += '&'
} else {
uri += '?';
}
var rNum = Math.floor(Math.random() * 1000000);
uri += rNum + anchorName;
}
top.window.document.location.href = uri;
} else {
$('.not_login_link').each(function () {
$(this).removeClass('not_login_link');
});
if(JSVARS && JSVARS['subscribe'] != undefined) {
$('#unisenderSubscribe').click();
JSVARS['subscribe'] = false;
}
$("#login_modal_popup").hide();
$('.cabinet').load('/ajax/login/userProfile', function () {
var userNavigation = $('.navigation.geo_navigation');
if (userNavigation) {
var url = document.location.href;
var reg = /^.*\/user\/(\d+)\/?.*$/gi;
var match = reg.exec(url);
if (!match || !match[1]) return;
var link = $('.cabinet a[href*="/user"]')[0];
var reg1 = /^.*\/user\/(\d+)\/?.*$/gi;
var match1 = reg1.exec($(link).attr('href'));
if (!match1 || !match1[1]) return;
if (match[1] && match1[1] && match[1] == match1[1]) {
var elem = $('Настройки');
elem.appendTo(userNavigation);
}
}
});
//$('body').removeClass('noscroll');
bodyFreezing.unfreeze();
}
});
$(document).on('auth.social.bind', function () {
$.get('/my/getservices_ajax',
{},
function(data) {
//TODO: Вынести как - то (Обобщить) или сделать постоянную загрузку аяксом
$('.servicesList').html(data);
$('.link_link').each(function() {
$(this).bind('click', function() {
var t = $(this).attr('id').split('_');
if(t[1] == 'livejournal') {
if($('#lj_nickname').val() == '') {
alert('Необходимо указать имя пользователя в сервисе Livejournal');
return false;
} else {
t[1] = t[1] +'/'+ $('#lj_nickname').val();
}
}
var height = (t[1] == 'twitter') ? 550 : 400;
var width = (t[1] == 'livejournal') ? 1024 : 600;
openModalWindow('/auth/bind/'+ t[1], height, width);
});
});
$('.link_unlink').each(function() {
$(this).bind('click', function() {
if(!confirm('Подтверждаете удаление?')) return false;
var t = $(this).attr('id').split('_');
$.ajax({
url : '/ajax/unlink/'+ t[1] +'/'+ JSVARS.secretToken,
type : 'GET',
success: function(data, textStatus, jqXHR){
if(data.unlinkResult) {
JSVARS.secretToken = data.unlinkResult.secretToken;
if(data.unlinkResult.status == 'error') {
//console.log('error');
//TODO: display errors
} else if (data.unlinkResult.status == 'success') {
$(document).trigger('auth.social.bind');
//window.location.href = window.location.href;
}
}
}
});
});
});
$('.toggle_publish').bind('click', function() {
var t = $(this).attr('id').split('_');
var _this = $(this);
$.ajax({
url : '/ajax/toggle/publish/'+ t[0] +'/'+ JSVARS.secretToken,
type : 'GET',
data : {state: $(this).prop('checked') === true ? 1 : 0},
success: function(data, textStatus, jqXHR){
if(data.toggleResult) {
JSVARS.secretToken = data.toggleResult.secretToken;
if(data.toggleResult.status == 'error') {
//console.log('error');
//TODO: display errors
} else if (data.toggleResult.status == 'success') {
setTimeout(function(){
_this.parents('.tooltip').fadeOut();
}, 1000);
}
}
}
});
});
});
//location.reload();
});
//dom events
$(document).on('click', '.not_login_link', function () {
if (JSVARS.user === 'confirmed') return; //на всякий случай
authTriggerElement = this;
if (JSVARS.user === 'unconfirmed') {
$.event.trigger('auth.confirmation', [JSVARS.user_has_email]);
} else {
$.event.trigger('auth.init');
}
return false;
});
$(document).on('click', '#login_close', function () {
$("#login_modal_popup").hide();
bodyFreezing.unfreeze();
});
$(document).on('click', '#registrBtn', function () {
if(JSVARS['provider'] !== undefined) {
_gaq.push(['_trackEvent', 'authorization', 'registration', JSVARS['provider']]);
}
$.get(
'/auth/confirm',
{subscribe: $('#subscribeAgree').prop('checked') ? 1 : 0},
function () {
$.event.trigger('auth.complete', [authTriggerElement]);
}
);
});
$(document).on('click', '#registrAgree', function () {
if ($(this).is(':checked')) {
$('#registrBtn').removeClass('disable').removeAttr('disabled');
} else {
$('#registrBtn').addClass('disable').attr('disabled', 'disabled');
}
});
$(document).on('click', '#notRegistrAgree', function () {
$('#login_close').trigger('click');
});
});
//service functions
function loadAuthOverlay(onComplete) {
bodyFreezing.freeze();
//$('body').addClass('noscroll');
if ($("#login_modal_popup").children().length > 0) {
onComplete();
} else {
var htmlString = '
';
var x = $(htmlString);
$('body').append(x);
x.show();
$('#loginModalContainer').load((JSVARS && JSVARS['auth_modal'] != undefined) ? JSVARS['auth_modal'] : '/auth/modal', function () {
$('#initAuth_facebook,#initAuth_vkontakte,#initAuth_twitter').bind('click', function () {
var str = this.id.split('_');
var height = (str[1] == 'twitter') ? 550 : 400;
openModalWindow('/auth/login/' + str[1], height);
});
$('#auth_livejournal_form').submit(function () {
var lj_user = $('#initAuth_livejournal_uname').val();
var regexp = new RegExp(/^[a-z\d\_\+]+$/i);
if (lj_user == '' || !regexp.test(lj_user)) {
$('#initAuth_livejournal_uname').parent().addClass('ym-error');
setTimeout(function () {
$('#initAuth_livejournal_uname').parent().removeClass('ym-error');
}, 3000);
return false;
}
var address = '/auth/login/livejournal/' + lj_user;
openModalWindow(address, 400, 1024);
return false;
});
onComplete();
});
}
}
function openModalWindow(address, height, width) {
if (!height || height < 1) height = 400;
if (!width || width < 1) width = 600;
modal_window = window.open(address, 'authWindow', 'width=' + width + ',height=' + height);
modal_window_close_interval = window.setInterval(function () {
if (modal_window.closed) {
window.clearInterval(modal_window_close_interval);
$.event.trigger('auth.social.fail');
}
}, 400);
}
/* /js/authFunctions.js end */
/* /js/jquery.cookie.js begin */
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));
/* /js/jquery.cookie.js end */
/* /js/main.js begin */
$(function(){
$('#site_rules_new_close').click(function () {
this.parentNode.remove();
$.get('/ajax/site_rules/accept');
});
if ($.cookie) {
var pageShow = $.cookie('_pageShow') || 0;
$.cookie('_pageShow', ++pageShow, { expires: 365, path: '/' });
var pageShow_auth = $.cookie('_pageShow_auth');
if (pageShow_auth) {
$.cookie('_pageShow_auth', ++pageShow_auth, { path: '/' });
}
}
$(document)
.on('mouseover', '.iClose', function(){ $(this).prev().show(); })
.on('mouseout', '.iClose', function(){ $(this).prev().hide(); })
.on('click', '.redigoPopup', function(e){
var el = $(e.target);
if(el.parents('.redigoPopup_frame').size() < 1 && !el.is('.popupNotClose')){
$(this).hide();
if($('.redigoPopup').not(':hidden').size() == 0)
bodyFreezing.unfreeze();
//$('body').removeClass('noscroll');
}
})
.on('click', '.subscribeUserProviderAction', function(e){
var el = $(e.target);
var provider = el.data('provider');
var type = el.data('type');
if (provider == 'twitter') {
var data = {
'provider': provider,
'type': type
};
$.get('/ajax/subscribeUserProvider/action', data);
$('#followMe').remove();
bodyFreezing.unfreeze();
if (type == 'later') {
_gaq.push(['_trackEvent', 'social_promo', 'twitter', 'remind_me_later']);
} else if (type == 'deny') {
_gaq.push(['_trackEvent', 'social_promo', 'twitter', 'reject']);
}
}
});
if (window.twttr && $('#followMe').length) {
window.twttr.ready(function(twttr){
twttr.events.bind('follow', function (event) {
$.get('/ajax/subscribeUserProvider/action', {
'provider': 'twitter',
'type': 'yes'
});
$('#followMe').hide();
bodyFreezing.unfreeze();
_gaq.push(['_trackEvent', 'social_promo', 'twitter', 'official']);
});
})
if($('#followMe').is(':visible'))
bodyFreezing.freeze();
}
var userSubMenuTimer = null;
$(document)
.on('click', '#currUser', function(){
if($('#userSubMenu').is(':hidden')){
$(this).addClass('act');
clearTimeout(userSubMenuTimer);
$('#userSubMenu').show();
}else{
$(this).removeClass('act');
$('#userSubMenu').hide();
}
})
.on('mouseleave', '#userSubMenu', function(){
userSubMenuTimer = setTimeout(function(){
$('#userSubMenu').hide();
$('#currUser').removeClass('act');
}, 1000);
});
var anchor = document.location.hash;
if(anchor.length > 0) {
try {
if ($(anchor).length) {
$('html, body').animate({scrollTop: $(anchor).offset().top - 200}, 500);
}
} catch (e) {
if (console && console.log) {
console.log(e);
}
}
}
$('.anchor').click(function(){
var t = $(this);
$('html, body').animate({scrollTop: Math.round($(t.attr('href')).offset().top - 200) }, 500);
});
})
var bodyFreezing = {
body: $('body'),
freeze: function(){
var w = bodyFreezing.getScrollWidth();
bodyFreezing.body.addClass('noscroll');
if(w > 0){
bodyFreezing.body.css('padding-right', w + 'px');
}
},
unfreeze: function(){
bodyFreezing.body.removeClass('noscroll').css('padding-right', '0px');
},
getScrollWidth: function(){
var div = document.createElement('div');
div.style.overflowY = 'scroll';
div.style.width = '50px';
div.style.height = '50px';
div.style.visibility = 'hidden';
document.body.appendChild(div);
var scrollWidth = div.offsetWidth - div.clientWidth;
document.body.removeChild(div);
return scrollWidth;
}
}
var main = {};
main.suggest = {
selectedIndex: -1,
searchRequest: null,
init: function(){
this.input_element = $('.with_suggest');
if(!this.input_element.length) return;
var t = this;
this.input_element.attr('autocomplete', 'off');
var params = this.input_element[0].onclick();
this.suggest_href = params.suggest;
this.form_href = this.input_element.parents('form').attr('action') + '?' + this.input_element.attr('name') + '=';
/*
if(params.example && params.example.length > 0){
$('Например: ' + params.example + '
').insertAfter(this.input_element.parent()).find('.pseudo_link').click(function(){
t.input_element.val(params.example);
t.input_element.focus();
});
}
*/
this.spinner = $('').insertBefore(this.input_element).hide();
this.suggest_element = $('').insertAfter(this.input_element.parents('form'));
this.suggest_element.bind('focus mousedown keydown', function(){t.over = true;});
this.suggest_element.bind('blur mouseup keyup', function(){t.over = false; t.input_element.focus();});
this.suggest_element.hide();
this.data = [];
this.input_element.bind('focus keyup mouseup change', function(){
if(t.searchRequest && typeof(t.searchRequest) == 'object') {
t.searchRequest.abort();
clearTimeout(t.loading);
t.spinner.hide();
t.hide();
}
t.show();
});
this.input_element.blur(function(){
if(!t.over){
t.hide();
}
});
},
show: function(){
var value = this.input_element.val();
if(!value || value.length < 2){
this.hide();
return;
}
if(this.data[value] == undefined){
// aborting the previous request
/*
if(this.searchRequest && typeof(this.searchRequest) == 'object') {
this.searchRequest.abort();
clearTimeout(this.loading);
this.spinner.hide();
}*/
this.spinner.show();
clearTimeout(this.loading);
t = this;
this.loading = setTimeout(function() {
t.searchRequest =
$.getJSON(
t.suggest_href + escape(value),
function(data){
t.data[value] = {data: data};
if(!data || !data.total){
t.suggest_element.hide();
}else{
t.make(value);
t.suggest_element.show();
}
t.spinner.hide();
}
).error(function(){ t.data[value] = ''; t.hide(); });
}, 500);
} else {
if(this.data && this.data[value] && this.data[value].data.total) {
this.make(value);
this.suggest_element.show();
} else {
this.hide();
}
}
},
hide: function(){
this.suggest_element.hide();
},
make: function(value){
if(this.old_value == value) return;
this.unbindKeys();
this.old_value = value;
var d = this.data[value];
var counter = 0;
if(d.data && !d.html){
this.spinner.hide();
d.html = '';
for(var i = 0, group, ii, item; i < d.data.groups.length; i++){
group = d.data.groups[i];
d.html += '
' + group.title + '
';
for(ii = 0; ii < group.items.length; ii++){
item = group.items[ii];
d.html += '
';
counter++;
}
d.html += '
';
}
d.html += '
';
}
this.suggest_element.html(d.html);
if(d.data && d.data.total > 0) {
//this.input_element.blur();
this.bindSuggestNavigation();
var _this = this;
$('.suggest .suri').each(
function() {
$(this).bind(
'mouseover',
function() {
$('.suggest .suri.active').removeClass('active');
var tmp = $(this).attr('id').split('_');
_this.selectedIndex = parseInt(tmp[1], 10);
}
);
}
).filter('[data-type]').click(function(){
_this.trackEvent($(this));
});
}
},
trackEvent: function(el) {
_gaq.push(['_trackEvent', 'SuggestSearch', el.data('type') + ' - ' + el.data('title'), this.input_element.val()]);
},
arrowNavigationSuggest : function (e) {
switch(e.keyCode || e.which) {
case 37: // go left
break;
case 38: //go up
var prevIndex = this.selectedIndex - 1;
var prevElement = $('#suri_'+ prevIndex);
$('.suggest .suri.active').removeClass('active');
if(!prevElement.length) {
this.selectedIndex = -1;
} else {
$(prevElement).addClass('active');
this.selectedIndex = prevIndex;
}
$(this.input_element).val($(this.input_element).val());
return false;
break;
case 39: // go right
break;
case 40: // go down
var nextIndex = this.selectedIndex + 1;
var nextElement = $('#suri_'+ nextIndex);
if(!nextElement.length) {
return false;
} else {
$('.suggest .suri.active').removeClass('active');
$(nextElement).addClass('active');
this.selectedIndex = nextIndex;
return false;
}
break;
case 13:
// console.log('We\'re here');
var aLink = $('#suri_'+ this.selectedIndex +' a');
if(this.selectedIndex > -1 && aLink.length) {
this.trackEvent($('.suggest .suri.active'));
window.document.location = $(aLink).attr('href');
return false;
}
return true;
default:
return true;
break;
}
},
preventDefaultKeys : function() {
$(document).bind('keypress keyup keydown', function(e) {
if(!e) var e = window.event;
var code = e.keyCode || e.which;
if(code == 37 || code == 38 || code == 39 || code == 40 || (this.selectedIndex > -1 && code == 13)) {
e.cancelBubble = true;
e.returnValue = false;
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return false;
} else {
return true;
}
});
},
bindSuggestNavigation : function() {
this.preventDefaultKeys();
$(document).bind('keyup', {_this: this}, function(event) { return event.data._this.arrowNavigationSuggest(event); } );
},
unbindKeys : function() {
this.selectedIndex = -1;
$(document).unbind('keyup');
$(document).unbind('keydown');
$(document).unbind('keypress');
}
};
Calculator = {
init: function(){
var calc = $(".calculator_link");
this.calc = calc;
if(this.calc.size()){
this.calc.bind("click", function(){
if($("#calculator").size()){
$('#currencyFrom').val('');
$('#currencyResults table.result tbody').html('');
$("#calculator").show();
} else {
Calculator.create_form();
$("body").append("");
$("#calculator").show();
$(document).on('click', '#calculator_overlay', function(){
$(this).hide();
$("#calculator").hide();
});
}
var price = parseInt($(this).data('price'));
var currency = $(this).data('currency');
if (price && currency) {
$('#currencyFromType', '#calculator').val(currency)
$('#currencyFrom', '#calculator').val(price).trigger('keyup');
}
$('#calculator').offset({ top: $(this).offset().top + 20, left: $(this).offset().left });
$("#calculator_overlay").show();
if(typeof calc_value != 'undefined' && calc_value > 0) {
$('#currencyFrom').val(calc_value);
Calculator.convertCurrency();
}
});
}
},
create_form: function(){
var form_src = '';
//Calculator.calc.parent().append(form_src);
$('body').append(form_src);
$('#calculator').offset({ top: Calculator.calc.offset().top + 20, left: Calculator.calc.offset().left });
$('#currencyFrom').bind("keyup", function(){
Calculator.convertCurrency();
});
$('#currencyFromType').bind("change", function(){
Calculator.convertCurrency();
});
$('#calculator .iClose').bind("click", function(){
$("#calculator").hide();
$("#calculator_overlay").hide();
});
$(window).resize(function() {
$('#calculator').offset({ left: Calculator.calc.offset().left });
});
},
convertCurrency: function() {
var sourceValue = Calculator.stringToFloat($('#currencyFrom').val()),
sourceCurrency = $('#currencyFromType').val();
//course = 'По курсу ЦБРФ на ';
if($('#currencyResults table.result tbody').size())
$('#currencyResults table.result tbody').html('');
else
$('#currencyResults').append('');
$('#currencyResults table.result').hide();
if(sourceValue > 0){
$('#currencyResults table.result').show();
if(sourceCurrency == 'RUB'){
if(custom_code.length > 0)
Calculator.convertAppendResult(custom_code, sourceValue/Calculator.stringToFloat(custom_rate));
Calculator.convertAppendResult('USD', sourceValue/Calculator.stringToFloat(usd));
Calculator.convertAppendResult('EUR', sourceValue/Calculator.stringToFloat(eur));
}
if(sourceCurrency == 'USD'){
if(custom_code.length > 0)
Calculator.convertAppendResult(custom_code, sourceValue * Calculator.stringToFloat(usd) / Calculator.stringToFloat(custom_rate));
Calculator.convertAppendResult('RUB', sourceValue * Calculator.stringToFloat(usd));
Calculator.convertAppendResult('EUR', sourceValue * Calculator.stringToFloat(usd) / Calculator.stringToFloat(eur));
}
if(sourceCurrency == 'EUR'){
if(custom_code.length > 0)
Calculator.convertAppendResult(custom_code, sourceValue * Calculator.stringToFloat(eur) / Calculator.stringToFloat(custom_rate));
Calculator.convertAppendResult('RUB', sourceValue * Calculator.stringToFloat(eur));
Calculator.convertAppendResult('USD', sourceValue * Calculator.stringToFloat(eur) / Calculator.stringToFloat(usd));
}
if(sourceCurrency == 'custom'){
Calculator.convertAppendResult('RUB', sourceValue * Calculator.stringToFloat(custom_rate));
Calculator.convertAppendResult('USD', sourceValue * Calculator.stringToFloat(custom_rate) / Calculator.stringToFloat(usd));
Calculator.convertAppendResult('EUR', sourceValue * Calculator.stringToFloat(custom_rate) / Calculator.stringToFloat(eur));
}
}
},
stringToFloat:function(value) {
return(value.toString().replace(",", ".").replace(" ", ""));
},
floatToString: function(value) {
//console.log(value);
value = value.toFixed(2).toString().replace(".", ",");
if(value.length < 7){
return(value);
}else{
if(value.length > 9){
var position1 = value.length - 9;
var position2 = value.length - 6;
return(value.substring(0,position1) + ' ' + value.substring(position1,position2) + ' ' + value.substring(position2, value.length));
}else{
var position = value.length - 6;
return(value.substring(0,position) + ' ' + value.substring(position, value.length));
}
}
},
convertAppendResult: function(currency, value) {
$('#currencyResults table.result tbody').append(
'' +
'≈ ' +
Calculator.floatToString(value) +
' | ' +
'' +
currency +
' | ' +
'
'
);
}
}
function controlMainHost() {
if(top.location.href != document.location.href && top.frames && top.frames.length > 0)
top.location = document.location.href;
}
//controlMainHost();
function equalHeight(items) {
var max = 0;
items.each(function() {
var h = $(this).height();
if(h > max) max = h;
});
items.height(max);
}
function words(num, one, two, ten){
if ((num % 10) == 0)
return ten;
if(20 > num && num > 10)
return ten;
if(num == 1 || (num % 10) == 1)
return one;
if((num % 10) > 4)
return ten;
return two;
}
function checkEmail(email){
var emailTest = "^[+_.0-9a-z-]+@([0-9a-z][0-9a-z_-]+.)+[a-z]{2,4}$";
var regex = new RegExp(emailTest);
if (regex.test(email.toLowerCase()))
return true;
return false;
}
if(jQuery) {
$.event.trigger('load.main.js');
(function($){
function reloadCounter() {
$("#ramblerTop100counter").html();
$('script[src*="st.top100.ru/top100/top100.js"]').remove();
var _top100q = _top100q || [];
_top100q.push(["setAccount", "2892367"]);
_top100q.push(["trackPageviewByLogo", document.getElementById("ramblerTop100counter")]);
(function(){
var top100 = document.createElement("script"); top100.type = "text/javascript";
top100.async = true;
top100.src = ("https:" == document.location.protocol ? "https:" : "http:") + "//st.top100.ru/top100/top100.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(top100, s);
})();
$("#liveinternet-counter").html("<\/a>");
$('script[src*="mc.yandex.ru/metrika/watch.js"]').remove();
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter7178416 = new Ya.Metrika({id:7178416, enableAll: true, trackHash:true, webvisor:true});
} catch(e) {}
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
$('script[src*="stats.g.doubleclick.net/dc.js"]').remove();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23363597-1']);
_gaq.push(['_setDomainName', '.redigo.ru']);
_gaq.push(['_setAllowHash', 'false']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
(function() {
var img = new Image();
img.src = 'http://www.tns-counter.ru/V13a***R>' + document.referrer.replace(/\*/g, '%2a') + '*sup_ru/ru/UTF-8/tmsec=redigo_total/' + Math.round(Math.random() * 1000000000);
})();
}
var cnt = 0;
$(document).on('ajax.reload', function () {
cnt++;
if (cnt < 3) return;
cnt = 0;
reloadCounter();
$('iframe[id^="AdFox_iframe"]').each(function () {
$(this).parent().prev().html('');
var e = $(this).contents(), n = $(this).attr("id"), i = $(this).parent(), r = e.find("script"), a = r.attr("src");
e.find("head");
if (!a) return;
$(this).remove();
i.append('');
var s = document.getElementById(n).contentDocument;
s.write('');
})
});
})(jQuery)
}
/* /js/main.js end */
/* /js/delayedLoad.js begin */
var delayedLoaders = [];
function delayedLoad(delayedSelectorName, delayedClassName, timeout) {
if(!timeout) var timeout = 500;
if(delayedSelectorName.length > 0 && delayedClassName.length > 0){
var elements = $(delayedSelectorName);
var totalLength = elements.length;
var key = delayedSelectorName +'_'+ timeout;
if(totalLength == 0) {
if(typeof delayedLoaders[key] != 'null') clearTimeout(delayedLoaders[key]);
return;
}
var sprintLength = 5;
if(sprintLength > totalLength) sprintLength = totalLength;
for(var i = 0; i < sprintLength; i++) {
var im = $(elements[i]);
if(im.attr('source')) {
im.attr('src', im.attr('source'));
im.removeAttr('source');
}
im.removeClass(delayedClassName).removeClass('imgLoader');
}
delayedLoaders[key] = setTimeout(
function(){
delayedLoad(delayedSelectorName, delayedClassName, timeout);
}, timeout
);
}
}
$(function() {
$('.DelayedLoad').unveil(0, function(){
$(this).load(function(){
$(this).removeClass('imgLoader');
});
});
});
(function($) {
$.fn.unveil = function(threshold, callback) {
var $w = $(window),
th = threshold || 0,
attrib = "source",
images = this,
loaded;
this.one("unveil", function() {
var source = this.getAttribute(attrib);
if (source) {
$(this).attr("src", source).removeAttr("source");
if (typeof callback === "function") callback.call(this);
}
});
function unveil() {
var inview = images.filter(function() {
var $e = $(this);
if ($e.is(":hidden")) return;
var wt = $w.scrollTop(),
wb = wt + $w.height(),
et = $e.offset().top,
eb = et + $e.height();
return eb >= wt - th && et <= wb + th;
});
loaded = inview.trigger("unveil");
images = images.not(loaded);
}
$w.scroll(unveil);
$w.resize(unveil);
unveil();
return this;
};
})(jQuery);
/* /js/delayedLoad.js end */
/* /js/geo.js begin */
$(function(){
$(window).resize(function(){
$('.geoPopup').hide();
});
$('.countryLink').click(function(){
var pos = $(this).offset(),
popup = $('#' + $(this).data('popup'));
$('.cityMenu', popup).html('').hide();
$('.childLink.selected').removeClass('selected').addClass('pseudoLink');
if(popup.is(':hidden')){
$('.geoPopup').hide();
popup.slideDown().offset({top: parseInt(pos.top + 25) });
}else
popup.hide();
});
$('.childLink').click(function(){
if($(this).hasClass('selected')){
var popup = $(this).parents('.geoPopup');
$('.cityMenu', popup).html('').hide();
$(this).removeClass('selected').addClass('pseudoLink');
}else{
$('.childLink.selected').removeClass('selected').addClass('pseudoLink');
var path = $(this).data('path');
$(this).removeClass('pseudoLink').addClass('selected');
cityMenu = $(this).parents('.geoPopup').find('.cityMenu');
cityMenu.html('').show();
$.ajax({
url: '/geo_ajax',
data:{
path: path
},
success: function(data){
if(data != '') cityMenu.html(data);
}
})
}
});
$('.geoPopup_close').click(function(){
$(this).parents('.geoPopup').hide();
});
});
/* /js/geo.js end */
/* /js/tmpl.min.js begin */
!function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){return b?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[b]||"\\"+b:c?"="===c?"'+_e("+d+")+'":"'+("+d+"==null?'':"+d+")+'":e?"';":f?"_s+='":void 0},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return(null==a?"":""+a).replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return b}):a.tmpl=b}(this);
/* /js/tmpl.min.js end */