// JavaScript Document
function ConvVolume () {
	var nVolume = document.forms[0].elements[0].value
	var cType = document.forms[0].elements[1].checked
	
	if (cType) { // Convert Cu. Ft. to Cu. Meters */
		nResult = nVolume * .7646 / 27
		cText = "Cubic Meters"
	} else { // Convert Cu. Meters to Cu.Feet */
		nResult = nVolume / .7646 * 27
		cText = "Cubic Feet"
	}

	document.forms[0].elements[5].value = nResult
	document.forms[0].elements[6].value = cText
}

function ConvWeight() {
	var nWeight = document.forms[1].elements[0].value
	var cType = document.forms[1].elements[1].checked
	if (cType)
		/* Convert Pounds to Kilos */
		{
		nResult = nWeight / 2.2046
		cText = "Kilos"
		}
	else
		/* Convert Kilos to Pounds */
		{
		nResult = nWeight * 2.2046
		cText = "Pounds"
		}
	document.forms[1].elements[5].value = nResult
	document.forms[1].elements[6].value = cText
}

function ConvVWght() {
	var nWeight = document.forms[2].elements[0].value
	var cCent = document.forms[2].elements[1].checked
	var cMtr = document.forms[2].elements[2].checked
	var cIn = document.forms[2].elements[3].checked
	var nResult = 0
	if (cCent)
		/* Convert Cubic Centimeters to Vol Kilos */
		nResult = nWeight * .00016666667
	if (cMtr)
		/* Convert Cubic Meters to Vol Kilos */
		nResult = nWeight * 167
	if (cIn)
		/* Convert Cubic Inches to Vol Kilos */
		nResult = nWeight * .002732240437158
	document.forms[2].elements[6].value = nResult
}

function FrontPage_Form1_Validator(theForm)
{

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Volume.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Volume\" field.");
    theForm.Volume.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Volume\" field.");
    theForm.Volume.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Volume_Result.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Volume_Result\" field.");
    theForm.Volume_Result.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Volume_Result\" field.");
    theForm.Volume_Result.focus();
    return (false);
  }
  return (true);
}
			
function FrontPage_Form2_Validator(theForm)
{
  var checkOK = "0123456789-.,";
  var checkStr = theForm.Weight.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Weight\" field.");
    theForm.Weight.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Weight\" field.");
    theForm.Weight.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Weight_Result.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Weight_Result\" field.");
    theForm.Weight_Result.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Weight_Result\" field.");
    theForm.Weight_Result.focus();
    return (false);
  }
  return (true);
}

function FrontPage_Form3_Validator(theForm)
{

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Volume.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Volume\" field.");
    theForm.Volume.focus();
    return (false);

  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Volume\" field.");
    theForm.Volume.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Weight_Result.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Weight_Result\" field.");
    theForm.Weight_Result.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Weight_Result\" field.");
    theForm.Weight_Result.focus();
    return (false);
  }
  return (true);
}