function roundIt()
{
	
	var featuredElement = document.getElementById("featured")
	var height = featuredElement.height;
	var width = featuredElement.width;
	var src = featuredElement.src;
	var large = src.replace(/images\//i, "images/vlrg_")
	tmp = large.split("images")
	large = "v"+tmp[1].substring(6)
	
	var collectionWrapper = document.getElementById('artCollection');
	var emTag = document.getElementById('description');
	
	var imageDiv = document.createElement('div');
	imageDiv.style.width = width;
	imageDiv.style.height = height;
	imageDiv.style.background = 'url(' + src + ') top left no-repeat';
	imageDiv.setAttribute('id','image');
	imageDiv.onclick = function()
	{
		WindowObjectReference = window.open("/viewPainting.php?i="+large, "viewPainting", "menubar=no,location=no,resizable=no,scrollbars=no,status=no");
	}
	
	var topDiv = document.createElement('div');
	topDiv.style.width = width;
	topDiv.style.height = height;
	topDiv.style.background = "transparent url(images/artBg_top.gif) 0 0 no-repeat";
	topDiv.style.cursor = "pointer";
	topDiv.setAttribute('id','top')
	
	
	var bottomDiv = document.createElement('div');
	bottomDiv.style.width = width;
	bottomDiv.style.height = height;
	bottomDiv.style.background = "transparent url(images/artBg_bottom.gif) bottom left no-repeat";
	bottomDiv.setAttribute('id','bottom')
	
	var spacerGif = document.createElement('img');
	spacerGif.src = "images/spacer.gif";
	spacerGif.width = width;
	spacerGif.height = height+44;
	
	bottomDiv.appendChild(spacerGif);
	topDiv.appendChild(bottomDiv);
	imageDiv.appendChild(topDiv);

	collectionWrapper.removeChild(featuredElement);
	collectionWrapper.insertBefore(imageDiv, emTag);
}
function blinds(imgSrc)
{
	medium = imgSrc.replace(/images\//i, "images/lrg_")
	large = imgSrc.replace(/images\//i, "images/vlrg_")
	tmp = large.split("images/")
	large = tmp[1]
	/*
	new Effect.Fade('image', {duration: .2,
				afterFinish: function(){
					$('image').style.backgroundImage = 'url('+replacementImage+')'
					new Effect.Appear('image', {duration: .2})
					}
				}); 
	*/
	new Effect.BlindUp('image', {duration: .2,
					afterFinish: function()
					{
						$('image').style.backgroundImage = 'url('+medium+')';
						$('image').onclick = function()
						{
							WindowObjectReference = window.open("/viewPainting.php?i="+large, "viewPainting", "menubar=no,location=no,resizable=no,scrollbars=no,status=no");
						}
						new Effect.BlindDown('image', {duration: .2})
					}
				}); 
}

function init()
{
	roundIt();
	smallerImages = document.getElementsByClassName('smallerCollection', $('artCollection'))
	smallerImages.each( function(div){
		div.onclick = function(){ 
			blinds(this.childNodes[0].src) 
			$('description').innerHTML = this.childNodes[0].alt;
			return false;
		}
	});
}
