window.addEvent('domready', function() {
	$$('.thumbs ul li a').each(function(el) {
		el.addEvent('click', function() {
			//get the full image links
			var newImageLinkPreview = el.get('href').replace('thumb', 'full');
			var newImageLinkZoom = el.get('href').replace('thumb', 'original');
			
			//set the appropriate links to the needed spaces
			$('previewLink').set('href', newImageLinkPreview);
			$('preview').set('src', newImageLinkPreview);
			$$('.zoom').set('href', newImageLinkZoom);
			
			//switch the active class
			$$('.thumbs ul li a.active').removeClass('active');
			el.addClass('active');
			
			//stop processing the click event
			return false;
		});
	});
	
	
	//handle the popup for send to friend
	$$('.email').each(function(el) {
		el.addEvent('click', function() {
			window.open(el.href, 'sendtofriend', 'width=462px;height=600px;scrollbars=true;');
			return false;
		});
	});
});
