/*** (c) Sergey Chitalov ***/

var OffsetFlag = 0,
	aParams = new Array(),
	pValue = new Array();

function ShowItems(URL, Params)
{
	if (Params.indexOf("offset") != -1)
		OffsetFlag = 1;

	aParams = Params.split("&");
	pValue = aParams[2].split("=");
	var MainContainer = $("AjaxBlock" + pValue[1]),
		Element = $("AjaxItems" + pValue[1]),
		Waiting = $("Waiting" + pValue[1]);

	if (Element && Waiting)
	{
		MainContainer.style.width = Element.offsetWidth;
		MainContainer.style.height = Element.offsetHeight;
		Element.style.display = "none";
		GetClassRequest(URL,Params);
	}
}

function GetClassRequest(URL,Params)
{
	var myAjax = new Ajax.Request(
			URL,
			{
				method: 'get',
				parameters: Params,
				onComplete: showResponse
			}
		);
}

function showResponse(originalRequest)
{
	$("AjaxItems" + pValue[1]).innerHTML = originalRequest.responseText;
	Element.show("AjaxItems" + pValue[1]);
	$("AjaxBlock" + pValue[1]).style.width = $("AjaxItems" + pValue[1]).offsetWidth;
	$("AjaxBlock" + pValue[1]).style.height = $("AjaxItems" + pValue[1]).offsetHeight;
	Element.hide("Waiting" + pValue[1]);
	OffsetFlag = 0;
}

function PleaseWait()
{
	var Waiting = $("Waiting" + pValue[1]);
	if (Waiting)
		Waiting.style.display = "block";
}
