

function setWhiteHeight () {
  var pt = document.getElementById('panels');
  var wd = document.getElementById('white');
  var wd1 = document.getElementById('white1');  
  wd.style.height = (pt.clientHeight-20)+'px';
  wd1.style.height = (pt.clientHeight-20)+'px';
  //loadBlockedDates();
}

function calc (strr,param) {
  showResult(strr,param);
}

function showResult(val,param) {  
  var rd = document.getElementById('calcResult');
  rd.style.height = '0px';
  rd.innerHTML = val;
  rd.style.display = 'block';
  if(param==1){
  var h = 50;
  }else{
  var h = 40;
  }
  var timer = window.setInterval(
    function () {
      var ch = parseInt(rd.style.height)+4;
      rd.style.height = ch+'px';
        if (ch >= h) {
          window.clearInterval(timer);
        }
    },
    h
  );
}


function setMargins () {
  var conf = {maxM: 45, mainWidth: 1006, maxT: 72, minT: 26};
  var base = document.body.parentNode.clientWidth;
    if (base < conf.mainWidth) {
      document.body.style.width = conf.mainWidth+'px';
      document.getElementById('header').style.marginLeft = '0px';
      document.getElementById('main').style.marginLeft = '0px';
      document.getElementById('top-today').style.marginLeft = conf.minT+'px';
    }
    else if (base < conf.mainWidth+conf.maxM) {
      document.body.style.width = '100%';
      document.getElementById('header').style.marginLeft = (base-conf.mainWidth)+'px';
      document.getElementById('main').style.marginLeft = (base-conf.mainWidth)+'px';
      document.getElementById('top-today').style.marginLeft = (conf.minT+base-conf.mainWidth)+'px';
    }
    else {
      document.body.style.width = '100%';
      document.getElementById('header').style.marginLeft = conf.maxM+'px';
      document.getElementById('main').style.marginLeft = conf.maxM+'px';
      document.getElementById('top-today').style.marginLeft = conf.maxT+'px';
    }
}

function dateStatus (date, y, m, d) {
    if (date.getTime() < ((new Date()).getTime() - 1000*60*60*24)) {
      return true;
    }
    else if (blockDates && blockDates[y+'-'+(m+1)+'-'+d]) {
      return true;
    }
  return false;
}

function loadBlockedDates (arr) {
  //делаем тут что-то чтобы загрузить данные с сервера. в итоге получаем что-то вроде
  blockDates = arr;
}

function setupForm2 (el2,el) {
        var offsetTop = el.offsetTop,
            top = 0;
        window.onscroll = function () {
          var yOffs = typeof window.pageYOffset == 'undefined' ? document.documentElement.scrollTop : window.pageYOffset;
          top = yOffs-offsetTop > 0 ? yOffs-offsetTop : 0;
            if (el.parentNode.offsetHeight < top+el.offsetHeight+30) {
              top = el.parentNode.offsetHeight-(el.offsetHeight+30);
            }				
        }
        
        window.setInterval(function () {
          var cy = parseInt(el.style.top) ? parseInt(el.style.top) : 0;		  
          if (cy == top){
		   el2.style.top = (cy)+'px';
		   el.style.top = (cy)+'px';
		   return;
          }
          var dy = Math.round((top-cy)/2);
          el.style.top = (cy+dy)+'px';
		  el2.style.top = (cy+dy)+'px';
        }, 2);
      }
function setupForm (el) {
        var offsetTop = el.offsetTop,
            top = 0;
        window.onscroll = function () {
          var yOffs = typeof window.pageYOffset == 'undefined' ? document.documentElement.scrollTop : window.pageYOffset;
          top = yOffs-offsetTop > 0 ? yOffs-offsetTop : 0;
            if (el.parentNode.offsetHeight < top+el.offsetHeight+20) {
              top = el.parentNode.offsetHeight-(el.offsetHeight+20);
            }
        }
        
        window.setInterval(function () {
          var cy = parseInt(el.style.top) ? parseInt(el.style.top) : 0;
          if (cy == top) return;
          var dy = Math.round((top-cy)/2);
          el.style.top = (cy+dy)+'px';
        }, 2);
      }



window.onresize = setMargins;