window.onerror = function errorHandler() {
  return true;
}

if (typeof(domain_url) != 'undefined')
{    
    var __hc = {
      i: null,
      h: 0,
      iframes: [null, null],
      path: domain_url + '/mbframe.htm#', // путь до height.html
      setHeight: function(height) {
        var ifr,i;
        for (i=0;i<2;i++) {
          if (this.iframes[i]) this.iframes[i].parentNode.removeChild(this.iframes[i]);
          ifr = document.createElement('IFRAME');
          ifr.style.display = 'none';
          this.iframes[i] = ifr;
          document.body.appendChild(this.iframes[i]);
          ifr.src = 'http://' + (i ? 'www.' : '') + this.path + height;
        }
      },
      onLoad: function(full) {
        this.checkHeight();
        if (full) {
          this.i = window.setInterval(this.bind(this.checkHeight), 500);
        }
      },
      checkHeight: function() {
        var h = this.getDocHeight();
        if (this.h == h) return;
        this.h = h;
        this.setHeight(this.h);
      },
      getDocHeight: function() {
        return Math.ceil(($("#embeded-content").height()) / 30) * 30;
      },
      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(full) {
        this.addEvent(window, 'load', this.bind(this.onLoad, full));
      }
    };

    __hc.init(true);
}

$(document).ready(function() {
    $('.flash').slideDown('normal');
    window.setTimeout(function() { $('.flash').slideUp('normal'); }, 10000);

    $(".show-modal-dialog").click(function(eventObj){
        $(".modal-dialog").hide();
        var dialog = $("#" + $(this).attr("rel"));
        dialog.fadeIn('fast');       
       // dialog.css('top', ($(this).offset().top + dialog.offset().top) + 'px');
        
        return false;
    });

    $(".hide-modal-dialog").click(function(eventObj){
        $(".modal-dialog").fadeOut('fast');
        return false;
    });

    $(".search-form-link").click(function(eventObj){
        $(".search-body").slideToggle('fast');
        return false;
    });

    $(".show-hidden-box").click(function(eventObj){
        $("#" + $(this).attr("rel")).slideDown();

        $(".hide-hidden-box[rel='" + $(this).attr("rel") + "']").show();
        $(".show-hidden-box[rel='" + $(this).attr("rel") + "']").hide();
        return false;
    });

    $(".hide-hidden-box").click(function(eventObj){
        $("#" + $(this).attr("rel")).slideUp();
        $(".show-hidden-box[rel='" + $(this).attr("rel") + "']").show();
        $(".hide-hidden-box[rel='" + $(this).attr("rel") + "']").hide();
        return false;
    });            
});
