function DivMove()
{
	var obj = new Object();

	obj.Offs = false;
	obj.OffsX = 0;
	obj.OffsY = 0;
	obj.MouseX = 0;
	obj.MouseY = 0;
	obj.ElementDiv = null;
	obj.ElementDivPopUp = 'ElementDivPopUp';


	//---------------------------------------------
	obj.CookieGet = function(check_name)
	//---------------------------------------------
	{
		var a_all_cookies = document.cookie.split(';');
		var a_temp_cookie = '';
		var cookie_name = '';
		var cookie_value = '';
		var b_cookie_found = false;
		for(i = 0; i < a_all_cookies.length; i++ )
		{
			a_temp_cookie = a_all_cookies[i].split('=');
			cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
			if(cookie_name == check_name)
			{
				b_cookie_found = true;
				if ( a_temp_cookie.length > 1 )
				{
					cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
				return cookie_value;
				break;
			}
			a_temp_cookie = null;
			cookie_name = '';
		}

		if(!b_cookie_found)	return null;
	}


	//---------------------------------------------
	obj.CookieSet = function(name, value, expires, path, domain, secure)
	//---------------------------------------------
	{
		var today = new Date();
		today.setTime( today.getTime() );

		if(expires) expires = expires * 1000 * 60 * 60 * 24;

		var expires_date = new Date( today.getTime() + (expires) );

		document.cookie =	name + "=" +escape( value ) +
							( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
							( ( path ) ? ";path=" + path : "" ) +
							( ( domain ) ? ";domain=" + domain : "" ) +
							( ( secure ) ? ";secure" : "" );
	}


	//---------------------------------------------
	obj.CookieDel = function(name, path, domain)
	//---------------------------------------------
	{
		if (obj.CookieGet(name)) document.cookie = name + "=" +((path) ? ";path=" + path : "") + (( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}


	//---------------------------------------------
	obj.xGetElementById = function(e)
	//---------------------------------------------
	{
		if(typeof(e)!='string') return e;
		var FrameName = window.self;
		if(FrameName.document.getElementById) e=FrameName.document.getElementById(e);
		else if(FrameName.document.all) e=FrameName.document.all[e];
		else e=null;
		return e;

	}

	//---------------------------------------------
	obj.xMoveTo = function(e, iX, iY)
	//---------------------------------------------
	{
		obj.xLeft(e, iX);
		obj.xTop(e, iY);
	}

	//---------------------------------------------
	obj.xWidthHeight = function(e, iX, iY)
	//---------------------------------------------
	{
		obj.xWidth(e, iX);
		obj.xHeight(e, iY);
	}

	//---------------------------------------------
	obj.xWidth = function(e, iX)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return 0;
		var css=obj.xDef(e.style);
		if(css && obj.xStr(e.style.width))
		{
			if(obj.xNum(iX)) e.style.width=iX+'px';
			else
			{
				iX=parseInt(e.style.width);
				if(isNaN(iX)) iX=0;
			}
		}
		else if(css && obj.xDef(e.style.width))
		{
			if(obj.xNum(iX)) e.style.width=iX;
			else iX=e.style.width;
		}
		return iX;
	}

	//---------------------------------------------
	obj.xHeight = function(e, iX)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return 0;
		var css=obj.xDef(e.style);
		if(css && obj.xStr(e.style.height))
		{
			if(obj.xNum(iX)) e.style.height=iX+'px';
			else
			{
				iX=parseInt(e.style.height);
				if(isNaN(iX)) iX=0;
			}
		}
		else if(css && obj.xDef(e.style.height))
		{
			if(obj.xNum(iX)) e.style.height=iX;
			else iX=e.style.height;
		}
		return iX;
	}

	//---------------------------------------------
	obj.xLeft = function(e, iX)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return 0;
		var css=obj.xDef(e.style);
		if(css && obj.xStr(e.style.left))
		{
			if(obj.xNum(iX)) e.style.left=iX+'px';
			else
			{
				iX=parseInt(e.style.left);
				if(isNaN(iX)) iX=0;
			}
		}
		else if(css && obj.xDef(e.style.pixelLeft))
		{
			if(obj.xNum(iX)) e.style.pixelLeft=iX;
			else iX=e.style.pixelLeft;
		}
		return iX;
	}

	//---------------------------------------------
	obj.xTop = function(e, iY)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return 0;
		var css=obj.xDef(e.style);
		if(css && obj.xStr(e.style.top))
		{
			if(obj.xNum(iY)) e.style.top=iY+'px';
			else
			{
				iY=parseInt(e.style.top);
				if(isNaN(iY)) iY=0;
			}
		}
		else if(css && obj.xDef(e.style.pixelTop))
		{
			if(obj.xNum(iY)) e.style.pixelTop=iY;
			else iY=e.style.pixelTop;
		}
		return iY;
	}

	//---------------------------------------------
	obj.xDef = function()
	//---------------------------------------------
	{
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
		return true;
	}

	//---------------------------------------------
	obj.xStr = function()
	//---------------------------------------------
	{
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
		return true;
	}

	//---------------------------------------------
	obj.xNum = function()
	//---------------------------------------------
	{
		for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
		return true;
	}

	//---------------------------------------------
	obj.xSetCursor = function(e, cur)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return ;
		if(e.style.cursor) e.style.cursor = cur;
	}

	//---------------------------------------------
	obj.xDisplayNone = function(e)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return ;
		if(e.style.display) e.style.display = 'none';
	}

	//---------------------------------------------
	obj.xDisplayBlock = function(e)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return ;
		if(e.style.display) e.style.display = 'block';
	}

	//---------------------------------------------
	obj.xShow = function(e) { return obj.xVisibility(e, 1); }
	//---------------------------------------------
	obj.xHide = function(e) { return obj.xVisibility(e, 0); }
	//---------------------------------------------

	//---------------------------------------------
	obj.xVisibility = function(e, bShow)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return null;
		if(e.style && obj.xDef(e.style.visibility))
		{
			if (obj.xDef(bShow)) e.style.visibility = bShow ? 'visible' : 'hidden';
			return e.style.visibility;
		}
		return null;
	}

	//---------------------------------------------
	obj.xInnerHtml = function(e, sHtml)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return '';
		if(obj.xStr(e.innerHTML))
		{
			if(obj.xStr(sHtml)) e.innerHTML = sHtml;
			else return e.innerHTML;
		}
	}

	//---------------------------------------------
	obj.xZIndex = function(e,uZ)
	//---------------------------------------------
	{
		if(!(e=obj.xGetElementById(e))) return 0;
		if(e.style && obj.xDef(e.style.zIndex))
		{
			if(obj.xNum(uZ)) e.style.zIndex=uZ;
			uZ=parseInt(e.style.zIndex);
		}
		return uZ;
	}


	//---------------------------------------------
	obj.CenterWindowDiv = function(IdDiv) // Utworz unikalny ID
	//---------------------------------------------
	{
		var Left = 0;
		var Top = 0;

		obj.xDisplayBlock(IdDiv);

		if(e=(obj.xGetElementById(IdDiv)))
		{
			if((w = parseInt(e.clientWidth)) && (h = parseInt(e.clientHeight)))
			{
				var EkranWidth = 100;
				var EkranHeight = 100;
				if (self.innerWidth) { 	EkranWidth = self.innerWidth; EkranHeight = self.innerHeight; }
				else if (document.documentElement && document.documentElement.clientWidth) { EkranWidth = document.documentElement.clientWidth;	EkranHeight = document.documentElement.clientHeight; }
				else if (document.body) { EkranWidth = document.body.clientWidth; EkranHeight = document.body.clientHeight; }

				Left = Math.round((EkranWidth-w)/2);
				Top = Math.round((EkranHeight-h)/2);
			}
		}

		if(Top < obj.IdDivMiniTop) Top = obj.IdDivMiniTop;
		if(Left < obj.IdDivMiniLeft) Left  = obj.IdDivMiniLeft;
		obj.xMoveTo(IdDiv, Left, Top);
	}


	//---------------------------------------------
	obj.DragStart = function() // wyjątki
	//---------------------------------------------
	{
		obj.ElementDiv = document.getElementById(obj.ElementDivPopUp);
		if(document.addEventListener) document.addEventListener('mousemove', obj.Drag, false);
		else document.attachEvent('onmousemove', obj.Drag);
	}
	//---------------------------------------------
	obj.DragStop = function() // wyjątki
	//---------------------------------------------
	{
		obj.ElementDiv = document.getElementById(obj.ElementDivPopUp);
		if(document.removeEventListener) document.removeEventListener('mousemove', obj.Drag, true);
		else document.detachEvent('onmousemove', obj.Drag);
		obj.ElementDiv = null;
		obj.Offs = false;
		obj.OffsX = 0;
		obj.OffsY = 0;
	}
	//---------------------------------------------
	obj.Drag = function(e)
	//---------------------------------------------
	{
		if(!obj.ElementDiv) return;
		if((document.getElementById) && !(document.all)) { obj.MouseX = e.pageX;  obj.MouseY = e.pageY; }
		else if(window.event) { obj.MouseX = window.event.x + document.body.scrollLeft; obj.MouseY = window.event.y + document.body.scrollTop; }

		if(obj.MouseX < 0) obj.MouseX = 0;
		if(obj.MouseY < 0) obj.MouseY = 0;

		if(!obj.Offs)
		{
			obj.OffsX = obj.MouseX - parseInt(obj.ElementDiv.style.left);
			obj.OffsY = obj.MouseY - parseInt(obj.ElementDiv.style.top);
			obj.Offs = true;
		}
		if(obj.ElementDiv.style.left) obj.ElementDiv.style.left	= obj.MouseX - obj.OffsX  + "px";
		if(obj.ElementDiv.style.top) obj.ElementDiv.style.top	= obj.MouseY - obj.OffsY  + "px";
		window.status = obj.OffsX+' '+obj.OffsY+' '+obj.MouseX+' '+obj.MouseY;
	}


	//---------------------------------------------
	obj.PopUpClose = function()
	//---------------------------------------------
	{
		obj.xDisplayNone(obj.ElementDivPopUp);
	}

	return obj;

}

var WebEditDivPopUp = DivMove();
