var CH=(navigator.userAgent.indexOf('Chrome')!=-1);
var SF=(navigator.userAgent.indexOf('Safari')!=-1 && !CH);
var OP=(navigator.userAgent.indexOf('Opera')!=-1);
var IE=(navigator.userAgent.indexOf('MSIE')!=-1 && !OP);
var FF=(navigator.userAgent.indexOf('Firefox')!=-1);
var MZ=(navigator.userAgent.indexOf('Gecko')!=-1 && !SF && !CH);
var PageIndex;
var PageOrder;
var PageHelp;

function getWindowW() { 
    var b=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
    return (IE)?(b.clientWidth):window.innerWidth; 
}
function getWindowH() { 
    var b=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
    return (IE)?(b.clientHeight):window.innerHeight; 
}
function getScrollBody() {
    return (CH || SF)?document.body:document.documentElement;
}
function getScrollW() { return getScrollBody().scrollWidth; }
function getScrollH() { return getScrollBody().scrollHeight; }
function getScrollX() { return getScrollBody().scrollLeft; }
function getScrollY() { return getScrollBody().scrollTop; }
function getDocumentW() { return document.body.offsetWidth; }
function getDocumentH() { return document.body.offsetHeight; }

var onloadFuncs=new Array();
function _onload() {
    _timer();
    //alert('onload');
    for (var i=0;i<onloadFuncs.length;i++) {
        //alert('begin: '+onloadFuncs[i]);
        eval(onloadFuncs[i]);
        //alert('done: '+onloadFuncs[i]);
    }
    /*$('debug').innerHTML=navigator.userAgent+'<br>'+
        'OP='+OP+', IE='+IE+', MZ='+MZ+', CH='+CH+', SF='+SF;*/
}
var timeout=10;
function _timer() {
    sizeMake();
    setTimeout('_timer()',timeout);
}

function setTitle(titleText) {
    document.title=(titleText?(titleText+' | '):'')+headTitleBase;
}

/* >>>>> для формы заказа */
var orderNoticeNotSet=false;
var orderCurrentPayType=0;
function orderNoticeFocus(obj) {
    obj.value='';
    obj.setAttribute('onfocus','');
}
function orderNoticeBlur(obj) {
    orderNoticeNotSet=false;
    if (obj.value=='') {
        obj.value='Подробно опишите что вы хотите рекламировать и какова цель рекламы...';
        obj.setAttribute('onfocus','orderNoticeFocus(this)');
        orderNoticeNotSet=true;
    }
}
function orderSubmit() {
    if (orderNoticeNotSet) {
        $('OrderForm')['notice'].value='';
    }
}
function orderCheckOptim() {
    if ($('OrderOptim').checked) {
        $('OrderOptimTariff').style.display='';
    }
    else {
        $('OrderOptimTariff').style.display='none';
    }
    var sheet=stylesheet();
    sheet[9].style.height=$('BlockForm').offsetHeight+'px';
}
function orderSetPayType() {
    var newType=$('OrderPayType').value;
    if ($('AddFields_'+orderCurrentPayType)) {
        $('AddFields_'+orderCurrentPayType).style.display='none';
    }
    if ($('AddFields_'+newType)) {
        $('AddFields_'+newType).style.display='';
    }
    orderCurrentPayType=newType;
}
/* <<<<< для формы заказа */

/* >>>>> для стилей */
var stylesheetId=0;
function stylesheet() {
    var f=true;
    if (!document.styleSheets[stylesheetId]) { f=false; }
    else if (document.styleSheets[stylesheetId].title!='dynamic') { f=false; }
    if (!f) {
        for (i=0;i<document.styleSheets.length;i++) {
            if (document.styleSheets[i].title=='dynamic') { stylesheetId=i; break; }
        }
    }
    return (IE) ? document.styleSheets[stylesheetId].rules : document.styleSheets[stylesheetId].cssRules;
}
/* <<<<< для стилей */

/* >>>>> для показа дополнительной инфы */
var addInfoStep=40;
var addInfoTimeout=10;
var addInfoTimer=0;
var addInfoInProcess=false;
var addInfoShowProcess=false;
var addInfoHideProcess=false;
var addInfoCurrentBlock='';
var addInfoCurrentArticle='';
var addInfoCurrentArticleBlock='';
var addInfoOpenBlock='';
var addInfoOpenArticle='';
var addInfoArticleStep=30;
var addInfoArticleTimeout=10;
var addInfoArticleTimer=0;
var addInfoArticleInProcess=false;

function addInfoOpen(block) {
    if (addInfoShowProcess || addInfoHideProcess) { return; }
    
    var locationPath=window.location.pathname;
    if (locationPath.lastIndexOf('/')!=locationPath.length-1) {
        locationPath+='/';
    }
    var hashBlock=block;
    if ($('InfoDetiles_'+block).style.display=='') {
        hashBlock='';
    }
    if (locationPath!='/') {
        window.location='/#about'+(hashBlock?('/'+hashBlock):'');
        return;
    }
    else {
        window.location.hash='#about'+(hashBlock?('/'+hashBlock):'');
    }
    addInfoSet(block);
}

function addInfoSet(block) {
    if (addInfoShowProcess || addInfoHideProcess) { return; }
    
    if ($('InfoDetiles_'+block)) {
        if ($('InfoDetiles_'+block).style.display=='') {
            addInfoCurrentBlock='';
            addInfoHide(block, true);
            addInfoScrollTo(0);
        }
        else {
            if (addInfoCurrentBlock=='') {
                addInfoShow(block, true);
            }
            else {
                addInfoShow(block, true);
                addInfoHide(addInfoCurrentBlock, true);
            }
            addInfoCurrentBlock=block;
            addInfoScrollToItem(block);
        }
    }
}
function addInfoShow(id,f) {
    var sheet=stylesheet();
    if (f) {
        addInfoShowProcess=true;
        $('InfoDetiles_'+id).style.overflow='hidden';
        $('InfoDetiles_'+id).style.width='0px';
        $('InfoDetiles_'+id).style.display='';
        $('InfoTitle_'+id).className='selected';
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        
        sheet[3].style.width=($('BlockInfo').offsetWidth+$('InfoDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth)+'px';
        if (IE) {
            sheet[3].style.width=(sheet[3].style.width.replace(/px/,'')+1)+'px';
        }
        
    }
    var childW=$('InfoDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth;
    var parentW=$('InfoDetiles_'+id).offsetWidth;
    var stop_s=false;
    parentW+=addInfoStep; 
    if (parentW >= childW) { 
        stop_s=true;
    }
    if (!stop_s) {
        $('InfoDetiles_'+id).style.width=parentW+'px';
        setTimeout('addInfoShow(\''+id+'\',false)',addInfoTimeout);
    }
    else {
        addInfoOpenBlock='';
        $('InfoDetiles_'+id).style.width='';
        $('InfoDetiles_'+id).style.overflow='';
        // отцентрировать показ на развернутый пункт
        
        if (addInfoOpenArticle) {
            addInfoArticleSet(addInfoCurrentBlock,addInfoOpenArticle);
        }
        else {
            setTitle(IndexContent.blocks[addInfoCurrentBlock].head_title);
        }
        setTimeout('addInfoShowProcess=false;',addInfoScrollTimeout*2);
    }
}
function addInfoHide(id,f) {
    var sheet=stylesheet();
    var childW=$('InfoDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth;
    if (f) {
        addInfoHideProcess=true;
        $('InfoDetiles_'+id).style.overflow='hidden';
        $('InfoDetiles_'+id).style.width=childW+'px';
        $('InfoDetiles_'+id).style.display='';
        $('InfoTitle_'+id).className='';
    }
    var parentW=$('InfoDetiles_'+id).offsetWidth;
    var stop_h=false;
    parentW-=addInfoStep; 
    if (parentW <= 0) { 
        stop_h=true;
    }
    if (!stop_h) {
        sheet[3].style.width=($('BlockInfo').offsetWidth-addInfoStep)+'px';
        $('InfoDetiles_'+id).style.width=parentW+'px';
        setTimeout('addInfoHide(\''+id+'\',false)',addInfoTimeout);
    }
    else {
        var cw=$('BlockInfo').offsetWidth-$('BlockInfoInner').offsetWidth;
        var divs=$('BlockInfoInner').childNodes;
        for (var i=0;i<divs.length;i++) {
            if (divs[i].nodeName.toLowerCase() == 'div') {
                if (divs[i].className.indexOf('column')!=-1) {
                    cw+=divs[i].offsetWidth;
                }
            }
        }
        cw-=1;
        $('InfoDetiles_'+id).style.display='none';
        $('InfoDetiles_'+id).style.width='';
        $('InfoDetiles_'+id).style.overflow='';
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        // пересчитать окончательный размер контента
        sheet[3].style.width=cw+'px';
        if (addInfoCurrentArticle!='') {
            // припрятать этот блок
            var aid='InfoArticle_'+id+'__'+addInfoCurrentArticle;
            if ($(aid)) {
                $(aid).className='article-short';
            }
            addInfoCurrentArticle='';
        }
        if (addInfoOpenBlock=='') {
            //addInfoScrollTo(0);
        }
        else {
            addInfoSet(addInfoOpenBlock);
        }
        if (addInfoCurrentBlock=='') {
            setTitle(IndexContent.info_title);
        }
        if (indexFirstReshow) {
            setTimeout("indexShowBlock('First')",addInfoScrollTimeout*2);
        }
        setTimeout('addInfoHideProcess=false;',addInfoScrollTimeout*2);
        
    }
    
}
function addInfoGoTo(id) {
    //alert(addInfoShowProcess + '-' + addInfoHideProcess);
    if (addInfoShowProcess || addInfoHideProcess) { return; }
    if ($('InfoDetiles_'+id)) {
        if ($('InfoDetiles_'+id).style.display=='') {
            // отцентрировать показ на развернутый пункт
            var wW=getWindowW();
            addInfoScrollTo($('InfoDetiles_'+id).offsetLeft-wW*0.381);
            addInfoCurrentBlock=id;
            if (!addInfoCurrentArticle) {
                setTitle(IndexContent.blocks[addInfoCurrentBlock].head_title);
            }
        }
        else {
            addInfoSet(id);
        }
    }
}
function addInfoArticleOpen(block,article) {
    if (addInfoArticleInProcess!=false && addInfoOpenArticle=='') { return; }
    
    var locationPath=window.location.pathname;
    if (locationPath.lastIndexOf('/')!=locationPath.length-1) {
        locationPath+='/';
    }
    var hashArticle=article;
    if ($('InfoArticle_'+block+'__'+article).className=='article-full') {
        hashArticle='';
    }
    if (locationPath!='/') {
        window.location='/#about/'+block+(hashArticle?('/'+article):'');
        return;
    }
    else {
        window.location.hash='#about/'+block+(hashArticle?('/'+article):'')
    }
    addInfoArticleSet(block,article);
}
function addInfoArticleSet(block,article) {
    if (addInfoArticleInProcess!=false && addInfoOpenArticle=='') { return; }
    
    if (block==addInfoCurrentBlock) {
        var aid='InfoArticle_'+block+'__'+article;
        if ($(aid)) {
            addInfoArticleInProcess=true;
            if ($(aid).className=='article-full') {
                addInfoArticleHide(block,article,true);
            }
            else {
                if (addInfoCurrentArticle=='') {
                    addInfoArticleShow(block,article,true);
                }
                else if (addInfoOpenArticle=='') {
                    addInfoOpenArticle=article;
                    addInfoArticleHide(block,addInfoCurrentArticle,true);
                }
                else {
                    addInfoArticleShow(block,addInfoOpenArticle,true);
                }
            }
        }
    }
    else {
        addInfoOpenArticle=article;
        addInfoSet(block);
    }
}
function addInfoArticleShow(block,article,f) {
    var sheet=stylesheet();
    var aid='InfoArticle_'+block+'__'+article;
    if (f) {
        $(aid).style.height=($(aid).offsetHeight-15)+'px';
        $(aid).style.overflow='hidden';
        $(aid).className='article-full';
        addInfoOpenArticle='';
    }
    var stop=false;
    var bH=$(aid).offsetHeight + addInfoArticleStep;
    var needH=$(aid).scrollHeight;
    if (bH>=needH) { stop=true; }
    
    if (!stop) {
        $(aid).style.height=(bH-15)+'px';
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        setTimeout('addInfoArticleShow(\''+block+'\',\''+article+'\',false)',addInfoArticleTimeout);
    }
    else {
        addInfoArticleInProcess=false;
        addInfoCurrentArticle=article;
        addInfoCurrentArticleBlock=block;
        $(aid).style.height='';
        $(aid).style.overflow='';
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        setTitle(IndexContent.blocks[addInfoCurrentBlock].articles[addInfoCurrentArticle].title);
    }
    
    
}
function addInfoArticleHide(block,article,f) {
    var sheet=stylesheet();
    var aid='InfoArticle_'+block+'__'+article;
    if (f) {
        $(aid).style.height=($(aid).offsetHeight-15)+'px';
        $(aid).style.overflow='hidden';
        if (IE) { getScrollBody().scrollTop=0; }
    }
    var stop=false;
    var bH=$(aid).offsetHeight - addInfoArticleStep;
    var needH=$(aid).getElementsByTagName('div').item(0).offsetHeight+15;
    if (bH<=needH) { stop=true; }
    
    if (!stop) {
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        $(aid).style.height=(bH-15)+'px';
        setTimeout('addInfoArticleHide(\''+block+'\',\''+article+'\',false)',addInfoArticleTimeout);
    }
    else {
        
        addInfoCurrentArticle='';
        $(aid).className='article-short';
        $(aid).style.height='';
        $(aid).style.overflow='';
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
        if (addInfoOpenArticle!='') {
            addInfoArticleSet(addInfoCurrentBlock,addInfoOpenArticle);
        }
        else {
            addInfoArticleInProcess=false;
            setTitle(IndexContent.blocks[addInfoCurrentBlock].head_title);
        }
    }
}
var addInfoScrollStep=18;
var addInfoScrollTimeout=10;
var addInfoScrollTimer=0;
var addInfoScrollTimer2=0;
var addInfoScrollInProcess=false;
function addInfoScrollTo(fsl) {
    clearTimeout(addInfoScrollTimer);
    if (indexInProcess) { return; }
    //var curScroll=getScrollBody().scrollLeft; // для страницы со скролом раскомментировать
    //var curScroll=$('Container').scrollLeft; // для страницы со скролом закомментировать
    var curScroll=-$('BlockInfo').offsetLeft; // для страницы со скролом закомментировать
    if (fsl<0) { fsl=0; }
    var sstop=true;
    var sl=0;
    if (curScroll > fsl) {
        if (curScroll-addInfoScrollStep >= fsl) { 
            sl= curScroll-addInfoScrollStep;
            sstop=false;
        }
        else {
            sl=fsl;
        }
    }
    else if (curScroll < fsl) {
        if (curScroll+addInfoScrollStep <= fsl) { 
            sl= curScroll+addInfoScrollStep;
            sstop=false;
        }
        else {
            sl=fsl;
        }
    }
    //getScrollBody().scrollLeft=sl; // для страницы со скролом раскомментировать
    //$('Container').scrollLeft=sl; // для страницы со скролом закомментировать
    $('BlockInfo').style.left=(-sl)+'px'; // для страницы со скролом закомментировать
    //alert('addInfoScrollTo '+fsl);
    if  (!sstop && !indexInProcess) {
        addInfoScrollTimer=setTimeout('addInfoScrollTo('+fsl+')',addInfoScrollTimeout);
    }
}
function addInfoScrollToItem(id) {
    clearTimeout(addInfoScrollTimer2);
    var bt=$('InfoTitle_'+id).parentNode;
    var pos=Number(bt.getAttribute('pos'));
    var wW=getWindowW();
    var fsl=pos*bt.offsetWidth+wW*(0.15-0.381);
    var curScroll=-$('BlockInfo').offsetLeft;
    if (fsl<0) { fsl=0; }
    var sl=0;
    var f=false;
    if (curScroll > fsl) {
        if (curScroll-addInfoScrollStep > fsl) { 
            sl= curScroll-addInfoScrollStep;
            f=true;
        }
        else {
            sl=fsl;
        }
    }
    else if (curScroll < fsl) {
        if (curScroll+addInfoScrollStep < fsl) { 
            sl= curScroll+addInfoScrollStep;
            f=true;
        }
        else {
            sl=fsl;
        }
    }
    $('BlockInfo').style.left=(-sl)+'px';
    //alert('addInfoScrollToItem '+id);
    if (addInfoShowProcess || addInfoHideProcess || f) {
        addInfoScrollTimer2=setTimeout('addInfoScrollToItem("'+id+'")',addInfoScrollTimeout);
    }
}
/* <<<<< для показа дополнительной инфы */

/* >>>> для FAQ */
var faqInProcess=false;
var faqStep=10;
var faqTimeout=10;
function faqSet(id) {
    if ($('FaqItem'+id).className.indexOf('faq-opened')!=-1) {
        faqClose(id,true);
    }
    else {
        faqOpen(id,true);
    }
}
function faqOpen(id,f) {
    var sheet=stylesheet();
    if (f) {
        $('FaqItemAnswer'+id).parentNode.style.height='0px';
        $('FaqItemAnswer'+id).parentNode.style.overflow='hidden';
        $('FaqItem'+id).className='faq-item faq-opened';
    }
    var stop=false;
    var nH=$('FaqItemAnswer'+id).parentNode.offsetHeight+faqStep - 11; // - padding
    if (nH >= $('FaqItemAnswer'+id).offsetHeight) {
        stop=true;
    }
    if (!stop) {
        $('FaqItemAnswer'+id).parentNode.style.height=nH+'px';
        setTimeout('faqOpen('+id+',false)',faqTimeout);
    }
    else {
        $('FaqItemAnswer'+id).parentNode.style.height='';
        $('FaqItemAnswer'+id).parentNode.style.overflow='';
    }
    
    sheet[9].style.height=$('BlockHelp').offsetHeight+'px';
}
function faqClose(id,f) {
    var sheet=stylesheet();
    if (f) {
        $('FaqItemAnswer'+id).parentNode.style.height=($('FaqItemAnswer'+id).parentNode.offsetHeight - 11)+'px';
        $('FaqItemAnswer'+id).parentNode.style.overflow='hidden';
    }
    var stop=false;
    var nH=$('FaqItemAnswer'+id).parentNode.offsetHeight-faqStep - 11; // - padding
    if (nH <= 0) {
        stop=true;
    }
    if (!stop) {
        $('FaqItemAnswer'+id).parentNode.style.height=nH+'px';
        setTimeout('faqClose('+id+',false)',faqTimeout);
    }
    else {
        $('FaqItem'+id).className='faq-item';
        $('FaqItemAnswer'+id).parentNode.style.height='';
        $('FaqItemAnswer'+id).parentNode.style.overflow='';
    }
    
    sheet[9].style.height=$('BlockHelp').offsetHeight+'px';
}

/* <<<< для FAQ */

/* >>>>> для показа контактов */
var contactsStep=40;
var contactsTimeout=10;
var contactsTimer=0;
var contactsInProcess=false;
var contactsShowProcess=false;
var contactsHideProcess=false;
var contactsCurrentBlock='';
var contactsOpenBlock='';
/**
 * наполняет контакты недостающей информацией
 * @return
 */
function contactsSetContent() {
    if(typeof(ContactsContent)=='undefiled') { return; }
    for (b_i in ContactsContent.blocks) {
        if (typeof(ContactsContent.blocks[b_i])=='object') {
            $('ContactsTitle_'+b_i).innerHTML=ContactsContent.blocks[b_i].title;
            $('ContactsDetiles_'+b_i).innerHTML=ContactsContent.blocks[b_i].text;
        }
    }
}
function contactsOpen(block) {
    if (contactsShowProcess || contactsHideProcess) { return; }
    
    var locationPath=window.location.pathname;
    if (locationPath.lastIndexOf('/')!=locationPath.length-1) {
        locationPath+='/';
    }
    var hashBlock=block;
    if ($('ContactsDetiles_'+block).style.display=='') {
        hashBlock='';
    }
    if (locationPath!='/help/'+HelpType+'/') {
        window.location='/help/'+HelpType+'/#'+(hashBlock?(hashBlock):'');
        return;
    }
    else {
        window.location.hash='#'+(hashBlock?(hashBlock):'');
    }
    contactsSet(block);
}
function contactsSet(id) {
    if (contactsShowProcess || contactsHideProcess) { return; }
    if ($('ContactsDetiles_'+id)) {
        if ($('ContactsDetiles_'+id).style.display=='') {
            contactsHide(id,true);
            contactsCurrentBlock='';
            contactsScrollTo(0);
        }
        else {
            if (contactsCurrentBlock=='') {
                contactsShow(id,true);
            }
            else {
                contactsHide(contactsCurrentBlock,true);
                contactsShow(id,true);
            }
            contactsCurrentBlock=id;
            contactsScrollToItem(id);
        }
    }
}
function getPreDelim(id) {
    var res=$('ContactsTitle_'+id).parentNode.previousSibling;
    if (!res) { return false; }
    if (res.nodeType!=1) { res=res.previousSibling; }
    if (!res) { return false; }
    res=res.previousSibling;
    if (!res) { return false; }
    if (res.nodeType!=1) { res=res.previousSibling; }
    return res;
}
function contactsShow(id,f) {
    var sheet=stylesheet();
    if (f) {
        contactsShowProcess=true;
        $('ContactsDetiles_'+id).style.overflow='hidden';
        $('ContactsDetiles_'+id).style.width='0px';
        $('ContactsDetiles_'+id).style.display='';
        $('ContactsTitle_'+id).className='selected';
        sheet[9].style.height=$('BlockHelp').offsetHeight+'px';
        
        sheet[24].style.width=($('BlockHelp').offsetWidth+$('ContactsDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth)+'px';
    }
    var childW=$('ContactsDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth;
    var parentW=$('ContactsDetiles_'+id).offsetWidth;
    var stop_s=false;
    parentW+=contactsStep; 
    /*if ($('ContactsDelim_'+id)) {
        var nW=$('ContactsDelim_'+id).offsetWidth-contactsStep/2;
        if (nW <= 1) { nW=1; }
        $('ContactsDelim_'+id).style.width=nW+'px';
    }
    var pred=getPreDelim(id);
    if (pred) {
        var nW=pred.offsetWidth-contactsStep/2;
        if (nW <= 1) { nW=1; }
        pred.style.width=nW+'px';
    }*/
    if (parentW >= childW) { 
        stop_s=true;
    }
    if (!stop_s) {
        $('ContactsDetiles_'+id).style.width=parentW+'px';
        setTimeout('contactsShow(\''+id+'\',false)',contactsTimeout);
    }
    else {
        contactsShowProcess=false;
        contactsOpenBlock='';
        
        setTitle(ContactsContent.blocks[contactsCurrentBlock].head_title);
        
        $('ContactsDetiles_'+id).style.width='';
        $('ContactsDetiles_'+id).style.overflow='';
    }
}
function contactsHide(id,f) {
    var sheet=stylesheet();
    var childW=$('ContactsDetiles_'+id).getElementsByTagName('div').item(0).offsetWidth;
    if (f) {
        contactsHideProcess=true;
        $('ContactsDetiles_'+id).style.overflow='hidden';
        $('ContactsDetiles_'+id).style.width=childW+'px';
        $('ContactsDetiles_'+id).style.display='';
        $('ContactsTitle_'+id).className='';
    }
    var parentW=$('ContactsDetiles_'+id).offsetWidth;
    var stop_h=false;
    parentW-=contactsStep; 
    var ff=true;
    var ds=0;
    /*if ($('ContactsDelim_'+id)) {
        var nW=$('ContactsDelim_'+id).offsetWidth+contactsStep/2;
        if (nW >= $('ContactsDelim_'+id).firstChild.offsetWidth) {
            $('ContactsDelim_'+id).style.width=''; 
        }
        else { 
            $('ContactsDelim_'+id).style.width=nW+'px'; 
            ff=false; 
        }
    }
    var pred=getPreDelim(id);
    if (pred) {
        var nW=pred.offsetWidth+contactsStep/2;
        if (nW >= pred.firstChild.offsetWidth) { 
            pred.style.width=''; 
        }
        else { 
            pred.style.width=nW+'px'; 
            ff=false; 
        }
    }*/
    if (parentW <= 0) { 
        stop_h=true;
    }
    if (!stop_h) {
        sheet[24].style.width=($('BlockHelp').offsetWidth-((ff)?contactsStep:0))+'px';
        $('ContactsDetiles_'+id).style.width=parentW+'px';
        setTimeout('contactsHide(\''+id+'\',false)',contactsTimeout);
    }
    else {
        contactsHideProcess=false;
        var cw=$('BlockHelp').offsetWidth-$('BlockHelpInner').offsetWidth;
        var divs=$('BlockHelpInner').childNodes;
        for (var i=0;i<divs.length;i++) {
            if (divs[i].nodeName.toLowerCase() == 'div') {
                if (divs[i].className.indexOf('column')!=-1) {
                    cw+=divs[i].offsetWidth;
                }
            }
        }
        $('ContactsDetiles_'+id).style.display='none';
        $('ContactsDetiles_'+id).style.width='';
        $('ContactsDetiles_'+id).style.overflow='';
        sheet[9].style.height=$('BlockHelp').offsetHeight+'px';
        // пересчитать окончательный размер контента
        sheet[24].style.width=cw+'px';
        if (contactsOpenBlock=='') {
            
        }
        else {
            contactsSet(contactsOpenBlock);
        }
        if (contactsCurrentBlock=='') {
            setTitle(ContactsContent.title);
        }
    }
    
}
function contactsGoTo(id) {
    if (contactsShowProcess || contactsHideProcess) { return; }
    if ($('ContactsDetiles_'+id)) {
        if ($('ContactsDetiles_'+id).style.display=='') {
            // отцентрировать показ на развернутый пункт
            var wW=getWindowW();
            contactsScrollTo($('ContactsDetiles_'+id).offsetLeft-wW*0.325);//325 | 381
            contactsCurrentBlock=id;
        }
        else {
            contactsSet(id);
        }
    }
}

var contactsScrollStep=18;
var contactsScrollTimeout=10;
var contactsScrollTimer=0;
var contactsScrollTimer2=0;
function contactsScrollTo(fsl) {
    clearTimeout(contactsScrollTimer);
    //var curScroll=getScrollBody().scrollLeft; // для страницы со скролом раскомментировать
    //var curScroll=$('Container').scrollLeft; // для страницы со скролом закомментировать
    var curScroll=-$('BlockHelp').offsetLeft; // для страницы со скролом закомментировать
    if (fsl<0) { fsl=0; }
    var sstop=true;
    var sl=0;
    if (curScroll > fsl) {
        if (curScroll-contactsScrollStep > fsl) { 
            sl= curScroll-contactsScrollStep;
            sstop=false;
        }
        else {
            sl=fsl;
        }
    }
    else if (curScroll < fsl) {
        if (curScroll+contactsScrollStep < fsl) { 
            sl= curScroll+contactsScrollStep;
            sstop=false;
        }
        else {
            sl=fsl;
        }
    }
    //getScrollBody().scrollLeft=sl; // для страницы со скролом раскомментировать
    //$('Container').scrollLeft=sl; // для страницы со скролом закомментировать
    $('BlockHelp').style.left=(-sl)+'px'; // для страницы со скролом закомментировать
    if  (!sstop) {
        contactsScrollTimer=setTimeout('contactsScrollTo('+fsl+')',contactsScrollTimeout);
    }
}
function contactsScrollToItem(id) {
    clearTimeout(contactsScrollTimer2);
    var bt=$('ContactsTitle_'+id).parentNode;
    var pos=Number(bt.getAttribute('pos'));
    var wW=getWindowW();
    //var fsl=pos*bt.offsetWidth+wW*(0.15-0.325);//+(pos-1)*0.234*wW;
    var fsl=pos*bt.offsetWidth+wW*(0.15-0.381);
    //if (pos>2) { fsl+=(pos-2)*0.082*wW; }
    var curScroll=-$('BlockHelp').offsetLeft;
    if (fsl<0) { fsl=0; }
    var sl=0;
    var f=false;
    if (curScroll > fsl) {
        if (curScroll-contactsScrollStep > fsl) { 
            sl= curScroll-contactsScrollStep;
            f=true;
        }
        else {
            sl=fsl;
        }
    }
    else if (curScroll < fsl) {
        if (curScroll+contactsScrollStep < fsl) { 
            sl= curScroll+contactsScrollStep;
            f=true;
        }
        else {
            sl=fsl;
        }
    }
    $('BlockHelp').style.left=(-sl)+'px';
    if (contactsShowProcess || contactsHideProcess || f) {
        contactsScrollTimer2=setTimeout('contactsScrollToItem("'+id+'")',contactsScrollTimeout);
    }
}
/* <<<<< для показа контактов */

/* >>>>> для обработки якорей */
var hashParsed=false;
var hashCurrent=false;
/**
 * выполняет проверку якоря и обработку данных
 * @return
 */
function hashParse() {
    var locationPath=window.location.pathname;
    if (locationPath.lastIndexOf('/')!=locationPath.length-1) {
        locationPath+='/';
    }
    
    var locationHash=window.location.hash; 
    if (!locationHash) { locationHash='#'; }
    
    if (window.location.href.indexOf('#')!=-1 && hashCurrent!==window.location.hash) {
        //alert(1);
        //return;
        params=locationHash.split('/');
        switch (params[0]) {
            case '#about': {
                
                if (locationPath!='/') { break; }
                if (addInfoShowProcess || addInfoHideProcess) { break; }
                if (addInfoArticleInProcess) { break; }
                
                if (mapOpened) { mapClose(); }
                if (clientsOpened) { clientsClose(); }
                
                var block=params[1]; var blockFound=false;
                var article=params[2]; var articleFound=false;
                indexShowBlock('Info');
                if (block && IndexContent.blocks[block]) {
                    blockFound=true;
                    if (article && IndexContent.blocks[block].articles[article]) {
                        articleFound=true;
                    }
                }
                if (articleFound) {
                    if (addInfoCurrentArticle!=article) {
                        addInfoArticleSet(block,article)
                    }
                }
                else if (blockFound) {
                    if (addInfoCurrentBlock==block && addInfoCurrentArticle!='') {
                        addInfoArticleSet(block,addInfoCurrentArticle);
                    }
                    else if (addInfoCurrentBlock!=block) {
                        addInfoSet(block);
                    }
                    else {
                        addInfoGoTo(block);
                    }
                }
                else if (addInfoCurrentBlock) {
                    addInfoSet(addInfoCurrentBlock);
                }
                
                if (firstExec) { hashParsed=true; }
                break;
            }
            case '#phone':
            case '#mail':
            case '#address': {
                
                if (locationPath!='/help/contacts/') { break; }
                if (contactsShowProcess || contactsHideProcess) { break; }
                
                if (mapOpened) { mapClose(); }
                if (clientsOpened) { clientsClose(); }
                
                var block=params[0].substr(1);
                if (contactsCurrentBlock!=block) {
                    contactsSet(block);
                }
                else {
                    contactsGoTo(block);
                }
                                 
                if (firstExec) { hashParsed=true; }
                break;
            }
            case '#beginner':
            case '#middle':
            case '#individual': {
                
                if (locationPath!='/help/price/') { break; }
                if (contactsShowProcess || contactsHideProcess) { break; }
                
                if (mapOpened) { mapClose(); }
                if (clientsOpened) { clientsClose(); }
                
                var block=params[0].substr(1);
                if (contactsCurrentBlock!=block) {
                    contactsSet(block);
                }
                else {
                    contactsGoTo(block);
                }
                                 
                if (firstExec) { hashParsed=true; }
                break;
            }
            case '#map': {
                mapSave(); mapOpen();
                break;
            }
            case '#account': {
                clientsSave(); clientsOpen();
                break;
            }
            case '#': {
                if (mapOpened) { mapClose(); }
                if (clientsOpened) { clientsClose(); }
                
                if (locationPath=='/') { 
                    if (!indexInProcess && !addInfoShowProcess && !addInfoHideProcess && !addInfoArticleInProcess) {
                        indexShowBlock('First'); 
                        if (firstExec) { hashParsed=true; }
                    }
                }
                else if (locationPath=='/help/'+HelpType+'/') {
                    if (contactsCurrentBlock!='') {
                        contactsSet(contactsCurrentBlock);
                    }
                    if (firstExec) { hashParsed=true; } 
                }
                break;
            }
        }
    }
    else {
        var mapPage=(locationPath.indexOf('/map/')==0) || locationHash=='#map';
        var clientsPage=(locationPath.indexOf('/account/')==0) || locationHash=='#account';
        if (window.location.href.indexOf('#')==-1 && !mapPage && mapOpened) {
            mapClose(); 
        }
        else if (window.location.href.indexOf('#')==-1 && !clientsPage && clientsOpened) {
            clientsClose(); 
        }
        else if (locationPath=='/' && window.location.href.indexOf('#')==-1) {
            if (!indexInProcess && !addInfoShowProcess && !addInfoHideProcess && indexActiveBlock!='First' && indexActiveBlock!='') { 
                indexShowBlock('First'); 
            }
        }
    }
    hashCurrent=window.location.hash;
    setTimeout('hashParse()',50);
    firstExec=false;
}
/* <<<<< для обработки якорей */

/* >>>>> для смены режимов первой страницы */
var indexActiveBlock='';
var indexInProcess=false;
var indexTurnStep=40;
var indexTurnTimeout=5;
var indexCurStep=1;
var indexFirstReshow=false;
/**
 * наполняет первую странцу недостающей информацией
 * @return
 */
function indexSetContent() {
    if(typeof(IndexContent)=='undefiled') { return; }
    //$('IndexOrder').innerHTML=IndexContent.index_order;
    $('IndexShort').innerHTML=IndexContent.index_short;
    $('BlockInfoInnerTitle').innerHTML=IndexContent.info;
    $('BlockFirstInner').innerHTML=IndexContent.first;
    for (b_i in IndexContent.blocks) {
        if (typeof(IndexContent.blocks[b_i])=='object') {
            $('InfoTitle_'+b_i).innerHTML=IndexContent.blocks[b_i].title;
            for (a_i in IndexContent.blocks[b_i].articles) {
                if (typeof(IndexContent.blocks[b_i].articles[a_i])=='object') {
                    $('InfoArticle_'+b_i+'__'+a_i).innerHTML=IndexContent.blocks[b_i].articles[a_i].text;
                }
            }
        }
    }
}
/**
 * открытие раздела с помощью якоря
 * @param key - имя раздела
 * @return
 */
function indexOpenBlock(key) {
    if (indexActiveBlock==key || indexInProcess) { return; }
    
    var pagePath=window.location.pathname;
    var hashKey='';
    switch (key) {
        case 'First': hashKey=''; break;
        case 'Info': hashKey='about'; break;
    }
    if (pagePath!='/') {
        window.location='/#'+hashKey;
        return;
    }
    else {
        window.location.hash='#'+hashKey;
    }
    indexShowBlock(key);
}
/**
 * Осуществляет показ блоков первой страницы
 * @param key - блок для показа
 * @return
 */
function indexShowBlock(key) {
    if (hashParsed) { hashParsed=false; return; }
    var sheet=stylesheet();
    if (indexActiveBlock==key || indexInProcess) { return; }
    switch (key) {
        case 'First': {
            if (indexActiveBlock=='') { 
                $('BlockFirst').style.left='0%';
                $('BlockInfo').style.left='100%';
                $('IndexShort').style.visibility='hidden';
                $('IndexOrder').style.visibility='hidden';
                $('PriceLink').style.visibility='hidden';
                indexCurStep=1;
            }
            else {
                if (addInfoCurrentBlock) {
                    indexFirstReshow=true;
                    addInfoSet(addInfoCurrentBlock);
                    return;
                }
                else {
                    indexFirstReshow=false
                    indexTurnRight(true);
                }
                setTitle(IndexContent.first_title);
            }
            
            break;
        }
        case 'Info': {
            if (indexActiveBlock=='') { 
                $('BlockFirst').style.left='-100%';
                $('BlockInfo').style.left='0%';
                $('IndexShort').style.visibility='visible';
                $('IndexOrder').style.visibility='visible';
                $('PriceLink').style.visibility='visible';
                indexCurStep=2;
            }
            else {
                indexTurnLeft(true);
                setTitle(IndexContent.info_title);
            }
            
            break;
        }
    }
    if (indexActiveBlock=='') {
        //$('Container').style.width=$('Block'+key).offsetWidth+'px';
        $('BlockFirst').style.position=$('BlockInfo').style.position='';
        sheet[9].style.height=$('Block'+key).offsetHeight+'px';
    }
    indexActiveBlock=key;
}
function indexTurnRight(f) {
    var sheet=stylesheet();
    if (f) {
        indexInProcess=true;
        // сделать размер рамки под первый блок
        // ширина первого блока точно не больше чем второго
        sheet[9].style.width=$('BlockFirst').offsetWidth+'px';
        $('IndexShort').style.visibility='hidden';
        $('IndexOrder').style.visibility='hidden';
        $('PriceLink').style.visibility='hidden';
    }
    var cLeft=$('BlockFirst').offsetLeft;
    
    var olF=$('BlockFirst').offsetLeft;
    var olI=$('BlockInfo').offsetLeft;
    
    cLeft+=indexTurnStep;
    var stop=false;
    if (cLeft>=0) { stop=true; }
    if (!stop) {
        $('BlockInfo').style.left=($('BlockInfo').offsetLeft+indexTurnStep)+'px';
        $('BlockFirst').style.left=cLeft+'px';
        
        var nlF=$('BlockFirst').offsetLeft;
        var nlI=$('BlockInfo').offsetLeft;
        
        //alert('F: '+olF+' -> '+nlF+' ('+(nlF-olF)+')'+'\n'+'I: '+olI+' -> '+nlI+' ('+(nlI-olI)+')');
        
        setTimeout('indexTurnRight(false)',indexTurnTimeout);
    }
    else {
        indexInProcess=false;
        indexCurStep=1;
        // заканчиваем двигать
        $('BlockInfo').style.left='100%';
        $('BlockFirst').style.left='0%';
        sheet[9].style.height=$('BlockFirst').offsetHeight+'px';
    }
}
function indexTurnLeft(f) {
    var sheet=stylesheet();
    if (f) {
        indexInProcess=true;
        // сделать размер рамки под второй блок
        // высота второго блока точно больше чем первого
        sheet[9].style.height=$('BlockInfo').offsetHeight+'px';
    }
    var cLeft=$('BlockInfo').offsetLeft;
    cLeft-=indexTurnStep;
    var stop=false;
    if (cLeft<=0) { stop=true; }
    if (!stop) {
        $('BlockFirst').style.left=($('BlockFirst').offsetLeft-indexTurnStep)+'px';
        $('BlockInfo').style.left=cLeft+'px';
        setTimeout('indexTurnLeft(false)',indexTurnTimeout);
    }
    else {
        indexInProcess=false;
        indexCurStep=2;
        // заканчиваем двигать
        $('BlockFirst').style.left='-100%';
        $('BlockInfo').style.left='0%';
        sheet[9].style.width=$('BlockInfo').offsetWidth+'px';
        $('IndexShort').style.visibility='visible';
        $('IndexOrder').style.visibility='visible';
        $('PriceLink').style.visibility='visible';
    }
}
/* <<<<< для смены режимов первой страницы */

/* >>>>> для карты */
var mapOpened;//=false;
var mapStep=40;
var mapTimer=0;
var mapTimeout=7;
var mapInProcess=false;
var mapBackPath='';
var mapBackTitle='';
function mapSetOpen() {
    if (mapInProcess) { return; }
    
    mapSave();
    window.location.hash="#map";
    
    mapOpen();
}
function mapSave() {
    mapBackPath=(window.location.hash!='#map')?window.location.hash:'#';
    mapBackTitle=document.title.replace(new RegExp('(( \\| )|)'+headTitleBase.replace(/\./,'\\.'),'i'), '');   
}
function mapOpen() {
    if (mapInProcess) { return; }
    
    $('Map').style.visibility='hidden';
    $('Map').style.display='';
    $('MapInner').style.width=($('Map').offsetWidth-25)+'px';
    //$('MapInner').style.cssFloat='left';
    $('Map').style.overflow='hidden';
    $('Map').style.minWidth='0px';
    $('Map').style.width='0px';
    $('Map').style.visibility='';
    getScrollBody().scrollLeft=0;
    mapInProcess=true;
    mapProcess('open');
}
function mapOpenDone() {
    //$('MapInner').style.cssFloat='';
    $('MapInner').style.width='';
    $('Map').style.overflow='';
    $('Map').style.minWidth='';
    $('Map').style.width='';
    $('Container').style.display='none';
    mapInProcess=false;
    mapOpened=true;
    setTitle(headTitles.map);
}
function mapSetClose() {
    if (mapInProcess) { return; }
    
    if (mapBackPath) { window.location.hash=mapBackPath; }
    else { window.location.hash='#'; }
    mapBackPath='';
    
    mapClose();
}
function mapClose() {
    if (mapInProcess) { return; }
    
    $('Container').style.display='';
    $('MapInner').style.width=($('Map').offsetWidth-25)+'px';
    //$('MapInner').style.cssFloat='left';
    $('Map').style.overflow='hidden';
    $('Map').style.minWidth='0px';
    $('Map').style.width=$('Map').offsetWidth+'px';
    mapOpened=false;
    mapInProcess=true;
    mapProcess('close');
}
function mapCloseDone() {
    $('Map').style.display='none';
    //$('MapInner').style.cssFloat='';
    $('MapInner').style.width='';
    $('Map').style.overflow='';
    $('Map').style.minWidth='';
    $('Map').style.width='';
    mapInProcess=false;
    setTitle(mapBackTitle);
    mapBackTitle='';
}
function mapProcess(type) {
    var nW=0;
    switch (type) {
        case 'open': {
            nW=$('Map').offsetWidth + clientsStep;
            if (nW >= $('MapInner').offsetWidth) {
                mapOpenDone();
                return;
            }
            
            break;
        }
        case 'close': {
            nW=$('Map').offsetWidth - clientsStep;
            if (nW <= 0) {
                mapCloseDone();
                return;
            }
            break;
        }
    }
    $('Map').style.width=nW+'px';
    mapTimer=setTimeout("mapProcess('"+type+"')",mapTimeout);
}
/* <<<<< для карты */

/* >>>>> для форм клиентов */
var clientsOpened=false;
var clientsStep=40;
var clientsTimer=0;
var clientsTimeout=7;
var clientsInProcess=false;
var clientsForms=new Array();
var clientsBackPath='';
var clientsBackTitle='';
function clientsPasswords(list,flag) {
    var itype=(flag)?'password':'text';
    for (var i=0;i<list.length;i++) {
        $(list[i]).type=itype;
    }
}
function clientsSetOpen() {
    if (clientsInProcess) { return; }
    
    clientsSave();
    window.location.hash="#account";
    
    clientsOpen();
}
function clientsSave() {
    clientsBackPath=(window.location.hash!='#account')?window.location.hash:'#';
    clientsBackTitle=document.title.replace(new RegExp('(( \\| )|)'+headTitleBase.replace(/\./,'\\.'),'i'), '');
}
function clientsOpen() {
    if (clientsInProcess) { return; }
    $('Clients').style.visibility='hidden';
    $('Clients').style.display='';
    $('ClientsInner').style.width=($('Clients').offsetWidth-8)+'px';
    $('ClientsInner').style.cssFloat='right';
    $('Clients').style.overflow='hidden';
    $('Clients').style.minWidth='0px';
    $('Clients').style.width='0px';
    $('Clients').style.visibility='';
    getScrollBody().scrollLeft=0;
    clientsInProcess=true;
    clientsProcess('open');
}
function clientsOpenDone() {
    $('ClientsInner').style.cssFloat='';
    $('ClientsInner').style.width='';
    $('Clients').style.overflow='';
    $('Clients').style.minWidth='';
    $('Clients').style.width='';
    $('Container').style.display='none';
    clientsInProcess=false;
    clientsOpened=true;
    setTitle(headTitles.clients);
}
function clientsSetClose() {
    if (clientsInProcess) { return; }
    
    if (clientsBackPath) { window.location.hash=clientsBackPath; }
    else { window.location.hash='#'; }
    clientsBackPath='';
    
    clientsClose();
}
function clientsClose() {
    if (clientsInProcess) { return; }
    $('Container').style.display='';
    $('ClientsInner').style.width=($('Clients').offsetWidth-8)+'px';
    $('ClientsInner').style.cssFloat='right';
    $('Clients').style.overflow='hidden';
    $('Clients').style.minWidth='0px';
    $('Clients').style.width=$('Clients').offsetWidth+'px';
    clientsOpened=false;
    clientsInProcess=true;
    clientsProcess('close');
}
function clientsCloseDone() {
    $('Clients').style.display='none';
    $('ClientsInner').style.cssFloat='';
    $('ClientsInner').style.width='';
    $('Clients').style.overflow='';
    $('Clients').style.minWidth='';
    $('Clients').style.width='';
    clientsInProcess=false;
    setTitle(clientsBackTitle);
    clientsBackTitle='';
}
function clientsProcess(type) {
    var nW=0;
    switch (type) {
        case 'open': {
            nW=$('Clients').offsetWidth + clientsStep;
            if (nW >= $('ClientsInner').offsetWidth) {
                clientsOpenDone();
                return;
            }
            
            break;
        }
        case 'close': {
            nW=$('Clients').offsetWidth - clientsStep;
            if (nW <= 0) {
                clientsCloseDone();
                return;
            }
            break;
        }
    }
    $('Clients').style.width=nW+'px';
    clientsTimer=setTimeout("clientsProcess('"+type+"')",clientsTimeout);
}
function clientsSelectForm(formName,ev) {
    if (ev && ($('ClientsMenu').className.indexOf('disabled')!=-1)) { return false; }
    for (var i=0;i<clientsForms.length;i++) {
        if ($('Link'+clientsForms[i])) {
            $('Link'+clientsForms[i]).className='';
        }
        $('Form'+clientsForms[i]).style.display='none';
    }
    if ($('Link'+formName)) {
        $('Link'+formName).className='selected';
    }
    $('Form'+formName).style.display='';
    return false;
}
function clientsFormSizer(wH) {
    for (var i=0;i<clientsForms.length;i++) {
        if ($('Form'+clientsForms[i]).style.display=='') {
            var pT=(wH-$('Form'+clientsForms[i]).offsetHeight-225)/2;
            if (pT<0) { pT=''; } else { pT+='px'; }
            $('Form'+clientsForms[i]).style.top=pT;
        }
    }
}
/* <<<<< для клиентов */

/* >>>>> для сообщений системы */
function msgDoneCLose() {
    var p=$('MsgDone');
    p.parentNode.removeChild(p);
    $('ClientsMenu').className="menu";
}
function msgClientsDoneCLose() {
    var p=$('MsgClientsDone');
    p.parentNode.removeChild(p);
    $('ClientsMenu').className="menu";
}
/* <<<<< для сообщений системы */

/* >>>>> изменение размеров областей страницы */
var sizeLast={
    'wW': 0,
    'wH': 0,
    'dW': 0,
    'dH': 0,
    'sW': 0,
    'sH': 0,
    'sL': 0,
    'sT': 0,
    'dwW': 0,
    'dwH': 0,
    'ddW': 0,
    'ddH': 0,
    'dsW': 0,
    'dsH': 0,
    'dsL': 0,
    'dsT': 0
};
var sizeCur = {
    'wW': 0,
    'wH': 0,
    'sW': 0,
    'sH': 0
}
var sizeCount=0;
var sizeFirstRun=true;
/**
 * проверка наличия изменений в размерах
 * @return bool
 */
function sizeCheck() {
    var retflag=false;
    sizeLast.dwW=getWindowW()-sizeLast.wW; sizeLast.wW=getWindowW();
    sizeLast.dwH=getWindowH()-sizeLast.wH; sizeLast.wH=getWindowH();
    sizeLast.ddW=getDocumentW()-sizeLast.dW; sizeLast.dW=getDocumentW();
    sizeLast.ddH=getDocumentH()-sizeLast.dH; sizeLast.dH=getDocumentH();
    sizeLast.dsW=getScrollW()-sizeLast.sW; sizeLast.sW=getScrollW();
    sizeLast.dsH=getScrollH()-sizeLast.sH; sizeLast.sH=getScrollH();
    sizeLast.dsL=getScrollX()-sizeLast.sL; sizeLast.sL=getScrollX();
    sizeLast.dsT=getScrollY()-sizeLast.sT; sizeLast.sT=getScrollY();
    
    if (
            sizeLast.dwW!=0 || sizeLast.dwH!=0 ||
            sizeLast.ddW!=0 || sizeLast.ddH!=0 ||
            sizeLast.dsW!=0 || sizeLast.dsH!=0
        ) {
        return true;
    }
    return false;
}
/**
 * осуществляет подгонку размеров элементов страницы
 * @return
 */
function sizeMake() {
    var sheet=stylesheet();
    var flag=sizeCheck();
    
    
    var wW=sizeCur.wW+sizeLast.dwW-20;
    var wH=sizeCur.wH+sizeLast.dwH;
    var cS=(sizeCur.wH < sizeCur.sH );
    var lS=(sizeLast.wH < sizeLast.dH );
    //if (lS) { wW-=20; }
    if (wW<850) { wW=850; }
    if (flag) {
        // сбрасываем параметры для варианта без JS - возможно сделать в отдельном куске
        sheet[10].style.position=''; // sheet[10] - карта 
        sheet[10].style.marginTop='';
        sheet[14].style.position=''; // sheet[10] - клиентское
        sheet[14].style.cssFloat='';
        //sheet[14].style.marginTop='';
        sheet[1].style.position=''; // sheet[10] - подвал
        //sheet[1].style.marginTop='';
        sheet[30].style.display='';
        
        // установить размеры для нужных элементов
        sheet[5].style.width=Math.floor(wW*(1-0.15*2)*0.33)+'px'; //(0.231+0.15)*wW=0.381*wW
        sheet[6].style.width=Math.floor(wW*0.50)+'px';
        sheet[6].style.paddingTop='100px';
        //sheet[4].style.width='';
        sheet[4].style.cssFloat='left';
        sheet[7].style.margin=sheet[8].style.margin='0 '+Math.floor(wW*0.15)+'px';
        sheet[13].style.margin='0 '+Math.floor(wW*0.15)+'px';
        sheet[13].style.width=Math.floor(wW*0.70)+'px';
        sheet[22].style.width=wW+'px';
        sheet[23].style.margin='0 '+Math.floor(wW*0.15)+'px';
        sheet[25].style.margin='0 '+Math.floor(wW*0.15)+'px';
        sheet[27].style.width=Math.floor(wW*(1-0.15*2)*0.33)+'px'; //(0.175+0.15)*wW=0.325*wW
        sheet[29].style.width=Math.floor(wW*(1-0.15*2)*0.12)+'px'; //(0.084+0.15)*wW=0.234*wW
        sheet[28].style.width=Math.floor(wW*0.50)+'px';
        sheet[28].style.paddingTop='100px';
        //sheet[26].style.width='';
        sheet[26].style.cssFloat='left';
        
        sheet[9].style.width=wW+'px'; // для страницы со скролом закомментировать
        sheet[9].style.marginBottom='100px'; 
        
        // корректно пересчитать размер области просмотра
        //$('Container').style.width=...
        if (true==PageIndex && !(addInfoShowProcess || addInfoHideProcess) && $('Container').style.display!='none') {
            sheet[2].style.width=wW+'px';
            var cw=$('BlockInfo').offsetWidth-$('BlockInfoInner').offsetWidth;
            var divs=$('BlockInfoInner').childNodes;
            for (var i=0;i<divs.length;i++) {
                if (divs[i].nodeName.toLowerCase() == 'div') {
                    if (divs[i].className.indexOf('column')!=-1) {
                        cw+=divs[i].offsetWidth;
                    }
                }
            }
            sheet[3].style.width=(cw)+'px';
            /*if (indexCurStep==1) { // для страницы со скролом раскомментировать
                sheet[9].style.width=$('BlockFirst').offsetWidth+'px';
            }
            else {
                sheet[9].style.width=$('BlockInfo').offsetWidth+'px';
            }*/
            
        }
        else if (true==PageOrder && $('Container').style.display!='none') {
            //sheet[9].style.width=(wW)+'px'; // для страницы со скролом раскомментировать
            sheet[9].style.height=$('BlockForm').offsetHeight+'px';
        }
        else if (true==PageHelp && $('Container').style.display!='none') {
            if (!$('ContactsBotLine')) {
                sheet[24].style.width=wW+'px';
                //sheet[9].style.width=(wW)+'px'; // для страницы со скролом раскомментировать
            }
            else if (!(contactsShowProcess || contactsHideProcess)) {
                var cw=$('BlockHelp').offsetWidth-$('BlockHelpInner').offsetWidth;
                var divs=$('BlockHelpInner').childNodes;
                for (var i=0;i<divs.length;i++) {
                    if (divs[i].nodeName.toLowerCase() == 'div') {
                        if (divs[i].className.indexOf('column')!=-1) {
                            cw+=divs[i].offsetWidth;
                        }
                    }
                }
                sheet[24].style.width=cw+'px';
                /*sheet[9].style.width=$('BlockHelp').offsetWidth+'px'; // для страницы со скролом раскомментировать */
            }
            sheet[9].style.height=$('BlockHelp').offsetHeight+'px';
        }
        
        /*sheet[9].style.width=wW+'px';*/
        sizeCount++;
        sizeCur.wW=sizeLast.wW;
        sizeCur.wH=sizeLast.wH;
        sizeCur.sW=sizeLast.sW;
        sizeCur.sH=sizeLast.sH;
    }
    
    
    var fT='';
    if ($('Map') && (mapOpened || sizeFirstRun)) {
        var mH=$('MapHeader').offsetHeight+$('MapContent').offsetHeight;
        mH=(mH < sizeLast.wH-100)?(sizeLast.wH-100):mH;
        //sheet[10].style.height=mH+'px';
        sheet[10].style.height='';
        sheet[11].style.height=(mH)+'px';
        //sheet[10].style.width=(wW+25)+'px';
        /* заменить на позиционирование футера */
        //$('Container').style.height=(mH-225)+'px';
        fT=(mH)+'px';
        //$('Container').style.width=(wW)+'px';
    }
    if($('Clients') && (clientsOpened || sizeFirstRun)) {
        var cH=$('ClientsHeader').offsetHeight+$('ClientsContent').offsetHeight;
        cH=(cH < sizeLast.wH-100)?(sizeLast.wH-100):cH;
        //sheet[14].style.height=cH+'px';
        sheet[14].style.height='';
        sheet[15].style.height=(cH-8)+'px';
        //sheet[14].style.width=(wW+20)+'px';
        //$('Container').style.height=(cH-225)+'px';
        fT=(cH)+'px';
        //$('Container').style.width=(wW)+'px';
    }
    
    clientsFormSizer(wH);
    
    if ($('MsgDone')) {
        $('MsgDone').style.height=($('Container').offsetHeight)+'px';
        $('MsgDone').style.left=sizeLast.sL+'px';
    }
    
    if ($('MsgClientsDone')) {
        $('MsgClientsDone').style.height=($('ClientsInner').offsetHeight-125-100)+'px';
    }
    
    if (!mapOpened && !clientsOpened && $('Container').style.display!='none') {
        var pH=$('Container').offsetHeight+125+100;
        //$('Container').style.height='';
        //$('Container').style.width='';
        if (wW < $('Container').offsetWidth) { wH-=20; }
        fT=((pH<wH?wH:pH)-100)+'px';
    }
    sheet[1].style.top=fT;
    sheet[1].style.left=sizeLast.sL+'px';
    
    
    sizeFirstRun=false;
}
/* <<<<< изменение размеров областей страницы */

