
var PosWinY;



Gallery = {
	listing : function(block_id, page)
	{
		
		if(!page)
			page = 0;
		if(!block_id)
			this.errors("No Block!");
		else
		{
			Gallery.StartLoading();
			new Ajax.Request('/ajax.php', {method: 'post', parameters:'C='+page+'&news=' + block_id, onSuccess:Gallery.processGetPost, onFailure:Gallery.ErrorView});

		}
		
	},

	processGetPost : function(req)
	{
		var i;
		if($('gallery_place'))
			i = $('gallery_place');
		
		if(req.responseText)
		{
			i.innerHTML = '';
			i.innerHTML = req.responseText;
		}
		Gallery.EndLoading();
	},
	
	StartLoading : function()
	{
		if($('Loading'))
			Gallery.EndLoading();
		var d = document.createElement("div");
		d.setAttribute("id", "Loading");
		d.className = "Loading";
		d.style.left = document.body.scrollWidth / 2 + 50 + "px";
		if(PosWinY)
			d.style.top = PosWinY + "px";
		else
			d.style.top = document.body.scrollTop + (document.body.clientHeight / 2) -100 + "px";

		var text = document.createTextNode("Завантаження...");
		d.appendChild(text);

		document.body.appendChild(d);
		document.body.style.cursor = "wait";
	},
	EndLoading : function()
	{
		if($('Loading'))
		{
			var d = $("Loading");
			document.body.removeChild(d);
			document.body.style.cursor = "default";
		}
	},
	errors : function(s)
	{
		alert(s);
	},
	ErrorView : function(t)
	{
		alert('Ошибка: ' + t.status + ' -- ' + t.statusText);
	},
	PosWin : function(e)
	{
		PosWinY = Event.pointerY(e) - 50;
	}
}

function go_cal(m, y, div_id)
{
	if (div_id)
	{
		new Ajax.Request('/ajax.php', {method: 'get', parameters:'m=' + m + '&y=' + y + '&block_id=' + div_id,
		onSuccess:function(req){
     	 var i;
			if($('news_calendar_'+div_id))
				i = $('news_calendar_'+div_id);
			
			if(req.responseText)
			{
				i.innerHTML = '';
				i.innerHTML = req.responseText;
			}
    	}, 
		onFailure:function()
		{
			alert('error');
		}
		});
	}
}


function clop(idd)
{
	if ($('submenu'+idd) != undefined)
	{
		if ($('submenu'+idd).style.display == 'none')
			$('submenu'+idd).style.display = 'block';
		else
			$('submenu'+idd).style.display = 'none';
		
	}
}