<!-- hide from old browsers
function ChemTable(ChemName) {
c=new MakeArray(3); {
	c[1]=1;
	c[2]=" ";
	c[3]=0;
	if (ChemName=="acetic acid") {
		c[1]=.0000175;
		c[2]="CH<SUB>3</SUB>COOH";
		c[3]=2*12.01115+4*1.00797+2*15.9994;
	  }
	if (ChemName=="arsenic acid") {
		c[1]=.006;
		c[2]="H<SUB>3</SUB>AsO<SUB>4</SUB>";
		c[3]=3*1.00797+74.9216+4*15.9994;}
	if (ChemName=="arsenious acid") {
		c[1]=.0000000006;
		c[2]="H<SUB>3</SUB>AsO<SUB>3</SUB>";
		c[3]=3*1.00797+74.9216+3*15.9994;}
	if (ChemName=="benzoic acid") {
		c[1]=.000063;
		c[2]="C<SUB>6</SUB>H<SUB>5</SUB>COOH";
		c[3]=6*12.01115+5*1.00797+12.01115+15.9994+15.9994+1.00797;}
	if (ChemName=="boric acid") {
		c[1]=.00000000064;
		c[2]="H<SUB>3</SUB>BO<SUB>3</SUB>";
		c[3]=3*1.00797+10.811+3*15.9994;}
	if (ChemName=="carbonic acid") {
		c[1]=.00000043;
		c[2]="H<SUB>2</SUB>CO<SUB>3</SUB>";
		c[3]=2*1.00797+12.01115+3*15.9994;}
	if (ChemName=="citric acid") {
		c[1]=.00074;
		c[2]="HOOC(OH)C(CH<SUB>2</SUB>COOH)<SUB>2</SUB>";
		c[3]=2*1.00797+3*15.9994+2*12.01115+2*(2*12.01115+3*1.00797+2*15.9994);}
	if (ChemName=="formic acid") {
		c[1]=.000176;
		c[2]="HCOOH";
		c[3]=2*1.00797+2*15.9994+12.01115;}
	if (ChemName=="hydrocyanic acid") {
		c[1]=.00000000072;
		c[2]="HCN";
		c[3]=1.00797+12.01115+14.0067;}
	if (ChemName=="hydrofluoric acid") {
		c[1]=.00067;
		c[2]="HF";
		c[3]=1.00797+18.9984;}
	if (ChemName=="hydrosulfuric acid") {
		c[1]=.000000091;
		c[2]="H<SUB>2</SUB>S"
		c[3]=2*1.00797+32.064;}
	if (ChemName=="hydrochloric acid") {
		c[1]=1.;
		c[2]="HCl";
		c[3]=1.00797+35.453;}
	if (ChemName=="hypochlorous acid") {
		c[1]=.000000011;
		c[2]="HOCl";
		c[3]=1.00797+15.9994+35.453;}
	if (ChemName=="perchloric acid") {
		c[1]=1.0;
		c[2]="HClO<SUB>4</SUB>"
		c[3]=1.00797+35.453+4*15.9994;}
	if (ChemName=="chlorous acid") {
		c[1]=.012;
		c[2]="HClO<SUB>2</SUB>";
		c[3]=1.00797+35.453+2*15.9994;}
	if (ChemName=="sulfuric acid") {
		c[1]=1.0;
		c[2]="H<SUB>2</SUB>SO<SUB>4</SUB>"
		c[3]=2*1.00797+32.064+4*15.9994;}
	if (ChemName=="sulfurous acid") {
		c[1]=.013;
		c[2]="H<SUB>2</SUB>SO<SUB>3</SUB>"
		c[3]=2*1.00797+32.064+3*15.9994;}
	if (ChemName=="nitric acid") {
		c[1]=1.0;
		c[2]="HNO<SUB>3</SUB>";
		c[3]=1.00797+14.0067+3*15.9994;}
	if (ChemName=="nitrous acid") {
		c[1]=.00051;
		c[2]="HNO<SUB>2</SUB>";
		c[3]=1.00797+14.0067+2*15.9994;}
	if (ChemName=="phenol acid") {
		c[1]=.00000000011;
		c[2]="C<SUB>6</SUB>H<SUB>5</SUB>OH"
		c[3]=6*12.01115+6*1.00797+15.9994;}
	if (ChemName=="phenol") {
		c[1]=.00000000011;
		c[2]="C<SUB>6</SUB>H<SUB>5</SUB>OH"
		c[3]=6*12.01115+6*1.00797+15.9994;}
	if (ChemName=="phosphoric acid") {
		c[1]=.011;
		c[2]="H<SUB>3</SUB>PO<SUB>4</SUB>"
		c[3]=3*1.00797+30.9738+4*15.9994;}
	if (ChemName=="phosphorous acid") {
		c[1]=.05;
		c[2]="H<SUB>3</SUB>PO<SUB>3</SUB>"
		c[3]=3*1.00797+30.9738+3*15.9994;}
	if (ChemName=="sodium hydroxide") {
		c[1]=1.0;
		c[2]="NaOH";
		c[3]=22.9898+15.9994+1.00797;}
	if (ChemName=="aniline") {
		c[1]=.0000000004;
		c[2]="C<SUB>6</SUB>H<SUB>5</SUB>NH<SUB>2</SUB>"
		c[3]=6*12.01115+7*1.00797+14.0067;}
	if (ChemName=="ammonia") {
		c[1]=.0000175;
		c[2]="NH<SUB>3</SUB>"
		c[3]=14.0067+3*1.00797;}
}
return c;
}

function Clear23(n) {
document.phCalculator.wt.value="";
document.phCalculator.vol.value="";
document.phCalculator.totalvol.value="";
document.phCalculator.volsource.value="";
document.phCalculator.concsource.value="";
}
function Clear13(n) {
document.phCalculator.conc.value="";
document.phCalculator.totalvol.value="";
document.phCalculator.volsource.value="";
document.phCalculator.concsource.value="";
}
function Clear12(n) {
document.phCalculator.conc.value="";
document.phCalculator.wt.value="";
document.phCalculator.vol.value="";
}

function MakeArray(n) {
this.length=n;
for (var i=1; i<=n; i++)
{this[i]=0}
return this ;
}

function pHcal() {
var strconc=document.phCalculator.conc.value;
var M=parseFloat(strconc);
var strwt=document.phCalculator.wt.value;
var W=parseFloat(strwt);
var strvol=document.phCalculator.vol.value;
var V=parseFloat(strvol);
var strtv=document.phCalculator.totalvol.value;
var TV=parseFloat(strtv);
var strvs=document.phCalculator.volsource.value;
var VS=parseFloat(strvs);
var strc=document.phCalculator.concsource.value;
var CS=parseFloat(strc);
var chem=document.phCalculator.chemical.value;
var ChemName=chem.toLowerCase();
var species=ChemName.indexOf("acid");
var Ka=1;
var c=ChemTable(ChemName);
    Ka=c[1];
var formula=c[2];
var MWt=c[3];
var x=0;
with (Math)
{
if (strwt != "" && strvol != "") {
	M=W/(MWt*V);
	strconc=M;}
if (strtv != "" && strvs != "" && strc != "") {
	M=CS*VS/TV;
	strconc=M;}
if (Ka!=1) {
	M=(-Ka + sqrt(Ka*Ka+4*M*Ka))/2}
if (M<.000001) {
	var x=((-M + sqrt(M*M+4*.00000000000001))/2);
 	M=M+x;}
var pH=-log(M)/log(10);
var pH1=round(pH*100);
var pH2=pH1/100;
if (species==-1) {
	pH2=14-pH2;}
}
var resultHTML="<p class=subtitle>pH Calculation Results<p>";
if (isNaN(pH2) || formula==" "){
	resultHTML += "<p class=formerror>Please select a chemical and enter valid numeric values in one of the three methods for solution concentration.</p>";}
else {
	if (formula==" ") {
		resultHTML += "<p class=emphasis><br>" + ChemName + " does not appear in the database.  It is assumed to be a strong acid in the following calculations.<br><br></p>";
	}
	if (x!=0) {
		resultHTML += "<p class=emphasis><br>The contribution of water to the pH has been accounted for due to the low concentration of " + ChemName + ".<br><br></p>";
	}
	resultHTML += "<p class=emphasis><br>The pH of " + strconc + " M " + ChemName + " is " + pH2 + ". <br><br></p>";
	
	if (formula!=" ") {
		resultHTML += "<p>The chemical formula for " + ChemName + " is " + formula + ". </p>";
	}
	if (MWt!=0) {
	resultHTML += "<p>The molecular weight for " + ChemName + " is " + MWt + " grams/mole. <br><br></p>";
	}
}
var ie4=document.all;
var ns4=document.layers;
var ns6=document.getElementById;

if(ie4) {
	showContentObj=document.all.div_results;
  }
if(ns6) {
	showContentObj=document.getElementById("div_results");
  }
if(ie4||ns6) {
  if(showContentObj.innerHTML!=resultHTML) {
  	showContentObj.innerHTML=resultHTML;
    }
  else {
  	showContentObj.innerHTML="";
    }
}
if(ns4) {
  document.ns_results.document.write(resultHTML);
  document.ns_results.document.close();
  }
}
//-->