/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var EventLog = {
    _elError : null,
    _elNote : null,
    _fnDisppear : null,
    Initialize : function(){
        this._elError = $("<div class=\"ui-widget event-log\"><div class=\"ui-state-error ui-corner-all\" style=\"padding: 0pt 0.7em;\"></div></div>").appendTo($("body:first")).hide();
        this._elNote = $("<div class=\"ui-widget event-log\"><div class=\"ui-state-highlight ui-corner-all\" style=\"padding: 0pt 0.7em;\"></div></div>").appendTo($("body:first")).hide();
        if ($.browser.msie && $.browser.version < 7){
            $(window).scroll(function(){
                $(".event-log").css("top", $(window).scrollTop() + 5);
            });
        }
    },
    Error : function(txt){
        if (this._elError == null) this.Initialize();
        clearTimeout(this._fnDisppear);
        this._elError.children("div").empty();
        tag = "<p><span class=\"ui-icon ui-icon-alert\" style=\"float: left; margin-right: 0.3em;\"/><strong>Error: </strong>" + txt + "</p>";
        $(tag).appendTo(this._elError.children("div"));
        this._AlignCenter();
        //this._elError.slideDown("slow");
        $(".event-log").hide();
        this._elError.show();
        this._Disappear();
    },
    Info : function(txt){
        // console.info("called");
        if (this._elNote == null) this.Initialize();
        clearTimeout(this._fnDisppear);
        this._elNote.children("div").empty();
        tag = "<p><span class=\"ui-icon ui-icon-info\" style=\"float: left; margin-right: 0.3em;\"/><strong>Note: </strong>" + txt + "</p>";
        $(tag).appendTo(this._elNote.children("div"));
        this._AlignCenter();
        //this._elNote.slideDown("slow");
        $(".event-log").hide();
        this._elNote.show();
        this._Disappear();
    },
    _AlignCenter : function(){
        pageWidth = $(document).width();
        eventWidth = this._elError.width();
        noteWidth = this._elNote.width();
        this._elError.css("left", pageWidth/2 - eventWidth/2);
        this._elNote.css("left", pageWidth/2 - noteWidth/2);
        if ($.browser.msie && $.browser.version < 7){
            // log.info($(document).scrollTop());
            this._elError.css("top", $(document).scrollTop() + 5);
            this._elNote.css("top", $(document).scrollTop() + 5);
        }
    },
    _Disappear : function(){
        this._fnDisppear = setTimeout(function(){
            $(".event-log").fadeOut();
        }, 5000);
    }
}