function my_window(w, h, _title, _content, _parent)
{
	this.title = _title;
	this.content = _content;
	this.parent = _parent;
	
	this.width = w;
	this.height = h;
	this.parent = _parent;
	this.asd = "asd";
	
	this.obj = $('<div class="my-win"></div>').css("width", w+"px");
	if (h!=0) this.obj.css("height", h+"px");
	
	this.container = $("<div class='my-win-container'></div>");
	this.titleObj = $('<div><div class="my-win-titleText_">'+this.title+'</div></div>').attr("class","my-win-title");
	this.contentObj = $('<div class="my-win-content">'+this.content+'</div>');
	this.closeBtn = $('<div id="closeBtn" onclick="this.win.hide();"></div>');
	
	this.obj.append(this.titleObj).append(this.contentObj);
	this.container.append(this.obj).css({left:300, top:100, position:"fixed", display:"none", opacity:0/**/});
	this.parent.append(this.container);
	this.container[0].win = this;
	this.titleObj[0].win = this;
	this.closeBtn[0].win = this;
	this.titleObj.prepend(this.closeBtn);
	this.obj[0].win = this;
	
	this.dropped = 0;
	this.oldX = 0;
	this.oldY = 0;
	
	this.titleObj.bind("mousedown", null, this.onmousedown);
	this.container.bind("mouseup", null, this.onmouseup);
	this.container.bind("mousemove", null, this.onmousemove);
	
	this.setContent =  function(val){this.contentObj.html(val);};
	
}

my_window.prototype.hide = function()
{
	this.container.animate({opacity:0.0, left:this.container[0].offsetLeft+50}, 200, function()
		{
			$(this).css({left:this.offsetLeft - 50, display:"none"}); 
		});
}

my_window.prototype.show = function()
{
	this.container.css({display:"block"});
		this.container.css({display:"block", left:this.container[0].offsetLeft+50/**/}).animate({opacity:1, left:this.container[0].offsetLeft-50/**/}, 200);
}

my_window.prototype.onmousedown = function(e)
{
	this.win.container[0].dropped = 1;

	this.win.container[0].oldX = e.pageX;
	this.win.container[0].oldY = e.pageY;
}

my_window.prototype.onmouseup = function(e)
{
	this.dropped = 0;
	this.parentNode.dropped = 0;
	
}

my_window.prototype.onmousemove = function(e)
{
	if (!this.win.container[0].dropped) {  return;}
	
	var dx = e.pageX - this.oldX;
	var dy = e.pageY - this.oldY ;
	
	var win = (this.win.container[0]);
	$(win).css({left: win.offsetLeft+dx, top:win.offsetTop+dy});

	this.oldX = e.pageX;
	this.oldY = e.pageY;
}



my_window.prototype.setContent = function(cont)
{
	this.contentObj.html(cont);
}

my_window.prototype.setTitle = function(text)
{
	this.titleObj.html(text).prepend(this.closeBtn);
}
