// used when there are more than one shipping option
// triggered when a selection in the shipping options drop down box is made
function changeShipping(shipping_prices, price_id) {
  shipping_price = shipping_prices[price_id];
  e = document.getElementById('shipping_price');
  if(e) {
    e.innerHTML = '$'+number_format(shipping_price,2,'.');
  }
  e = document.getElementById('total_price');
  if(e) {
    var total_price = shipping_price + product_price + current_letter_box_price;
    e.innerHTML = '$'+number_format(total_price,2,'.');
  }
}

// function calculates letter box price to be added to total product price
function addLetterBoxPrice(number) {
  current_letter_box_price = (number-letter_box_unpaid_letters)*letter_box_price;
  if(current_letter_box_price < 0) {
    current_letter_box_price = 0;
  }
  document.getElementById('price').innerHTML = '$'+number_format(product_price + current_letter_box_price,2,'.');
  document.getElementById('price2').innerHTML = '$'+number_format(product_price + current_letter_box_price,2,'.');
  if(product_price_without_discount > product_price) {
    document.getElementById('old_price').innerHTML = '$'+number_format(product_price_without_discount + current_letter_box_price,2,'.');
  }
  e = document.getElementById('total_price');
  if(e) {
    var total_price = shipping_price + product_price + current_letter_box_price;
    e.innerHTML = '$'+number_format(total_price,2,'.');
  }
}

// function used on category and landing pages
function flipArrow(id) {
  img = document.getElementById('arrow_'+id);
  if(img.src.match('/images/arrow_up.gif')) {
    img.src = '/images/arrow_down.gif';
  } else {
    img.src = '/images/arrow_up.gif';
  }
}
