//
//definition of the VIData object begins here
//******************************************
function VIData(c,t)
{
    this.chemical=c;
    this.temp=t;
    this.ii = -1;
    this.selectedIndex = -1;
}

//data
VIData.prototype.chName = new Array;
VIData.prototype.chCasNo = new Array;
VIData.prototype.chHc25 = new Array;
VIData.prototype.chBp = new Array;
VIData.prototype.chBpTempC = new Array;
VIData.prototype.chTcK = new Array;
VIData.prototype.chVpMmHg = new Array;
VIData.prototype.chDeltaH = new Array;
VIData.prototype.chDeltaHRef = new Array;


for (i=0;i<100;i++)
{
 VIData.prototype.chName[i] = " ";
 VIData.prototype.chCasNo[i] = i;
 VIData.prototype.chHc25[i] = i;
 VIData.prototype.chBp[i] = i;
 VIData.prototype.chBpTempC[i] = i;
 VIData.prototype.chTcK[i] = i;
 VIData.prototype.chVpMmHg[i] = i;
 VIData.prototype.chDeltaH[i] = i;
 VIData.prototype.chDeltaHRef[i] = i;
}



//define functions

//add all data to the data set
function VIData_addOne(casNo,name,hl25,nbp,nbpTempC,tcK,vpMmHg,deltaH,deltaHRef)
{
  this.ii = this.ii + 1;

  //cas number
  this.chCasNo[this.ii] = casNo;
  //chemical name
  this.chName[this.ii] = name;
  //henry constant at 25 C (atm-m3/mol)
  this.chHc25[this.ii] = hl25;
  //Normal boiling point (K)
  this.chBp[this.ii] = nbp;
  //Normal boiling point (C)
  this.chBpTempC[this.ii] = nbpTempC;
  //Critical Temperature (K)
  this.chTcK[this.ii] = tcK;
  //vapor pressure at 25 C in mmHg
  this.chVpMmHg[this.ii] = vpMmHg;
  //Enthalpy of vaporization at Normal Boiling point (cal/mol)
  this.chDeltaH[this.ii] = deltaH;
  //Reference for deltaH (1 through 4)
  this.chDeltaHRef[this.ii] = deltaHRef;

  this.entriesThermo = this.ii+1;
}

//determine if chemical is in the data set
function VIData_cPresent()
{
  var boolChemical = false;

  for (i=0 ; i<=this.entriesThermo ; i=i+1) 
    {   
     if (this.chemical==this.chName[i]) {this.selectedIndex=i; boolChemical=true;}
    }
  
  return boolChemical;
}

//determine henry constant at 25C
function VIData_getHenryConstant25() {return this.chHc25[this.selectedIndex];}
function VIData_getNormalBoilingPointK() {return this.chBp[this.selectedIndex];}
function VIData_getCriticalTemperatureK() {return this.chTcK[this.selectedIndex];}
function VIData_getVaporPressure25() {return this.chVpMmHg[this.selectedIndex];}
function VIData_getEnthalpyOfVaporization() {return this.chDeltaH[this.selectedIndex];}



VIData.prototype.addOne = VIData_addOne;
VIData.prototype.cPresent = VIData_cPresent;
VIData.prototype.getHenryConstant25 = VIData_getHenryConstant25;
VIData.prototype.getNormalBoilingPointK =  VIData_getNormalBoilingPointK; 
VIData.prototype.getCriticalTemperatureK = VIData_getCriticalTemperatureK;
VIData.prototype.getVaporPressure25 = VIData_getVaporPressure25;
VIData.prototype.getEnthalpyOfVaporization = VIData_getEnthalpyOfVaporization; 
//******************************************
//Definition of the VIData object ends here
