jQuery(document).ready(function() {

	// Init frontpage blocks positions
	jQuery('section.blocks').masonry({
		itemSelector: '.type-blocks',
		columnWidth: 240
	});

	// Resize background for <body>
	jQuery('body').css('height', jQuery(document).height() );

	// Init hover effect on frontpage blocks
	jQuery("section.blocks .type-blocks").hover(
		function () {
			jQuery('.block-inner', this).fadeIn(300);
		}, 
		function () {
			jQuery('.block-inner', this).fadeOut(300);
		}
	);

	// Show image on hover on shop/product page
	jQuery('.attachment-gold-thumbnails').hover(function(){
		jQuery(this).parents('.imagecol:first').find('.product_image').attr('src', jQuery(this).parent().attr('rev'));
		jQuery(this).parents('.imagecol:first').find('.product_image').parent('a:first').attr('href', jQuery(this).parent().attr('href'));
		return false;
	});
	
	jQuery('.wpsc_buy_button').bind('click', function() {
		jQuery('.wpsc_checkout_button').delay(500).fadeIn(300);
	});
	
	// Disable image title on the product page
	jQuery('.wpcart_gallery img').attr('title', '');
	jQuery('.wpcart_gallery a').attr('title', '');
	jQuery('#content img').attr('title', '');

	// Disable break line at textarea on checkout page
	function limitTextareaLine(e) {
		if(e.keyCode == 13 && jQuery(this).val().split("\n").length >= 1) { 
			return false;
		}
	}
	jQuery('#wpsc_shopping_cart_container textarea').keydown(limitTextareaLine);

});
