<!--


/**
 * png
 */

blankPNG = new Image();
blankPNG.src = '/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/pixels/t_pixel.gif';


function loadPNG(obj) {

	if (navigator.appName == 'Microsoft Internet Explorer') {

		obj.onload = '';
		obj.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + obj.getAttribute('src') + '", sizingMethod="noscale")';
		obj.src = blankPNG.src;

	}

}



/**
 * scripts
 */

isIE = (navigator.appName.indexOf('Microsoft') == -1) ? false : true;
isMozilla = (navigator.appName.indexOf('Netscape') == -1) ? false : true;

stopSlideScrollBarConstant = 0;
menuBlocksAmount = 0;
lastCommentsObject1 = '';
lastCommentsObject2 = '';
lastVacancyObject = '';
lastVacancyPosition = '';
lastGalleryObject = '';
lastGalleryPhoto = '';
lastDropDownList = '';


function underlineTopMenu(obj) {

	var image = obj.parentNode.getElementsByTagName('img')[0];

	image.className = (image.className == '') ? 'underline' : '';

}

function changeAmount(obj, number) {
	if (document.all[obj].getAttribute('value') == 1 && number == -1) {
		return;
	}
	persons=Number(document.all[obj].getAttribute('value')) + number;
	document.all[obj].setAttribute('value', persons);
	//document.getElementById("calculator_amount").value=persons;
	recountCalculatorSum();
}

function loadMenu(e) {
	if (isIE) {
		var divsArr = document.body.getElementsByTagName('div');

		for (var a = 0, b = divsArr.length; a < b; a++) {
			if (divsArr[a].className == 'container_calculator_popup_1') {

				divsArr[a].onmouseover = function() {this.className = 'container_calculator_popup_2'}
				divsArr[a].onmouseout = function() {this.className = 'container_calculator_popup_1'}
			}
		}
		var divsArr2 = document.body.getElementsByTagName('span');

		for (var a = 0, b = divsArr2.length; a < b; a++) {
			if (divsArr2[a].className == 'ingredients_container_1') {
				divsArr2[a].onmouseover = function() {this.className = 'ingredients_container_2'}
				divsArr2[a].onmouseout = function() {this.className = 'ingredients_container_1'}
			}
		}
	}
}

function roloverSubmenu(obj, hide, show) {
	var parent = obj.parentNode.parentNode.parentNode;
	if (parent.tagName.toLowerCase() != 'td') {

		parent = parent.parentNode;

	}
	var divsArr = parent.getElementsByTagName('div');
	divsArr[hide].style.display = 'none';
	divsArr[show].style.display = '';
}

function getCommentsParentObject(obj) {
	var parent = obj.parentNode;

	while (parent.tagName.toLowerCase() != 'td') {
		parent = parent.parentNode;
	}
	return parent;
}

function loadMap(e) {
	if (isIE) {
		var divsArr = document.all.map_1.getElementsByTagName('div');
		for (var a = 0, b = divsArr.length; a < b; a++) {
			if (divsArr[a].className == 'map_1') {
				divsArr[a].onmouseover = function() {this.className += ' active_map'}
				divsArr[a].onmouseout = function() {this.className = 'map_1'}
			}
		}
	}
}

function expandVacancy(obj, div_position, id) {
	var div = obj.getElementsByTagName('div')[1];

	if (div.style.display == 'none') {

		if (lastVacancyObject) {

			expandVacancy(lastVacancyObject, lastVacancyPosition, id);

		}
		div.style.display = '';
		document.all.vacancy_popup.style.top = 47 * div_position - 47;
		document.all.vacancy_popup.style.display = '';
		document.all.vacancy_id.value = id;
		lastVacancyObject = obj;
		lastVacancyPosition = div_position;
	}
	else {
		div.style.display = 'none';
		document.all.vacancy_popup.style.display = 'none';
		lastVacancyObject = '';
	}
}

function showMapAddress(id, cmd) {
	if (cmd == 'show') {
		document.all['map_address_' + id].className += ' active_map';
	}
	else {
		document.all['map_address_' + id].className = 'map_1';
	}
}

function loadGallery(obj) {
	if (obj.className == 'gallery_list_1') {
		if (lastGalleryObject) {
			loadGallery(lastGalleryObject);
		}
		obj.className += ' gallery_list_1_active';
		lastGalleryObject = obj;
	}
	else {
		obj.className = 'gallery_list_1';
		lastGalleryObject = '';
	}
}

function loadPhotos(e) {

	if (isIE) {
		var divsArr = document.all.photos_container.getElementsByTagName('img');
		for (var a = 0, b = divsArr.length; a < b; a++) {
			divsArr[a].onmouseover = function() {this.parentNode.className += ' photo_1_active'}
			divsArr[a].onmouseout = function() {this.parentNode.className = this.parentNode.className.replace(' photo_1_active', '')}
		}
	}
}

function highlightArrow(obj, cmd) {
	var imagesArr = obj.getElementsByTagName('img');

	if (cmd == 'over') {
		imagesArr[0].style.display = 'none';
		imagesArr[1].style.display = '';
	}
	else {
		imagesArr[0].style.display = '';
		imagesArr[1].style.display = 'none';
	}
}

function showPhoto(obj, id) {
	if (lastGalleryPhoto) {

		lastGalleryPhoto.className = 'photo_1';

	}

	obj.className += ' photo_1_clicked';
	document.all.gallery_photo_container.getElementsByTagName('td')[0].innerHTML = '<img src="' + obj.getAttribute('photo_id') + '"><br>';
	document.all.gallery_photo_container.style.height = document.all.gallery_photo_container.getElementsByTagName('td')[0].getElementsByTagName('img')[0].height;

	lastGalleryPhoto = obj;

	//--RK
	if (lastGalleryPhoto.getAttribute('id')==startphoto){
		document.getElementById('right_slider').style.display='block';
		document.getElementById('left_slider').style.display='none';
	}
	else if (lastGalleryPhoto.getAttribute('id')==endphoto-1){
		document.getElementById('left_slider').style.display='block';
		document.getElementById('right_slider').style.display='none';
	}
	else{
		document.getElementById('left_slider').style.display='block';
		document.getElementById('right_slider').style.display='block';
	}
	//--!RK

}

//--RK
function showPhotoInvite(obj) {
	if (lastGalleryPhoto)
		lastGalleryPhoto.className = 'photo_1';
	obj.className += ' photo_1_clicked';
	document.all.gallery_photo_container.innerHTML = '<img src="' + obj.getAttribute('photo_id') + '"><br>';
	document.all.invite_image.value=obj.getAttribute('photo_id');
	setCookie('image',obj.getAttribute('photo_id'));
	lastGalleryPhoto = obj;
}

function setCookie(name,value){
	document.cookie=name+"="+value;
	//document.cookie=name+"="+value+"; expires=3600;";
}
function setCookieExpires(name,value,expires){
	document.cookie=name+"="+value+"; expires="+expires;
}
function setCookiePath(name,value){
	document.cookie=name+"="+value+"; path=/menu/;";
	//document.cookie=name+"="+value+"; path=/menu/;expires=3600;";
}
function setCookieExpiresPath(name,value,expires){
	document.cookie=name+"="+value+"; expires="+expires+"; path=/menu/;";
}
function getCookie(name){
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return setStr;
}
function checkInviteForm(preview){
	var Fields=new Array();
	Fields[0]='time';
	Fields[1]='name1';
	Fields[2]='name2';
	Fields[3]='email';
	Fields[4]='text';
	var Object=null;
	var FlagForm=true;
	for(i=0;i<Fields.length;i++){
		Object=eval("document.InviteForm."+Fields[i]);
		if(Object.value==""){
			showField(Fields[i]);
			FlagForm=false;
		}else{
			if(Fields[i]=="email"){
				if(checkEMail(Object.value)!=true){
					showField(Fields[i]);
					FlagForm = false;
				}
			}
		}
	}
	if(FlagForm==false)
		return false;
	else{
		if (preview==false)
			document.getElementById('InviteForm').submit();
 		return true;
	}
}

function checkEMail(email){
	var FlagEmail=false;
  	reg=new RegExp('^([a-zA-Z0-9-._]+)(@)([a-zA-Z0-9-.]+)(.)([a-zA-Z]{2,4})$');
  	FlagEmail=reg.test(email);
	return FlagEmail;
}
function checkPhone(phone){
	var FlagPhone=false;
  	reg=new RegExp('^[0-9-\+]+$');
  	Flag=reg.test(phone);
	return Flag;
}

function showField(field){
	var FormField=eval("document.InviteForm."+field);
	FormField.style.backgroundColor = "#eeeeee";
	FormField.style.color = "#000000";
}

function clearField(field){
	field.style.backgroundColor = "#ffffff";
	field.style.color = "#000000";
}
//--!RK

function slidePhoto(direction) {
	var divsArr = document.all.photos_container.getElementsByTagName('div');

	if ((direction == 'left' && divsArr[0].className.indexOf('photo_1_clicked') != -1) || (direction == 'right' && divsArr[divsArr.length - 1].className.indexOf('photo_1_clicked') != -1)) {

		return;

	}

	for (var a = 0, b = divsArr.length; a < b; a++) {
		if (divsArr[a].className.indexOf('photo_1_clicked') != -1) {

			var nextDiv = (direction == 'left') ? divsArr[a - 1] : divsArr[a + 1];

			nextDiv.className += ' photo_1_clicked';
			document.all.gallery_photo_container.getElementsByTagName('td')[0].innerHTML = '<img src="' + nextDiv.getAttribute('photo_id') + '"><br>';
			lastGalleryPhoto.className = 'photo_1';
			lastGalleryPhoto = nextDiv;

			//--RK
			if (lastGalleryPhoto.getAttribute('id')==startphoto){
				document.getElementById('left_slider').style.display='none';
			}
			else if (lastGalleryPhoto.getAttribute('id')==endphoto-1){
				document.getElementById('right_slider').style.display='none';
			}
			else{
				document.getElementById('left_slider').style.display='block';
				document.getElementById('right_slider').style.display='block';
			}
			//--!RK

			return;
		}
	}
}

function loadDropdown(e) {

	var divsArr = document.all.form_send_1.getElementsByTagName('div');

	for (var a = 0, b = divsArr.length; a < b; a++) {
		if (divsArr[a].className == 'drop_down_1') {
			var divsArr2 = divsArr[a].getElementsByTagName('div');

			for (var c = 0, d = divsArr2.length; c < d; c++) {
				if (isIE) {
					divsArr2[c].onmouseover = function() {this.className = 'drow_down_active'}
					divsArr2[c].onmouseout = function() {this.className = ''}
				}
				divsArr2[c].onclick = function() {
					document.all[this.getAttribute('field_name') + '_id'].value = this.getAttribute('element_id');
					setCookie(this.getAttribute('field_name')+'_id',this.getAttribute('element_id'));
					document.all[this.getAttribute('field_name') + '_name'].value = this.innerHTML;
					document.all['form_' + this.getAttribute('field_name')].style.visibility = 'hidden'
				}
				//--RK
				if (c==0)
					setCookie(divsArr2[c].getAttribute('field_name')+'_id',divsArr2[c].getAttribute('element_id'));
				//--!RK
			}
		}
	}
}
function checkDropDownList(event) {

	if (lastDropDownList) {

		var srcEl = (navigator.appName == 'Microsoft Internet Explorer') ? event.srcElement : event.target;

		while (srcEl.tagName.toLowerCase() != 'body') {

			if (srcEl.getAttribute('dropdown') == lastDropDownList) {

				return;

			}

			srcEl = srcEl.parentNode;

		}

		document.all['form_' + lastDropDownList].style.visibility = 'hidden';

	}

}
function showDropdownList(obj,event) {
	document.all['form_' + obj].style.visibility = 'visible';
	checkDropDownList(event);
	lastDropDownList = obj;
}

function loadCompanySubmenu(e) {
	document.all.company_submenu.onmouseover = function() {this.getElementsByTagName('table')[0].style.display = ''}
	document.all.company_submenu.onmouseout = function() {this.getElementsByTagName('table')[0].style.display = 'none'}
}

function expandTestimonial(obj) {
	var divsArr = obj.parentNode.getElementsByTagName('div');

	if (divsArr[2]) {
		divsArr[2].style.display = '';
	}
}

/*Object.prototype.attachEvent = function (sEvent, fnHandler, bUseCapture) {
	this.addEventListener(sEvent.substring(2), fnHandler, bUseCapture);
}

Object.prototype.detachEvent = function (sEvent, fnHandler, bUseCapture) {
	this.removeEventListener(sEvent.substring(2), fnHandler, bUseCapture);
}*/

//D2S-JAVA

function adjustIframDivWidth(intId) {

	var intOuterWidth = document.getElementById('table_menu_block_' + intId).offsetWidth;
	document.getElementById('iframe_div_' + intId).style.width = intOuterWidth;
	document.getElementById('iframe_block_' + intId).style.width = intOuterWidth;
	return false;
}

function switchMenuBlock(obj, block_id) {
	var imagesArr = obj.getElementsByTagName('img');

	adjustIframDivWidth(block_id);

	if (imagesArr[0].style.display == 'none') {
		imagesArr[1].style.display = 'none';
		imagesArr[0].style.display = '';
		document.all['iframe_block_' + block_id].style.display = '';
		obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.cells[1].style.display = '';
		//--RK
		OpenBlocks[block_id]=true;
		//--!RK
	} else {
		imagesArr[0].style.display = 'none';
		imagesArr[1].style.display = '';
		document.all['iframe_block_' + block_id].style.display = 'none';
		obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.cells[1].style.display = 'none';
		//--RK
		OpenBlocks[block_id]=false;
		closeWindow();
		//--!RK
	}

	var objMenu_right_border = document.getElementById('menu_right_border_' + block_id);
	if(objMenu_right_border != null){
		var intOuterWidth = document.getElementById('table_menu_block_' + block_id).offsetWidth -10;
		objMenu_right_border.style.left = intOuterWidth;
	}
	manageResize();
	return false;
}

function manageResize() {

	if (PageID==12 || PageID==13 || PageID==14 || PageID==15 || PageID==17){
		resizeScrollbar(30);
		for(key in OpenBlocks){
			if (!isNaN(key)){
				resizeScrollbar(key);
			}
		}
	}


	adjustAllIframDivs();

	var maxPercentLeft = 200;
	var maxPercentRight = 500;
	var max = 1400;
	var min = 970;
	var minResolution = 1260;
	var contentMinWidth = 880;
	var clientWidth = document.body.clientWidth;
	if (clientWidth < minResolution) {

		var percent = (clientWidth - contentMinWidth) / 2;

	}
	else {

		var percent = clientWidth / 100 * 15;

	}

	if (percent >= maxPercentLeft) {

		var left = 0;
		var right = '100%';

	}
	else {

		var left = -maxPercentLeft + percent;
		//var right = document.body.scrollWidth - percent - 435;
		var right = document.body.scrollWidth - percent - 400;

	}
	//rand=Math.ceil(Math.random()*3);
	//document.all.left_background.style.backgroundImage = 'url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/main_left_'+rand+'.jpg)';
	//document.all.right_background.style.backgroundImage = 'url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/main_right_'+rand+'.jpg)';
	//document.all.left_background.style.backgroundRepeat = 'no-repeat';
	//document.all.right_background.style.backgroundRepeat = 'no-repeat';
	document.all.left_background.style.backgroundPosition = left + ' 0px';
	document.all.right_background.style.backgroundPosition = right + ' 0px';

	return false;
}
function manageResizeOnLoad() {

	if (PageID==12 || PageID==13 || PageID==14 || PageID==15 || PageID==17){
		resizeScrollbar(30);
	}

	adjustAllIframDivs();

	var maxPercentLeft = 200;
	var maxPercentRight = 500;
	var max = 1400;
	var min = 970;
	var minResolution = 1260;
	var contentMinWidth = 880;
	var clientWidth = document.body.clientWidth;

	if (clientWidth < minResolution) {

		var percent = (clientWidth - contentMinWidth) / 2;

	}
	else {

		var percent = clientWidth / 100 * 15;

	}

	if (percent >= maxPercentLeft) {

		var left = 0;
		var right = '100%';

	}
	else {

		var left = -maxPercentLeft + percent;
		//var right = document.body.scrollWidth - percent - 435;
		var right = document.body.scrollWidth - percent - 400;

	}
	rand=Math.ceil(Math.random()*3);
	document.all.left_background.style.backgroundImage = 'url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/main_left_'+rand+'.jpg)';
	document.all.right_background.style.backgroundImage = 'url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/main_right_'+rand+'.jpg)';
	document.all.left_background.style.backgroundRepeat = 'no-repeat';
	document.all.right_background.style.backgroundRepeat = 'no-repeat';
	document.all.left_background.style.backgroundPosition = left + ' 0px';
	document.all.right_background.style.backgroundPosition = right + ' 0px';

	return false;
}


function adjustAllIframDivs()
{
	var arrAllTables = document.getElementsByTagName('table');
	for (var i=0;i<arrAllTables.length;i++) {

		if(arrAllTables[i].id.indexOf("table_menu_block_") != -1)
		{
			var intId = arrAllTables[i].id.replace(/table_menu_block_/,"");
			var intOuterWidth = document.getElementById('table_menu_block_' + intId).offsetWidth-5;
			document.getElementById('iframe_div_' + intId).style.width = intOuterWidth;
			document.getElementById('iframe_block_' + intId).style.width = intOuterWidth;

			var objMenu_right_border = document.getElementById('menu_right_border_' + intId);
			if(objMenu_right_border != null)
			{
				objMenu_right_border.style.left = intOuterWidth -10;
			}
		}
	}
	return false;
}
/*
function resizeScrollbar(id) {
	var minSliderAreaWidthPixels = 565;
	var minBlockWidth = 855;
	var documentWidth = document.body.scrollWidth;
	var sides = documentWidth / 100 * 15 * 2;
	var block_width = documentWidth - sides - 22;

	if (block_width < minBlockWidth)
	{
		block_width = minBlockWidth;
	}

	var DivWidth = document.getElementById('iframe_block_' + id).offsetWidth;
	var TableWidth = document.getElementById('iframe_block_table_' + id).offsetWidth;
	var ScrollBarWidth = ((DivWidth-60)/TableWidth)*DivWidth;
	var intMaxWidthScroller = document.getElementById('iframe_' + id + '_div').offsetWidth;

	if(ScrollBarWidth <= intMaxWidthScroller)
	{
		document.getElementById('iframe_' + id + '_slider').style.width = ScrollBarWidth + "px";
		document.getElementById('iframe_' + id + '_slider').style.display = '';
		document.getElementById("iframe_" + id + "_slider_left_area").style.width = "0px";
		document.getElementById("iframe_" + id + "_slider_right_area").style.width = (intMaxWidthScroller - ScrollBarWidth-30) +"px";
	}
	else
	{
		document.getElementById('iframe_' + id + '_slider').style.width = "0px";
		document.getElementById('iframe_' + id + '_slider').style.display = 'none';
		document.getElementById("iframe_" + id + "_slider_left_area").style.width = "0px";;
		document.getElementById("iframe_" + id + "_slider_right_area").style.width = "0px";
	}

	return false;
}
 */
function resizeScrollbar(id) {

	document.getElementById('iframe_' + id + '_div' ).parentNode.parentNode.style.display =  '';
	var DivWidth = document.getElementById('iframe_block_' + id).offsetWidth;
	var TableWidth = document.getElementById('iframe_block_table_' + id).offsetWidth;
	var ScrollBarWidth = ((DivWidth-240)/TableWidth)*DivWidth-82;
	if (ScrollBarWidth<100) {
		ScrollBarWidth = 100;
	}
	var intMaxWidthScroller = document.getElementById('iframe_' + id + '_div').offsetWidth-60;
		//console.log(ScrollBarWidth+"|"+intMaxWidthScroller+"|"+id);
	if(intMaxWidthScroller==0)
	return false;
	if(ScrollBarWidth <= intMaxWidthScroller)
	{
		document.getElementById('iframe_' + id + '_slider').style.width = ScrollBarWidth + "px";
		document.getElementById('iframe_' + id + '_slider').style.display = '';
		document.getElementById("iframe_" + id + "_slider_left_area").style.width = "0px";
		var strSliderLeftAreaWidth = (intMaxWidthScroller - ScrollBarWidth-30);
		if(strSliderLeftAreaWidth > 0){
			document.getElementById("iframe_" + id + "_slider_right_area").style.width = strSliderLeftAreaWidth;
		}

	}
	else
	{
		//alert(ScrollBarWidth);
		//alert(intMaxWidthScroller);
		document.getElementById('iframe_' + id + '_slider').style.width = "0px";
		document.getElementById('iframe_' + id + '_slider').style.display = 'none';
		document.getElementById("iframe_" + id + "_slider_left_area").style.width = "0px";;
		document.getElementById("iframe_" + id + "_slider_right_area").style.width = "0px";
		document.getElementById('iframe_' + id + '_div' ).parentNode.parentNode.style.display =  'none';
	}

	return false;
}


var str_gDirection ="";
var int_gID ="";
var obj_gActivatedInterval = null;

function fSlideScrollBar(strDirection,intID){
	document.onmouseup = fStopSlideScrollBar;
	str_gDirection = strDirection;
	int_gID = intID;
	fMoveProductDiv();
	obj_gActivatedInterval = window.setInterval("fMoveProductDiv()", 50);
	return false;
}

function fStopSlideScrollBar()
{
	str_gDirection = null;
  	int_gID = null;
	document.onmouseup = null;
	window.clearInterval(obj_gActivatedInterval);
	obj_gActivatedInterval= null;
	return false;
}

function fMoveProductDiv()
{
	if(int_gID != "")
	{
		var strProductDivName = "iframe_block_content_" + int_gID;
		var objVisibleDiv = document.getElementById(strProductDivName);
		var intDivMarginLeft = objVisibleDiv.style.marginLeft;
		intDivMarginLeft = intDivMarginLeft.replace(/px/,"");

		var intProductDivWidth = document.getElementById("iframe_block_table_" + int_gID).offsetWidth ;
		var intOverDivWidth = document.getElementById("iframe_block_" + int_gID).offsetWidth ;
		var intProductDivMax = (intProductDivWidth - intOverDivWidth)*-1;

		if(str_gDirection == "right")
		{
			intDivMarginLeft = parseInt(intDivMarginLeft) - intProductDivWidth * 0.001;
		}
		if(str_gDirection == "left")
		{
			intDivMarginLeft = parseInt(intDivMarginLeft) + intProductDivWidth * 0.001;
		}
		if(intDivMarginLeft > 0)
		{
			intDivMarginLeft = 0;
		}
		if(intDivMarginLeft < intProductDivMax )
		{
			intDivMarginLeft = intProductDivMax;
		}
		objVisibleDiv.style.marginLeft = intDivMarginLeft;

		var objScrollBar = document.getElementById("iframe_" + int_gID + "_slider");
		var objOverDiv = document.getElementById("iframe_" + int_gID + "_div");

		var intMaxWidth = parseInt(objOverDiv.offsetWidth) - parseInt(objScrollBar.offsetWidth) - 1;
		var intNewLeftWidth = (intDivMarginLeft/intProductDivMax)*intMaxWidth;
		objScrollBar.style.left = intNewLeftWidth + "px";

		var intMaxWidthScroller = (document.getElementById('iframe_' + int_gID + '_div').offsetWidth) - objScrollBar.offsetWidth;
		document.getElementById("iframe_" + int_gID + "_slider_left_area").style.width = (intNewLeftWidth) + "px";;
		document.getElementById("iframe_" + int_gID + "_slider_right_area").style.width = (intMaxWidthScroller - intNewLeftWidth-30) +"px";
	}
	return false;
}

var intXPosition=null;
var objElementActiveted=null;
var intLeftOffset = 0;
var intMaxWidth = 0;
var intIFrameId = 0;
var intMaxWidthRight = 0 ;

function fgetGlobalCoord(e)
{
	var e;
	if (!e)	{
		window.MouseX = event.clientX;
		window.MouseY = event.clientY;
	} else {
		window.MouseX = e.pageX;
		window.MouseY = e.pageY;
	}
	return false;
}

function fMouseMoveScroll (e) {
	if(objElementActiveted == null)
		return false;

	fgetGlobalCoord(e);
	if(intXPosition == null)
	{
		intXPosition = window.MouseX;
	}
	else
	{
		var intNewXPosition = window.MouseX;

		var strTempName = objElementActiveted.id + "_left_area";
		objScroll_Left_Area = document.getElementById(strTempName);
		strTempName = objElementActiveted.id + "_right_area";
		objScroll_Right_Area = document.getElementById(strTempName);

		var intNewLeftWidth = intNewXPosition - intXPosition + intLeftOffset;

		if(intNewLeftWidth > intMaxWidth )
		{
			intNewLeftWidth = intMaxWidth;
		}
		if(intNewLeftWidth < 0)
		{
			intNewLeftWidth = 0;
		}
		objElementActiveted.style.left = intNewLeftWidth + "px";
		objScroll_Left_Area.style.width = intNewLeftWidth + "px";
		objScroll_Right_Area.style.width = (intMaxWidth - intNewLeftWidth) + "px";

		var strProductDivName = "iframe_block_content_" + intIFrameId;
		var objVisibleDiv = document.getElementById(strProductDivName);
		var intDivMarginLeft = objVisibleDiv.style.marginLeft;
		intDivMarginLeft = intDivMarginLeft.replace(/px/,"");

		var intProductDivWidth = document.getElementById("iframe_block_table_" + intIFrameId).offsetWidth ;
		var intOverDivWidth = document.getElementById("iframe_block_" + intIFrameId).offsetWidth ;
		var intProductDivMax = (intProductDivWidth - intOverDivWidth)*-1;

		intDivMarginLeft = intProductDivMax*(intNewLeftWidth/intMaxWidth);

		if(intDivMarginLeft > 0)
		{
			intDivMarginLeft = 0;
		}
		if(intDivMarginLeft < intProductDivMax )
		{
			intDivMarginLeft = intProductDivMax;
		}

		objVisibleDiv.style.marginLeft = intDivMarginLeft;
	}
	return false;
}

function fRemoveInitScrollBar(objElement)
{
	objElementActiveted=null;
	intXPosition=null;
	intXPosition=null;
    objElementActiveted=null;
	intLeftOffset = null;
	intMaxWidth = null;
	intIFrameId = null;
	document.onmousemove = null;
	document.onmouseup = null;
	return false;
}

function fInitScrollBar(objElement,intFrameId)
{
	objElementActiveted=objElement;

	var strTempName = objElementActiveted.id + "_left_area";
	objScroll_Left_Area = document.getElementById(strTempName);
	strTempName = "iframe_" + intFrameId + "_div";
	objOverDiv = document.getElementById(strTempName);
	intIFrameId = intFrameId;

	intLeftOffset = parseInt(objScroll_Left_Area.offsetWidth);
	intMaxWidth = parseInt(objOverDiv.offsetWidth) - parseInt(objElementActiveted.offsetWidth) - 30;
	document.onmousemove = fMouseMoveScroll;
	document.onmouseup = fRemoveInitScrollBar;
	return false;
}

function fMoveScrollBarByClick(intID,strToDirection)
{
	var strProductDivName = "iframe_block_content_" + intID;
	var objVisibleDiv = document.getElementById(strProductDivName);
	var intDivMarginLeft = objVisibleDiv.style.marginLeft;
	intDivMarginLeft = intDivMarginLeft.replace(/px/,"");

	var intProductDivWidth = document.getElementById("iframe_block_table_" + intID).offsetWidth ;
	var intOverDivWidth = document.getElementById("iframe_block_" + intID).offsetWidth ;
	var intProductDivMax = (intProductDivWidth - intOverDivWidth)*-1;

	if(strToDirection == "right")
	{
		intDivMarginLeft = parseInt(intDivMarginLeft) - intProductDivWidth * 0.15;
	}
	if(strToDirection == "left")
	{
		intDivMarginLeft = parseInt(intDivMarginLeft) + intProductDivWidth * 0.15;
	}
	if(intDivMarginLeft > 0)
	{
		intDivMarginLeft = 0;
	}
	if(intDivMarginLeft < intProductDivMax )
	{
		intDivMarginLeft = intProductDivMax;
	}
	objVisibleDiv.style.marginLeft = intDivMarginLeft;

	var objScrollBar = document.getElementById("iframe_" + intID + "_slider");
	var objOverDiv = document.getElementById("iframe_" + intID + "_div");

	var intMaxWidth = parseInt(objOverDiv.offsetWidth) - parseInt(objScrollBar.offsetWidth) - 30;
	var intNewLeftWidth = (intDivMarginLeft/intProductDivMax)*intMaxWidth;
	objScrollBar.style.left = intNewLeftWidth + "px";

	var intMaxWidthScroller = (document.getElementById('iframe_' + intID + '_div').offsetWidth) - objScrollBar.offsetWidth;
	document.getElementById("iframe_" + intID + "_slider_left_area").style.width = (intNewLeftWidth) + "px";;
	document.getElementById("iframe_" + intID + "_slider_right_area").style.width = (intMaxWidthScroller - intNewLeftWidth-30) +"px";

	return false;
}

function add_to_calculator_window(strVisible,objProduct)
{/*
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		var abc=objProduct.parentNode;
		if(strVisible == "1"){
			abc.childNodes[2].style.visibility = "visible";
		}
		else{
			abc.childNodes[2].style.visibility = "hidden";
		}
	}
 */
}/*
function checkDropDownList(event) {

	if (lastDropDownList) {

		var srcEl = (navigator.appName == 'Microsoft Internet Explorer') ? event.srcElement : event.target;

		while (srcEl.tagName.toLowerCase() != 'body') {

			if (srcEl.getAttribute('dropdown') == lastDropDownList) {

				return;

			}

			srcEl = srcEl.parentNode;

		}

		document.all['form_' + lastDropDownList].style.visibility = 'hidden';

	}

}*/

function insertImage(obj) {
	obj.setAttribute('src', obj.getAttribute('to_load'));
}

function openYear(object,year){
	if (object.className=="archiveYearClose"){
		object.className="archiveYearOpen";
		document.getElementById(year).style.display="block";
	}else{
		object.className="archiveYearClose";
		document.getElementById(year).style.display="none";
	}
}

/**
 * calculator
 */

var arrayCalculator=new Array();
var CalculatorInnerTXT="";
var arrayCalculatorElements=new Array();
var arrayCalculatorNumbers=new Array();
var OpenCalculator=false;
var CalculatorSum=0;

function addToCalculator(Card_ID){
    if (notmoscow==0) {
        str=getCookie('calculator');
        strNum=getCookie('calculatorNumbers');
        //alert(str);
        if (str!=null && str!=""){
            arrayElements=str.split(',');
            arrayNumbers=strNum.split(',');
            var isFound = false;
            for (var i=0;i<arrayElements.length;i++) {
                if (arrayElements[i]==Card_ID) {
                    isFound=true;
                    nextElement=i;
                    break;
                }
            }
            if (isFound) {
                arrayCalculatorElements=arrayElements;
                arrayNumbers[nextElement]=parseInt(arrayNumbers[nextElement])+1;
            } else {
                nextElement=arrayElements.length;
                arrayElements[nextElement]=Card_ID;
                arrayNumbers[nextElement]=1;
            }
            arrayCalculatorElements=arrayElements;
            arrayCalculatorNumbers=arrayNumbers;
            str=arrayElements.join(',');
            strNum=arrayNumbers.join(',');
            setCookie('calculator',str);
            setCookiePath('calculator',str);
            setCookie('calculatorNumbers',strNum);
            setCookiePath('calculatorNumbers',strNum);
        }
        else{
            arrayCalculatorElements[0]=Card_ID;
            arrayCalculatorNumbers[0]=1;
            str=Card_ID;
            strNum=1;
            setCookie('calculator',str);
            setCookiePath('calculator',str);
            setCookie('calculatorNumbers',strNum);
            setCookiePath('calculatorNumbers',strNum);
        }
        //alert(str);
        getCalculatorArray();
    }
}
function minusFromCalculator(Card_ID){
    str=getCookie('calculator');
    strNum=getCookie('calculatorNumbers');
    arrayElements=str.split(',');
    arrayNumbers=strNum.split(',');
    var isFound = false;
    for (var i=0;i<arrayElements.length;i++) {
        if (arrayElements[i]==Card_ID) {
            isFound=true;
            nextElement=i;
            break;
        }
    }
    arrayCalculatorElements=arrayElements;
    arrayNumbers[nextElement]=parseInt(arrayNumbers[nextElement])-1;
    arrayCalculatorNumbers=arrayNumbers;
    str=arrayElements.join(',');
    strNum=arrayNumbers.join(',');
    setCookie('calculator',str);
    setCookiePath('calculator',str);
    setCookie('calculatorNumbers',strNum);
    setCookiePath('calculatorNumbers',strNum);
    getCalculatorArray();
}
function reloadCalculator(){
    //alert(1);
    if (!OpenCalculator && arrayCalculatorElements.length){
        if (navigator.appName == 'Microsoft Internet Explorer'){
            switchCalculatorVisibility();
            OpenCalculator=true;
        }//alert(arrayCalculatorElements[0]);
        else{
            if (arrayCalculatorElements[0]!=''){
                switchCalculatorVisibility();
                OpenCalculator=true;
            }
        }
    }
    else if (OpenCalculator && !arrayCalculatorElements.length){
        switchCalculatorVisibility();
        OpenCalculator=false;
    }
    CalculatorSum=0;
    CalculatorInnerTXT='<table cellpadding="0" cellspacing="0" id="iframe_block_table_30"><tr>';
    i=0;
    for(key in arrayCalculatorElements){
        if (!isNaN(key)){
            elementID=arrayCalculatorElements[key];
            //alert(elementID);
            if (elementID!=""){
                i++;
                CalculatorSum+=Number(arrayCalculator[elementID]["price"]*parseInt(arrayCalculatorNumbers[key]));
                CalculatorInnerTXT+='<td width="180">';
                CalculatorInnerTXT+='<div class="calculator_menu" style="background-image: url(\'/CommonFiles/Yaposhka/01_Products/'+arrayCalculator[elementID]["image"]+'/'+arrayCalculator[elementID]["image"]+'_Calculator.jpg\')">';
                CalculatorInnerTXT+='<div class="dash">';
                CalculatorInnerTXT+='<div class="price_1">'+(arrayCalculator[elementID]["price"])+'.—</div>';
                CalculatorInnerTXT+='<div class="quantity">Количество: '+(parseInt(arrayCalculatorNumbers[key]))+' шт.</div>';
                if (parseInt(arrayCalculatorNumbers[key])==1) {
                    CalculatorInnerTXT+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/close_1.gif" class="close_1" alt="Убрать" title="Убрать" onClick="deleteFromCalculator('+key+')">';
                } else {
                    CalculatorInnerTXT+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/minus_1.gif" class="minus_1" alt="Уменьшить" title="Уменьшить" onClick="minusFromCalculator('+elementID+')">';
                }
                CalculatorInnerTXT+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/plus_1.gif" class="plus_1" alt="Увеличить" title="Увеличить" onClick="addToCalculator('+elementID+')">';
                CalculatorInnerTXT+='<div class="title">'+arrayCalculator[elementID]["name"]+'</div>';
                CalculatorInnerTXT+='</div>';
                CalculatorInnerTXT+='</div>';
                CalculatorInnerTXT+='</td>';
            }
        }
    }
    //CalculatorSum*=document.getElementById("calculator_amount").value;
    CalculatorInnerTXT+="</tr></table>";
    if (!i){
        CalculatorInnerTXT='<table cellpadding="0" cellspacing="0" id="iframe_block_table_30"><tr><td width="180">&nbsp;</td></tr></table>';
    }
    //alert(CalculatorInnerTXT);
    document.getElementById("iframe_block_content_30").innerHTML=CalculatorInnerTXT;
    document.getElementById("calculator").innerHTML=(CalculatorSum*document.getElementById("calculator_amount").value)+'.-';
    manageResize();
    //resizeScrollbar(30);
}
function switchCalculatorVisibility() {
    if (notmoscow == 0) {
        if (arrayCalculatorElements.length){
            if (document.all.calculator_block.style.visibility == 'hidden') {
                var display = 'visible';
                var display2 = 'hidden';
                document.all.calculator_block.style.position='relative';
                document.all.calculator_block.style.width='100%';
                OpenCalculator=true;
                resizeScrollbar(30);
            }
            else {
                var display = 'hidden';
                var display2 = 'visible';
                document.all.calculator_block.style.position='absolute';
                document.all.calculator_block.style.width='1%';
                OpenCalculator=false;
            }
        }
        else{
                var display = 'hidden';
                var display2 = 'visible';
                document.all.calculator_block.style.position='absolute';
                document.all.calculator_block.style.width='1%';
                OpenCalculator=false;
        }
        document.all.calculator_block.style.visibility = display;
        if (display=='hidden') {
            $('#orderButton').removeClass('orderButtonActive');
            $('#orderhidden').show();
            $('#ordervisible').hide();
        } else {
            $('#orderButton').addClass('orderButtonActive');
            $('#orderhidden').hide();
            $('#ordervisible').show();
        }
        document.all.calculator_pixel_div.style.visibility = 'visible';//display2;
    } else {
        return false;
    }

}
function getCalculatorFromCookie(){
    str=getCookie('calculator');
    strNum=getCookie('calculatorNumbers');
    //alert(str);
    if (str!=null){
        arrayElements=str.split(',');
        arrayNumbers=strNum.split(',');
        nextElement=arrayElements.length;
        arrayCalculatorElements=arrayElements;
        arrayCalculatorNumbers=arrayNumbers;
    }
}
function deleteFromCalculator(id){
    arrayCalculatorElements.splice(id,1);
    arrayCalculatorNumbers.splice(id,1);
    str=arrayCalculatorElements.join(',');
    strNum=arrayCalculatorNumbers.join(',');
    setCookie('calculator',str);
    setCookiePath('calculator',str);
    setCookie('calculatorNumbers',strNum);
    setCookiePath('calculatorNumbers',strNum);
    getCalculatorArray();
}
function recountCalculatorSum(){
    //CalculatorSum*=document.getElementById("calculator_amount").value;
    document.getElementById("calculator").innerHTML=CalculatorSum;//(CalculatorSum*document.getElementById("calculator_amount").value)+'.-';
}
function showSaveMenu(){
    document.getElementById("savemenu").style.display="block";
}
function hideSaveMenu(){
    document.getElementById("savemenu").style.display="none";
    document.getElementById("savemenu_save").style.display="block";
    document.getElementById("savemenu_field").style.display="block";
    document.getElementById("savemenu_name").style.display="block";
    document.getElementById("message").style.display="none";
}
function saveSaveMenu(){
    name=document.getElementById("savemenu_name").value;
    if (name!=''){
        menuID=getCookie('menu');
        //person=document.getElementById("calculator_amount").value;
        if (menuID==null)
            menuID=1;
        else
            menuID++;
        menu=arrayCalculatorElements.join(",");
        setCookieExpires("menulist["+menuID+"][name]",name,"Mon, 01-Jan-2010 00:00:00 GMT");
        //setCookieExpires("menulist["+menuID+"][person]",person,"Mon, 01-Jan-2010 00:00:00 GMT");
        setCookieExpires("menulist["+menuID+"][menu]",menu,"Mon, 01-Jan-2010 00:00:00 GMT");
        setCookieExpires("menulist["+menuID+"][sum]",CalculatorSum,"Mon, 01-Jan-2010 00:00:00 GMT");
        setCookieExpires("menu",menuID,"Mon, 01-Jan-2010 00:00:00 GMT");
        document.getElementById("savemenu_save").style.display="none";
        document.getElementById("savemenu_field").style.display="none";
        document.getElementById("savemenu_name").style.display="none";
        document.getElementById("message").style.display="block";
    }
}

/**
 * gallery
 */

function show_gallerylist(){
    str='';
    for(i=0;i<list.length;i++)
        str+=list[i];
    document.getElementById('gallerylist').innerHTML=str;
}
function show_galleries(page){
    show_gallerylist();
    //str='';
    //max_galleries_page=1;
    //if (max_galeries_page<=list.length) max=max_galeries_page;
    //else max=list.length;
    //for(i=page-1;i<max*page;i++)
    //    str+=list[i];
    //document.getElementById('gallerylist').innerHTML=str;
}

var startphoto;
var endphoto;
function show_photoes(page){
    max_photoes_page=15;
    if (max_photoes_page<=photoes.length) max=max_photoes_page;
    else max=photoes.length;
    str='';
    startphoto=max*(page-1);
    endphoto=max*page;
    for(i=startphoto;i<endphoto;i++){
        if (!isNaN(photoes[i])){
            j=i;
            str+='<div id="'+i+'" class="photo_1" onclick="showPhoto(this)" photo_id="'+photoes[i]["big"]+'"><img src="'+photoes[i]["small"]+'"></div>';
        }
    }
    endphoto=j+1;
    document.getElementById("photos_container").innerHTML=str;
    pages=Math.ceil(photoes.length/max_photoes_page);
    if (pages>1)
        show_pages(max_photoes_page,photoes.length,page);
    showPhoto(document.getElementById(startphoto));
}
function show_photoes_invite(page){
    max_photoes_page=15;
    if (max_photoes_page<=photoes.length) max=max_photoes_page;
    else max=photoes.length;
    str='';
    startphoto=max*(page-1);
    endphoto=max*page;
    for(i=page-1;i<max*page;i++)
        str+='<div id="'+i+'" class="photo_1" onclick="showPhotoInvite(this)" photo_id="'+photoes[i]["big"]+'" id="'+i+'"><img src="'+photoes[i]["small"]+'"></div>';
    document.getElementById("photos_container").innerHTML=str;
    pages=Math.ceil(photoes.length/max_photoes_page);
    if (pages>1)
        show_pages(max_photoes_page,photoes.length,page);
    showPhotoInvite(document.getElementById(startphoto));
}
function show_pages(photoes_page,photoes,curr_page){
    pages=Math.ceil(photoes/photoes_page);
    str='<table width="7%" cellpadding="0" cellspacing="0" class="paging_1"><tr>';
    for(i=0;i<pages;i++){
        curr=i+1;
        if (curr==curr_page)
            str+='<td><div class="active">'+curr+'</div></td>';
        else
            str+='<td><div><a href="javascript:show_photoes('+curr+')" class="small_2">'+curr+'</a></div></td>';
    }
    str+='</tr></table>';
    document.getElementById("photoes_pages").innerHTML=str;
}

/**
 * ajax
 */

function AJAXInteractionBlocks(BlockID,GroupID) {

    var req = init();
    var Bid=BlockID;
    var Gid=GroupID;
    var BlockArray=new Array();
    req.onreadystatechange=getBlock;

    function init() {
        var HttpRequest=null;
        try{HttpRequest=new XMLHttpRequest();}
        catch (e){
            try{HttpRequest=new ActiveXObject('Msxml2.XMLHTTP');}
            catch (e){Httprequest=new ActiveXObject('Microsoft.XMLHTTP');}
        }
        return HttpRequest;
    }

    function getBlock() {
        if (req.readyState==4 || req.readyState=='complete'){
            Response=req.responseText;
            BlockArray=eval('('+Response+')');
            showBlock();
        }
    }
    function showBlock(){
        txt='<table cellpadding="0" cellspacing="0" id="iframe_block_table_'+Bid+'"><tr>';
        //txt+=InnerTXT;
        //txt+='<td id="preload_'+Bid+'" width="226" style="background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/preload.gif) no-repeat center center;">&nbsp;</td>';
        for(key in BlockArray){
            if (!isNaN(key)){
                rating=getRating(key);
                image='/CommonFiles/Yaposhka/01_Products/'+BlockArray[key]["art"]+'/'+BlockArray[key]["art"]+'_Menu.jpg';
                if (BlockArray[key]["novelty"]==0)
                    novelty="";
                else
                    novelty='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/new.png" width="54" height="54" class="new" onload="loadPNG(this)">';
                if (BlockArray[key]["light"]==0)
                    light="";
                else
                    light='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/light.png" width="74" height="74" class="light" onload="loadPNG(this)">';
                if (BlockArray[key]["weight"]=="")
                    weight="";
                else{
                    weight="("+BlockArray[key]["weight"]+")";
                    weight=weight.replace(' ','&nbsp;');
                }
                if (BlockArray[key]["consist"]=="")
                    consist="";
                else{
                    consist='<li>';
                    consist+='<span class="ingredients_container_1">';
                    consist+='<a href="javascript:void(0)" class="gray_1">Состав</a>';
                    consist+='<div class="container_ingredients_popup_1">';
                    consist+='<table cellpadding="0" cellspacing="0" class="ingredients_popup">';
                    consist+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_1.png" width="220" height="7" onload="loadPNG(this)"><br></td></tr>';
                    consist+='<tr><td class="link">'+BlockArray[key]["consist"]+'</td></tr>';
                    consist+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_3.png" width="220" height="8" onload="loadPNG(this)"><br></td></tr>';
                    consist+='</table></div></span></li>';
                }
                txt+='<td width="226" id="card_'+key+'" >';
                txt+='<div class="menu_line_1">';
                txt+='<div class="menu_price_1">'+BlockArray[key]["price"]+'.—</div>';
                txt+='<div class="menu_line_2">';
                txt+='<div class="menu_line_3">';
                txt+='<div class="menu_line_4">';
                txt+='<div class="menu_product_1" style="background: url(\''+image+'\') no-repeat 100% 100%">';
                if (BlockArray[key]["usefororder"]=='1') {
                    txt+='<div class="container_calculator_popup_1">';
                    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/to_calculator_1.gif" width="9" height="12" alt="В корзину" title="В корзину" class="add_to_calculator"   onmouseout="add_to_calculator_window(0,this);" onmouseover="add_to_calculator_window(1,this);" onclick="javascript:addToCalculator('+key+');">';
                    txt+='<table cellpadding="0" cellspacing="0" class="add_to_calculator_popup" onmouseout="add_to_calculator_window(0,this);" onmouseover="add_to_calculator_window(1,this);">';
                    txt+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_1.png" width="149" height="7" onload="loadPNG(this)"><br></td></tr>';
                    txt+='<tr><td class="link"><a href="javascript:addToCalculator('+key+')" class="blue_1">добавить в корзину</a><br></td></tr>';
                    txt+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_3.png" width="149" height="8" onload="loadPNG(this)"><br></td></tr>';
                    txt+='</table></div>';
                }
                txt+='<div style="width:160px;">';
                if (BlockArray[key]["usefororder"]=='1') {
                    txt+='<a href="javascript:addToCalculator('+key+')" class="black_1" title="Добавить блюдо в корзину">'+BlockArray[key]["name"]+'</a>';
                } else {
                    txt+='<strong>'+BlockArray[key]["name"]+'</strong>';
                }
                txt+=' <b class="weight_1">'+weight+'</b></div>';
                txt+=rating;
                txt+='<ul class="bullets_1">';
                txt+=consist;
                txt+='<li><a href="javascript:void(0)" class="gray_1" onClick="showCommentWindow('+key+',event)">Отзывы</a>';
                txt+='</li></ul>';
                txt+='</div></div></div></div>';
                txt+=novelty;
                txt+=light;
                txt+='</div></td>';
            }
        }
        txt+='</tr></table>';
        document.getElementById("iframe_block_content_"+Bid).innerHTML=txt;
        loadMenu();
        resizeScrollbar(Bid);
    }

    function getRating(key){
        flag=true;
        if (getCookie("vote_"+key)==null)
            flag=false;
        rating='';
        rate=Number(BlockArray[key]["rating"]);
        rate_floor=Math.floor(rate);
        for(i=1;i<=rate_floor;i++){
            if (flag || isNaN(Gid))
                rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_1.gif" width="18" height="16" class="star_1"><!--<div class="star_one"></div>-->';
            else
                rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_1.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
        }
        for(i=rate_floor+1;i<=5;i++){
            if (i==Math.ceil(rate)){
                if (flag || isNaN(Gid))
                    rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_3.gif" width="18" height="16" class="star_1">';
                else
                    rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_3.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
            }
            else{
                if (flag || isNaN(Gid))
                    rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_2.gif" width="18" height="16" class="star_1">';
                else
                    rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_2.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
            }
        }
        return rating;
    }

    this.LoadBlock=function() {
        URL='/?reqMode=xHTTP&reqType=Block&reqGroup='+Gid;
        req.open('GET',URL,true);
        req.send(null);
    }

}

function AJAXInteractionMy(BlockID,GroupID) {

    var req = init();
    var Bid=BlockID;
    var Gid=GroupID;
    var BlockArray=new Array();
    req.onreadystatechange=getBlock;

    function init() {
        var HttpRequest=null;
        try{HttpRequest=new XMLHttpRequest();}
        catch (e){
            try{HttpRequest=new ActiveXObject('Msxml2.XMLHTTP');}
            catch (e){Httprequest=new ActiveXObject('Microsoft.XMLHTTP');}
        }
        return HttpRequest;
    }

    function getBlock() {
        if (req.readyState==4 || req.readyState=='complete'){
            Response=req.responseText;
            //alert(Response);
            BlockArray=eval('('+Response+')');
            showBlock();
        }
    }
    function showBlock(){
        txt='<table cellpadding="0" cellspacing="0" id="iframe_block_table_'+Bid+'"><tr>';
        //txt+=InnerTXT;
        //txt+='<td id="preload_'+Bid+'" width="226" style="background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/preload.gif) no-repeat center center;">&nbsp;</td>';
        for(key in BlockArray){
            if (!isNaN(key)){
                rating=getRating(key);
                image='/CommonFiles/Yaposhka/01_Products/'+BlockArray[key]["art"]+'/'+BlockArray[key]["art"]+'_Menu.jpg';
                if (BlockArray[key]["novelty"]=="")
                    novelty="";
                else
                    novelty='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/new.png" width="54" height="54" class="new" onload="loadPNG(this)">';
                if (BlockArray[key]["weight"]=="")
                    weight="";
                else{
                    weight="("+BlockArray[key]["weight"]+")";
                    weight=weight.replace(' ','&nbsp;');
                }
                if (BlockArray[key]["consist"]=="")
                    consist="";
                else{
                    consist='<li>';
                    consist+='<span class="ingredients_container_1">';
                    consist+='<a href="javascript:void(0)" class="gray_1">Состав</a>';
                    consist+='<div class="container_ingredients_popup_1">';
                    consist+='<table cellpadding="0" cellspacing="0" class="ingredients_popup">';
                    consist+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_1.png" width="149" height="7" onload="loadPNG(this)"><br></td></tr>';
                    consist+='<tr><td class="link">'+BlockArray[key]["consist"]+'</td></tr>';
                    consist+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_3.png" width="149" height="8" onload="loadPNG(this)"><br></td></tr>';
                    consist+='</table></div></span></li>';
                }
                txt+='<td width="226" id="card_'+key+'">';
                txt+='<div class="menu_line_1">';
                txt+='<div class="menu_price_1">'+BlockArray[key]["price"]+'.—</div>';
                txt+='<div class="menu_line_2">';
                txt+='<div class="menu_line_3">';
                txt+='<div class="menu_line_4">';
                txt+='<div class="menu_product_1" style="background: url(\''+image+'\') no-repeat 100% 100%">';
                txt+='<div class="container_calculator_popup_1">';
                txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/to_calculator_1.gif" width="9" height="11" alt="В корзину" title="В корзину" class="add_to_calculator"   onmouseout="add_to_calculator_window(0,this);" onmouseover="add_to_calculator_window(1,this);">';
                txt+='<table cellpadding="0" cellspacing="0" class="add_to_calculator_popup" onmouseout="add_to_calculator_window(0,this);" onmouseover="add_to_calculator_window(1,this);">';
                txt+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_1.png" width="149" height="7" onload="loadPNG(this)"><br></td></tr>';
                txt+='<tr><td class="link"><a href="javascript:addToCalculator('+key+')" class="blue_1">добавить в корзину</a><br></td></tr>';
                txt+='<tr><td><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/popup_1_3.png" width="149" height="8" onload="loadPNG(this)"><br></td></tr>';
                txt+='</table></div>';
                txt+='<div style="width:150px;"><a href="javascript:addToCalculator('+key+')" class="black_1">'+BlockArray[key]["name"]+'</a> <b class="weight_1">'+weight+'</b></div>';
                txt+=rating;
                txt+='<ul class="bullets_1">';
                txt+=consist;
                txt+='<li><a href="javascript:void(0)" class="gray_1" onClick="showCommentWindow('+key+',event)">Отзывы</a>';
                txt+='</li></ul>';
                txt+='</div></div></div></div>';
                txt+=novelty;
                txt+='</div></td>';
            }
        }
        txt+='</tr></table>';
        document.getElementById("iframe_block_content_"+Bid).innerHTML=txt;
        loadMenu();
        resizeScrollbar(Bid);
    }

    function getRating(key){
        flag=true;
        if (getCookie("vote_"+key)==null)
            flag=false;
        rating='';
        rate=Number(BlockArray[key]["rating"]);
        rate_floor=Math.floor(rate);
        for(i=1;i<=rate_floor;i++){
            if (flag)
                rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_1.gif" width="18" height="16" class="star_1">';
            else
                rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_1.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
        }
        for(i=rate_floor+1;i<=5;i++){
            if (i==Math.ceil(rate)){
                if (flag)
                    rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_3.gif" width="18" height="16" class="star_1">';
                else
                    rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_3.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
            }
            else{
                if (flag)
                    rating+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_2.gif" width="18" height="16" class="star_1">';
                else
                    rating+='<a href="javascript:SetRate('+i+','+key+')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_2.gif" width="18" height="16" class="star_1" id="star_'+i+'_'+key+'" onMouseOver="RateOver('+i+','+key+')" onMouseOut="RateOut('+key+')"></a>';
            }
        }
        return rating;
    }

    this.LoadBlock=function() {
        URL='?reqMode=xHTTP&reqType=MyFood&reqGroup='+Gid;
        req.open('GET',URL,true);
        req.send(null);
    }

}






var HttpRequest=null;
function getHttpRequest() {
    var HttpRequest=null;
    try{HttpRequest=new XMLHttpRequest();}
    catch (e){
	try{HttpRequest=new ActiveXObject('Msxml2.XMLHTTP');}
	catch (e){Httprequest=new ActiveXObject('Microsoft.XMLHTTP');}
    }
    return HttpRequest;
}

var test=new Array();
//--Загрузка содержимого открытого блока

var BlockID=null;
var GroupID=null;
var FoodID=0;
var InnerTXT="";
var OpenBlocks=new Array();
var LoadedBlocks=new Array();
function GetContent(id,gid){
    BlockID=id;
    GroupID=gid;
    InnerTXT="";
    if (OpenBlocks[id]){
        if (LoadedBlocks[id]==undefined){
            FoodID=1;
            test[id]= new AJAXInteractionBlocks(id,gid);
            test[id].LoadBlock();
            LoadedBlocks[id]=id;
        }

        //LoadBlock(gid);
    }
    else{
        showList(BlockID);
    }
}
/*
function LoadBlock(gid){
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCard;
    URL='/?reqMode=xHTTP&reqType=Food&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function LoadAdditionalBlock(gid){
    FoodID++;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCard;
    URL='/?reqMode=xHTTP&reqType=Food&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function ShowFoodCard(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!=''){
            InnerTXT+=HttpResponse;
            document.getElementById("iframe_block_content_"+BlockID).innerHTML=showList(BlockID);
            resizeScrollbar(BlockID);
            loadMenu();
            if (isNaN(GroupID) && FoodID<=10)
                LoadAdditionalBlock(GroupID);
            else if (!isNaN(GroupID))
                setTimeout("LoadAdditionalBlock("+GroupID+")",500);
        }
        else{
            document.getElementById("preload").style.display="none";
            resizeScrollbar(BlockID);
        }
    }
}*/
function showList(BlockID){
    txt='<table cellpadding="0" cellspacing="0" id="iframe_block_table_'+BlockID+'"><tr>';
    txt+=InnerTXT;
    txt+='<td id="preload" width="226" style="background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/preload.gif) no-repeat center center;">&nbsp;</td>';
    txt+='</tr></table>';
    return txt;
}

//--!Загрузка содержимого открытого блока

//--Загрузка моего меню
function GetContentMy(id,gid){
    BlockID=id;
    GroupID=gid;
    InnerTXT="";
    if (OpenBlocks[id]){
        FoodID=1;
            test[id]= new AJAXInteractionMy(id,gid);
            test[id].LoadBlock();
            LoadedBlocks[id]=id;
    }
    else{
        showList(BlockID);
    }
}
function LoadBlockMy(gid){
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCardMy;
    URL='/?reqMode=xHTTP&reqType=MyFood&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function LoadAdditionalBlockMy(gid){
    FoodID++;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCardMy;
    URL='/?reqMode=xHTTP&reqType=MyFood&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function ShowFoodCardMy(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!=''){
            InnerTXT+=HttpResponse;
            document.getElementById("iframe_block_content_"+BlockID).innerHTML=showList(BlockID);
            resizeScrollbar(BlockID);
            loadMenu();
            if (isNaN(GroupID) && FoodID<=10)
                LoadAdditionalBlockMy(GroupID);
            else if (!isNaN(GroupID))
                setTimeout("LoadAdditionalBlockMy("+GroupID+")",500);
        }
        else{
            document.getElementById("preload").style.display="none";
            resizeScrollbar(BlockID);
        }
    }
}
//--!Загрузка моего меню

//--Загрузка содержимого последних открытых блоков
function GetContentR(blockID){
    GroupID=BlocksID[CurrentBlockID];
    BlockID=Blocks[GroupID];
    InnerTXT="";
    OpenBlocks[Blocks[CurrentBlockID]]=true;
    switchMenuBlock(document.getElementById("block1_"+BlockID),BlockID);
    if (OpenBlocks[BlockID]){
        FoodID=1;
            test[BlockID]= new AJAXInteractionBlocks(BlockID,GroupID);
            test[BlockID].LoadBlock();
            LoadedBlocks[BlockID]=BlockID;
    }
    else{
        showList(BlockID);
    }
}
function LoadBlockR(gid){
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCardR;
    URL='/?reqMode=xHTTP&reqType=Food&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function LoadAdditionalBlockR(gid){
    FoodID++;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ShowFoodCardR;
    URL='/?reqMode=xHTTP&reqType=Food&reqId='+FoodID+'&reqGroup='+gid;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function ShowFoodCardR(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!=''){
            InnerTXT+=HttpResponse;
            document.getElementById("iframe_block_content_"+BlockID).innerHTML=showListR(BlockID);
            resizeScrollbar(BlockID);
            loadMenu();
            if (isNaN(GroupID) && FoodID<=10)
                LoadAdditionalBlockR(GroupID);
            else if (!isNaN(GroupID))
                setTimeout("LoadAdditionalBlockR("+GroupID+")",500);
        }
        else{
            document.getElementById("preload_"+BlockID).style.display="none";
            resizeScrollbar(BlockID);
            CurrentBlockID++;
            if (!isNaN(BlocksID[CurrentBlockID]))
                GetContentR(CurrentBlockID);
            else{
                getCalculatorFromCookie();
                getCalculatorArray();
            }
        }
    }
}
function showListR(BlockID){
    txt='<table cellpadding="0" cellspacing="0" id="iframe_block_table_'+BlockID+'"><tr>';
    txt+=InnerTXT;
    txt+='<td id="preload_'+BlockID+'" width="226" style="background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/parts/preload.gif) no-repeat center center;">&nbsp;</td>';
    txt+='</tr></table>';
    return txt;
}
//--!Загрузка содержимого последних открытых блоков

//--Выставление рейтинга блюду
var Stars=new Array();
var CardID=null;
function RateOver(rate,id){
    for(i=1;i<=5;i++)
        Stars[i]=document.getElementById("star_"+i+"_"+id).src;
    for(i=1;i<=rate;i++){
        document.getElementById("star_"+i+"_"+id).src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_1.gif";
    }
    for(i=rate+1;i<=5;i++){
        document.getElementById("star_"+i+"_"+id).src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/star_2.gif";
    }
}
function RateOut(id){
    for(i=1;i<=5;i++)
        document.getElementById("star_"+i+"_"+id).src=Stars[i];
}
function SetRate(rate,id){
    setCookieExpires("vote_"+id,rate,"Mon, 01-Jan-2010 00:00:00 GMT");
    setCookieExpiresPath("vote_"+id,rate,"Mon, 01-Jan-2010 00:00:00 GMT");
    CardID=id;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=ReloadCard;
    URL='/?reqMode=xHTTP&reqType=Vote&reqId='+CardID+'&reqRate='+rate;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function ReloadCard(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        //alert(HttpResponse);
        document.getElementById("card_"+CardID).innerHTML=HttpResponse;
        //alert(document.getElementById("card_"+CardID).innerHTML);
        GetContent(1,'c'+TopID);
    }
}
//--!Выставление рейтинга блюду

//--Работа с калькулятором
function getCalculatorArray(){
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=putCalculator;
    URL='?reqMode=xHTTP&reqType=Calculator&reqAction=get';
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function putCalculator(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!=""){
            arrayCalculator=eval('('+HttpResponse+')');
        }
        //alert(HttpResponse);
        reloadCalculator();
    }
}
//--!Работа с калькулятором

//--Загрузка отзывов
var CategoryID=null;
var GroupID2=null;
var FoodID2=null;
function loadCommentsCategory(cid,obj){
    CategoryID=cid;
    objectComments=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuOneInformation;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Category&reqId='+CategoryID;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function loadCommentsAddress(cid,obj){
    CategoryID=cid;
    objectComments=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuOneInformationAddress;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Address&reqId='+CategoryID;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getMenuOneInformationAddress(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        //alert(HttpResponse);
        if (HttpResponse!='')
            arrayComments=eval('('+HttpResponse+')');
        putMenuOne(false);
    }
}
function loadCommentsAddressLast(cid,obj){
    CategoryID=cid;
    objectComments=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuOneInformationAddressLast;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Address&reqId='+CategoryID;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getMenuOneInformationAddressLast(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='')
            arrayComments=eval('('+HttpResponse+')');
            i=0;
            for (key in arrayComments){
                if (!i && !isNaN(key)){
                    loadAddress(key,document.getElementById("g"+key));
                    i++;
                }
            }
        putMenuOne(false);
    }
}
function getMenuOneInformation(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='')
            arrayComments=eval('('+HttpResponse+')');
        putMenuOne(true);
    }
}
function loadCommentsGroup(gid,obj){
    GroupID2=gid;
    objectComments2=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuTwoInformation;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Group&reqId='+GroupID2;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getMenuTwoInformation(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='')
            arrayComments2=eval('('+HttpResponse+')');
        putMenuTwo();
    }
}
function loadFood(id){
    FoodID2=id;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getFoodInformation;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Food&reqId='+FoodID2;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getFoodInformation(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        arrayCommentsCard=eval('('+HttpResponse+')');
        showComments();
    }
}
function loadAddress(id){
    FoodID2=id;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getAddressInformation;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=SingleAddress&reqId='+FoodID2;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getAddressInformation(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        //alert(HttpResponse);
        arrayCommentsCard=eval('('+HttpResponse+')');
        showAddressComments();
    }
}

function getCommentsNumber(CategoryID,type){
    var HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=function(){
        if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
            HttpResponse=HttpRequest.responseText;
            HttpRequest=null;
            document.getElementById("cn"+CategoryID).innerHTML="("+HttpResponse+")";
        }
    }
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Number&reqId='+CategoryID+'&reqObject='+type;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
//--!Загрузка отзывов

//--Оставление отзывов
var ObjectID=null;
var CommentType=false;
function putCommentObject(id,type,place){
    if (checkCommentForm()){
        ObjectID=id;
        HttpRequest=getHttpRequest();
        //if (place)
            HttpRequest.onreadystatechange=ReloadComments;
        //else
        //    HttpRequest.onreadystatechange=ReloadCommentWindow;
        URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Put&reqId='+ObjectID+'&reqObject='+type;
        HttpRequest.open('POST',URL,true);
        HttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        HttpRequest.send('name='+document.getElementById("cName").value+'&text='+document.getElementById("cText").value+'&phone='+document.getElementById("cPhone").value+'&mail='+document.getElementById("cMail").value);
    }
    else{
        errorFields();
    }
}
function ReloadComments(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        document.getElementById('cText').value='Ваш отзыв добавлен и ждет одобрения модератора. После одобрения, он будет добавлен на сайт';
        /*
        if (!CommentType)
            loadFood(ObjectID);
        else
            loadAddress(ObjectID);
                                                             */
    }
}
function ReloadCommentWindow(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        document.getElementById("comment").innerHTML="Спасибо! Ваш отзыв сохранен.";
    }
}
var CommentType='';
function loadLastComment(type){
    CommentType=type;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=openLastComment;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Last&reqObject='+type;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function openLastComment(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='{}'){
            lastCommentArray=eval('('+HttpResponse+')');
            if (CommentType=="ADM"){
                loadCommentsAddressLast(lastCommentArray["cid"],document.getElementById("c"+lastCommentArray["cid"]));
            }
            else{
                loadCommentsCategory2(lastCommentArray["cid"],document.getElementById("c"+lastCommentArray["cid"]));
            }
        }
        //loadCommentsGroup(lastCommentArray["gid"],document.getElementById("g"+lastCommentArray["gid"]));
        //alert(HttpResponse);
    }
}
function loadCommentsCategory2(cid,obj){
    CategoryID=cid;
    objectComments=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuOneInformation2;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Category&reqId='+CategoryID;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getMenuOneInformation2(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='')
            arrayComments=eval('('+HttpResponse+')');
        putMenuOne(true);
        loadCommentsGroup2(lastCommentArray["gid"],document.getElementById("g"+lastCommentArray["gid"]));
    }
}
function loadCommentsGroup2(gid,obj){
    GroupID2=gid;
    objectComments2=obj;
    HttpRequest=getHttpRequest();
    HttpRequest.onreadystatechange=getMenuTwoInformation2;
    URL='/?reqMode=xHTTP&reqType=Comments&reqGet=Group&reqId='+GroupID2;
    HttpRequest.open('GET',URL,true);
    HttpRequest.send(null);
}
function getMenuTwoInformation2(){
    if (HttpRequest.readyState==4 || HttpRequest.readyState=='complete'){
	HttpResponse=HttpRequest.responseText;
        HttpRequest=null;
        if (HttpResponse!='')
            arrayComments2=eval('('+HttpResponse+')');
        putMenuTwo();
        loadFood(lastCommentArray["id"]);
    }
}

//--!Оставление отзывов

/**
 * menu
 */

var Blocks=new Array();
var BlocksID=new Array();
var CurrentBlockID=0;
function addBlockList(id,gid){
    Blocks[gid]=id;
}
function formBlocksID(){
    i=0;
    tmp_array=new Array();
    for (key in arrOpenBlocks){
        if (!isNaN(key.replace('c',''))){
            BlocksID[i]=key;
            tmp_array[i]=key;
            i++;
        }
    }
    /*
    tmp_array=new Array();
    i=0;
    for (key in Blocks){
        if (!isNaN(key.replace('c',''))){
            tmp_array[i]=key;
            i++;
        }
    }
    */
    str=tmp_array.join(",");
    //setCookieExpires("blocks["+PageID+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
    setCookieExpires("blocks["+PageID+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
    setCookieExpiresPath("blocks["+PageID+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
}
function OpenBlock(){
    getCalculatorFromCookie();
    getCalculatorArray();
    if (PageID==12 || PageID==13 || PageID==14 || PageID==15 || PageID==17){
        formBlocksID();
        for (key in BlocksID){
            if (!isNaN(key.replace('c',''))){
                gid=BlocksID[key];
                id=Blocks[gid];
                OpenBlocks[Blocks[key]]=true;
                switchMenuBlock(document.getElementById("block1_"+id),id);
                test[key]= new AJAXInteractionBlocks(id,gid);
                test[key].LoadBlock();
                LoadedBlocks[key]=key;
            }
        }
        /*
        key=BlocksID[CurrentBlockID];
        if (!isNaN(key.replace('c','')))
            GetContentR(CurrentBlockID);
        else{
            //getCalculatorFromCookie();
            //getCalculatorArray();
        }
        */
            manageResize();
    }
}
function checkOpenBlock(block_id){
    if (OpenBlocks[block_id]==true)
        addOpenBlock(block_id,PageID);
    else
        removeOpenBlock(block_id,PageID);
}
function addOpenBlock(block_id,page_id){
    for (key in Blocks){
        if (Blocks[key]==block_id)
            block_gid=key;
    }
    blockArray=formCookieBlock(page_id);
    if (blockArray==null)
        str=block_gid;
    else{
        newElement=blockArray.length;
        blockArray[newElement]=block_gid;
        str=blockArray.join(',');
    }
    setCookieExpires("blocks["+page_id+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
    setCookieExpiresPath("blocks["+page_id+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
}
function removeOpenBlock(block_id,page_id){
    for (key in Blocks){
        if (Blocks[key]==block_id)
            block_gid=key;
    }
    blockArray=formCookieBlock(page_id);
    if (blockArray!=null){
        newBlockArray=new Array();
        i=0;
        for(key in blockArray){
            if (!isNaN(key) && blockArray[key]!=block_gid){
                newBlockArray[i]=blockArray[key];
                i++;
            }
        }
        str=newBlockArray.join(',');
        setCookieExpires("blocks["+page_id+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
        setCookieExpiresPath("blocks["+page_id+"]",str,"Mon, 01-Jan-2010 00:00:00 GMT");
    }
}
function formCookieBlock(page_id){
    str=getCookie('blocks['+page_id+']');
    if (str==null)
        blockArray=str;
    else
        blockArray=str.split(",");
    return blockArray;
}
//--�����
function getColors(id){
    if (id>10)
        color=id-10*Math.floor(id/10);
    else
        color=id;
}
//--!����

/**
 * comments
 */

var arrayComments=new Array();
var arrayComments2=new Array();
var objectComments=null;
var objectComments2=null;
var CommentMenuOneTXT="";
var arrayCommentsCard=new Array();
var CommentsCardTXT="";
var CommentsTXT="";
function putMenuOne(type){
    if (type)
        formMenuOne();
    else
        formMenuOneAddress();
    showCommentsMenu1(objectComments);
}
function formMenuOne(){
    CommentMenuOneTXT='<table width="100%" cellpadding="0" cellspacing="0" class="submenu_4">';
    for(key in arrayComments){
        if (!isNaN(key)){
            CommentMenuOneTXT+='<tr class="first" onclick="loadCommentsGroup('+key+',this)" id="g'+key+'">';
            CommentMenuOneTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_1.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_1.gif" class="image_2"></th>';
            CommentMenuOneTXT+='<td><div>'+arrayComments[key]["name"]+' <span>('+arrayComments[key]["count"]+')</span></div></td>';
            CommentMenuOneTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_2.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_2.gif" class="image_2"></th>';
            CommentMenuOneTXT+='</tr>';
        }
    }
    CommentMenuOneTXT+='</table>';
}
function formMenuOneAddress(){
    CommentMenuOneTXT='<table width="100%" cellpadding="0" cellspacing="0" class="submenu_4">';
    for(key in arrayComments){
        if (!isNaN(key)){
            CommentMenuOneTXT+='<tr class="first" onclick="loadAddress('+key+',this)" id="g'+key+'">';
            CommentMenuOneTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_1.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_1.gif" class="image_2"></th>';
            CommentMenuOneTXT+='<td><div>'+arrayComments[key]["name"]+', '+arrayComments[key]["street"]+' <span>('+arrayComments[key]["count"]+')</span></div></td>';
            CommentMenuOneTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_2.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_2.gif" class="image_2"></th>';
            CommentMenuOneTXT+='</tr>';
        }
    }
    CommentMenuOneTXT+='</table>';
}
function putMenuTwo(){
    formMenuTwo();
    showCommentsMenu2(objectComments2);
}
function formMenuTwo(){
    CommentMenuTwoTXT='<table width="100%" cellpadding="0" cellspacing="0" class="submenu_4">';
    for(key in arrayComments2){
        if (!isNaN(key)){
            CommentMenuTwoTXT+='<tr class="first" onclick="loadFood('+key+')">';
            CommentMenuTwoTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_1.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_1.gif" class="image_2"></th>';
            CommentMenuTwoTXT+='<td><div>'+arrayComments2[key]["name"]+' <span>('+arrayComments2[key]["count"]+')</span></div></td>';
            CommentMenuTwoTXT+='<th><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_1_2.gif" class="image_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/2_2_2.gif" class="image_2"></th>';
            CommentMenuTwoTXT+='</tr>';
        }
    }
    CommentMenuTwoTXT+='</table>';
}
function hideCommentsMenu1() {
	if (lastCommentsObject1) {
		lastCommentsObject1.className = lastCommentsObject1.className.replace(' active', '');
		lastCommentsObject1.getElementsByTagName('div')[0].style.background = '';
	}
        lastCommentsObject2=null;
        hideComments();
}
function hideCommentsMenu2() {
	if (lastCommentsObject2) {
		lastCommentsObject2.className = lastCommentsObject2.className.replace(' active', '');
		lastCommentsObject2.getElementsByTagName('div')[0].style.background = '';
	}
        hideComments();
}
function showCommentsMenu1(obj){
	if (obj.className.indexOf('active') == -1){
		hideCommentsMenu1();
		obj.className += ' active';
		obj.getElementsByTagName('div')[0].style.background = '#E6EEE9';
		lastCommentsObject1 = obj;
		document.getElementById("menuOne").innerHTML=CommentMenuOneTXT;
	}
}
function showCommentsMenu2(obj, table_index){
	if (obj.className.indexOf('active') == -1){
		hideCommentsMenu2();
		obj.className += ' active';
		obj.getElementsByTagName('div')[0].style.background = '#E6EEE9';
		lastCommentsObject2 = obj;
		document.getElementById("menuTwo").innerHTML=CommentMenuTwoTXT;
	}
}
function showComments(){
    showCommentsCard();
    showCommentsList();
}
function showAddressComments(){
    showAddressCommentsCard();
    showAddressCommentsList();
}
function showCommentsCard(){
    FoodCard=arrayCommentsCard["information"];
    txt="";
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/pixels/t_pixel.gif" class="separator_2"><br><br>';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="testimonial_photo">';
    txt+='<table width="2%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%"><div class="photo_frame_1" style="width:120px;height:120px;background:url('+FoodCard["image"]+') no-repeat center center;">&nbsp;</div></td>';
    txt+='<td width="1%" style="vertical-align: bottom"><div class="price"><span>'+FoodCard["price"]+' руб.</span></div></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="39%" style="font-size: 11px; padding: 5 5 0 0"><b>'+FoodCard["name"]+'</b> '+FoodCard["weight"]+'<br>'+FoodCard["consist"]+'</td>';
    txt+='<td width="60%">';
    txt+='<form name="commentForm" method="post" action="">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="50%" style="padding: 5 0 10 0"><b>Оставь свой отзыв</b></td>';
    txt+='<td width="50%" style="padding: 0 0 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br></td>';
    txt+='<td width="98%"><input type="text" name="" id="cName" value="Ваше имя" class="input2" onfocus="if (this.value == \'Ваше имя\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваше имя\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="50%" style="padding: 0 5 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cPhone" value="Ваш телефон" class="input2" onfocus="if (this.value == \'Ваш телефон\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш телефон\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="50%" style="padding: 0 0 0 5">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cMail" value="Ваш E-mail" class="input2" onfocus="if (this.value == \'Ваш E-mail\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш E-mail\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<div class="comment_1">';
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_1.gif" width="6" height="6" style="position: absolute; top: -1; left: -1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_2.gif" width="6" height="6" style="position: absolute; top: -1; right: -2"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_3.gif" width="6" height="6" style="position: absolute; right: -2; bottom: -1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_4.gif" width="6" height="6" style="position: absolute; left: -1; bottom: -1">';
    txt+='<textarea name="" id="cText" class="input3" onfocus="if (this.value == \'Оставьте ваш отзыв\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Оставьте ваш отзыв\'}">Оставьте ваш отзыв</textarea><br>';
    txt+='<a href="javascript:putCommentObject('+arrayCommentsCard["information"]["id"]+',\'PDM\',true)" class="gray_3"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/send_1.gif" width="20" height="20" alt="Отправить" title="Отправить" class="sinput1">Отправить</a><br>';
    txt+='</div></form><div style="text-align:center;line-height:26px;height:26px;;font-size:11px;">*поля "Ваше имя" и "Отзыв" обязательны, а так же "Телефон" или "E-mail"</div></td>';
    txt+='</tr></table>';
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/pixels/t_pixel.gif" class="separator_3"><br>';
    CommentsCardTXT=txt;
    document.getElementById("info").innerHTML=CommentsCardTXT;
}
function showCommentsList(){
    FoodComments=arrayCommentsCard["comments"];
    txt="";
    for(key in FoodComments){
        if (!isNaN(key)){
            txt+='<div class="comment_2">';
            txt+='<div>'+FoodComments[key]["name"]+'</div>';
            txt+=FoodComments[key]["body"];
            txt+='</div>';
        }
    }
    CommentsTXT=txt;
    document.getElementById("comments").innerHTML=CommentsTXT;
}
function showAddressCommentsCard(){
    FoodCard=arrayCommentsCard["information"];
    txt="";
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/pixels/t_pixel.gif" class="separator_2"><br><br>';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="testimonial_photo">';
    txt+='<table width="2%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%"><div class="photo_frame_1" style="width:120px;height:120px;background:url('+FoodCard["image"]+') no-repeat center center;">&nbsp;</div></td>';
    txt+='<td width="1%" style="vertical-align: bottom"></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="39%" style="font-size: 11px; padding: 5 0 0 0"></td>';
    txt+='<td width="60%">';
    txt+='<form name="commentForm" method="post" action="">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="50%" style="padding: 5 0 10 0"><b>Оставь свой отзыв</b></td>';
    txt+='<td width="50%" style="padding: 0 0 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br></td>';
    txt+='<td width="98%"><input type="text" name="" id="cName" value="Ваше имя" class="input2" onfocus="if (this.value == \'Ваше имя\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваше имя\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="50%" style="padding: 0 5 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cPhone" value="Ваш телефон" class="input2" onfocus="if (this.value == \'Ваш телефон\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш телефон\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="50%" style="padding: 0 0 0 5">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cMail" value="Ваш E-mail" class="input2" onfocus="if (this.value == \'Ваш E-mail\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш E-mail\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<div class="comment_1">';
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_1.gif" width="6" height="6" style="position: absolute; top: -1; left: -1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_2.gif" width="6" height="6" style="position: absolute; top: -1; right: -2"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_3.gif" width="6" height="6" style="position: absolute; right: -2; bottom: -1"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/4_4.gif" width="6" height="6" style="position: absolute; left: -1; bottom: -1">';
    txt+='<textarea name="" id="cText" class="input3" onfocus="if (this.value == \'Оставьте ваш отзыв\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Оставьте ваш отзыв\'}">Оставьте ваш отзыв</textarea><br>';
    txt+='<a href="javascript:putCommentObject('+arrayCommentsCard["information"]["id"]+',\'ADM\',true)" class="gray_3" onClick="CommentType=true"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/send_1.gif" width="20" height="20" alt="Отправить" title="Отправить" class="sinput1">Отправить</a><br>';
    txt+='</div></form><div style="text-align:center;line-height:26px;height:26px;font-size:11px;">*поля "Ваше имя" и "Отзыв" обязательны, а так же "Телефон" или "E-mail"</div></td>';
    txt+='</tr></table>';
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/pixels/t_pixel.gif" class="separator_3"><br>';
    CommentsCardTXT=txt;
    document.getElementById("info").innerHTML=CommentsCardTXT;
}
function showAddressCommentsList(){
    FoodComments=arrayCommentsCard["comments"];
    txt="";
    for(key in FoodComments){
        if (!isNaN(key)){
            txt+='<div class="comment_2">';
            txt+='<div>'+FoodComments[key]["name"]+'</div>';
            txt+=FoodComments[key]["body"];
            txt+='</div>';
        }
    }
    CommentsTXT=txt;
    document.getElementById("comments").innerHTML=CommentsTXT;
}
function hideComments(){
    document.getElementById("info").innerHTML="";
    document.getElementById("comments").innerHTML="";
    document.getElementById("menuTwo").innerHTML="";
}
function showCommentWindow(id,event){
    x=Number(event.clientX) + Number(document.body.scrollLeft);
    y=Number(event.clientY) + Number(document.body.scrollTop);
    document.getElementById("comment").style.top=y+"px";
    document.getElementById("comment").style.left=x+"px";
    txt="";
    txt+='<div style="width:300px;height:200px;position:absolute;z-index:150;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/comment1.png\', sizingMethod=\'noscale\')"><img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/comment1.png" style="position:absolute" onLoad="loadPNG(this)"></div><div style="width:280px;height:180px;margin-top:10px;margin-left:10px;z-index:200;position:absolute;"><form name="commentForm" method="post" action="">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="280" style="padding: 0 0 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cName" value="Ваше имя" class="input2" onfocus="if (this.value == \'Ваше имя\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваше имя\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="20" valign="top" align="right">';
    txt+='<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/backgrounds/savemenu_close.gif" style="width:9px;height:9px;position:relative;margin-left:10px;" onClick="closeWindow('+id+')">';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="140" style="padding: 0 5 10 0">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cPhone" value="Ваш телефон" class="input2" onfocus="if (this.value == \'Ваш телефон\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш телефон\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='<td width="140" style="padding: 0 0 0 5">';
    txt+='<table width="100%" cellpadding="0" cellspacing="0"><tr>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_1.gif" width="6" height="24"><br>--></td>';
    txt+='<td width="98%"><input type="text" name="" id="cMail" value="Ваш E-mail" class="input2" onfocus="if (this.value == \'Ваш E-mail\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Ваш E-mail\'}"><br></td>';
    txt+='<td width="1%" class="input_padding_1"><div style="width:6px;height:24px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif) no-repeat center center;"></div><!--<img src="/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/corners/3_1_2.gif" width="6" height="24"><br>--></td>';
    txt+='</tr></table>';
    txt+='</td>';
    txt+='</tr></table>';
    txt+='<div class="comment_1">';
    txt+='<div class="corner_1"></div><div class="corner_2"></div><div class="corner_3"></div><div class="corner_4"></div>';
    txt+='<textarea name="" id="cText" class="input3" onfocus="if (this.value == \'Оставьте ваш отзыв\') {this.value = \'\'}; this.style.backgroundColor=\'#ffffff\';" onblur="if (this.value == \'\') {this.value = \'Оставьте ваш отзыв\'}">Оставьте ваш отзыв</textarea><br>';
    txt+='<a href="javascript:putCommentObject('+id+',\'PDM\',false)" class="gray_3"><div style="width:20px;height:20px;background:url(/CommonFiles/Yaposhka/WPG_Templates/Images/Yaposhka/icons/send_1.gif) no-repeat center center; float:left;"></div><div style="margin-top:3px;width:100px;">Отправить</div></a>';
    txt+='</div></form><div style="text-align:center;line-height:26px;height:26px;font-size:11px;">*поля "Ваше имя" и "Отзыв" обязательны, а так же "Телефон" или "E-mail"</div></div>';
    document.getElementById("comment").innerHTML=txt;
    document.getElementById("comment").style.display="block";
}
function closeWindow(id){
    document.getElementById("comment").style.display="none";
}
var errorArray=new Array();
function checkCommentForm(){
    flag=true;
    objName=document.getElementById("cName");
    objText=document.getElementById("cText");
    objPhone=document.getElementById("cPhone");
    objMail=document.getElementById("cMail");
    if (objName.value=="" || objName.value=="Ваше имя"){
	errorArray[errorArray.length]='cName';
	flag=false;
    }
    if (objText.value=="" || objText.value=="Оставьте ваш отзыв" || objText.value=="Ваш отзыв добавлен и ждет одобрения модератора. После одобрения, он будет добавлен на сайт"){
	errorArray[errorArray.length]='cText';
	flag=false;
    }
    if (objMail.value!="" && objMail.value!="Ваш E-mail" && !checkEMail(objMail.value)){
	errorArray[errorArray.length]='cMail';
	flag=false;
    }
    if (objPhone.value!="" && objPhone.value!="Ваш телефон" && !checkPhone(objPhone.value)){
	errorArray[errorArray.length]='cPhone';
	flag=false;
    }
    if ((objMail.value=="" || objMail.value=="Ваш E-mail") && (objPhone.value=="" || objPhone.value=="Ваш телефон")){
	errorArray[errorArray.length]='cPhone';
	errorArray[errorArray.length]='cMail';
	flag=false;
    }
    return flag;
}
function errorFields(){
    for(key in errorArray){
	if (!isNaN(key)){
	    obj=document.getElementById(errorArray[key]);
	    obj.style.backgroundColor = "#eeeeee";
	    obj.style.color = "#000000";

	}
    }
    errorArray.splice(0,errorArray.length);
}

/**
 * flashDetect
 */

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";


if (MSDetect == "true") {
	var doc = '<scr' + 'ipt language="VBScript"\> \n';
	doc += 'on error resume next \n';
	doc += '	For i = 3 to 10\n';
	doc += '		If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then\n';
	doc += '\n';
	doc += '		Else\n';
	doc += '			flashinstalled = 2\n';
	doc += '			flashversion = i\n';
	doc += '		End If\n';
	doc += '	Next\n';
	doc += '\n';
	doc += 'If flashinstalled = 0 Then\n';
	doc += '	flashinstalled = 1\n';
	doc += 'End If\n';
	doc += '</scr' + 'ipt\> \n';
	document.write(doc);
}

function overwriteWithFlash(strSRC, strName, intWidth, intHeight, intFlashVersion){
/*
	if(flashinstalled == 0)
		return false;
	if(flashversion < intFlashVersion)
		return false;
*/
if (!DetectFlashVer(intFlashVersion,0,0))
	return false;

	var strFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
	strFlash += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ';
	strFlash += 'width="'+intWidth+'" height="'+intHeight+'" id="oSwf'+strName+'" align="middle">';
	strFlash += '<param name="movie" value="'+strSRC+'" />';
	strFlash += '<param name="quality" value="high" />';
	strFlash += '<param name="bgcolor" value="#ffffff" />';
	strFlash += '<param name="wmode" value="opaque" />';
	strFlash += '<embed src="'+strSRC+'" ';
	strFlash += 'quality="high" bgcolor="#ffffff" ';
	strFlash += 'width="'+intWidth+'" height="'+intHeight+'" ';
	strFlash += 'name="oSwf'+strName+'" align="middle" type="application/x-shockwave-flash" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	document.getElementById(strName).innerHTML = strFlash;

}

/**
 * runActiveContent
 */

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}

	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

/*
 * new calculator
 **/
notmoscow = 0;
$(document).ready(function(){
    notmoscow = Number(getCookie('notmoscow'));
    if (notmoscow == 1) {
        setCookie('calculator','');
        setCookiePath('calculator','');
        setCookie('calculatorNumbers','');
        setCookiePath('calculatorNumbers','');
        $('#ordervisible, #orderhidden').hide();
        $('#ordernotmoscow').show();
        $('#orderBoxButton').css('cursor','default');
    } else {
        $('#orderhidden').show();
    }

});

$(window).load(function() {
    var form = $('#window_call_form');
    if (form.size()>0) {
        form.centerwindowhandler({bgzindex:10000,bgclickable:true,fadespeed:200});
        form.find('a.window_close_button').eq(0).click(function(){
            form.centerwindowhandlerStopAction();
            return false;
        });
        var formResponse = $('#window_call_form_response');
        if (formResponse.size()>0) {
            formResponse.centerwindowhandler({bgzindex:10000,bgclickable:true,fadespeed:200});
            formResponse.find('a.window_close_button').eq(0).click(function(){
                formResponse.centerwindowhandlerStopAction();
                return false;
            });
        }
        var callButton = $('#callButton');
        if (callButton.size()>0) {
            callButton.click(function(){
                form.centerwindowhandlerStartAction();
                return false;
            });
        }
    }
    if (notmoscow == 0) {
        var form2 = $('#window_order_form');
        if (form2.size()>0) {
            form2.centerwindowhandler({bgzindex:10000,bgclickable:true,fadespeed:200});
            form2.find('a.window_close_button').eq(0).click(function(){
                form2.centerwindowhandlerStopAction();
                return false;
            });
            var formResponse2 = $('#window_order_form_response');
            if (formResponse2.size()>0) {
                formResponse2.centerwindowhandler({bgzindex:10000,bgclickable:true,fadespeed:200});
                formResponse2.find('a.window_close_button').eq(0).click(function(){
                    formResponse2.centerwindowhandlerStopAction();
                    return false;
                });
            }
            var formResponse3 = $('#window_order_form_response2');
            if (formResponse3.size()>0) {
                formResponse3.centerwindowhandler({bgzindex:10000,bgclickable:true,fadespeed:200});
                formResponse3.find('a.window_close_button').eq(0).click(function(){
                    formResponse3.centerwindowhandlerStopAction();
                    return false;
                });
            }
            var orderButton = $('#orderButton');
            if (orderButton.size()>0) {
                orderButton.click(function(){
                    if (!orderButton.hasClass('orderButtonActive')) {
                        return false;
                    } else {
                        var sum = parseInt($('#calculator').text().replace('.-',''));
                        if (sum>=1000) {
                            form2.centerwindowhandlerStartAction();
                        } else {
                            formResponse3.centerwindowhandlerStartAction();
                        }
                    }
                    return false;
                });
            }
        }
    } else {
        var orderButton = $('#orderButton');
        if (orderButton.size()>0) {
            orderButton.click(function(){
                return false;
            });
        }
    }
});

function fCheckCallForm()
{
    var requiredFields = new Array('callName','callPhone','callTime');
    var requiredFieldsMesssages = new Array('Вы не представились','Вы ввели недопустимый телефон','Вы не указали время звонка');
    var isError = false;
    var form = $('#window_call_form');
    form.find('div.window_form_data_error').removeClass('window_form_data_error');
    form.find('label.window_form_data_label_error').removeClass('window_form_data_label_error');
    form.find('td.window_form_error').text('');
    var message = '';
    for (var i=0;i<requiredFields.length;i++) {
        if (form.find('#'+requiredFields[i]).val()==''
            || (form.find('#'+requiredFields[i]).attr('id')=='callPhone' && !/[0-9\ \+\-\(\)]+/.test(form.find('#'+requiredFields[i]).val()))) {
            message = requiredFieldsMesssages[i];
            form.find('label[for="'+form.find('#'+requiredFields[i]).attr('id')+'"]').addClass('window_form_data_label_error');
            form.find('#'+requiredFields[i]).parent().addClass('window_form_data_error');
            form.find('#'+requiredFields[i]).parent().find('div').addClass('arrowError');
            form.find('td.window_form_error').text(message);
            isError = true;
            break;
        }
    }
    if (!isError) {
        $.ajax({
          type: 'POST',
          url: '/?reqMode=xHTTP&reqType=call',
          data: {
              callName: form.find('#callName').val(),
              callPhone: form.find('#callPhone').val(),
              callTime: form.find('#callTime').val()
          },
          success: function(data) {
            if (data == '') {
                form.centerwindowhandlerStopAction();
                $('#window_call_form_response').centerwindowhandlerStartAction();
            } else {
                form.find('td.window_form_error').text(data);
            }
          }
        });
    }
    return false;
}
function fCheckOrderForm()
{
    var requiredFields = new Array('orderName','orderPhone','orderMetro','orderStreet','orderHouse','orderPorch','orderCode','orderFloor','orderFlat');
    var requiredFieldsMesssages = new Array('Вы не представились','Вы не указали телефон','Вы не указали станцию метро', 'Вы не указали улицу','Вы не указали номер дома','Вы не указали номер корпуса','Вы не указали номер подъезда','Вы не указали этаж','Вы не указали номер квартиры');
    var isError = false;
    var form = $('#window_order_form');
    form.find('div.window_form_data_error').removeClass('window_form_data_error');
    form.find('label.window_form_data_label_error').removeClass('window_form_data_label_error');
    form.find('div.arrowError').removeClass('arrowError');
    form.find('td.window_form_error').text('');
    for (var i=0;i<requiredFields.length;i++) {
        if (form.find('#'+requiredFields[i]).val()=='') {
            form.find('#'+requiredFields[i]).parent().addClass('window_form_data_error');
            form.find('label[for="'+form.find('#'+requiredFields[i]).attr('id')+'"]').addClass('window_form_data_label_error');
            form.find('#'+requiredFields[i]).parent().find('div').addClass('arrowError');
            form.find('td.window_form_error').text(requiredFieldsMesssages[i]);
            isError = true;
            break;
        }
    }
    if (!isError) {
        $.ajax({
          type: 'POST',
          url: '/?reqMode=xHTTP&reqType=order',
          data: {
              orderName: form.find('#orderName').val(),
              orderPhone: form.find('#orderPhone').val(),
              orderEmail: form.find('#orderEmail').val(),
              orderMetro: form.find('#orderMetro').val(),
              orderStreet: form.find('#orderStreet').val(),
              orderHouse: form.find('#orderHouse').val(),
              orderBlock: form.find('#orderBlock').val(),
              orderPorch: form.find('#orderPorch').val(),
              orderCode: form.find('#orderCode').val(),
              orderFloor: form.find('#orderFloor').val(),
              orderFlat: form.find('#orderFlat').val(),
              orderDesc: form.find('#orderDesc').val(),
              orderElements: getCookie('calculator'),
              orderNumbers: getCookie('calculatorNumbers')
          },
          success: function(data) {
            if (data == '') {
                form.centerwindowhandlerStopAction();
                $('#window_order_form_response').centerwindowhandlerStartAction();
                setCookie('calculator', '');
                setCookie('calculatorNumbers', '');
                arrayCalculatorElements= new Array();
                arrayCalculatorNumbers = new Array();
                reloadCalculator();
            } else {
                form.find('td.window_form_error').text(data);
            }
          }
        });
    }    
    return false;
}


//-->

