function $_id(name) {

	return document.getElementById(name);
}

function ShowLayer(layer) {

	$_id(layer).style.display = 'block';
}

function HideLayer(layer){

	$_id(layer).style.display = 'none';
}


function showGallery (type) {

	document.getElementById('Gallery').style.display = 'block';
}

function hideGallery (){

	document.getElementById('Gallery').style.display = 'none';
	document.getElementById('loading').style.display = 'none';
}

function showMap (){

	document.getElementById('map').style.display = 'block';
}

function hideMap (){

	document.getElementById('map').style.display = 'none';
}

function loading(status) {

	if (status == 1) document.getElementById('loading').style.display = 'block';
	if (status == 0) document.getElementById('loading').style.display = 'none';

}

function SEvents(type) {

	NewCode = new Ajax.Request('/admin/modules/module/block/gallery/handler/ShowGallery.handler.php',
	{
		parameters:
		{
			type : type
		},
		onSuccess: function(req){
			document.getElementById('ModuleGallery').innerHTML = req.responseText;
			loading(0);
			showGallery (type);
		},
		onFailure: function(req){},
		onLoading: function(req){loading(1);}
	});

}

function SEvents_vip(type) {

	NewCode = new Ajax.Request('/admin/modules/module/block/gallery_vip/handler/ShowGallery.handler.php',
	{
		parameters:
		{
			type : type
		},
		onSuccess: function(req){
			document.getElementById('ModuleGallery').innerHTML = req.responseText;
			loading(0);
			showGallery (type);
		},
		onFailure: function(req){},
		onLoading: function(req){loading(1);}
	});

}

// JavaScript Document
Gallery = function(items, itemscount, toshow, redraw, prefix)
{
	this.prefix = prefix;
	this.items = items;
	this.redraw = redraw;
	this.toshow = toshow;
	this.selected = 0;

	this.itemscount = itemscount;

	this.current = 0;

	this.Prev = function()
	{
		if (this.current>0)
		{
			this.current--;
			this.redraw(this, this.prefix);
		}
	}

	this.Next = function()
	{
		if (this.current+this.toshow<this.itemscount)
		{
			this.current++;
			this.redraw(this, this.prefix);
		}
	}
}

redrawfunction = function (gallery)
{

	document.getElementById('previewImage1_'+gallery.prefix).src = '/images/gallery/'+gallery.prefix+'/'+gallery.items[gallery.current]['sm'];
	document.getElementById('previewImage2_'+gallery.prefix).src = '/images/gallery/'+gallery.prefix+'/'+gallery.items[gallery.current+1]['sm'];
	document.getElementById('previewImage3_'+gallery.prefix).src = '/images/gallery/'+gallery.prefix+'/'+gallery.items[gallery.current+2]['sm'];

	if (gallery.selected == gallery.current)
	{
	}
	else
	{

	}

	if (gallery.selected == (gallery.current+1))
	{

	}
	else
	{

	}

	if (gallery.selected == (gallery.current+2))
	{

	}
	else
	{

	}
}

selfunction = function (gallery, num, type)
{
	if (gallery.items[num])
	{
		document.getElementById('PreviewPhoto_'+gallery.prefix).src = '/images/gallery/'+type+'/'+gallery.items[gallery.current+num]['big'];
	}
	gallery.selected = gallery.current+num;
	gallery.redraw(gallery, gallery.prefix);
}
