var price_change_handler = new PriceChangeHandler();

function PriceChangeHandler () {
  
  /**
  * Processes the returned XML DOM nodes
  **/
  this.process = function (top_node) {
    var price_holder = document.getElementById ('price');
    var price = top_node.getElementsByTagName ('total');
    
    if (price.item (0).firstChild.data == '$0.00') {
      price_holder.innerHTML = "select options above";
    } else {
      price_holder.innerHTML = price.item (0).firstChild.data;
    }
  }
}


function ajax_update_price () {
  window.setTimeout ('ajax_update_price_act ()', 200);
}


function ajax_update_price_act () {
  
  var id = document.forms.cart.elements['id'];
  var size = document.forms.cart.elements['SizeChoice'];
  var finish = document.forms.cart.elements['FinishChoice'];
  var qty = document.forms.cart.elements['qty'];
  
  // gather fields and do AJAX submit
  var post_data = '';
  
  post_data = 'id=' + id.value + '&qty=' + qty.value;
  
  if (size != undefined) {
    post_data += '&size='+ size.value;
  }
  
  if (finish != undefined) {
    post_data += '&finish=' + finish.value;
  }
  
  queue.request ('POST', 'ajax_calc_price.php', price_change_handler, post_data);
}


