jQuery(document).ready(function() {
	jQuery('#product-decription-long-toggle').click(function() {
        if (jQuery('#product-decription-long-hidden').css('display') == 'none') {
			jQuery('#product-decription-long-hidden').fadeIn(500);
        } else {
			jQuery('#product-decription-long-hidden').fadeOut(500);
        }
	});

    if (jQuery('#amount').length > 0) {
		var amount = new LiveValidation('amount', { wait: 100 });
		amount.add( Validate.Presence );
		amount.add( Validate.Numericality, { onlyInteger: true } );
	}

    // If the product is a packet product, check that no variant packet products are left un-selected
    // If any are, mark them briefly with bold and do not allow the form to submit
    jQuery('.ProductItem form').submit(function() {
        jQuery('.packetVariant option:selected[value=""]').parent().css('font-weight', 'bold');
        setTimeout(function() { jQuery('.packetVariant option:selected[value=""]').parent().css('font-weight', 'normal') }, 500);
        var emptyPacket = jQuery('.packetVariant option:selected[value=""]').length > 0;
		return !emptyPacket;
    })
});
