
	/* ===== GET ELEMENT BY ID ===== */
	
	function $(ID)
	{
		return document.getElementById(ID);
	}

	/* ===== GALLERY ===== */
	
	function Gallery(cat)
	{
		this.imgs = new Array();
		this.cur = 0;
		this.img 	= $(cat + 'Pic');
		this.txt = $(cat + 'Text');
		this.prev = $(cat + 'Prev');
		this.next = $(cat + 'Next');
	}
	
	Gallery.prototype.addImage = function(imagePath)
	{
		this.imgs.push('photos/' + imagePath);
	}
	
	Gallery.prototype.setImage = function(step)
	{
		if(step == -1)
		{
			if(this.cur > 0)
			{
				this.cur += step;
				this.img.src = this.imgs[this.cur];
			}
		}
		else
		{
			if(this.cur < this.imgs.length - 1)
			{
				this.cur += step;
				this.img.src = this.imgs[this.cur];
			}
		}
		
		this.txt.innerHTML = (this.cur + 1) + ' / ' + this.imgs.length;
	}
	
	Gallery.prototype.ready = function()
	{
		var self = this;
		
		this.img.src = this.imgs[this.cur];
		this.txt.innerHTML = '1 / ' + this.imgs.length;
		
		this.prev.onclick = function()
		{
			self.setImage(-1);
		}
		
		this.next.onclick = function()
		{
			self.setImage(+1);
		}
		
		this.img.onclick = function()
		{
			openPopup('photos/big-' + self.imgs[self.cur].substr(7), 660, 436);
			
		}
	}
	
	/* ===== SCROLLTO ===== */
	
	function st(to, hide)
	{
		if(hide) hideMenu();
		
		var offsetY = document.documentElement.scrollTop;
		var scrToY = (window.ActiveXObject) ? $(to).offsetTop + 340  :  $(to).offsetTop;
		
		switch(true)
		{
			case (scrToY - offsetY) > 0 && (scrToY - offsetY) < 1000 : loops = 10; break;
			case (scrToY - offsetY) > 1000 && (scrToY - offsetY) < 2000 : loops = 20; break;
			default: loops = 30; break;
		}
		
		var step = (scrToY - offsetY) / loops;
				
		for(var i = 0; i < loops + 1; i++)
		{
			window.setTimeout('window.scrollTo(0, ' + (i * step + offsetY) + ')', i * 25);
		}
	}
	
	function scrollToTop()
	{
		var offsetY = document.documentElement.scrollTop;
		var step = offsetY / 10;
		var j = 0;
		
		for(var i = 9; i >= 0; i--, j++)
		{
			window.setTimeout('window.scrollTo(0, ' + i * step + ')', j * 25);
		}
	}
	
	/* ===== MENU ===== */
	
	var timer = null;
	
	function showMenu()
	{
		$('submenu').style.display = 'block';
	}
	
	function hideMenu()
	{
		$('submenu').style.display = 'none';
	}
	
	function tm(type)
	{
		if (type)
		{
			timer = window.setTimeout(hideMenu, 250);
		}
		else
		{
			window.clearTimeout(timer);
		}
	}
	
	/* ===== POPUP ===== */
	
	function openPopup(_url, _width, _height)
	{
		var top = (screen.height - _height) / 2;
		var left = (screen.width - _width) / 2;
		var features = 'width=' + _width + ', height=' + _height + ', top=' + top + ', left=' + left + ', scrollbars=0, resizable=0, statusbar=0';
		
		window.open(_url, '', features);
	}
	