//
// DIY Calculators Common Functions Library $Version$
//

var errtxt = "";
var errnum = 0;

// paint coverage figures
// Updated by M Glancy 30-05-02
var coverages = new Array(
	0,	// Select paint type option - none selected
	0,	// Blank optiuon - none selected
	16,	// liquid gloss
	13,	// nondrip gloss
	12,	// eggshell
	15,	// matt emulsion
	14,	// silk emulsion
	12,	// non-drip emulsion
	11,	// primer/undercoat
	15	// varnish
);


// the scale conversion factor in metres/unit
var scale = 1;

function addErr(txt) {
	errtxt += txt + '. ';
	errnum++;
}

function clearErr() {
	errtxt = "";
	errnum = 0;
}

function float2currency(rawcost) {
	var pounds = Math.floor( rawcost );
	var pence = Math.round( (rawcost - pounds) * 100 );
	if ( pence < 10 ) {
		pence = "0" + pence;
	}
	var rv = pounds + "." + pence;
	return rv;
}

function cannotContinue() {
	if ( errnum ) {
		if (errnum == 1) {
			alert( "Sorry, there was a problem: " + errtxt );
		} else {
			alert( "Sorry, there were " + errnum + " problems: " + errtxt );
		}
		return 1;
	} else {
		return 0;
	}
}