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%">';
                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:160px;"><a href="javascript:addToCalculator('+key+')" class="black_1" title="Добавить блюдо в калькулятор">'+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+=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"]);
    }
}

//--!Оставление отзывов