	
	$ = function(elId)
	{
		return document.getElementById(elId);
	}
	
	function gallery()
	{
	
	}

	gallery.init = function()
	{
		$('topControls').onmouseover = gallery.showTopControls;
		$('topControls').onmouseout = gallery.hideTopControls;
		$('shadower').onmouseover = gallery.showTopControls;
		$('shadower').onmouseout = gallery.hideTopControls;
		$('shadower').onclick = gallery.hideImg;
       	$('image').onclick = gallery.next;
}
		
	gallery.windowSize = function()
	{
		w = $('window');
		img = $('image');
		//alert(img.offsetWidth + ' x ' + img.offsetHeight);
		w.style.marginLeft = '-' + (img.offsetWidth/2)+'px';
		w.style.marginTop = '-' + (img.offsetHeight/2)+'px';
	}
	
	gallery.showImg = function(index)
	{
		gallery.itemIndex = index;
		
		$('image').src = gallery.items[gallery.itemIndex].src;
		$('shadower').style.display = 'block';
		$('window').style.display = 'block';
	
		gallery.initTitle(index);
		
		return false;
	}
	
	gallery.initTitle = function(index)
	{
		if(gallery.items[gallery.itemIndex].title)
		{
			$('image_title').style.display = 'block';
			$('image_title').innerHTML = gallery.items[gallery.itemIndex].title;
		}
		else
			$('image_title').style.display = 'none';
	}
	
	gallery.hideImg = function()
	{
		$('image_title').style.display = 'none';
		$('shadower').style.display = 'none';
		$('window').style.display = 'none';
	}
	
	gallery.next = function()
	{
		gallery.itemIndex++;

		if(gallery.itemIndex < gallery.items.length)
		{
			$('image').src = gallery.items[gallery.itemIndex].src;
			gallery.initTitle(gallery.itemIndex);			
		}
		else
			gallery.hide();
			
		return false;
	}

	gallery.hide = function()
	{
		gallery.hideImg();
		gallery.hideTopControls();		
	}
	
	gallery.previous = function()
	{
		gallery.itemIndex--;
				
		if(gallery.itemIndex >= 0)
		{
			$('image').src = gallery.items[gallery.itemIndex].src;
			gallery.initTitle(gallery.itemIndex);						
		}
		else
			gallery.hide();
		
		return false;
	}
	
	gallery.showTopControls = function()
	{
		$('topControls').style.display = 'block'
	}

	gallery.hideTopControls = function()
	{
		$('topControls').style.display = 'none'
	}
	
	gallery.items = new Array();
	gallery.itemIndex = 0;
	

