document.write("");document.write("");
function Preloader() {
} (
function() {
request_form = {},buyer_name = '',
buyer_addr = '',
buyer_phone = '',
buyer_mail = '',
buyer_id = 0, Preloader.prototype = {
Request : "http://www.kalyanmalyan.ru/basket/load.php?",
Subsys : function() { return new Subsys_JsHttpRequest_Js() },
is_empty : function(str) {
return (str.replace(/\s\s+/gi,'')=='');
},
is_email : function (email) {
var reg = /[0-9a-z_\.\-]+@[0-9a-z_\-^.]+\.[a-z]{2,4}/i;
return reg.test(email);
},
SendRequest : function(what) {
req = this.Subsys();
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.responseJS.error) {
alert(req.responseJS.error);
return false;
}
if (req.responseJS.answer == 'ok') {
document.getElementById('request_form').innerHTML = '';
document.getElementById('request_form').style.display = 'none';
if (what == 'add') alert('Товар добавлен в корзину!');
else if (what == 'order') {
alert('Заказ отправлен! \r\nСпасибо за покупку!');
window.location.replace('http://www.kalyanmalyan.ru/index.php');
}
else if (what == 'question') alert('Вопрос отправлен администратору!\r\nВы получите ответ на указанный емайл!\r\nСпасибо!');
}
}
}
req.caching = true;
// document.getElementById('request').innerHTML = this.Request;
req.open('POST', this.Request, true);
req.send({ q: this.Request, test:303 });
},
CreateLayer : function() {
document.write('
');
},
Ask : function () {
if (!this.request_form) this.request_form = document.getElementById('request_form');
this.request_form.innerHTML = '';
this.request_form.style.display = 'block';
},
AskQuestion : function() {
this.Request = "http://www.kalyanmalyan.ru/basket/load.php?";
var ml = document.getElementById('email').value;
var qu = document.getElementById('question').value;
var focus = false;
if (this.is_empty(ml) || this.is_empty(qu)) {
var report = 'Вы не заполнили обязательные поля!\r\n\r\n';
if (this.is_empty(ml)) {
report += '- Введите свой email!\r\n';
focus = document.getElementById('email');
}
if (this.is_empty(qu)) {
if (!focus) focus = document.getElementById('question');
report += '- Введите свой вопрос!\r\n';
}
alert(report);
focus.focus();
return false;
}
if (!this.is_email(document.getElementById('email').value)) {
alert('Неверный формат email-адреса!');
document.getElementById('email').focus();
return false;
}
this.Request += 'act=question&eml=' + escape(ml) + '&quest='+ escape(qu) + '&rand='+Math.floor(Math.random() * 1000000);
this.ClearForm();
this.SetLoading('Отправка вопроса!
Подождите...');
this.SendRequest('question');
},
Add : function(res_id) {
this.Request = "http://www.kalyanmalyan.ru/basket/load.php?";
this.request_form = document.getElementById('request_form');
this.Request += 'act=add&res_id=' + res_id + '&rand='+Math.floor(Math.random() * 1000000);
if (document.getElementById('aroma_' + res_id)) {
this.Request += '&aromat='+document.getElementById('aroma_' + res_id).value;
}
this.ClearForm();
this.SetLoading('Добавление товара!
Подождите...');
this.SendRequest('add');
},
Delete : function(res_id) {
if (confirm('Удалить товар из корзины?')) {
if (document.getElementById('prod_'+res_id)) {
Fat.fade_element('prod_'+res_id, 30, 1000, '#CC3300', '#FFFFFF');
this.Request = "http://www.kalyanmalyan.ru/basket/load.php?";
this.Request += 'act=del&res_id=' + res_id + '&rand='+Math.floor(Math.random() * 1000000);
this.SendRequest('del');
}
}
},
BuyIt : function(resource_id, resource_name, resource_price) {
SetScroll();
this.request_form = document.getElementById('request_form');
this.request_form.innerHTML = '';
this.request_form.style.display = 'block';
},
ClearForm : function() {
this.request_form.style.display = 'none';
this.request_form.innerHTML = '';
},
SetLoading : function(text) {
this.request_form.style.display = 'block';
this.request_form.innerHTML = '';
},
BuyClick : function() {
this.Request = "http://www.kalyanmalyan.ru/basket/load.php?";
canceled = false;
changed = false;
var focus = false;
if (this.is_empty(document.getElementById('fio').value) || this.is_empty(document.getElementById('address').value) || this.is_empty(document.getElementById('phone').value) || this.is_empty(document.getElementById('email').value)) {
var report = 'Вы не заполнили обязательные поля!\r\n\r\n';
if (this.is_empty(document.getElementById('fio').value)) {
report += '- Фамилия Имя Отчество\r\n';
focus = document.getElementById('fio');
}
if (this.is_empty(document.getElementById('address').value)) {
report += '- Адрес\r\n';
if (!focus) focus = document.getElementById('address');
}
if (this.is_empty(document.getElementById('phone').value)) {
report += '- Телефон\r\n';
if (!focus) focus = document.getElementById('phone');
}
if (this.is_empty(document.getElementById('email').value)) {
report += '- Email\r\n';
if (!focus) focus = document.getElementById('email');
}
alert(report);
focus.focus();
return false;
}
if (!this.is_email(document.getElementById('email').value)) {
alert('Неверный формат email-адреса!');
document.getElementById('email').focus();
return false;
}
if ( (buyer_name !='' && buyer_name != document.getElementById('fio').value) || (buyer_addr != '' && buyer_addr != document.getElementById('address').value) || (buyer_phone != '' && buyer_phone != document.getElementById('phone').value) || (buyer_mail != '' && buyer_mail != document.getElementById('email').value)) {
if (confirm('Изменить Ваши персональные данные?')) {
buyer_name = document.getElementById('fio').value;
buyer_addr = document.getElementById('address').value;
buyer_phone = document.getElementById('phone').value;
buyer_mail = document.getElementById('email').value;
changed = true;
}
else canceled = true;
}
if ((buyer_name =='' || buyer_addr == '' || buyer_phone == '' || buyer_mail == '') && !canceled) {
buyer_name = document.getElementById('fio').value;
buyer_addr = document.getElementById('address').value;
buyer_phone = document.getElementById('phone').value;
buyer_mail = document.getElementById('email').value;
}
this.Request += 'fio=' + escape(document.getElementById('fio').value) + '&addr=' + escape(document.getElementById('address').value) + '&phone=' + escape(document.getElementById('phone').value) + '&eml=' + escape(document.getElementById('email').value)+'&buyer='+buyer_id + '&rand='+Math.floor(Math.random() * 1000000);
if (changed) this.Request += '&ch=1';
this.ClearForm();
this.SetLoading('Отправка запроса.
Подождите...');
this.SendRequest('order');
}
}
})();
function SetScroll() {
var heights = window.document.body.offsetHeight;
var Top = document.documentElement.scrollTop;
document.getElementById('request_form').style.top = Top+100;
}
window.onscroll = function () {
SetScroll();
}
shown=''
function OpenPhotos(url, width, height) {
if ( shown=='' || shown.closed) {
shown=window.open('http://www.kalyanmalyan.ru/img.php?image='+url,'OpenFile', 'scrollbars=yes, status=no, high, width=450, height=650');
}
else {
shown.close();
shown=window.open('http://www.kalyanmalyan.ru/img.php?image='+url,'OpenFile', 'scrollbars=yes, status=no, toolbar=no, high, width=450, height=650');
}
}
var maxlength = 300;
function Countlimit() {
var counts = 0;
mess = document.getElementById('question');
counter = document.getElementById('question_count');
counts = maxlength-mess.value.length;
if (counts<0) {
mess.value=mess.value.substring(0,maxlength);
counter.innerHTML=0;
}
else counter.innerHTML=counts;
}
var Pl = new Preloader();