﻿var _taffh =
{
  i: null,
  lastHeight: 0,
  iframes: [null, null],
  iDisableTime: 0,
  path: "",

  setForceHeight: function (height, iSec) {
    this.iDisableTime = iSec;
    this.setHeight(height);
  },

  setHeight: function (height) {
    for (var i = 0; i < 2; i++) {
      if (this.iframes[i]) this.iframes[i].parentNode.removeChild(this.iframes[i]);
      var fr = document.createElement("IFRAME");
      fr.style.display = "none";
      this.iframes[i] = fr;
      document.body.appendChild(this.iframes[i]);
      fr.src = "http://" + (i ? "www." : "") + this.path + height;
    }
  },

  onLoad: function () {
    this.checkHeight();
    this.i = window.setInterval(this.bind(this.checkHeight), 100);
  },

  checkHeight: function () {
    if (this.iDisableTime <= 0) {
      var h = this.getContainerHeight();
      if (this.lastHeight == h) return;
      this.setHeight(this.lastHeight = h);
    }
    else {
      this.iDisableTime -= 100;
    }
  },

  getContainerHeight: function () {
    return document.getElementById("body").offsetHeight + 15;
  },

  addEvent: function (o, t, h) {
    if (o.addEventListener) o.addEventListener(t, h, false);
    else if (o.attachEvent) o.attachEvent("on" + t, h);
  },

  bind: function (method) {
    var context = this, args = arguments;
    return function () { return method.apply(context, Array.prototype.slice.call(args, 1)); };
  },

  init: function (path) {
    this.path = path;
    this.addEvent(window, "load", this.bind(this.onLoad, true));
  }
};

if (window.name && window.name != undefined && window.name == "taff" && framePath && framePath != undefined && framePath != "") { _taffh.init(framePath); }
