function WindowResize (idWindow, widthWindow, heightWindow) {

	function getElementsByClass(searchClass) {
		var arr = [];
		var els = document.getElementsByTagName('*');
		for (i = 0, j = 0, elsLen = els.length; i < elsLen; i++) {
			if (els[i].className.indexOf(searchClass) != -1)
				arr[j++] = els[i];
		}
		return arr;
}
	
	var currentObject = this;
	
	this.id = getElementsByClass(idWindow)[0];
	this.maxHeight = heightWindow;
	this.minHeight = 0;
	this.timer = 10;
	this.init();
}

WindowResize.prototype.init = function () {
	var but = new Array(5);
	for (var i = this.id.firstChild, j = 0; i; i = i.nextSibling) {
		if (i.nodeType == 1) but[j++] = i;
	}
	this.maxbutton = but[0];
	this.minbutton = but[1];
};

WindowResize.prototype.start = function (event) {
	
	var elementToDrag = this.prop;
	var startX = event.clientX;
	var startY = event.clientY;
	var origX = elementToDrag.offsetLeft;
	var origY = elementToDrag.offsetTop;
	var deltaX = startX - origX;
	var deltaY = startY - origY;
	elementToDrag.style.zIndex = 9999;
	
	//bindAction.add(document, "mouseup", upHandler);
	//bindAction.add(document, "mousemove", clearSelection);
	//bindAction.add(document, "mousemove", moveHandler);

	function clearSelection (e) {
		if (document.selection && document.selection.empty) {
			document.selection.empty();
		}
		else if (window.getSelection) {
			var sel = window.getSelection();
			if (sel && sel.removeAllRanges);
			sel.removeAllRanges();
		}
	};

	function moveHandler (e) {
		elementToDrag.style.left = (e.clientX - deltaX)+"px";
		elementToDrag.style.top = (e.clientY - deltaY)+"px";
	}
	
	function upHandler (e) {
		bindAction.remove(document, "mouseup",upHandler);
		bindAction.remove(document, "mousemove",moveHandler);
		elementToDrag.style.zIndex = 3;
	}
}

WindowResize.prototype.minimize = function () {
	var currentObject = this;
	var curHeight = this.id.offsetHeight;

	clearInterval(this.idClearTime);
	this.idClearTime = setInterval(function () { _smallerHeight () }, this.timer);
	
	var _smallerHeight = function () {
		if (curHeight > currentObject.minHeight) {
			curHeight -= 10;
			if (curHeight >= 0)
			    currentObject.id.style.height = curHeight+"px";
		}
		else {
			clearInterval(currentObject.idClearTime);
			currentObject.id.style.display = "none";
			currentObject.minbutton.setAttribute("style", "display: none;");
		}
	};

};

WindowResize.prototype.maximize = function (event) {
	var currentObject = this;
	var curHeight = this.id.offsetHeight;
	//alert(getComputedStyle(this.id, "").getPropertyValue("position"));
	if(this.id.className.indexOf("formobrsv2") != -1){
		this.id.style.top = event.pageY - 350 + 'px';
	}
	else if(this.id.className.indexOf("formobrsv ") != -1) {
		this.id.style.top = '40px';
	}
	else
		this.id.style.top = 0;
	clearInterval(this.idClearTime);
	this.idClearTime = setInterval(function () { _biggerHeight () }, this.timer)
	this.minbutton.setAttribute("style", "display: block");
	
	var _biggerHeight = function () {
		if (curHeight < currentObject.maxHeight) {
			curHeight += 10;
			currentObject.id.style.height = curHeight+"px";
		}
		else {
			clearInterval(currentObject.idClearTime);
		}
	};
	this.id.style.display = "block";
};
