var Growl = Class.create();
Growl.DefaultOptions
      = {icon:'javascripts/growl/growl.jpg',title:'Notification',message:'Something <b>happens</b>',background:'javascripts/growl/smoke.png',duration:4};
function inIE() {
    return!!(window.attachEvent && !window.opera);
}
var count = 0;
Growl.prototype = {initialize:function(options) {
    this.options = Object.extend(Object.extend({}, Growl.DefaultOptions), options || {});
},createGui:function() {
    this.container = Builder.node('div', {style:'display:none;opacity:0;position:absolute;'});
    var shift = Position.page(document.body);
    $(this.container).setStyle({top:((Math.abs(shift[1]) + 10) + (count * 80))
          + 'px',left:($(document.body).getWidth() - 315) + 'px'});
    if (inIE()) {
        this.container.appendChild(Builder.node('img', {src:'javascripts/growl/smoke.gif'}));
    }
    else {
        this.container.appendChild(Builder.node('img', {style:'opacity:0.85;filter:alpha(opacity=85);',src:this.options.background}));
    }
    var content = Builder.node('div', {style:"position:absolute;left:5px;top:0;width:298px;color:white;font:12px 'Lucida Grande',Arial,Helvetica,Verdana,sans-serif;"});
    this.container.appendChild(content);
    content.appendChild(Builder.node('img', {style:'float:left;margin:12px;',src:this.options.icon}));
    content.appendChild(Builder.node('h3', {style:'margin:0;padding:10px 0'}, this.options.title));
    content.appendChild($(Builder.node('p', {style:'margin:0 10px'})).update(this.options.message));
    document.body.appendChild(this.container);
},smoke:function() {
    this.createGui();
    count = count + 1;
    var temporary = this.container;
    var current = count;
    var fadeDuration = 1 / 4 * this.options.duration;
    Effect.Appear(temporary, {duration:fadeDuration,to:1});
    setTimeout(function() {
        Effect.DropOut(temporary, {duration:fadeDuration});
        if (count == current)count = 0;
    }, fadeDuration * 2000);
}};
