function form2trash(id) {    if (timeRemaining != '') {        $('#not-working-popup').verticalCenter();        $('.not-working-popup').css('display', 'block');        $('#not-working-time').text(timeRemaining);        $('body').bind('click', function() {            $('.not-working-popup').css('display', 'none');        });        return false;    }	$('.ordern').hide();	$('#intval_' + id).val(1);	$('#add_' + id).show();	return false;}function add2trash(id) {	$.post("/add2trash.php", {		id: id,		num: $('#intval_' + id).val()	}, function (data) {		$('#trash-full').html(data);		$('#add_' + id).hide();	});}function recalc() {	summa = 0;	$('.summa').each(function () {		summa += parseFloat($(this).attr('summa'));	});	$('.total-summa').html(number_format(summa, 2, ',', ' ')).attr('totalsumma', summa);	discount_provision = $('#discount_provision').val();	discount = parseFloat($('#discount_summa').val());	if (discount > 0) {		if (discount_provision == 'summa') {			min_summa = parseFloat($('#provision_value').val());			if (summa > min_summa) {				if ($('#discount_type').val() == 'rub') {					summa = summa - discount;				} else {					summa = summa - (summa * (discount / 100))				}				$('#tdisc').html('Итого с учетом скидки');			} else {				$('#tdisc').html('Итого');			}		} else {			if ($('#discount_type').val() == 'rub') {				summa = summa - discount;			} else {				summa = summa - (summa * (discount / 100));			}			$('#tdisc').html('Итого с учетом скидки');		}	} else {		$('#tdisc').html('Итого');	}	$('.total-summa-itogo').html(number_format(summa, 2, ',', ' '));	check_order();}function change_filter(id) {	var elem_id = '#' + id;	checked = $(elem_id).children('input').attr('checked');	if (checked == 'checked') {		$(elem_id).removeClass('b-checkbox_checked');		$(elem_id).children('input').removeAttr('checked');	} else {		$(elem_id).addClass('b-checkbox_checked');		$(elem_id).children('input').attr('checked', 'checked');	}	changeFilter(); /*if ($(elem_id).children('input').is(':checked')) {      $(elem_id).addClass('b-checkbox_checked')    } else {      $(elem_id).removeClass('b-checkbox_checked')    }      changeFilter();  }*/}function change_box(id) {	checked = $('#checkbox_' + id).attr('checked');	if (checked == 'checked') {		$('#checkbox_' + id).attr('checked', false);		$('#link_' + id).removeClass('cheke');		$.post("/upd2trash.php", {			id: id,			num: 0		});		$('#trow_' + id).css({			'opacity': '0.2'		});		$('#summa_' + id).html('0,00').attr('summa', '0');	} else {		$('#checkbox_' + id).attr('checked', true);		$('#link_' + id).addClass('cheke');		$.post("/upd2trash.php", {			id: id,			num: $('#intval_' + id).val()		});		$('#trow_' + id).css({			'opacity': '1'		});		summa = $('#intval_' + id).val() * $('#intval_' + id).attr('price');		$('#summa_' + id).html(number_format(summa, 2, ',', ' ')).attr('summa', summa);	}	recalc();}function hideAllTeasersBlocks() {	$('.b-teasers').css('display', 'none');}function showAllTeasersBlocks() {	$('.b-teasers').css('display', 'block');}function showTeasersBlockById(id) {	$('#' + id).css('display', 'block');}function showAllTeasers() {	$('div.l-teaser').css('display', 'block');}function showTeaser(teaser) {	teaser.css('display', 'block');}function hideAllTeasersByTeasersBlockId(id) {	$('#' + id + ' div.l-teaser').css('display', 'none');}function changeFilter() {    showAllTeasersBlocks();    showAllTeasers();    var show_filter_text = 'Вы можете выбрать блюда по параметрам';    if ($('#filter-form :input:checked').size() > 0) {        var begin;        show_filter_text = '';        var $sections = $('#filter-form :input:checked[name="section"]');        if ($sections.size() > 0) {            hideAllTeasersBlocks();            show_filter_text += 'Вы выбрали: ';            begin = 0;            $sections.each(function () {                if (begin == 0) {                    show_filter_text += $(this).after().next().children().text();                } else if ($sections.length == begin+1) {                    show_filter_text += ' и ' + $(this).after().next().children().text();                } else {                    show_filter_text += ', ' + $(this).after().next().children().text();                }                begin++;                showTeasersBlockById($(this).val());            });            show_filter_text += '. ';        } else {            $sections = $('#filter-form :input[name="section"]');        }        var $preferences = $('#filter-form :input:checked[name="preferences"]');        if ($preferences.size() > 0) {            if (show_filter_text != '') {                show_filter_text +=  ' ';            }            show_filter_text += 'Обязательно: ';            begin = 0;            $preferences.each(function () {                if (begin == 0) {                    show_filter_text += $(this).after().next().children().text();                } else if ($preferences.length == begin+1) {                    show_filter_text += ' и ' + $(this).after().next().children().text();                } else {                    show_filter_text += ', ' + $(this).after().next().children().text();                }                begin++;            });            show_filter_text += '. ';            $sections.each(function () {                var section = this;                var section_has_class = false;                $('#' + $(section).val() + ' div.l-teaser').each(function () {                    var teaser_has_class = false;                    var teaser = this;                    $preferences.each(function () {                        if ($(teaser).hasClass('pref_' + $(this).val())) {                            teaser_has_class = true;                            section_has_class = true;                        }                    });                    if (!teaser_has_class) {                        $(this).css('display', 'none');                    }                });                if (!section_has_class) {                    $('#' + $(this).val()).css('display', 'none');                }            });        }        var $compositions = $('#filter-form :input:checked[name="composition"]');        if ($compositions.size() > 0) {            if (show_filter_text != '') {                show_filter_text +=  ' ';            }            show_filter_text += 'Состав: ';            begin = 0;            $compositions.each(function () {                if (begin == 0) {                    show_filter_text += $(this).after().next().children().text();                } else if ($compositions.length == begin+1) {                    show_filter_text += ' и ' + $(this).after().next().children().text();                } else {                    show_filter_text += ', ' + $(this).after().next().children().text();                }                begin++;            });            show_filter_text += '. ';            $sections.each(function () {                var section = this;                var section_has_class = false;                $('#' + $(section).val() + ' div.l-teaser').each(function () {                    var teaser_has_class = false;                    var teaser = this;                    $compositions.each(function () {                        if ($(teaser).hasClass('comp_' + $(this).val())) {                            teaser_has_class = true;                            if ($(teaser).css('display') != 'none') {                                section_has_class = true;                            }                        }                    });                    if (!teaser_has_class) {                        $(this).css('display', 'none');                    }                });                if (!section_has_class) {                    $('#' + $(this).val()).css('display', 'none');                }            });        }    } else {        showAllTeasersBlocks();        showAllTeasers();    } /*$.post("/filter.php", $('#filter-form').formSerialize(), function(data){      $('#product-data').html(data);      teasersInit();    });*/    $('#small-filter-text').html(show_filter_text);}var close_popup = false; /* Открыть pop-up */function showPopup(popup_type) {	if ($.browser.msie) {		$('#opaco').height($(document).height()).toggleClass('popup-hidden');	} else {		$('#opaco').height($(document).height()).toggleClass('popup-hidden').fadeTo('slow', 0.7);	}	$('#popup').html($('#popup_' + popup_type).html()).center().toggleClass('popup-hidden');	return false;} /* Закрыть pop-up окно */function closePopup() {	$('#opaco').toggleClass('popup-hidden').removeAttr('style');	$('#popup').toggleClass('popup-hidden');	$('#popup').css('width', '530px');	$('#popup').css('height', '460px');	$('.popup-close').css('margin-top', '-40px');	$('.popup-close').css('margin-right', '20px');	close_popup = false;	return false;}function checkOrderCallForm() {    disabled = false;    i = 0;    r = '';    val = $('#order-call-name').val();    if (val.length < 3) {        disabled = true;        r += 'имя';        i++;    }    val = $('#order-call-phone').val();    if (val.length < 3) {        disabled = true;        if (i > 0) r += ', ';        r += 'телефон';        i++;    }    if (i > 0) {        $('#hint-order-call').html('Осталось заполнить: ' + r);    } else {        $('#hint-order-call').html('');    }    if (disabled) {        $('.b-button_send-order-call').addClass('disabled');    } else {        $('.b-button_send-order-call').removeClass('disabled');    }    return !disabled;}function sendData() {	if ($('.b-button_send-order-call').hasClass('disabled')) {		return false;	}	$.post("/add_order_call.php", {		name: $('#order-call-name').val(),		phone: $('#order-call-phone').val(),		time: $('#order-call-time').val(),		message: $('#order-call-message').val()	}, function (data) {		if (data) {			$('.order-call-error').html(data);		} else {			closePopup();			$('#popup').css('width', '650px');			$('#popup').css('height', '150px');			close_popup = true;			$('div').click(function () {				if (close_popup) {					closePopup();				}			});			$('#order-name-complete-msg').text($('#order-call-name').val());			showPopup('order-call-complete');		}	});	return false; /*return closePopup();*/}function showSuccessPopup (title, message) {    $('#popup').css('width', '650px');    $('#popup').css('height', '150px');    $('#popup_submit-success').find('.title').text(title);    $('#popup_submit-success').find('.popup-description').text(message);    showPopup('submit-success');}$(document).ready(function () {    if (getHash() == 'success' && isset(successTitle) && isset(successMessage)) {        showSuccessPopup(successTitle, successMessage);    }	$(document).bind('click', function (e) {		if ($(e.target).closest('.b-teaser-top').length > 0 || systemClick) {			return false;		} else {			$('.b-teaser-top:visible').hide();		}	});	$('.b-teaser footer .b-button').click(function (e) {		e.stopPropagation();	});	$(document).keyup(function (event) {		if (event.keyCode == 27) {			$('.ordern').hide();		}	});	$('.button-plus').live('click', function () {		id = $(this).attr('row');		val = parseInt($('#intval_' + id).val());		if (val < 1 || val > 98 || isNaN(val)) {			val = 1;		} else {			val++;		}		$('#intval_' + id).val(val);	});	$('.sign-plus_and_minus').live('mousedown', function () {        $(this).prev().addClass('down');        $(this).css({ 'top' : '-10px' });	});	$('.sign-plus_and_minus').live('mouseup', function () {        $(this).prev().removeClass('down');        $(this).css({ 'top' : '-12px' });        $(this).prev().click();	});	$('.sign-plus').hover(function () {            $(this).prev().addClass('sign-plus-hover');	    }, function() {            $(this).prev().removeClass('sign-plus-hover');    });	$('.sign-minus').hover(function () {            $(this).prev().addClass('sign-minus-hover');	    }, function() {            $(this).prev().removeClass('sign-minus-hover');    });	$('.button-minus').live('click', function () {		id = $(this).attr('row');		val = parseInt($('#intval_' + id).val());		if (val < 1 || val > 98 || isNaN(val)) {			val = 1;		} else {			val--;		}		if (val < 1) val = 1;		$('#intval_' + id).val(val);	});	$('.button-minus').live('click', function () {		id = $(this).attr('row');		val = parseInt($('#intval_' + id).val());		if (val < 1 || val > 98 || isNaN(val)) {			val = 1;		} else {			val--;		}		if (val < 1) val = 1;		$('#intval_' + id).val(val);	});	$('.clearfilter').click(function () { /*$('.b-checkbox > input[type="checkbox"]').each(function(){  	  $(this).removeAttr('checked');	  $(this).parent('.b-checkbox').removeClass('b-checkbox_checked');    });*/        $('.b-checkbox > input[type="checkbox"]').each(function(){            $(this).removeAttr('checked');            $(this).parent('.b-checkbox').removeClass('b-checkbox_checked');        });		showAllTeasersBlocks();		showAllTeasers(); /*$.post("/filter.php", $('#filter-form').formSerialize(), function(data){      $('#product-data').html(data);    });*/	});	$('#small-filter').hover(function (e) {		var scrollTop = $(window).scrollTop();		if (scrollTop > 200) {			$('#small-filter').hide();			$('#big-filter').slideDown("normal", function () {});		}	}, function (e) {});	$('#big-filter').hover(function (e) {}, function (e) {		var scrollTop = $(window).scrollTop();		if (scrollTop > 200) {			$('#big-filter').slideUp("normal", function () {				$('#small-filter').show();			});		}	});	$(window).scroll(function () {		var scrollTop = $(window).scrollTop();		if (scrollTop > 200) {			$('#a-nav').css({				'height': '123px'			});			$('#big-filter').hide();			$('#small-filter').show();			var navWidth = $('#nav').parent().width();			$('#nav').css({				'position': 'fixed',				'top': '0',				'z-index': '9999',				'width': navWidth + 'px'			});			var setNavWidth = function () {					navWidth = $('#nav').parent().width();					$('#nav').css({						'width': navWidth + 'px'					});				};			$(window).bind('resize', setNavWidth);		} else {			$('#a-nav').height(0);			$('#big-filter').show();			$('#small-filter').hide();			$('#nav').css({				'position': 'relative',				'width': '100%'			});			$(window).unbind('resize', setNavWidth);		}	});	$('.b-checkbox > input[type="checkbox"]')	.bind('change', function(){	  if (!$(this).is(':checked')) {		$(this).parent('.b-checkbox').addClass('b-checkbox_checked');	  } else {		$(this).parent('.b-checkbox').removeClass('b-checkbox_checked');	  }	});		$('.b-button').not('.disabled').bind('mousedown', function(){		$(this).addClass('down');	});	$('.b-button').not('.disabled').bind('mouseup', function(){		$(this).removeClass('down');	});	$('.b-button_send-order').bind('mousedown', function(){        if (!$(this).hasClass('disabled')) {		    $(this).addClass('down');        }	});	$('.b-button_send-order').bind('mouseup', function(){        if (!$(this).hasClass('disabled')) {		    $(this).addClass('down');        }	});	var params = {		changedEl:".b-form .field__select select, .b-form .field__misc select",		scrollArrows:false	};	cuSel(params);	/* SLIDER */	var slides = $('#slideshow').find('.slide');	var slideActive = slides.filter('.active');	var slideAnimTime = 650;	var slideshowTime = 2000 + slideAnimTime * 2;	var slideshow = false;	slides.filter(':hidden').css({		opacity: 0	});	$('#slideshow .container-controls').css({		opacity: 0	}); /*	$('#slideshow').append('<ul class="pages"></ul>')	var i = 0;	slides.each(function(){		$(this).css({'z-index':i})		i+=1;		$('#slideshow ul.pages').append('<li><a href="#" class="js">'+i+'</a></li>')	});	*/	var slidePages = $('#slideshow ul.pages li a');	var i = 0;	slidePages.each(function () {		$(this).data('slide', slides.filter(':eq(' + i + ')'));		i += 1;	});	var controlsFadeTime = 200;	var controlsCss = {		'display': 'block'	};	if ($.browser.msie && $.browser.version <= 8.0) {		controlsFadeTime = 0;		controlsCss = {			'display': 'block',			height: $('#slideshow').height()		};	}	$('#slideshow').hover(function () {		$('#slideshow .container-controls').dequeue().clearQueue().stop().css(controlsCss).animate({			opacity: 1		}, controlsFadeTime, function () {			$(this).css({				opacity: ''			});		});	}, function () {		$('#slideshow .container-controls').delay(200).animate({			opacity: 0		}, controlsFadeTime * 2, function () {			$(this).css({				'display': 'none'			});		});	});	slidePages.bind('click', function () {		stopSlideshow();		slideGo($(this).data('slide'));	});	slidePages.eq(slideActive.index()).addClass('active');	$('#slideshow .slide-prev').bind('click', function () {		stopSlideshow();		slidePrev();	});	$('#slideshow .slide-next').bind('click', function () {		stopSlideshow();		slideNext();	});	$('#slideshow .slide-play').bind('click', function () {		$(this).hide();		$('.slide-pause', '#slideshow').show();		setTimeout(function () {			slideNext();		}, slideAnimTime);		slideshow = true;	});	var stopSlideshow = function () {			slideshow = false;			$('#slideshow .slide-pause').hide();			$('#slideshow .slide-play').show();		};	$('#slideshow .slide-pause').bind('click', function () {		stopSlideshow();	});	var slideNext = function () {			var slide = slideActive.next();			if (slideActive.next().index() >= slides.length) slide = slides.first();			slideGo(slide);		};	var slidePrev = function () {			var slide = slideActive.prev();			if (slideActive.prev().index() < 0) slide = slides.last();			slideGo(slide);		};	var slideGo = function (slide) {			if (!slide.is('.active')) {				var img = slide.css('background-image');				img = img.replace("url(", "").replace(")", "").replace('"', '').replace('"', '');				var image = $('<img class="tempImage" style="position:absolute;left:-1px;top:-1px;width:0;height:0" src="' + img + '" />').appendTo('body');				$('#slideshow .loading').css({					display: 'block',					opacity: 0				}).dequeue().stop().animate({					opacity: 0.9				}, 1000);				$('#slideshow .loading .dots').text('');				var dots = 3;				var i = 0;				var dotsAnim = setInterval(function () {					i += 1;					if (i > dots) {						$('#slideshow .loading .dots').text('');						i = 0;					} else {						$('#slideshow .loading .dots').text($('#slideshow .loading .dots').text() + '.');					}				}, 150);				image.bind('load', function () {					clearInterval(dotsAnim);					$('#slideshow .loading').dequeue().stop().animate({						opacity: 0					}, function () {						$(this).css({							display: 'none'						});					});					image.remove();					slides.not(slide).removeClass('active').css({						'z-index': function () {							var z = parseInt($(this).css('z-index'));							return z - 1;						}					}).dequeue().stop().animate({						opacity: 0					}, slideAnimTime);					slideActive = slide;					slide.addClass('active').css({						'z-index': function () {							var z = parseInt($(this).css('z-index'));							return 100;						},						display: 'block'					}).dequeue().stop().animate({						opacity: 1					}, slideAnimTime, function () {						$(this).css({							opacity: ''						});						if (slideshow) setTimeout(function () {							if (slideshow) slideNext()						}, slideshowTime);					});					slidePages.removeClass('active');					slidePages.eq(slideActive.index()).addClass('active');				});				if ($.browser.msie && $.browser.version <= 6.0) image.filter(function () {					if (this.readyState == "uninitialized") {						$(this).trigger('load');					}				});			}		};	$('a.js').bind('click', function (event) {		event.preventDefault();	});	$(".slidedownButton").click(function () {		$(".slideupButton").addClass("active");		$(".slidedownButton").addClass("active");		$(".list2", ".contBox").animate({			"width": "30%"		}, 800);		$(".contBox2", ".rightBox").animate({			"height": "420px"		}, 800);		$(".slide2", ".contBox").animate({			"width": "255%"		}, 800, function () {			$(".cont1", ".textBox1").fadeIn("slow");		});		$(".offersBox").addClass("active");		$(".listBox", ".leftBox").addClass("active");		$(".textBox1").show();		$(".textBox").hide();		$(".cont1", ".textBox").hide();		return false;	});	$(".slideupButton").click(function () {		$(".slideupButton").removeClass("active");		$(this).addClass("active");		$(".slidedownButton").removeClass("active");		$(this).removeClass("active");		$(".slide2", ".contBox").animate({			"width": "100%"		}, 800, function () {			$(".cont1", ".textBox").fadeIn("slow");		});		$(".contBox2", ".rightBox").animate({			"height": "310px"		}, 800);		$(".list2", ".contBox").animate({			"width": "100%"		}, 800);		$(".offersBox").removeClass("active");		$(".listBox", ".leftBox").removeClass("active");		$(".textBox").show();		$(".textBox1").hide();		$(".cont1", ".textBox1").hide();		return false;	});	$('#recall').bind('click', function () {        if (timeRemaining != '') {            $('#not-working-popup').verticalCenter();            $('.not-working-popup').css('display', 'block');            $('#not-working-time').text(timeRemaining);            $('body').bind('click', function() {                $('.not-working-popup').css('display', 'none');            });            return false;        } else {		    $('#popup').css('height', '357px');		    showPopup('order-call-form');		    checkOrderCallForm();        }	});	$('#opaco').bind('click', function () {		closePopup();	});	$('#submit-order-call').bind('click', function () {		if (checkOrderCallForm()) {			sendData();		}		return false;	});/*    $('.disabled').bind('click', function() {        return false;    });*/});jQuery.fn.center = function () {	this.css("position", "absolute");	this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");	this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");	return this;};jQuery.fn.verticalCenter = function () {	this.css("position", "absolute");	this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");	return this;};function getHash() {  var hash = window.location.hash;  window.location.hash = '';  return hash.substring(1);}function isset () {    var a=arguments, l=a.length, i=0;    if (l===0) {        throw new Error('Empty isset');    }    while (i!==l) {        if (typeof(a[i])=='undefined' || a[i]===null) {            return false;        } else {            i++;        }    }    return true;}
