function Layer (name) {
    //name,position,state,top,left,Zindex,span
    this.name = name;
    this.browser_ok = bw.ie || bw.dom;
    this.type = 'layer';
}
    Layer.prototype.open_s = function (style) {
        style = style?'style="'+style+'" ':'';
        if (this.browser_ok) {
            return '<div id="'+this.name+'_id" '+style+' \>';
        }
        return false;
    }
    Layer.prototype.open = function (style) {
        style = style?style:false;
        if(s = this.open_s(style)){
            document.write(s);
            return true;
        }
        return false;
    }
    Layer.prototype.close_s = function () {
        if (this.browser_ok) {
            return '<\/div\>';
        }
        return false;
    }
    Layer.prototype.close = function () {
        if(s = this.close_s()){
            document.write(s);
            this.set_dom_object();
            return true;
        }
        return false;
    }
    Layer.prototype.update_html = function (htmlcode) {
        return this.set_css_style('innerHTML',htmlcode);
    }
    Layer.prototype.show = function () {
        return this.set_css_style('visibility','visible');
    }
    Layer.prototype.hide = function () {
        this.set_css_style('visibility','hidden');
    }
    Layer.prototype.set_css_style = function (style,value,debug){
        if (debug)alert('Style : '+style+'\n'+'Value : '+value+'\n'+'ENTERING FUNCTION');
        if(this.exists()){
            if (debug)alert('Style : '+style+'\n'+'Value : '+value+'\n'+'DOM EXISTS');
            if (this.elements.style[style] = value) {
                if (debug)alert('Style : '+style+'\n'+'Value : '+value+'\n'+'VALUE ASSIGNED TO STYLE RETURNING TRUE');
                return true;
            } 
            else if (debug) alert('Style : '+style+'\n'+'Value : '+value+'\n'+'ERROR ASSIGNING STYLE');
            //return true;
        } else {
            if (debug)alert('Style : '+style+'\n'+'Value : '+value+'\n'+'DIV DOES NOT EXISTS PUSHING TO STACK');
            dhtml_stack.push(this.name+'.set_css_style(\''+style+'\',\''+value+'\','+debug+')');
        }
        if (debug)alert('Style : '+style+'\n'+'Value : '+value+'\n'+'RETURN FALSE');
        return false;
    }
    Layer.prototype.get_css_style = function (style){
        return this.elements.style[style];
    }
    Layer.prototype.exists = function () {
        if (this.elements && this.elements.style)
            return true;
        return false;
    }
    Layer.prototype.set_dom_object = function (div_id) {//alert(this.name + ' => ' + div_id);
        if (div_id) var id = div_id;
        else var id = this.name+'_id'
        if(bw.dom){
            this.elements = document.getElementById(id);//alert(id + ' : ' + this.elements);
        } else if(bw.ie){
            this.elements = document.all(id);
        }
        if(!this.elements){
            window.onload = after_on_load;
            //alert('Pushing to onload (div_id = '+div_id+'): '+id);
            dhtml_stack.push(this.name+'.set_dom_object("'+id+'")');
            return onload_event = true;
        }
        window.onload = after_on_load;
        //after_on_load();
        return this.elements;
    }
    Layer.prototype.moveTo = function (x,y,width,height) {//alert(x+':'+y+':'+width+':'+height);
        if (x == "center") {//alert('center');
            this.set_css_style('marginLeft',((width/2)*-1)+'px');
            this.set_css_style('left','50%');
        } else if(x){
            this.set_css_style('left',parseInt(x)+'px');
        }
        if (y == "center"){//alert('center');
            this.set_css_style('marginTop',((height/2)*-1)+'px');
            this.set_css_style('top','50%');
        } else if(y){
            this.set_css_style('top', parseInt(y)+'px');
        }
    };
    Layer.prototype.moveBy = function (x,y) {
        this.set_css_style('left',(parseInt(x)+parseInt(this.get_css_style('left')))+'px');
        this.set_css_style('top',(parseInt(x)+parseInt(this.get_css_style('top')))+'px');
    }

