var Gallery = {	
	galleries : false,
	
	init : function (galleryData)
	{
		var item;
		Gallery.galleries = galleryData;
		
		for(var i = 0; i < galleryData.items.length; ++i)
		{
			item = galleryData.items[i];
		//	console.info(item);
			/* Such a messy workaround.... I know*/
			if (!item.dummy)
			{
				galleryItemHolder = document.createElement('td');
				galleryItemHolder.setAttribute('vAlign', 'top');
							
				Utils._setClass(galleryItemHolder, 'galleryItemHolder');
				galleryItem = document.createElement('img');
				galleryItem.setAttribute('src', item.image);
				
				
				galleryItem.style.width = '150px';
				galleryItem.style.height = '98px';				
				
				
				galleryItem.setAttribute('id', 'item-' + item.galleryID);
				galleryItem.setAttribute('galleryid', item.galleryID);
				Utils._setClass(galleryItem, 'galleryItem');
				Utils._doRegisterEvent(galleryItem, 'mouseover', Gallery.hoverItem);
				Utils._doRegisterEvent(galleryItem, 'click', function (e, item) {window.location = item.link;}, item);
				Utils._doRegisterEvent(galleryItem, 'mouseout', Gallery.unHoverItem);
				galleryItemHolder.appendChild(galleryItem);
				
				
				$('galleryItems').appendChild(galleryItemHolder);
			}
		}
		$('galleryItems').appendChild(document.createElement('td'));
	},
	
	hoverItem : function (e)
	{
		var obj = Utils._getSrcElement(e);

		if (navigator.appVersion.indexOf('MSIE 6.0') == -1)		
		{
			//obj.style.position = 'relative';
			
			setTimeout(function ()
			{
				obj.style.width = '160px';
				obj.style.height = '104px';
			}, 50);
			
			setTimeout(function ()
			{
				obj.style.width = '175px';
				obj.style.height = '114px';
			}, 80);

			setTimeout(function ()
			{
				obj.style.width = '200px';
				obj.style.height = '130px';
			}, 100);
		}
		
		// Really... IE sucks.
		//if (navigator.appVersion.indexOf('MSIE 6.0') != -1)		
		//obj.style.marginTop = '-50px';
	},
	
	unHoverItem : function (e)
	{
		var obj = Utils._getSrcElement(e);
		
		if (navigator.appVersion.indexOf('MSIE 6.0') == -1)		
		{		
			setTimeout(function ()
			{
				obj.style.width = '200px';
				obj.style.height = '130px';
			}, 50);
			
			setTimeout(function ()
			{
				obj.style.width = '175px';
				obj.style.height = '114px';
			}, 80);

			setTimeout(function ()
			{
				obj.style.width = '160px';
				obj.style.height = '104px';			
			}, 100);		
			
			
			setTimeout(function ()
			{
				obj.style.width = '150px';
				obj.style.height = '98px';	
			}, 140);				

			//obj.style.position = 'static';		
			obj.style.marginTop = '0';
		}
	}
	
};