/*
	Very Primitive 'Dashboard' Gallery
	Verity Computing
*/

function picture()
{
	this.title= 	null;
	this.thumb=	null;
	this.full=	null;
	this.caption= 	null;
}

var gallery = 
{
	pictures: new Array(),

	addpicture: function(title,thumb,full,caption)
	{
		var tmp = new picture();
		tmp.title=title;
		tmp.thumb=thumb;
		tmp.full=full;
		tmp.caption=caption;
		gallery.pictures.push(tmp);
	},

	dimscreen: function()
	{
		var btag = document.getElementsByTagName('body')[0];
		document.body.style.overflow = 'hidden';
		if (!(document.getElementById('darkBackgroundLayer')))
		{
			var bg = document.createElement('div');
			bg.setAttribute('id', 'darkBackgroundLayer');
			bg.setAttribute('class', 'darkenBackground');
			bg.style.cssText = 'position:fixed; z-index:10; padding-top:10px; width:100%; height:100%; top:0px; left:0px; overflow:auto; background-image:url(images/blacktrans.png); text-align:center;';
			/*bg.onclick=function(e)
			{
				document.body.style.overflow = 'auto';
				var bgtag = document.getElementById('darkBackgroundLayer');
				
				while (bgtag.hasChildNodes())
				{
					bgtag.removeChild(bgtag.firstChild);
				}
				bgtag.style.display = 'none';
			}*/
			btag.appendChild(bg);
		}
		else
		{
			document.getElementById('darkBackgroundLayer').style.display = 'block';
		}
	},

	showpicture: function(num)
	{
		gallery.dimscreen();
		var parent=document.getElementById('darkBackgroundLayer');

		var ttl = document.createElement('p');
		ttl.setAttribute('class', 'largetitle');
		ttl.style.cssText = 'font-family:sans-serif, verdana, arial; font-size:14pt; font-weight:bold; color:#ffffff;';
		if (gallery.pictures[num].title != null)
			ttl.innerHTML=gallery.pictures[num].title;
		parent.appendChild(ttl);

		var div = document.createElement('div');
		div.style.cssText = 'position:relative;';
		
		var img = document.createElement('img');
		img.setAttribute('src', gallery.pictures[num].full);
		img.style.cssText = 'position:relative; border:2px #ffffff solid;';
		var parent=document.getElementById('darkBackgroundLayer');
		div.appendChild(img);
		parent.appendChild(div);

		var closeimg = document.createElement('img');
		closeimg.setAttribute('src', 'images/close-image.png');
		closeimg.style.cssText = 'cursor:pointer; position:absolute; z-index:20; bottom:-20px;';
		div.appendChild(closeimg);
		closeimg.onclick=function(e)
			{
				document.body.style.overflow = 'auto';
				var bgtag = document.getElementById('darkBackgroundLayer');
				
				while (bgtag.hasChildNodes())
				{
					bgtag.removeChild(bgtag.firstChild);
				}
				bgtag.style.display = 'none';
			}
		
	}
}
