var pound = String.fromCharCode(163); 

function getAttPriceFromString(posVal) {
     // the format of this is "1 (+$9.40)".  Parse out the upcharge
     var open = posVal.indexOf(pound);
     var close = posVal.indexOf(")"); 
     if ((open != -1) && (close != -1)) {
         var posValFloat = parseFloat(posVal.substring(open+1, close)); 
         return posValFloat;
     } 
     return 0;
}

function getAttPriceFromStringNoBrackets(posVal) {
     // the format of this is "One Leg +$32.10"  Parse out the upcharge
     var open = posVal.indexOf(pound);
     var close = posVal.length;
     if ((open != -1) && (close != -1)) {
         var posValFloat = parseFloat(posVal.substring(open+1, close)); 
         return posValFloat;
     } 
     return 0;
}

function getAttPrice(attid) { 
  // the format of this is "1 (+$9.40)".  Parse out the upcharge
  var attrib = document.getElementById(attid); 
  var pos = attrib.selectedIndex;
  if (pos != 0) {
     var posVal = attrib[pos].text;
     return getAttPriceFromString(posVal);
  }
  return 0;
}

function getAttPriceNoBrackets(attid) { 
  // the format of this is "One Leg +$32.10"  Parse out the upcharge
  var attrib = document.getElementById(attid); 
  var pos = attrib.selectedIndex;
  if (pos != 0) {
     var posVal = attrib[pos].text;
     return getAttPriceFromStringNoBrackets(posVal);
  }
  return 0;
}

function estimate(product, price) {
  var error = false;
  var total = price; 

  var displayErrors = false; 
//for standard wall bays and gondolas
  if (product == 188 || product == 146||product == 147||product == 48 || product == 142||product == 143){  
     total += getAttPrice("attrib-34");
     total += getAttPrice("attrib-43");
     total += getAttPrice("attrib-38");
     total += getAttPrice("attrib-36");
     total += getAttPrice("attrib-37");
     total += getAttPrice("attrib-39");
     //total += getAttPriceNoBrackets("attrib-11");
	 }
//for magazine units
	else if (product == 60 || product == 148||product == 149){  
     total += getAttPrice("attrib-34");
     total += getAttPrice("attrib-43");
     total += getAttPrice("attrib-41");
     
  } else {
     error = true; 
  }
  
  var priceString = ""; 
  if (error) 
      priceString = "Price cannot be determined at this time";
  else { 
      total = Math.round(total * 100)/100;
      priceString = "" + pound + total.toFixed(2);
  }
  var child = document.getElementById("hiddenPrice").firstChild;
  while (child.nodeType != 3) 
     child = child.nextSibling; 
  if (child == null) alert(priceString); 
  var newText=document.createTextNode(priceString);
  document.getElementById("hiddenPrice").replaceChild(newText, child); 
  document.getElementById("hiddenPrice").style.visibility = "visible"; 
}
