function createXHR()
{
	xmlhttp=null
	// code for Mozilla, etc.
	if( window.XMLHttpRequest )
	{
		xmlhttp=new XMLHttpRequest()
	}
	// code for IE
	else if( window.ActiveXObject )
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return xmlhttp
}

function divRefresh( d_id, href, parm )
{
	ddiv = document.getElementById( d_id )
	if( ddiv == null )
		return
	c_save = ddiv.style.cursor
	ddiv.style.cursor = 'wait'
	content = XHRsend( href, parm )
	if( content != false )
		ddiv.innerHTML = content
	ddiv.style.cursor = c_save
}

function XHRsend( href, parm )
{
	try
	{
		xh = createXHR()
		if( parm == null )
			parm = ''
		xh.open( 'POST', href, false )
		xh.send( parm.toJSONString() )
		if( xh.status != 200 )
		{
			if( xh.status == 404 && xh.statusText == "Reload" )
			{
				c_reload()
				return false
			}
			else
			{
				alert( 'Błąd servera: ' + xh.statusText + ' ' + xh.status )
				return false
			}
		}
		else
		{
			content = xh.responseText
		}
		return content
	}
	catch( e )
	{
		return false
	}
}

function c_reload()
{
	window.location.reload()
}

