function Window(appid) {
	// === 基本 ===
	this._title = '';
	this._borderStyle = 'border';
	this._size = {width:0,height:0};
	this._x = 200;
	this._y = 200;
	this._styleBackgroundImage = '';
	this._styleBackgroundSize = '';
	// --- 事件 ---
	this.onResize = function() {};
	// --- 方法 ---
	this.add = function(obj) {
		this._obj.find('.content').append(obj._dom);
	};
	// --- 创建 DOM ---
	this._obj = $('<div class="window" winid="'+WINID+'" appid="'+appid+'" style="z-index:'+WININDEX+';"><div class="title"><span>&nbsp;</span><div class="controls"><div class="min"></div><div class="max"></div><div class="close"></div></div></div><div class="content"></div></div>');
	this._obj.appendTo('body');
	// --- 绑定移动 ---
	this._obj.draggable({
		handle: '.title',
		cancel: '.controls',
		scroll: false,
		start: function() {
			$(this).css({'z-index':WININDEX});
			++WININDEX;
		},
		stop: function(e, ui) {
			if(ui.offset.top < 0) {
				$(this).css({'top':'0'});
			} else if(ui.offset.top > $(window).height() - $(this).children('.title').outerHeight()) {
				$(this).css({'top':$(window).height() - $(this).children('.title').outerHeight() + 'px'});
			}
			if(ui.offset.left < 0) {
				$(this).css({'left':'0'});
			} else if(ui.offset.left > $(window).width() - $(this).outerWidth()) {
				$(this).css({'left':$(window).width() - $(this).outerWidth() + 'px'});
			}
		}
	}).css({'position':'absolute'});
	++WINID;
	++WININDEX;
}
Window.prototype = {
	get title() {
		return this._title;
	},
	set title(val) {
		this._title = val;
		this._obj.find('.title>span').text(val!='' ? val : '&nbsp;');
	},
	get width() {
		return this._size.width;
	},
	get height() {
		return this._size.height;
	},
	set size(val) {
		this._size = {width:val[0],height:val[1]};
		this._obj.find('.content').css({'width':val[0]+'px','height': val[1]+'px'});
		this.onResize();
	},
	get x() {
		return this._x;
	},
	set x(val) {
		this._x = val;
		this._obj.css('top', val+'px');
	},
	get y() {
		return this._y;
	},
	set y(val) {
		this._y = val;
		this._obj.css('left', val+'px');
	},
	get borderStyle() {
		return this._borderStyle;
	},
	set borderStyle(val) {
		if(val == 'border' || val == 'none') {
			this._borderStyle = val;
			this._obj.addClass(val);
		}
	},
	get styleBackgroundImage() {
		return this._styleBackgroundImage;
	},
	set styleBackgroundImage(val) {
		if(val == '') {
			this._styleBackgroundImage = '';
			this._obj.find('.content').css('background-image', 'none');
		} else if(val.substr(0, 4) == 'url(') {
			this._styleBackgroundImage = '';
			this._obj.find('.content').css('background-image', val);
		}
	},
	get styleBackgroundSize() {
		return this.styleBackgroundSize;
	},
	set styleBackgroundSize(val) {
		this._styleBackgroundSize = '';
		this._obj.find('.content').css('background-size', val);
	}
};