window.addEvent('load', function() {
	//Bottom content rounded border
	addBottomRound();
	
	//Detail swatch change
	$$('.swatch').each(function(el){
		var thumb = $E('img',el);
		if (thumb.src.contains('blank.gif')) {
			el.removeClass('pointer');
		} else {
			el.addEvent('click', function() {
				changeImage(thumb);
			});
		}
	});
});

function addBottomRound() {  
	var myTBody = $('ContentCell').getFirst().getFirst();  

	newRow = htmlToElements("<tr class='bottomround'><td>&nbsp;</td></tr>");  
	newRow.injectInside(myTBody);  
}  

function htmlToElements(str){  
	return new Element('div').setHTML('<table><tbody>' + str + '</tbody></table>').getElement('tr');  
}  

function changeImage(thumb) {
				var idx = -1;
				var img = $('productimage');
				img.src = thumb.src.replace('w=50', 'w=300');
				var ddl = $E('.colorlist');
				for (var i=0; i<ddl.length; i++){
					if (ddl.options[i].text==thumb.alt) idx=i;
				}
				if (idx != -1) ddl.selectedIndex = idx;
			}
			