function Settings() {
    this.init();

    this.cfg = {
        hasSizeBtn: false,
        hasRefreshBtn: false,
        hasSettingsBtn: false,
        hasDrag: false,
        title: "Page Settings",
        module: "Settings"
    }


    this.domContent = [
        { tag: "div", className: "menu_panel", style: {textAlign: "center"},
          innerHTML: "<h1>Page title</h1>",
          childs: [
        
            createColorSelectDom("Set title color", "title", "select_title_color"),
            { tag: "span", innerHTML: "&nbsp;&nbsp;|&nbsp;&nbsp;" },
            createFontSelectDom("Set title font", "title", "select_title_font"), 
            { tag: "span", innerHTML: "&nbsp;&nbsp;|&nbsp;&nbsp;" },
            createFontSizeSelectDom("Set title font size", "title", "select_title_font_size"), 
            { tag: "div", className: "menu_panel", style: {textAlign: "center"},
              innerHTML: "Title text: ",
              childs: [
                { tag: "input", type: "text", size: "60", id: "title_text",
                  events: { onkeyup: "applyTitleText()" }
                }
              ]
            },
/*          { tag: "div", className: "menu_panel", style: {textAlign: "center"},
              childs: [
                { tag: "input", type: "button", value: " Save ",
                  events: { onclick: "save()" }
                }
              ]
            }*/
          ]
        },


        { tag: "hr", width: "100%"},

        { tag: "div", className: "menu_panel", style: {textAlign: "center"},
          innerHTML: "<h1>Page background</h1>",
          childs: [
            createColorSelectDom("Set page background color", "background", "select_page_color"),

            { tag: "div", className: "menu_panel", innerHTML: "or set background image:", style: {textAlign: "center"}},
            { tag: "div", className: "menu_panel", style: {textAlign: "center"},
              innerHTML: "URL: ",
              childs: [
                { tag: "input", type: "text", size: "60", id: "select_background", value: "http://"},
                { tag: "input", type: "button", value: " Preview ",
                  events: { onclick: "setBckgroundImage()" }
                }
              ]
            },
/*            { tag: "div", className: "menu_panel", style: {textAlign: "center"},
              childs: [
                { tag: "input", type: "button", value: " Save ",
                  events: { onclick: "save()" }
                }
              ]
            }*/
          ]
        },

	{ tag: "hr", width: "100%"},

	{ tag: "div", className: "menu_panel", style: {textAlign: "center"},
	  childs: [
	    createColorSelectDom("Set widgets border color", "wborder", "select_wborder_color"),
	    {tag: "div", childs: [
	
	    { tag: "input", type: "checkbox", id: "chtransp",
	      events: { onclick: "changeTransparency()" } },
	    { tag: "span", innerHTML: "Make widgets transparent when dragging", 
	      style: { display: "inline" } } ]}
 
	  ]
	},


        { tag: "div", className: "menu_panel", style: {textAlign: "center"},
          childs: [
            { tag: "input", type: "button", value: " Save ",
              events: { onclick: "save()" }
            }
          ]
        }
	  
    ]


    this.getSignature = function() {
        return SYSWIDGET_WKEY+4;
    }

    this.defaultProfile["title"] = "Page Title";
    this.defaultProfile["title_color"] = "#007700";
    this.defaultProfile["title_font"] = "Arial, Helvetica";
    this.defaultProfile["title_font_size"] = "18px";
    this.defaultProfile["background_style"] = "color";
    this.defaultProfile["background"] = "#FFFFFF";
//    this.defaultProfile["transp_drag"] = true;



    this.onBuildInterface = function() {
        this.elements.window.style.width = "600";
        this.setTitle(this.cfg.title);
        this.buildDomModel(this.elements.content, this.domContent);        
        this.applyTitleLook();
        this.elements.title_text.value = this.profile.title;
        this.applyTitleText();
        this.applyBackgoundLook();
	if(this.profile.wborder_color)
		this.applyWborderColor();
	if(this.profile.transp)
	    this.elements["chtransp"].checked = this.profile.transp;
	else this.elements["chtransp"].checked = false;
	this.changeTransparency();
    }



    this.close = function() {
        desktop.closeCurrentPage();
    }
 
    this.onSelectColor = function(target, color) {
        switch(target) {
            case "title":
                this.profile.title_color = color;
                this.applyTitleLook();
                break;

            case "background":
                this.profile.background_style = "color";
                this.profile.background = color;
                this.applyBackgoundLook();
                break;
	    
	    case "wborder":
		this.profile.wborder_color = color;
		this.applyWborderColor();
		break;
        }
    }

    this.onSelectFont = function(target, font) {
        switch(target) {
            case "title":
                this.profile.title_font = font;
                this.applyTitleLook();
                break;
        }
    }

    this.onSelectFontSize = function(target, fontSize) {
        switch(target) {
            case "title":
                this.profile.title_font_size = fontSize;
                this.applyTitleLook();
                break;
        }
    }

    this.applyTitleLook = function() {
        with(desktop.elements.main_title) {
            innerHTML = this.profile.title;
            style.fontFamily = this.profile.title_font;
            style.fontSize = this.profile.title_font_size;
            style.color = this.profile.title_color;
        }
    }

    this.applyTitleText = function() {
        this.profile.title = trim(this.elements.title_text.value);
        document.title = this.profile.title;
        desktop.elements.main_title.innerHTML = this.profile.title;
    }


    this.setBckgroundImage = function() {
        this.profile.background_style = "img";
        this.profile.background = trim(this.elements.select_background.value);
        this.applyBackgoundLook();
    }


    this.applyBackgoundLook = function() {
        if(this.profile.background_style == "color") {
            document.body.style.backgroundImage = '';
            document.body.style.backgroundColor = this.profile.background;
        } else {
            document.body.style.backgroundColor = '';
            document.body.style.backgroundImage = "url("+this.profile.background+")";
        }
    }

    this.changeTransparency = function() {
	this.profile.transp = this.elements['chtransp'].checked;
	kernel.transp_drag = this.profile.transp;
    }

    this.applyWborderColor = function() {
	for(w in kernel.widgets) {
	    if(els = kernel.getWidget(w).elements)
		if(wnd = els.window)
		    wnd.style.borderColor = this.profile.wborder_color;
	}
	kernel.wborder_color = this.profile.wborder_color;
    }
}
Settings.prototype = new Widget();
