$(document).ready(function() {
  var error_el = $('div.error_holder');
  if(error_el.length > 0) {
    var reqHeight = $(error_el).height();
    var showTime = 10000;
    if(reqHeight >= 70) {
      $(error_el).css('top', '0px');
      $(error_el).css('left', '450px');
      $(error_el).css('width', '300px');
      $(error_el).css('text-align', 'left');
      error_el.children('div.close').css('display', 'block');
      showTime = 600000;
    } else {
      reqHeight += -32;
    }
    $.fn.wait = function(time, type) {
      time = time || showTime;
      type = type || "fx";
      return this.queue(type, function() {
        var self = this;
        setTimeout(function() {
          $(self).dequeue();
        }, time);
      });
    };
    function runIt() {
      $(error_el).wait()
                 .slideUp();
    }
    $(error_el).show();
    runIt();
    error_el.children('div.close').click(function(event) {
      $(error_el).hide();
    });
  }
});

function notice(type, message) {
  var ui_el = $('div.ui_notices:first');
  ui_el.children().remove();
  ui_el.append('<div style="display:none;"></div>');
  var notice_el = ui_el.children();
  notice_el.attr('class', 'error_holder ' + type).css('text-align', 'center').html('<p>' + message + '</p>');
  $.fn.wait = function(time, type) {
    time = time || 5000;
    type = type || "fx";
    return this.queue(type, function() {
      var self = this;
      setTimeout(function() {
        $(self).dequeue();
      }, time);
    });
  };
  function runIt() {
    $(notice_el).slideDown()
                .wait()
                .slideUp();
  }
  runIt();
}