var productCode;
var productCost;

function doPrice() {
	var index = getSelectedRadio(document.forms["purchase"].pcode);
	productCode = document.forms["purchase"].pcode[index].value;
	switch (productCode) {
		case '300019631' : productCost = '49.5'; break;
		case '300019632' : productCost = '199.5'; break;
		case '300019633' : productCost = '39'; break;
		case '300019634' : productCost = '99'; break;
		case '300019635' : productCost = '99'; break;
		case '300019636' : productCost = '725'; break;
		case '300019637' : productCost = '873'; break;
		case '300019638' : productCost = '1297'; break;
		case '300019639' : productCost = '1847'; break;
	}
	document.forms["purchase"].cost.value = "£" + productCost;
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function