if(typeof ge!='function'){function ge(el){return(typeof el=='string'||typeof el=='number')?document.getElementById(el):el}}
if(typeof ce!='function'){function ce(tagName,att){var el=document.createElement(tagName);if(att){$.each(att,function(i,v){if(i=='className')$(el).attr('class',v);else $(el).attr(i,v)})}return el}}
function rand(mi, ma) { return Math.random() * (ma - mi + 1) + mi; }
function irand(mi, ma) { return Math.floor(rand(mi, ma)); }
function isFunction(obj) {return Object.prototype.toString.call(obj) === '[object Function]'; }
function isArray(obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }
function isObject(obj) { return Object.prototype.toString.call(obj) === '[object Object]'; }
function htmlspecialchars_decode(s,q){s=unescape(s.toString());s=s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');if(q=='ENT_QUOTES'){s=s.replace(/"/g,'"')}else if(q!='ENT_NOQUOTES'){s=s.replace(/"/g,'"')}return s}
function selectedText(){var txt='';if(window.getSelection){txt=window.getSelection().toString()}else if(document.getSelection){txt=document.getSelection()}else if(document.selection){txt=document.selection.createRange().text}return txt}
function doSomething(e){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation()}
function parse_url(url){if(url.indexOf('/?')!=-1){url=url.replace(/^(.*?)\/\?/i,'');url=url.split('&');var link=new Array();for(var pair in url){pair=url[pair].split('=');link[pair[0]]=htmlspecialchars_decode(pair[1],'ENT_QUOTES')}return link}else{return false}}
var addHoverClass = function() { if(isObject(this)) {$(this).addClass('hover');} };
var removeHoverClass = function() { if(isObject(this)) {$(this).removeClass('hover');} };
var hoverClass = function() { if(isObject(this)) {$(this).toggleClass('hover');} };
if(!staticFiles) var staticFiles = {};
var stManager = {
add: function(files, callback) {
var v = '';
if(!isArray(files)) files = [files];
for(var i in files) {
var f = files[i];
if(!staticFiles[f]) {
if (f.indexOf('.js') != -1) {
headNode.appendChild(ce('script', {
type: 'text/javascript',
src: '/js/' + f
}));
// !!!!!!!!!!!! файл считается загруженным всегда, чтоб файл считался загруженным после его реальной загрузки, необходимо код поместить в сам файл js
stManager.done(f);
} else {
headNode.appendChild(ce('link', {
type: 'text/css',
rel: 'stylesheet',
href: '/css/' + f + '?'// + Math.random()
}));
stManager.done(f);
}
}
}
},
done: function(files) {
if(!isArray(files)) files = [files];
for(var i in files) {
var f = files[i];
staticFiles[f] = {
t: '',
l: 1
};
}
}
};
function showMap(file) {
$.fancybox({href : file, title : 'Схема проезда'});
}
var pbox = {
create: function(option) {
var self = this;
pbox.init();
var setting = {
width: 350,
title: '',
ajax: false,
byclick: false,
content: '',
replaceTo: function(data){ return data; }
};
if(this.setting) {
setting = $.extend(this.setting, option);
} else {
setting = this.setting = $.extend(setting, option);
}
curPB.setting = setting;
if(!setting.title) { $(curPB.titleWrap).hide(); } else {
$(curPB.title).html(setting.title); }
if(!setting.nav) { $(curPB.nav).hide(); } else { $(curPB.nav).html(setting.nav).show(); }
if(setting.byclick) { $(pbLayerWrap).click(function(ev){ if(ev.target == curPB.wrap) { pbox.hide(); } }); }
$(pbLayer).css('width', setting.width+'px');
$(pbBody).html('
загрузка...
');
pbox.show();
if(setting.content) {
this.content(setting.content);
if(setting.onSuccess) {
self.uniB();
setting.onSuccess($(pbBody).html());
}
}
if(setting.ajax) {
pbox.loader('show');
if(setting.ajax.response != 'false') setting.ajax.response = true;
$.post(setting.ajax.url, setting.ajax.field, function(data){
$body = $(''+setting.replaceTo(data)+'
');
self.content($body);
if(setting.ajax.onSuccess) {
setting.ajax.onSuccess($(pbBody).html(), $body);
self.uniB();
}
if(setting.onSuccess) {
setting.onSuccess($(pbBody).html(), $body);
self.uniB(); // UniButton
}
pbox.loader('hide');
});
}
return this;
},
setOption: function (name, value) {
eval('this.setting.'+name+' = value;');
},
width: function(w, anim, time) {
if(anim && time) {
$(pbLayer).stop().animate({width: w}, time);
return;
}
$(pbLayer).width(w);
},
content: function (html) {
if(html) {
return $(pbBody).html('').append(html);
}
return $(pbBody);
},
title: function(h) { $(curPB.title).html('').append(h); },
nav: function(h) {
if(h == false) {
$(curPB.nav).hide();
} else {
$(curPB.nav).html('').append(h);
}
},
onResize: function() {},
loader: function(type){
var self = this;
if(type=='show') {
var lw = $(curPB.loader).width();
var lh = $(curPB.loader).height();
var th = curPB.titleWrap.style.display!='none' ? $(curPB.titleWrap).height() : 0;
var nh = curPB.nav.style.display!='none' ? $(curPB.nav).height() : 0;
$(curPB.loader).css({
'margin-top' : (($(pbLayer).height()/2) - (lh/2)+(th-nh)) +'px',
'margin-left': ((curPB.setting.width/2) - (lw/2)) +'px'
}).show();
self._loaderTime = setTimeout(self.loader, 7000, 'hide');
} else { clearTimeout(self._loaderTime); $(curPB.loader).hide(); }
},
_loaderTime: 0,
show: function() {
$(pbLayerWrap).show();
$(pbLayer).show(); //.fadeIn(200);
$('body').xScroll('off');
},
hide: function(time) {
var _this;
if(this.setting.onClose) {this.setting.onClose.call(this);}
if(!time) time = 0;
setTimeout(function(){
$(pbLayer).fadeOut(100, function(){
$(pbLayerWrap).hide();
$('body').xScroll('on');
});
}, time);
},
uniB: function() {
$(':submit,:button', curPB.wrap || document.body).unibutton({
classWrap: 'pbox_button',
classButton: 'button',
classHover: 'pbox_button_hover'
});
},
init: function() {
if(!window.curPB) window.curPB = {}; else return;
try{stManager.add('pbox.css');}catch(e){}
if(!ge('pbox_layer_wrap')) {
$(bodyNode).append('');
}
if(!window.pbLayerWrap) {
window.pbLayerWrap = ge('pbox_layer_wrap');
window.pbLayer = ge('pbox_layer');
window.pbBody = ge('pbox_body');
}
curPB = $.extend({
layout: ge('pbox_layout'),
loader: ge('pbox_loader'),
wrap: ge('pbox_wrap'),
titleWrap: ge('pbox_title_wrap'),
title: ge('pbox_title'),
nav: ge('pbox_nav')
});
$(curPB.loader).text('Загрузка...');
setInterval(pbox.onResize, 100);
}
};
var faq = {
send: function(form) {
if(this._send) return;
this._send = true;
// проверка на введенныве данные
var box = $(''),
dataArray = $(form).serializeArray(),
err = '',
data = {};
for(var k in dataArray) {
data[dataArray[k]['name']] = $.trim(dataArray[k]['value']);
}
if(data && data['name'].length < 2) { err += 'Поле "Ваше имя" содержит мало символов\n'; }
if(data && data['text'].length < 5) { err += 'Поле "Вопрос" содержит мало символов\n'; }
if(err.length) { alert('Сообщение нельзя отправить, поскольку допущены ошибки:\n\n' + err); setTimeout('faq._send = false;', 100); return; }
$('.progress', form).stop().fadeTo(100, 1);
$.post(form.action, data, function(res){
try {
res = $.parseJSON(res);
$('.progress', form).stop().fadeTo(100, 0);
if(res && isObject(res)) {
if(res['status'] == 'OK') {
if(res['message']) {
box.append(res['message']);
$(form).before(box).hide();
}
form.reset();
}
if(res['status'] == 'ERROR' && res['message'].length) {
alert(res['message']);
}
}
} catch(e) { alert(e +'\n'+ res); }
faq._send = false;
});
},
more: function(el) {
var box = $(el).parent(),
form = box.next();
form.show();
box.remove();
}
};
if(typeof order_service != 'function') {
function order_service(form) {
if(this.send) return;
this.send = true;
var self = this,
box = $(''),
dataArray = $(form).serializeArray(),
err = '',
data = {};
// группируем данные
for(var k in dataArray) { data[dataArray[k]['name']] = $.trim(dataArray[k]['value']); }
// проверка на введенные данные
if(data && data['name'].length < 2) { err += 'Поле "Ваше имя" содержит мало символов\n'; }
if(data && data['notice'].length < 6) { err += 'Поле "Ваш email ли телефон" содержит мало символов\n'; }
if(err.length) { alert('Сообщение нельзя отправить, поскольку допущены ошибки:\n\n' + err); setTimeout('self.send = false;', 500); return; }
$('.progress', form).stop().fadeTo(100, 1);
$.post(form.action, data, function(res){
try {
res = $.parseJSON(res);
$('.progress', form).stop().fadeTo(100, 0);
if(res && isObject(res)) {
if(res['status'] == 'OK') {
if(res['message']) {
box.append(res['message']);
$(form).before(box).hide();
}
form.reset();
}
if(res['status'] == 'ERROR' && res['message'].length) {
alert(res['message']);
}
}
} catch(e) { alert(e +'\n'+ res); }
self.send = false;
});
}
}
function initNode() {
if(window.htmlNode && window.headNode && window.bodyNode) return;
window.htmlNode = document.getElementsByTagName('html')[0];
window.headNode = document.getElementsByTagName('head')[0];
window.bodyNode = document.getElementsByTagName('body')[0];
if(!window.htmlNode) window.htmlNode = document.html;
if(!window.headNode) window.headNode = document.head;
if(!window.bodyNode) window.bodyNode = document.body;
}
function widget_update(form) {
if(form._send) return;
form._send = true;
$('.progress', form).stop().fadeTo(100, 1);
$.getJSON(form.action, function(data){
form._send = false;
if(data && isObject(data)) {
$(':hidden', form).val( data['id'] );
$('p', form).html( $.trim(data['content']) );
}
$('.progress', form).stop().fadeTo(100, 0);
if(widget_update['resize']) {
widget_update.resize();
}
});
}
$(function(){
// Инициализация модуля Node
initNode();
if(typeof window['placeholder'] == 'function') {
$('input[placeholder],textarea[placeholder]').placeholder();
}
if(window.SID) {
$(':input[name=sid]').val(window.SID);
}
$(':submit,:button').unibutton();
$('a.fancybox').fancybox();
// Begin UL LI colorisaze
$('div.page_content ul li').each(function(){
var li = $(this), span = $('');
span.css('color', li.css('color'));
li.html(span.append(li.html())).css('color', '#400681');
});
// :UL LI
// Begin is Resize background
var imData = [],
doc = $(document),
imList = $('body > img.imbg'),
imLast = imList.filter(':last'),
timeout = 0;
function resizeWindow() {
if('console' in window) {
console.log('resize');
}
//return;
imList = $('body > img.imbg');
var ih = imLast.height(),
dh = doc.height(),
ic = (dh / ih),
im = Math.ceil(ic),
imSize = imList.size(),
top = 0;
if(ih < 100 || imSize > 200) {return;}
if(imSize < im) {
for(; imSize < im; imSize++) {
imList.filter(':first').before('');
if(imSize>10) break;
}
imList = $('body > img.imbg');
}
if(imList.filter(':visible').size() < im) {
imList.filter(':hidden').show();
}
if(imSize > im) {
imList.filter(':gt('+ (im-2) +'):not(:last)').hide();
}
imList.filter(':visible:not(:last)').each(function(i){
if(i == 0) {
top = -((((im - ic) * 100) * ih) / 100);
} else { top += ih; }
$(this).css('top', top);
});
if(timeout==0) {
timeout = setTimeout(resizeWindow, 1000);
}
}
imLast.load(resizeWindow);
$(window).resize(resizeWindow);
setInterval(resizeWindow, 2000);
widget_update.resize = resizeWindow;
// end resize
});
// Загружаем и инициализируем nicEditor
function onDomEditor(callback) {
stManager.add('editor.js', callback);
}
// Запрет выделения
(function($){
$.fn.onSelect = function(status){
this.each(function() {
if(status) {
this.onselectstart = function() {};
this.unselectable = "off";
$(this).css('-moz-user-select', 'auto');
} else {
this.onselectstart = function() { return false; };
this.unselectable = "on";
$(this).css('-moz-user-select', 'none');
}
});
return this;
};
$.fn.reset = function() {
this[0].reset();
return this;
};
$.fn.tips = function(options) {
var defaults = {
width: 'auto',
ajax: false,
content: '',
onComplete: function(){},
margin: '',
x: 0, y: 0,
opacity: '0.95'
};
var cache = {}, self = this;
setting = $.extend({}, defaults, options);
function closeTip(){ cache.box.fadeOut(200, hide); };
function init() {
if(cache.init) return;
cache.box = $('').show();
cache.content = $('').append(setting.content);
cache.close = $('').click(closeTip);
cache.box.append(cache.close).append(cache.content);
$(self).after(cache.box);
style();
}
function style() {
if(!cache.box) return;
$p = $(self).position();
cache.box.css({
'top' : ($p.top + setting.y) +'px',
'left': ($p.left + setting.x) +'px',
'opacity' : setting.opacity || '0.95',
'margin' : setting.margin
});
}
// Success
init();
setting.onComplete(cache.box);
return {
close: function() {
closeTip(cache.box);
},
el: function() {
return cache.box;
},
setOption: function(n,v) {
eval('setting.'+ n +' = v;');
style();
},
content: function(el) {
if(!cache.content) return;
cache.content.html('').append(el);
}
};
};
$.fn.outerHTML = function() {
return $("").append(this.clone()).html();
};
$.fn.xScroll = function(type){
$(this).each(function(){
if(type == 'off') {
$(this).css({overflow: 'hidden'});
} else {
$(this).css({overflow: 'visible', overflowX: 'hidden'});
}
});
return this;
};
/* uniBotton */
$.fn.unibutton = function(options) {
var self = this,
setting = $.extend({}, {
classButton: 'button',
classWrap: 'wrap_button',
classHover: 'hover_button'
}, options);
this.each(function(){
var input = $(this);
var wrapper = input.parent();
if(!input.hasClass(setting.classButton)) {
input.addClass(setting.classButton);
}
if(!wrapper.is('.'+ setting.classWrap)) {
wrapper = $('
');
input.after(wrapper).appendTo(wrapper);
}
wrapper.click(function(){
var el = $(':first', this);
if(el.attr('type') == 'submit') {
$(el).parents('form').submit();
}
}).hover(function(){
$(this).addClass(setting.classHover);
},function(){
$(this).removeClass(setting.classHover).removeClass('down_button');
}).mousedown(function(){
$(this).addClass('down_button');
}).mouseup(function(){
$(this).removeClass('down_button');
});
});
this.onSelect(false);
};
$.fn.checked = function(mode) {
var mode = mode || 'on';
return this.each(function() {
switch(mode) {
case 'on':
case true:
this.checked = true;
break;
case 'off':
case false:
this.checked = false;
break;
case 'toggle':
this.checked = !this.checked;
break;
}
});
};
$.fn.autoResize = function() {
this.bind('keyup keypress', function(){
this.style.height='';
this.style.overflowY = 'hidden';
/*
if(parseInt(this.style.minHeight)