function notifier () {
  var myWindows = new Array();
  
  this.display = display;
  this.kill = kill;
  
  function display (id,text) {
    wind = new notifyWindow();
    var thisWind = new Array();
    thisWind['id'] = id;
    thisWind['ptr'] = wind;
    wind.open(text);
    if (myWindows.length > 0) {
      wind.setPrev(myWindows[myWindows.length-1]['ptr']);
    } else {
      wind.setTop();
    }
    myWindows.push(thisWind);
  }
  
  function kill (id) {
    for (var x=0; x<myWindows.length; x++) {
      if (myWindows[x]['id'] == id) {
        myWindows[x]['ptr'].close();
        delete myWindows[x]['ptr'];
        myWindows.splice(x,1);
      }
    }
  }
}

function notifyWindow () {
  var myTarget = 0;
  var myNotify = null;
  var myPrev = null;
  var myNext = null;
  var scrollTop = getScrollTop();
  var scrollLeft = getScrollLeft();
  var winWidth = getWinWidth();
  var winHeight = getWinHeight();
  this.open = open;
  this.setPrev = setPrev;
  this.setNext = setNext;
  this.setTop = setTop;
  this.slideTop = slideTop;
  this.doSlide = doSlide;
  this.close = close;
  
  function open (text) {
    myNotify = document.createElement('div');
    myNotify.className = 'notifyContainer';
    myNotify.innerHTML = '<div class="notifyBody"><p>'+text+'</p></div>';
    document.getElementsByTagName('body')[0].appendChild(myNotify);
    myNotify.style.left = winWidth/2 + scrollLeft - myNotify.offsetWidth/2 + 'px';
  }
  function setPrev (prev) {
    myPrev = prev;
    if (myPrev != null)
      prev.setNext(this);
  }
  function setNext (next) {
    if (myNext == null && next != null)
      next.setTop(myNotify.offsetTop + myNotify.offsetHeight);
    else if (next != null)
      next.slideTop(myNotify.offsetTop + myNotify.offsetHeight);
    myNext = next;
  }
  function setTop (top) {
    if (top == null || top == '' || top == 'undefined') {
      top = winHeight/2 + scrollTop - myNotify.offsetHeight;
    }
    myNotify.style.top = top + 'px';
    myNotify.style.visibility = 'visible';
    if (myNext != null) {
      myNext.setTop(top + myNotify.offsetHeight);
    }
  }
  function slideTop (top) {
    myTarget = top;
    doSlide();
  }
  function doSlide () {
    if (myNotify.offsetTop > myTarget) {
      myNotify.style.top = myNotify.offsetTop - 2 + 'px';
      setTimeout(doSlide,25);
    } else {
      myNotify.style.top = myTarget + 'px';
    }
    if (myNext != null)
      myNext.setTop(myNotify.offsetTop + myNotify.offsetHeight);
  }
  function close () {
    if (myPrev != null && myNext != null) {
      myNext.setPrev(myPrev);
    } else if (myPrev != null) {
      myPrev.setNext(null);
    } else if (myNext != null) {
      myNext.slideTop(myNotify.offsetTop);
      myNext.setPrev(null);
    }
    myNotify.parentNode.removeChild(myNotify);
  }
}
function getWinHeight () {
  var y;
  if (self.innerHeight) { // all except Explorer
  	y = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
  	y = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
  	y = document.body.clientHeight;
  }
  return y;
}
function getWinWidth () {
  var x;
  if (self.innerWidth) { // all except Explorer
  	x = self.innerWidth;
  } else if (document.documentElement && document.documentElement.clientWidth) {	// Explorer 6 Strict Mode
  	x = document.documentElement.clientWidth;
  } else if (document.body) { // other Explorers
  	x = document.body.clientWidth;
  }
  return x;
}
function getScrollTop () {
  var y;
  if (self.pageYOffset) { // all except Explorer
  	y = self.pageYOffset;
  } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
  	y = document.documentElement.scrollTop;
  } else if (document.body) { // all other Explorers
  	y = document.body.scrollTop;
  }
  return y;
}
function getScrollLeft () {
  var x;
  if (self.pageYOffset) { // all except Explorer
  	x = self.pageXOffset;
  } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
  	x = document.documentElement.scrollLeft;
  } else if (document.body) { // all other Explorers
  	x = document.body.scrollLeft;
  }
  return x;
}
var notify = new notifier();
