document.observe('dom:loaded', function() {
	if ($$('.productInfoExtraImages img')) {
		$$('.productInfoExtraImages img').each(function(img) {
			img.setOpacity(0.5);
			img.observe('mouseover', function() {
				$(this).setOpacity(1);
			});
			img.observe('mouseout', function() {
				$(this).setOpacity(0.5);
			});
		});
	}
	
	// Fixing shopping cart position
	dims = document.viewport.getDimensions();
	//alert(dims.width);
	if (dims.width > 1250) {
		if ($("cellShoppingCartContainer"))
			$("cellShoppingCartContainer").remove();
		margins = (dims.width-960)/2
		fromRight = margins-150;
		$('shoppingCartContainer').setStyle({position: 'fixed', right: fromRight + 'px'});
	} else {
		if (!$("cellShoppingCartContainer")) {
			row = $('shopTable').rows[0];
			var td = new Element('td', {id: 'cellShoppingCartContainer'});
			$(row).insert({bottom: td});
			td.setStyle({width: '150px', position: 'relative'});
			div = new Element('div');
			td.insert({top: div});
			div.setStyle({width: '150px', height: td.getHeight()+'px', position: 'static'});
			div.insert({top: $('shoppingCartContainer')});
			$('shoppingCartContainer').setStyle({right: '0', position: 'absolute'});
			window.onscroll = function() {
				var scroll_top = 155 + document.viewport.getScrollOffsets().top;
				$('shoppingCartContainer').setStyle({top: scroll_top+'px'});
			}
		}
	}
	
	$('newsletter_email_address').observe('focus', function() { 
		$(this).writeAttribute({'defaultvalue': this.value});
		this.value = ''; 
	});
	$('newsletter_email_address').observe('blur', function() {
		if (this.getValue().blank())
			this.value = $(this).readAttribute('defaultvalue');
	});
});

