jQuery(document).ready(function($) {
$('#noscript_css').attr('disabled', true);
$('#main_links a').each(function(){
var span = '';
$(this).append(span).find('.hover').hide().html($(this).html());
});
$('.quantity_area').prepend('Quantity:
');
$("#main_links a").hover(
function () {
$(this).find('.hover').fadeIn();
},
function () {
$(this).find('.hover').fadeOut();
}
);
});
function update_order_form_values() {
total_value = 0;
quantity_count = 0;
$j('#submit_order_inside .note:last').text("$1 shipping for orders over $20");
$j('input.quantity').each(function() {
id = this.id.split(/-/)[1];
item_area = $j('#item_display-'+id);
quantity = $j('#item_quantity-'+id).val();
prices = item_prices['item_'+id];
$j.each(prices, function(i, price) {
if (quantity >= price[0] ) {
item_price = price[1];
}
});
row_value = item_price * quantity;
item_area.find('.quantity').text(quantity);
item_area.find('.unit_price').text(number_to_currency(item_price));
item_area.find('.total_price').text(number_to_currency(row_value));
if (quantity > 0) {
item_area.show();
} else {
item_area.hide();
}
quantity_count += quantity;
total_value += row_value;
});
if (total_value == 0) {
shipping = 0;
} else if(total_value >= 20) {
shipping = 1;
}
else {
shipping = 3.75;
}
$j('#shipping .currency').text(number_to_currency(shipping));
total_value += shipping;
if (quantity_count > 0) {
$j('#shipping').show();
$j('#nothing_ordered').hide();
} else{
$j('#shipping').hide();
$j('#nothing_ordered').show();
}
$j('#full_total').text(number_to_currency(total_value));
}
function number_to_currency(number) {
return '$' + number_with_precision(number);
}
function number_with_precision(number, precision) {
if (precision === undefined) { precision = 2; }
return Number(number).toFixed(precision);
}