/* alert('loading'); */ function otherPress() { height = document.getElementById('heightotherstate').value ; if ( !isNaN(height) ) { if ( (height.length == 1 && height >= 5) || (height.length == 2) ) { calcTotal(); } } } function calcTotal() { //get width var width = getSelectedRadioValue(document.forms[1].width) ; //get height var height = getSelectedRadioValue(document.forms[1].heightpre) ; if ( height == 'other' ) { height = document.getElementById('heightotherstate').value ; if ( isNaN(height) ) { alert('The advert must be a minimum of 5cm high'); document.getElementById('heightotherstate').value = '5' ; height = 5 ; } else { if ( height != '' ) { if ( height > 32 ) { alert('The advert must be a maximum of 32cm high'); document.getElementById('heightotherstate').value = '32' ; height = 32 ; } if ( height < 5 ) { alert('The advert must be a minimum of 5cm high'); document.getElementById('heightotherstate').value = '5' ; height = 1 ; } } } } if ( width!='' && height!='' ) { var sqcm = width * height ; //get type if ( getSelectedRadioValue(document.forms[1].type) == 'premium' ) { var fee = 500 ; } else { var fee = 0 ; } var numFee = parseInt(fee) ; var numSqcm = parseInt(sqcm) ; var numCost = parseFloat(44.5) ; var numTotal = numFee + (numSqcm * numCost); if ( numTotal.toFixed ) { numTotal = numTotal.toFixed(2); } else { numTotal = Math.round(numTotal*100)/100 ; } //that's the ex-vat total after rounding. VAT is now being applied after rounding (correct?) var numVat = numTotal * 0.175; if ( numVat.toFixed ) { numVat = numVat.toFixed(2); } else { numVat = Math.round(numVat*100)/100; } //that's vat after rounding. var numTotalIncVat = (numTotal * 1) + (numVat * 1) ; // alert(numTotal); // alert(numVat); // alert(numTotalIncVat) ; if ( numTotalIncVat.toFixed ) { numTotalIncVat = numTotalIncVat.toFixed(2); } else { numTotalIncVat = Math.round(numTotalIncVat*100)/100; } //that's the total including vat after rounding. document.getElementById('cost_exvat').value = numTotal; document.getElementById('vat').value = numVat; document.getElementById('cost').value = numTotalIncVat; //update the graphic newwidth = width * 15 ; //convert string to number width = width * 1; newwidth = newwidth * 1; newwidth = newwidth + width; document.getElementById('highlight').style.width = newwidth+'px'; document.getElementById('highlight').style.height = Math.round((height * 3.46))+'px'; } } 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