/**var parent_obj = new Object();

parent_obj['element_id'] = null;
parent_obj['element_tag_name'] = 'body';
* 
* windowId - Id всплывающего окна
* 
* positionType - тип расположения окна относительно родителя
* 	- center  - по центру
*   - center_x - по центру горизонтально
*   - center_y - по центру вертикально
* 	- normal, null - простое отображение
* 
**/

var PopUpWindow = Class.create({
	initialize: function(window_id, position_type, insert_status, parent_obj){
		if (undefined == window_id)
			return false;
		this.windowId = window_id;
		this.windowElm = $(window_id);
		
		this.windowShowStatus = false;
		
		if (undefined == position_type)
			this.positionType = 'center';
		else
			this.positionType = position_type;
		
		if (true == insert_status)	
		{
			this.insertStatus = insert_status;
			
			if (null != parent_obj['element_id'])
			{
				this.parentType = 'id';
				this.parentTypeName = parent_obj['element_id'];
			}
			else if (null != parent_obj['element_tag_name'])
			{
				this.parentType = 'tag_name';
				this.parentTypeName = parent_obj['element_tag_name'];
			}
			else
				return false;
			
			this.GetParentElm();
		}
		
		
	},
	
	ShowWindow: function(){
		
		if ((false === this.windowShowStatus) && (true === this.insertStatus))
			this.InserWindowInParent();
			
		this.windowElm.style.display = 'block';
		
		if ('center' == this.positionType)
			this.ShowCenterElm();
		
		this.windowShowStatus = true;
	},
	
	HideWindow: function(){
		this.windowElm.style.display = 'none';	
	},
	
	GetParentElm: function(){
		if ('id' == this.parentType)
			this.parentElm = $(this.parentTypeName);
		else if ('tag_name' == this.parentType)
		{
			var elm_arr = $$(this.parentTypeName);
			this.parentElm = elm_arr[0];
		}
	},
	
	InserWindowInParent: function(){
		this.parentElm.insert($(this.windowElm));
	},
	
	ShowCenterElm: function(){ 
		var mar_top;
		var mar_left;
		mar_left = this.windowElm.getWidth()/2;
		mar_top = this.windowElm.getHeight()/2;
		this.windowElm.setStyle({marginTop: "-"+mar_top+"px", marginLeft: "-"+mar_left+"px", top: ((getClientHeight()/2) + getBodyScrollTop()) + "px", left: getClientWidth()/2 + "px"});
	}
})


function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.documentElement.clientHeight;
}

function showCenterElement(c_element)
{
	
	var mar_top;
	var mar_left;
	mar_left = c_element.getWidth()/2;
	mar_top = c_element.getHeight()/2;
	c_element.setStyle({marginTop: "-"+mar_top+"px", marginLeft: "-"+mar_left+"px", top: (getClientHeight() + getBodyScrollTop())/2 + "px", left: getClientWidth()/2 + "px"})

	
}

function getBodyScrollTop()
{
    return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
    return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}