//capacitor charge/ power calculator functions
//copyright Simon Carter 2002
//Please contact me via www.electronics2000.co.uk if you wish to use these
//and ensure this header block remains intact

function calcchrg (obj) {
with (Math){
v = calculatemult2(obj.voltsmult.selectedIndex,eval(obj.volts.value));
c = calculatemult3(obj.capmult.selectedIndex,eval(obj.cap.value));
c = abs(c);
v = abs(v);
	if((v)&&(c)){
		q = format2(v * c);
		w = format2((c * v * v) /2);
		SetText("charge", q + " Coulombs");
		SetText("energy", w + " Joules");}
	else{	SetText("charge", "?");
		SetText("energy", "?");}}
}
