$j = jQuery.noConflict();

$j(document).ready(function() {
	if (typeof spConfig != 'undefined') {
		$j.each(spConfig.config.attributes, function(id, attribute) {
			$j('#attribute' + id).hide();
			$j('.price-box').hide();
			$j.each(attribute.options, function(idx, option) {
				var span = $j('<span>', {
					'style': 'display: block; margin: 8px 0;'
				});
				var html = $j('<input>', {
					'type': 'radio',
					'name': 'option' + id,
					'id': 'option' + id + idx,
					'change': function() {
						$j('#attribute' + id + ' option[value='+option.id+']').attr('selected', 'selected');
						spConfig.reloadPrice();
					},
					'click': function() {
						$j('#attribute' + id + ' option[value='+option.id+']').attr('selected', 'selected');
						$j('input', $j(this).parent().parent()).attr('checked', false);
						$j(this).attr('checked', 'checked');
						spConfig.reloadPrice();
					}
				});
				var label = $j('<label>', {
					'style': 'padding: 10px;',
					'for': 'option' + id + idx,
					'html': option.label + ' <strong>AU$' + (parseFloat(option.price) + parseFloat(spConfig.config.basePrice)).toFixed(2) + '</strong>'
				});
				span.append(html);
				span.append(label);
				$j('#attribute' + id).before(span);
				$j('.product-options input').attr('name', 'foo');
			});
		});
	}

	if (typeof opConfig != 'undefined') {
		$j('.price-box').hide();
		$j.each(opConfig.config, function(id, option) {
			$j.each(option, function(idx, priceDiff) {
				var price = priceDiff + optionsPrice.productOldPrice;
				var span = $j('<span>', {
					'class': 'price-notice',
					'html': $j('<span>', {
						'class': 'price',
						'text': 'AU$' + price
					})
				});
				$j('input[value="'+ idx +'"]').siblings('span').children('label').children('.price-notice').remove();
				$j('input[value="'+ idx +'"]').siblings('span').children('label').append(span);
			});
		});
	}
});

