function ICMSWindow(width, height)
{
	var obj = this;
	var state;
	this.currentWidth = width;
	this.currentHeight = height;
	this.previousWidth = 0;
	this.previousHeight = 0;
	var x;
	if(!jQuery('body').children().is('#icmswindow'))
	{
		jQuery('body').append('<div id="icmswindow">'
									+ '<table style="width:100%;">'
										+ '<tr>'
											+ '<td id="icmswindowtitle"></td>'
											+ '<td style="width:0px;" align="right"><img id="closeICMSWindow" src="/images/icons/close.jpg" style="position:relative;right:0;display:block;cursor:pointer;"/></td></tr>'
										+ '<tr>'
											+ '<td id="icmswindowcontent" colspan="2" style="width:100%;">'
												+ '<img style="position:absolute;margin-left:-33px;margin-top:-33px;left:50%;top:50%;" src="/images/ajaxLoader3.gif" />'
											+ '</td>'
										+ '</tr>'
									+ '</table>'
								+ '</div>');
	}
	jQuery('#icmswindowcontent').html('<img style="position:absolute;margin-left:-33px;margin-top:-33px;left:50%;top:50%;" src="/images/ajaxLoader3.gif" />');
	//obj.showLoading();
	ml = - width / 2;
	jQuery('#icmswindow').css("margin-left", ml);
	jQuery('#icmswindow').css("width", width);
	mt = - height / 2;
	jQuery('#icmswindow').css("margin-top", mt);
	jQuery('#icmswindow').css("height", height);
	this.close = function()
	{
		jQuery('#icmswindow').hide();
		doDay();
	}
	jQuery('#closeICMSWindow').click(this.close);
	doNight();
	this.setTitle = function(title)
	{
		jQuery('#icmswindowtitle').html(title);
	}
	this.setContent = function(content)
	{
		jQuery('#icmswindowcontent').html(content);
	}
	this.show = function()
	{
		jQuery('#icmswindow').show();
	}
	this.rememberState = function()
	{
		obj.state = jQuery('#icmswindowcontent').html();
	}
	this.updateContent = function(answer)
	{
		var error = null;
		var ok = null;
		var str = '';
		var size;
		eval(answer);
		if(error)
		{
			size = error.list.length;
			str += '<table style="width:100%;height:180px;text-align:center;color:red;"><tr><td style="vertical-align:top;">';
			for(var i = 0; i < size; i++)
			{
				str += error.list[i] + '<br/>';
			}
			str += '</td></tr><tr><td><input type="button" id="backState" value="OK"  style="background-image:url(/images/arzam/button.gif);border:1px solid black;cursor:pointer;">';
			str += '</td></tr></table>';
			obj.resize(310, 200);
			obj.setContent(str);
		}
		if(ok)
		{
			//alert(answer);
			str += '<table style="width:100%;height:180px;text-align:center;color:red;"><tr><td style="vertical-align:top;">';
			str += ok.message;
			str += '</td></tr><tr><td><input type="button" id="ok" value="OK"  style="background-image:url(/images/arzam/button.gif);border:1px solid black;cursor:pointer;">';
			str += '</td></tr></table>';
			obj.resize(310, 200);
			obj.setContent(str);
		}
	}
	this.showLoading = function()
	{
		jQuery('#icmswindowcontent').html('<img style="position:absolute;margin-left:-33px;margin-top:-33px;left:50%;top:50%;" src="/images/ajaxLoader3.gif" />');
	}
	this.resize = function(width, height)
	{
		obj.previousWidth = obj.currentWidth;
		obj.previousHeight = obj.currentHeight;
		obj.currentWidth = width;
		obj.currentHeight = height;
        var ml = - width / 2;
		jQuery('#icmswindow').css("margin-left", ml);
		jQuery('#icmswindow').css("width", width);
		var mt = - height / 2;
		jQuery('#icmswindow').css("margin-top", mt);
		jQuery('#icmswindow').css("height", height);
	}
	this.backState = function()
	{
		obj.resize(obj.previousWidth, obj.previousHeight);
		obj.setContent(obj.state);
		elementList = jQuery('#userForm :input');
		//alert(size = elementList.length);
		size = elementList.length
		for(var i=0; i < size; i++)
		{
			key = jQuery(elementList[i]).attr('name');// + ' = ' + jQuery(elementList[i]).val());
			//alert
			jQuery(elementList[i]).val(ICMSWindow.x[key]);
		}
		/*for(var element in elementList)
		{
			key = jQuery(elementList[element]).attr('name');
			alert(key);
		}*/
		/*for (var index in ICMSWindow.x)
		{
			//jQuery('#userForm input').attr('name','validate[login]]').val('x');
			jQuery()
		}*/
		//jQuery('#userForm *').attr('name','validate[login]]').val('x');
		//inpt = jQuery('#userForm input');
		jQuery('#addUsersRecord').click(addUser);
	}
	this.setParamState = function(x)
	{
		//alert(paramState.length);
		ICMSWindow.x = x;
		//alert(obj.paramState.length);
	}
}